mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-07-10 15:15:58 +00:00
Add default Undefined sampler compare function
Bug: dawn:367 Change-Id: I27ee54b0117c90dd554690e4fabc939d679c4005 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/18422 Commit-Queue: Austin Eng <enga@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
f93791ab62
commit
d6a5431304
19
dawn.json
19
dawn.json
@ -394,14 +394,15 @@
|
|||||||
"compare function": {
|
"compare function": {
|
||||||
"category": "enum",
|
"category": "enum",
|
||||||
"values": [
|
"values": [
|
||||||
{"value": 0, "name": "never"},
|
{"value": 0, "name": "undefined"},
|
||||||
{"value": 1, "name": "less"},
|
{"value": 1, "name": "never"},
|
||||||
{"value": 2, "name": "less equal"},
|
{"value": 2, "name": "less"},
|
||||||
{"value": 3, "name": "greater"},
|
{"value": 3, "name": "less equal"},
|
||||||
{"value": 4, "name": "greater equal"},
|
{"value": 4, "name": "greater"},
|
||||||
{"value": 5, "name": "equal"},
|
{"value": 5, "name": "greater equal"},
|
||||||
{"value": 6, "name": "not equal"},
|
{"value": 6, "name": "equal"},
|
||||||
{"value": 7, "name": "always"}
|
{"value": 7, "name": "not equal"},
|
||||||
|
{"value": 8, "name": "always"}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"compute pass descriptor": {
|
"compute pass descriptor": {
|
||||||
@ -1248,7 +1249,7 @@
|
|||||||
{"name": "mipmap filter", "type": "filter mode", "default": "nearest"},
|
{"name": "mipmap filter", "type": "filter mode", "default": "nearest"},
|
||||||
{"name": "lod min clamp", "type": "float", "default": "0.0f"},
|
{"name": "lod min clamp", "type": "float", "default": "0.0f"},
|
||||||
{"name": "lod max clamp", "type": "float", "default": "1000.0f"},
|
{"name": "lod max clamp", "type": "float", "default": "1000.0f"},
|
||||||
{"name": "compare", "type": "compare function", "default": "never"}
|
{"name": "compare", "type": "compare function", "default": "undefined"}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"sampler descriptor dummy anisotropic filtering": {
|
"sampler descriptor dummy anisotropic filtering": {
|
||||||
|
@ -83,7 +83,12 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
mSamplerDesc.AddressW = AddressMode(descriptor->addressModeW);
|
mSamplerDesc.AddressW = AddressMode(descriptor->addressModeW);
|
||||||
mSamplerDesc.MipLODBias = 0.f;
|
mSamplerDesc.MipLODBias = 0.f;
|
||||||
mSamplerDesc.MaxAnisotropy = 1;
|
mSamplerDesc.MaxAnisotropy = 1;
|
||||||
mSamplerDesc.ComparisonFunc = ToD3D12ComparisonFunc(descriptor->compare);
|
if (descriptor->compare != wgpu::CompareFunction::Undefined) {
|
||||||
|
mSamplerDesc.ComparisonFunc = ToD3D12ComparisonFunc(descriptor->compare);
|
||||||
|
} else {
|
||||||
|
// Still set the function so it's not garbage.
|
||||||
|
mSamplerDesc.ComparisonFunc = D3D12_COMPARISON_FUNC_NEVER;
|
||||||
|
}
|
||||||
mSamplerDesc.MinLOD = descriptor->lodMinClamp;
|
mSamplerDesc.MinLOD = descriptor->lodMinClamp;
|
||||||
mSamplerDesc.MaxLOD = descriptor->lodMaxClamp;
|
mSamplerDesc.MaxLOD = descriptor->lodMaxClamp;
|
||||||
}
|
}
|
||||||
|
@ -20,22 +20,22 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
|
|
||||||
D3D12_COMPARISON_FUNC ToD3D12ComparisonFunc(wgpu::CompareFunction func) {
|
D3D12_COMPARISON_FUNC ToD3D12ComparisonFunc(wgpu::CompareFunction func) {
|
||||||
switch (func) {
|
switch (func) {
|
||||||
case wgpu::CompareFunction::Always:
|
case wgpu::CompareFunction::Never:
|
||||||
return D3D12_COMPARISON_FUNC_ALWAYS;
|
return D3D12_COMPARISON_FUNC_NEVER;
|
||||||
case wgpu::CompareFunction::Equal:
|
|
||||||
return D3D12_COMPARISON_FUNC_EQUAL;
|
|
||||||
case wgpu::CompareFunction::Greater:
|
|
||||||
return D3D12_COMPARISON_FUNC_GREATER;
|
|
||||||
case wgpu::CompareFunction::GreaterEqual:
|
|
||||||
return D3D12_COMPARISON_FUNC_GREATER_EQUAL;
|
|
||||||
case wgpu::CompareFunction::Less:
|
case wgpu::CompareFunction::Less:
|
||||||
return D3D12_COMPARISON_FUNC_LESS;
|
return D3D12_COMPARISON_FUNC_LESS;
|
||||||
case wgpu::CompareFunction::LessEqual:
|
case wgpu::CompareFunction::LessEqual:
|
||||||
return D3D12_COMPARISON_FUNC_LESS_EQUAL;
|
return D3D12_COMPARISON_FUNC_LESS_EQUAL;
|
||||||
case wgpu::CompareFunction::Never:
|
case wgpu::CompareFunction::Greater:
|
||||||
return D3D12_COMPARISON_FUNC_NEVER;
|
return D3D12_COMPARISON_FUNC_GREATER;
|
||||||
|
case wgpu::CompareFunction::GreaterEqual:
|
||||||
|
return D3D12_COMPARISON_FUNC_GREATER_EQUAL;
|
||||||
|
case wgpu::CompareFunction::Equal:
|
||||||
|
return D3D12_COMPARISON_FUNC_EQUAL;
|
||||||
case wgpu::CompareFunction::NotEqual:
|
case wgpu::CompareFunction::NotEqual:
|
||||||
return D3D12_COMPARISON_FUNC_NOT_EQUAL;
|
return D3D12_COMPARISON_FUNC_NOT_EQUAL;
|
||||||
|
case wgpu::CompareFunction::Always:
|
||||||
|
return D3D12_COMPARISON_FUNC_ALWAYS;
|
||||||
default:
|
default:
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ namespace dawn_native { namespace metal {
|
|||||||
|
|
||||||
// static
|
// static
|
||||||
ResultOrError<Sampler*> Sampler::Create(Device* device, const SamplerDescriptor* descriptor) {
|
ResultOrError<Sampler*> Sampler::Create(Device* device, const SamplerDescriptor* descriptor) {
|
||||||
if (descriptor->compare != wgpu::CompareFunction::Never &&
|
if (descriptor->compare != wgpu::CompareFunction::Undefined &&
|
||||||
device->IsToggleEnabled(Toggle::MetalDisableSamplerCompare)) {
|
device->IsToggleEnabled(Toggle::MetalDisableSamplerCompare)) {
|
||||||
return DAWN_VALIDATION_ERROR("Sampler compare function not supported.");
|
return DAWN_VALIDATION_ERROR("Sampler compare function not supported.");
|
||||||
}
|
}
|
||||||
@ -75,10 +75,12 @@ namespace dawn_native { namespace metal {
|
|||||||
mtlDesc.lodMinClamp = descriptor->lodMinClamp;
|
mtlDesc.lodMinClamp = descriptor->lodMinClamp;
|
||||||
mtlDesc.lodMaxClamp = descriptor->lodMaxClamp;
|
mtlDesc.lodMaxClamp = descriptor->lodMaxClamp;
|
||||||
|
|
||||||
if (descriptor->compare != wgpu::CompareFunction::Never) {
|
if (descriptor->compare != wgpu::CompareFunction::Undefined) {
|
||||||
// Anything other than Never is unsupported before A9, which we validate in
|
// Sampler compare is unsupported before A9, which we validate in
|
||||||
// Sampler::Create.
|
// Sampler::Create.
|
||||||
mtlDesc.compareFunction = ToMetalCompareFunction(descriptor->compare);
|
mtlDesc.compareFunction = ToMetalCompareFunction(descriptor->compare);
|
||||||
|
// The value is default-initialized in the else-case, and we don't set it or the
|
||||||
|
// Metal debug device errors.
|
||||||
}
|
}
|
||||||
|
|
||||||
mMtlSamplerState = [device->GetMTLDevice() newSamplerStateWithDescriptor:mtlDesc];
|
mMtlSamplerState = [device->GetMTLDevice() newSamplerStateWithDescriptor:mtlDesc];
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
#include "dawn_native/metal/UtilsMetal.h"
|
#include "dawn_native/metal/UtilsMetal.h"
|
||||||
|
|
||||||
|
#include "common/Assert.h"
|
||||||
|
|
||||||
namespace dawn_native { namespace metal {
|
namespace dawn_native { namespace metal {
|
||||||
|
|
||||||
MTLCompareFunction ToMetalCompareFunction(wgpu::CompareFunction compareFunction) {
|
MTLCompareFunction ToMetalCompareFunction(wgpu::CompareFunction compareFunction) {
|
||||||
@ -34,6 +36,8 @@ namespace dawn_native { namespace metal {
|
|||||||
return MTLCompareFunctionEqual;
|
return MTLCompareFunctionEqual;
|
||||||
case wgpu::CompareFunction::Always:
|
case wgpu::CompareFunction::Always:
|
||||||
return MTLCompareFunctionAlways;
|
return MTLCompareFunctionAlways;
|
||||||
|
default:
|
||||||
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ namespace dawn_native { namespace opengl {
|
|||||||
gl.SamplerParameterf(sampler, GL_TEXTURE_MIN_LOD, descriptor->lodMinClamp);
|
gl.SamplerParameterf(sampler, GL_TEXTURE_MIN_LOD, descriptor->lodMinClamp);
|
||||||
gl.SamplerParameterf(sampler, GL_TEXTURE_MAX_LOD, descriptor->lodMaxClamp);
|
gl.SamplerParameterf(sampler, GL_TEXTURE_MAX_LOD, descriptor->lodMaxClamp);
|
||||||
|
|
||||||
if (ToOpenGLCompareFunction(descriptor->compare) != GL_NEVER) {
|
if (descriptor->compare != wgpu::CompareFunction::Undefined) {
|
||||||
gl.SamplerParameteri(sampler, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
|
gl.SamplerParameteri(sampler, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
|
||||||
gl.SamplerParameteri(sampler, GL_TEXTURE_COMPARE_FUNC,
|
gl.SamplerParameteri(sampler, GL_TEXTURE_COMPARE_FUNC,
|
||||||
ToOpenGLCompareFunction(descriptor->compare));
|
ToOpenGLCompareFunction(descriptor->compare));
|
||||||
|
@ -79,8 +79,14 @@ namespace dawn_native { namespace vulkan {
|
|||||||
createInfo.mipLodBias = 0.0f;
|
createInfo.mipLodBias = 0.0f;
|
||||||
createInfo.anisotropyEnable = VK_FALSE;
|
createInfo.anisotropyEnable = VK_FALSE;
|
||||||
createInfo.maxAnisotropy = 1.0f;
|
createInfo.maxAnisotropy = 1.0f;
|
||||||
createInfo.compareOp = ToVulkanCompareOp(descriptor->compare);
|
if (descriptor->compare != wgpu::CompareFunction::Undefined) {
|
||||||
createInfo.compareEnable = createInfo.compareOp == VK_COMPARE_OP_NEVER ? VK_FALSE : VK_TRUE;
|
createInfo.compareOp = ToVulkanCompareOp(descriptor->compare);
|
||||||
|
createInfo.compareEnable = VK_TRUE;
|
||||||
|
} else {
|
||||||
|
// Still set the compareOp so it's not garbage.
|
||||||
|
createInfo.compareOp = VK_COMPARE_OP_NEVER;
|
||||||
|
createInfo.compareEnable = VK_FALSE;
|
||||||
|
}
|
||||||
createInfo.minLod = descriptor->lodMinClamp;
|
createInfo.minLod = descriptor->lodMinClamp;
|
||||||
createInfo.maxLod = descriptor->lodMaxClamp;
|
createInfo.maxLod = descriptor->lodMaxClamp;
|
||||||
createInfo.unnormalizedCoordinates = VK_FALSE;
|
createInfo.unnormalizedCoordinates = VK_FALSE;
|
||||||
|
@ -23,22 +23,22 @@ namespace dawn_native { namespace vulkan {
|
|||||||
|
|
||||||
VkCompareOp ToVulkanCompareOp(wgpu::CompareFunction op) {
|
VkCompareOp ToVulkanCompareOp(wgpu::CompareFunction op) {
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case wgpu::CompareFunction::Always:
|
case wgpu::CompareFunction::Never:
|
||||||
return VK_COMPARE_OP_ALWAYS;
|
return VK_COMPARE_OP_NEVER;
|
||||||
case wgpu::CompareFunction::Equal:
|
|
||||||
return VK_COMPARE_OP_EQUAL;
|
|
||||||
case wgpu::CompareFunction::Greater:
|
|
||||||
return VK_COMPARE_OP_GREATER;
|
|
||||||
case wgpu::CompareFunction::GreaterEqual:
|
|
||||||
return VK_COMPARE_OP_GREATER_OR_EQUAL;
|
|
||||||
case wgpu::CompareFunction::Less:
|
case wgpu::CompareFunction::Less:
|
||||||
return VK_COMPARE_OP_LESS;
|
return VK_COMPARE_OP_LESS;
|
||||||
case wgpu::CompareFunction::LessEqual:
|
case wgpu::CompareFunction::LessEqual:
|
||||||
return VK_COMPARE_OP_LESS_OR_EQUAL;
|
return VK_COMPARE_OP_LESS_OR_EQUAL;
|
||||||
case wgpu::CompareFunction::Never:
|
case wgpu::CompareFunction::Greater:
|
||||||
return VK_COMPARE_OP_NEVER;
|
return VK_COMPARE_OP_GREATER;
|
||||||
|
case wgpu::CompareFunction::GreaterEqual:
|
||||||
|
return VK_COMPARE_OP_GREATER_OR_EQUAL;
|
||||||
|
case wgpu::CompareFunction::Equal:
|
||||||
|
return VK_COMPARE_OP_EQUAL;
|
||||||
case wgpu::CompareFunction::NotEqual:
|
case wgpu::CompareFunction::NotEqual:
|
||||||
return VK_COMPARE_OP_NOT_EQUAL;
|
return VK_COMPARE_OP_NOT_EQUAL;
|
||||||
|
case wgpu::CompareFunction::Always:
|
||||||
|
return VK_COMPARE_OP_ALWAYS;
|
||||||
default:
|
default:
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user