mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-27 15:30:35 +00:00
[spline/bezier]Trying to fix a problem that wrong texture format causes a crash.
This commit is contained in:
parent
f14b75492d
commit
e6af91f1b0
@ -926,16 +926,17 @@ void DrawEngineCommon::SubmitSpline(const void *control_points, const void *indi
|
||||
patch.patchFacing = patchFacing;
|
||||
|
||||
if (g_Config.bHardwareTessellation && g_Config.bHardwareTransform && !g_Config.bSoftwareRendering) {
|
||||
float *pos = (float*)(decoded + 65536 * 18); // Size 3 float
|
||||
float *tex = pos + count_u * count_v * 3; // Size 3 float
|
||||
float *col = tex + count_u * count_v * 3; // Size 4 float
|
||||
int stride = g_Config.iGPUBackend == GPU_BACKEND_VULKAN || g_Config.iGPUBackend == GPU_BACKEND_DIRECT3D11 ? 4 : 3;
|
||||
float *pos = (float*)(decoded + 65536 * 18); // Size 3 float (4 for Vulkan and D3D11)
|
||||
float *tex = pos + count_u * count_v * stride; // Size 3 float (4 for Vulkan and D3D11)
|
||||
float *col = tex + count_u * count_v * stride; // Size 4 float
|
||||
const bool hasColor = (origVertType & GE_VTYPE_COL_MASK) != 0;
|
||||
const bool hasTexCoords = (origVertType & GE_VTYPE_TC_MASK) != 0;
|
||||
|
||||
for (int idx = 0; idx < count_u * count_v; idx++) {
|
||||
memcpy(pos + idx * 3, points[idx]->pos.AsArray(), 3 * sizeof(float));
|
||||
memcpy(pos + idx * stride, points[idx]->pos.AsArray(), 3 * sizeof(float));
|
||||
if (hasTexCoords)
|
||||
memcpy(tex + idx * 3, points[idx]->uv, 2 * sizeof(float));
|
||||
memcpy(tex + idx * stride, points[idx]->uv, 2 * sizeof(float));
|
||||
if (hasColor)
|
||||
memcpy(col + idx * 4, Vec4f::FromRGBA(points[idx]->color_32).AsArray(), 4 * sizeof(float));
|
||||
}
|
||||
@ -1008,9 +1009,10 @@ void DrawEngineCommon::SubmitBezier(const void *control_points, const void *indi
|
||||
ERROR_LOG(G3D, "Something went really wrong, vertex size: %i vs %i", vertexSize, (int)sizeof(SimpleVertex));
|
||||
}
|
||||
|
||||
float *pos = (float*)(decoded + 65536 * 18); // Size 3 float
|
||||
float *tex = pos + count_u * count_v * 3; // Size 3 float
|
||||
float *col = tex + count_u * count_v * 3; // Size 4 float
|
||||
int stride = g_Config.iGPUBackend == GPU_BACKEND_VULKAN || g_Config.iGPUBackend == GPU_BACKEND_DIRECT3D11 ? 4 : 3;
|
||||
float *pos = (float*)(decoded + 65536 * 18); // Size 3 float (4 for Vulkan and D3D11)
|
||||
float *tex = pos + count_u * count_v * stride; // Size 3 float (4 for Vulkan and D3D11)
|
||||
float *col = tex + count_u * count_v * stride; // Size 4 float
|
||||
const bool hasColor = (origVertType & GE_VTYPE_COL_MASK) != 0;
|
||||
const bool hasTexCoords = (origVertType & GE_VTYPE_TC_MASK) != 0;
|
||||
|
||||
@ -1022,9 +1024,9 @@ void DrawEngineCommon::SubmitBezier(const void *control_points, const void *indi
|
||||
tessDataTransfer->PrepareBuffers(pos, tex, col, count_u * count_v, hasColor, hasTexCoords);
|
||||
for (int idx = 0; idx < count_u * count_v; idx++) {
|
||||
SimpleVertex *point = simplified_control_points + (indices ? idxConv.convert(idx) : idx);
|
||||
memcpy(pos + idx * 3, point->pos.AsArray(), 3 * sizeof(float));
|
||||
memcpy(pos + idx * stride, point->pos.AsArray(), 3 * sizeof(float));
|
||||
if (hasTexCoords)
|
||||
memcpy(tex + idx * 3, point->uv, 2 * sizeof(float));
|
||||
memcpy(tex + idx * stride, point->uv, 2 * sizeof(float));
|
||||
if (hasColor)
|
||||
memcpy(col + idx * 4, Vec4f::FromRGBA(point->color_32).AsArray(), 4 * sizeof(float));
|
||||
}
|
||||
|
@ -975,7 +975,7 @@ void DrawEngineD3D11::TessellationDataTransferD3D11::SendDataToShader(const floa
|
||||
view[0]->Release();
|
||||
}
|
||||
desc.Width = size;
|
||||
desc.Format = DXGI_FORMAT_R32G32B32_FLOAT;
|
||||
desc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
|
||||
HRESULT hr = device_->CreateTexture1D(&desc, nullptr, &data_tex[0]);
|
||||
if (FAILED(hr)) {
|
||||
INFO_LOG(G3D, "Failed to create D3D texture for HW tessellation");
|
||||
@ -998,7 +998,7 @@ void DrawEngineD3D11::TessellationDataTransferD3D11::SendDataToShader(const floa
|
||||
view[1]->Release();
|
||||
}
|
||||
desc.Width = size;
|
||||
desc.Format = DXGI_FORMAT_R32G32B32_FLOAT;
|
||||
desc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
|
||||
HRESULT hr = device_->CreateTexture1D(&desc, nullptr, &data_tex[1]);
|
||||
if (FAILED(hr)) {
|
||||
INFO_LOG(G3D, "Failed to create D3D texture for HW tessellation");
|
||||
|
@ -944,7 +944,7 @@ void DrawEngineVulkan::TessellationDataTransferVulkan::PrepareBuffers(float *&po
|
||||
if (prevSize < size) {
|
||||
prevSize = size;
|
||||
|
||||
data_tex[0]->CreateDirect(size, 1, 1, VK_FORMAT_R32G32B32_SFLOAT, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
|
||||
data_tex[0]->CreateDirect(size, 1, 1, VK_FORMAT_R32G32B32A32_SFLOAT, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
|
||||
}
|
||||
pos = (float *)data_tex[0]->Lock(0, &rowPitch);
|
||||
|
||||
@ -953,7 +953,7 @@ void DrawEngineVulkan::TessellationDataTransferVulkan::PrepareBuffers(float *&po
|
||||
if (prevSizeTex < size) {
|
||||
prevSizeTex = size;
|
||||
|
||||
data_tex[1]->CreateDirect(size, 1, 1, VK_FORMAT_R32G32B32_SFLOAT, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
|
||||
data_tex[1]->CreateDirect(size, 1, 1, VK_FORMAT_R32G32B32A32_SFLOAT, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
|
||||
}
|
||||
tex = (float *)data_tex[1]->Lock(0, &rowPitch);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user