diff --git a/rpcs3/Emu/RSX/D3D12/D3D12GSRender.cpp b/rpcs3/Emu/RSX/D3D12/D3D12GSRender.cpp index fcfaec85db..dadd5c8051 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12GSRender.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12GSRender.cpp @@ -345,24 +345,28 @@ void D3D12GSRender::FillVertexShaderConstantsBuffer() memcpy((char*)constantsBufferMap + m_constantsBufferOffset + currentoffset, scaleOffsetMat, 16 * sizeof(float)); currentoffset += 16 * sizeof(float); + size_t bufferSize = currentoffset; + for (const RSXTransformConstant& c : m_transform_constants) { + size_t offset = c.id * 4 * sizeof(float) + currentoffset; float vector[] = { c.x, c.y, c.z, c.w }; - memcpy((char*)constantsBufferMap + m_constantsBufferOffset + currentoffset, vector, 4 * sizeof(float)); - currentoffset += 4 * sizeof(float); + memcpy((char*)constantsBufferMap + m_constantsBufferOffset + offset, vector, 4 * sizeof(float)); + size_t bufferSizeCandidate = offset + 4 * sizeof(float); + bufferSize = bufferSizeCandidate > bufferSize ? bufferSizeCandidate : bufferSize; } m_constantsBuffer->Unmap(0, &range); // Align to 256 byte - currentoffset = (currentoffset + 255) & ~255; + bufferSize = (bufferSize + 255) & ~255; D3D12_CONSTANT_BUFFER_VIEW_DESC constantBufferViewDesc = {}; constantBufferViewDesc.BufferLocation = m_constantsBuffer->GetGPUVirtualAddress() + m_constantsBufferOffset; - constantBufferViewDesc.SizeInBytes = (UINT)currentoffset; + constantBufferViewDesc.SizeInBytes = (UINT)bufferSize; D3D12_CPU_DESCRIPTOR_HANDLE Handle = m_constantsBufferDescriptorsHeap->GetCPUDescriptorHandleForHeapStart(); Handle.ptr += m_constantsBufferIndex * m_device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); m_device->CreateConstantBufferView(&constantBufferViewDesc, Handle); - m_constantsBufferOffset += currentoffset; + m_constantsBufferOffset += bufferSize; } void D3D12GSRender::FillPixelShaderConstantsBuffer() diff --git a/rpcs3/Emu/RSX/D3D12/D3D12PipelineState.cpp b/rpcs3/Emu/RSX/D3D12/D3D12PipelineState.cpp index 613a65fad6..66032a0dc7 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12PipelineState.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12PipelineState.cpp @@ -256,6 +256,7 @@ void Shader::Compile(SHADER_TYPE st) cbuffer CONSTANT : register(b0) { float4x4 scaleOffsetMat; + float4 vc[468]; }; struct vertex { @@ -271,7 +272,13 @@ void Shader::Compile(SHADER_TYPE st) pixel main(vertex In) { pixel Out; - Out.pos = mul(float4(In.pos.x, In.pos.y, 0., 1.), scaleOffsetMat); + float4 pos = In.pos; + pos.w = dot(pos, vc[259]); + pos.z = dot(pos, vc[258]); + pos.y = dot(pos, vc[257]); + pos.x = dot(pos, vc[256]); + pos.z = 0; + Out.pos = mul(pos, scaleOffsetMat); Out.color = In.color; return Out; });