mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-08-07 12:45:57 +00:00
Support depth32float sampling on D3D12
Bug: dawn:367 Change-Id: I026e718130cbd92427c6292045fd041c878d4f77 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/20840 Commit-Queue: Austin Eng <enga@chromium.org> Reviewed-by: Stephen White <senorblanco@chromium.org>
This commit is contained in:
parent
e8bf706d16
commit
071fe56ffe
@ -46,18 +46,30 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
// D3D12_FILTER_MIN_LINEAR_MAG_POINT_MIP_LINEAR = 0x11 17 1 0 1
|
// D3D12_FILTER_MIN_LINEAR_MAG_POINT_MIP_LINEAR = 0x11 17 1 0 1
|
||||||
// D3D12_FILTER_MIN_MAG_LINEAR_MIP_POINT = 0x14 20 1 1 0
|
// D3D12_FILTER_MIN_MAG_LINEAR_MIP_POINT = 0x14 20 1 1 0
|
||||||
// D3D12_FILTER_MIN_MAG_MIP_LINEAR = 0x15 21 1 1 1
|
// D3D12_FILTER_MIN_MAG_MIP_LINEAR = 0x15 21 1 1 1
|
||||||
|
// D3D12_FILTER_COMPARISON_MIN_MAG_MIP_POINT, = 0x80 128
|
||||||
|
// D3D12_FILTER_COMPARISON_MIN_MAG_POINT_MIP_LINEAR, = 0x81 129
|
||||||
|
// D3D12_FILTER_COMPARISON_MIN_POINT_MAG_LINEAR_MIP_POINT, = 0x84 132
|
||||||
|
// D3D12_FILTER_COMPARISON_MIN_POINT_MAG_MIP_LINEAR, = 0x85 133
|
||||||
|
// D3D12_FILTER_COMPARISON_MIN_LINEAR_MAG_MIP_POINT, = 0x90 144
|
||||||
|
// D3D12_FILTER_COMPARISON_MIN_LINEAR_MAG_POINT_MIP_LINEAR,= 0x91 145
|
||||||
|
// D3D12_FILTER_COMPARISON_MIN_MAG_LINEAR_MIP_POINT, = 0x94 148
|
||||||
|
// D3D12_FILTER_COMPARISON_MIN_MAG_MIP_LINEAR, = 0x95 149
|
||||||
|
|
||||||
// if mip mode is linear, add 1
|
// if mip mode is linear, add 0x1
|
||||||
// if mag mode is linear, add 4
|
// if mag mode is linear, add 0x4
|
||||||
// if min mode is linear, add 16
|
// if min mode is linear, add 0x10
|
||||||
|
// if comparison, add 0x80
|
||||||
|
|
||||||
uint8_t mode = 0;
|
uint8_t mode = 0;
|
||||||
|
if (descriptor->compare != wgpu::CompareFunction::Undefined) {
|
||||||
|
mode += 0x80;
|
||||||
|
}
|
||||||
|
|
||||||
switch (descriptor->minFilter) {
|
switch (descriptor->minFilter) {
|
||||||
case wgpu::FilterMode::Nearest:
|
case wgpu::FilterMode::Nearest:
|
||||||
break;
|
break;
|
||||||
case wgpu::FilterMode::Linear:
|
case wgpu::FilterMode::Linear:
|
||||||
mode += 16;
|
mode += 0x10;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,7 +77,7 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
case wgpu::FilterMode::Nearest:
|
case wgpu::FilterMode::Nearest:
|
||||||
break;
|
break;
|
||||||
case wgpu::FilterMode::Linear:
|
case wgpu::FilterMode::Linear:
|
||||||
mode += 4;
|
mode += 0x4;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,7 +85,7 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
case wgpu::FilterMode::Nearest:
|
case wgpu::FilterMode::Nearest:
|
||||||
break;
|
break;
|
||||||
case wgpu::FilterMode::Linear:
|
case wgpu::FilterMode::Linear:
|
||||||
mode += 1;
|
mode += 0x1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -772,6 +772,11 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
TextureView::TextureView(TextureBase* texture, const TextureViewDescriptor* descriptor)
|
TextureView::TextureView(TextureBase* texture, const TextureViewDescriptor* descriptor)
|
||||||
: TextureViewBase(texture, descriptor) {
|
: TextureViewBase(texture, descriptor) {
|
||||||
mSrvDesc.Format = D3D12TextureFormat(descriptor->format);
|
mSrvDesc.Format = D3D12TextureFormat(descriptor->format);
|
||||||
|
if (descriptor->format == wgpu::TextureFormat::Depth32Float) {
|
||||||
|
// TODO(enga): This will need to be much more nuanced when WebGPU has
|
||||||
|
// texture view compatibility rules.
|
||||||
|
mSrvDesc.Format = DXGI_FORMAT_R32_FLOAT;
|
||||||
|
}
|
||||||
mSrvDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;
|
mSrvDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;
|
||||||
|
|
||||||
// Currently we always use D3D12_TEX2D_ARRAY_SRV because we cannot specify base array layer
|
// Currently we always use D3D12_TEX2D_ARRAY_SRV because we cannot specify base array layer
|
||||||
|
@ -505,7 +505,4 @@ TEST_P(DepthSamplingTest, CompareFunctionsNonNormalizedContentsCompute) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(crbug.com/dawn/367): Does not work on D3D12 because we need to reinterpret the texture view
|
DAWN_INSTANTIATE_TEST(DepthSamplingTest, D3D12Backend(), MetalBackend(), OpenGLBackend(), VulkanBackend());
|
||||||
// as R32Float to sample it. See tables here:
|
|
||||||
// https://docs.microsoft.com/en-us/windows/win32/direct3ddxgi/hardware-support-for-direct3d-12-1-formats
|
|
||||||
DAWN_INSTANTIATE_TEST(DepthSamplingTest, MetalBackend(), OpenGLBackend(), VulkanBackend());
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user