mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-21 03:55:32 +00:00
d3d12: Some fixe to textures
This commit is contained in:
parent
782a11b47f
commit
3a75e6a357
2 changed files with 24 additions and 7 deletions
|
@ -626,7 +626,7 @@ void D3D12GSRender::ExecCMD()
|
|||
{
|
||||
if (!m_textures[i].IsEnabled()) continue;
|
||||
|
||||
Microsoft::WRL::ComPtr<ID3D12Resource> Texture, vramTexture;
|
||||
ID3D12Resource *Texture, *vramTexture;
|
||||
size_t textureSize = m_textures[i].GetWidth() * m_textures[i].GetHeight() * 4;
|
||||
D3D12_RESOURCE_DESC textureDesc = {};
|
||||
textureDesc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER;
|
||||
|
@ -672,9 +672,9 @@ void D3D12GSRender::ExecCMD()
|
|||
m_currentStorageOffset += textureSize;
|
||||
|
||||
D3D12_TEXTURE_COPY_LOCATION dst = {}, src = {};
|
||||
dst.pResource = vramTexture.Get();
|
||||
dst.pResource = vramTexture;
|
||||
dst.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX;
|
||||
src.pResource = Texture.Get();
|
||||
src.pResource = Texture;
|
||||
src.Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT;
|
||||
src.PlacedFootprint.Footprint.Depth = 1;
|
||||
src.PlacedFootprint.Footprint.Width = m_textures[i].GetWidth();
|
||||
|
@ -686,7 +686,7 @@ void D3D12GSRender::ExecCMD()
|
|||
|
||||
D3D12_RESOURCE_BARRIER barrier = {};
|
||||
barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
|
||||
barrier.Transition.pResource = vramTexture.Get();
|
||||
barrier.Transition.pResource = vramTexture;
|
||||
barrier.Transition.StateBefore = D3D12_RESOURCE_STATE_COPY_DEST;
|
||||
barrier.Transition.StateAfter = D3D12_RESOURCE_STATE_GENERIC_READ;
|
||||
commandList->ResourceBarrier(1, &barrier);
|
||||
|
@ -698,11 +698,14 @@ void D3D12GSRender::ExecCMD()
|
|||
srvDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;
|
||||
D3D12_CPU_DESCRIPTOR_HANDLE Handle = m_textureDescriptorsHeap->GetCPUDescriptorHandleForHeapStart();
|
||||
Handle.ptr += (m_currentTextureIndex + usedTexture) * m_device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
|
||||
m_device->CreateShaderResourceView(vramTexture.Get(), &srvDesc, Handle);
|
||||
m_device->CreateShaderResourceView(vramTexture, &srvDesc, Handle);
|
||||
|
||||
// TODO : Correctly define sampler
|
||||
D3D12_SAMPLER_DESC samplerDesc = {};
|
||||
samplerDesc.Filter = D3D12_FILTER_MIN_MAG_MIP_POINT;
|
||||
samplerDesc.AddressU = D3D12_TEXTURE_ADDRESS_MODE_WRAP;
|
||||
samplerDesc.AddressV = D3D12_TEXTURE_ADDRESS_MODE_WRAP;
|
||||
samplerDesc.AddressW = D3D12_TEXTURE_ADDRESS_MODE_WRAP;
|
||||
Handle = m_samplerDescriptorHeap->GetCPUDescriptorHandleForHeapStart();
|
||||
Handle.ptr += (m_currentTextureIndex + usedTexture) * m_device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
|
||||
m_device->CreateSampler(&samplerDesc, Handle);
|
||||
|
|
|
@ -435,10 +435,24 @@ void FragmentDecompiler::insertConstants(std::stringstream & OS)
|
|||
OS << "{" << std::endl;
|
||||
for (ParamType PT : m_parr.params[PF_PARAM_UNIFORM])
|
||||
{
|
||||
if (PT.type == "sampler2D")
|
||||
continue;
|
||||
for (ParamItem PI : PT.items)
|
||||
OS << " " << PT.type << " " << PI.name << ";" << std::endl;
|
||||
}
|
||||
OS << "};" << std::endl;
|
||||
OS << "};" << std::endl << std::endl;
|
||||
size_t textureIndex = 0;
|
||||
for (ParamType PT : m_parr.params[PF_PARAM_UNIFORM])
|
||||
{
|
||||
if (PT.type != "sampler2D")
|
||||
continue;
|
||||
for (ParamItem PI : PT.items)
|
||||
{
|
||||
OS << "Texture2D " << PI.name << " : register(t" << textureIndex << ");" << std::endl;
|
||||
OS << "sampler " << PI.name << "sampler : register(s" << textureIndex << ");" << std::endl;
|
||||
textureIndex++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FragmentDecompiler::insertMainStart(std::stringstream & OS)
|
||||
|
@ -616,7 +630,7 @@ std::string FragmentDecompiler::Decompile()
|
|||
case RSX_FP_OPCODE_DDY: SetDst("dFdy($0)"); break;
|
||||
case RSX_FP_OPCODE_NRM: SetDst("normalize($0)"); break;
|
||||
case RSX_FP_OPCODE_BEM: LOG_ERROR(RSX, "Unimplemented TEX_SRB instruction: BEM"); break;
|
||||
case RSX_FP_OPCODE_TEX: SetDst("float4(0., 0., 0., 0.);//texture($t, $0.xy)"); break;
|
||||
case RSX_FP_OPCODE_TEX: SetDst("$t.Sample($tsampler, $0.xy)"); break;
|
||||
case RSX_FP_OPCODE_TEXBEM: SetDst("texture($t, $0.xy, $1.x)"); break;
|
||||
case RSX_FP_OPCODE_TXP: SetDst("textureProj($t, $0.xyz, $1.x)"); break; //TODO: More testing (Sonic The Hedgehog (NPUB-30442/NPEB-00478) and The Simpsons Arcade Game (NPUB30563))
|
||||
case RSX_FP_OPCODE_TXPBEM: SetDst("textureProj($t, $0.xyz, $1.x)"); break;
|
||||
|
|
Loading…
Add table
Reference in a new issue