mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-04 09:00:44 +00:00
Test that sampler heaps are represented in structured data properly
* This is a test of a specific case of lazy serialisation, but in particular D3D12 descriptors do some aliasing tricks for types to compress the data, so repeated serialisation needs to be safe.
This commit is contained in:
@@ -158,8 +158,35 @@ float4 main() : SV_Target0
|
||||
CHECK_HR(dev->CreateDescriptorHeap(&desc, __uuidof(ID3D12DescriptorHeap), (void **)&descHeap));
|
||||
}
|
||||
|
||||
ID3D12DescriptorHeapPtr sampHeap;
|
||||
|
||||
{
|
||||
D3D12_DESCRIPTOR_HEAP_DESC desc;
|
||||
desc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE;
|
||||
desc.NodeMask = 1;
|
||||
desc.NumDescriptors = 2000;
|
||||
desc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER;
|
||||
CHECK_HR(dev->CreateDescriptorHeap(&desc, __uuidof(ID3D12DescriptorHeap), (void **)&sampHeap));
|
||||
}
|
||||
|
||||
sampHeap->SetName(L"Sampler Heap");
|
||||
|
||||
D3D12_SAMPLER_DESC samplerDesc = {};
|
||||
samplerDesc.Filter = D3D12_FILTER_ANISOTROPIC;
|
||||
samplerDesc.AddressU = samplerDesc.AddressV = samplerDesc.AddressW =
|
||||
D3D12_TEXTURE_ADDRESS_MODE_BORDER;
|
||||
samplerDesc.MaxAnisotropy = 4;
|
||||
samplerDesc.MinLOD = 1.5f;
|
||||
UINT increment = dev->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER);
|
||||
D3D12_CPU_DESCRIPTOR_HANDLE samplerStart = sampHeap->GetCPUDescriptorHandleForHeapStart();
|
||||
dev->CreateSampler(&samplerDesc, {samplerStart.ptr + increment * 1234});
|
||||
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE descGPUHandle = descHeap->GetGPUDescriptorHandleForHeapStart();
|
||||
|
||||
ID3D12DescriptorHeap *heaps[] = {
|
||||
descHeap.GetInterfacePtr(), sampHeap.GetInterfacePtr(),
|
||||
};
|
||||
|
||||
D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc = {};
|
||||
srvDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
srvDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;
|
||||
@@ -318,7 +345,7 @@ float4 main() : SV_Target0
|
||||
|
||||
cmd->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
||||
|
||||
cmd->SetDescriptorHeaps(1, &descHeap.GetInterfacePtr());
|
||||
cmd->SetDescriptorHeaps(2, heaps);
|
||||
|
||||
IASetVertexBuffer(cmd, vb2, sizeof(DefaultA2V), 0);
|
||||
IASetVertexBuffer(cmd, vb, sizeof(DefaultA2V), 0);
|
||||
|
||||
@@ -72,4 +72,28 @@ class D3D12_Parameter_Zoo(rdtest.TestCase):
|
||||
|
||||
out.Shutdown()
|
||||
|
||||
res = self.get_resource_by_name("Sampler Heap")
|
||||
|
||||
sdfile = self.controller.GetStructuredFile()
|
||||
|
||||
chunk = sdfile.chunks[res.initialisationChunks[-1]]
|
||||
|
||||
desc1234 = chunk.GetChild(2).GetChild(1234).GetChild(3)
|
||||
|
||||
rdtest.log.comment('desc1234: ' + desc1234.name)
|
||||
|
||||
# filter
|
||||
self.check(desc1234.GetChild(0).AsString() == 'D3D12_FILTER_ANISOTROPIC')
|
||||
self.check(desc1234.GetChild(0).AsInt() == 0x55)
|
||||
|
||||
# wrapping
|
||||
self.check(desc1234.GetChild(1).AsString() == 'D3D12_TEXTURE_ADDRESS_MODE_BORDER')
|
||||
self.check(desc1234.GetChild(1).AsInt() == 4)
|
||||
|
||||
# MaxAnisotropy
|
||||
self.check(desc1234.GetChild(1).AsInt() == 4)
|
||||
|
||||
# MinLod
|
||||
self.check(desc1234.GetChild(8).AsFloat() == 1.5)
|
||||
|
||||
rdtest.log.success("Overlay color is as expected")
|
||||
Reference in New Issue
Block a user