d3d12: Fix increment size for sampler and row pitch for swizzled textures

This commit is contained in:
vlj 2015-05-29 01:09:53 +02:00 committed by Vincent Lejeune
parent 262d3d0755
commit 3e11598941
2 changed files with 4 additions and 4 deletions

View File

@ -76,7 +76,7 @@ void D3D12GSRender::ResourceStorage::Init(ID3D12Device *device)
check(device->CreateHeap(&heapDescription, IID_PPV_ARGS(&m_textureStorage))); check(device->CreateHeap(&heapDescription, IID_PPV_ARGS(&m_textureStorage)));
D3D12_DESCRIPTOR_HEAP_DESC textureDescriptorDesc = {}; D3D12_DESCRIPTOR_HEAP_DESC textureDescriptorDesc = {};
textureDescriptorDesc.NumDescriptors = 1024; // For safety textureDescriptorDesc.NumDescriptors = 2048; // For safety
textureDescriptorDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV; textureDescriptorDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV;
textureDescriptorDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE; textureDescriptorDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE;
check(device->CreateDescriptorHeap(&textureDescriptorDesc, IID_PPV_ARGS(&m_textureDescriptorsHeap))); check(device->CreateDescriptorHeap(&textureDescriptorDesc, IID_PPV_ARGS(&m_textureDescriptorsHeap)));
@ -665,7 +665,7 @@ void D3D12GSRender::ExecCMD()
samplerDesc.AddressV = D3D12_TEXTURE_ADDRESS_MODE_WRAP; samplerDesc.AddressV = D3D12_TEXTURE_ADDRESS_MODE_WRAP;
samplerDesc.AddressW = D3D12_TEXTURE_ADDRESS_MODE_WRAP; samplerDesc.AddressW = D3D12_TEXTURE_ADDRESS_MODE_WRAP;
Handle = m_perFrameStorage.m_samplerDescriptorHeap->GetCPUDescriptorHandleForHeapStart(); Handle = m_perFrameStorage.m_samplerDescriptorHeap->GetCPUDescriptorHandleForHeapStart();
Handle.ptr += (m_perFrameStorage.m_currentTextureIndex + usedTexture) * m_device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); Handle.ptr += (m_perFrameStorage.m_currentTextureIndex + usedTexture) * m_device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER);
m_device->CreateSampler(&samplerDesc, Handle); m_device->CreateSampler(&samplerDesc, Handle);
} }

View File

@ -188,7 +188,7 @@ size_t D3D12GSRender::UploadTextures()
for (int j = 0; j < m_textures[i].GetWidth(); j++) for (int j = 0; j < m_textures[i].GetWidth(); j++)
{ {
dst[(row * rowPitch) + j] = src[LinearToSwizzleAddress(j, i, 0, log2width, log2height, 0)]; dst[(row * rowPitch / 4) + j] = src[LinearToSwizzleAddress(j, i, 0, log2width, log2height, 0)];
} }
} }
else else
@ -271,7 +271,7 @@ size_t D3D12GSRender::UploadTextures()
samplerDesc.MinLOD = m_textures[i].GetMinLOD() >> 8; samplerDesc.MinLOD = m_textures[i].GetMinLOD() >> 8;
samplerDesc.MaxLOD = m_textures[i].GetMaxLOD() >> 8; samplerDesc.MaxLOD = m_textures[i].GetMaxLOD() >> 8;
Handle = m_perFrameStorage.m_samplerDescriptorHeap->GetCPUDescriptorHandleForHeapStart(); Handle = m_perFrameStorage.m_samplerDescriptorHeap->GetCPUDescriptorHandleForHeapStart();
Handle.ptr += (m_perFrameStorage.m_currentTextureIndex + usedTexture) * m_device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); Handle.ptr += (m_perFrameStorage.m_currentTextureIndex + usedTexture) * m_device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER);
m_device->CreateSampler(&samplerDesc, Handle); m_device->CreateSampler(&samplerDesc, Handle);
commandList->Close(); commandList->Close();