mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-07-07 13:45:51 +00:00
Remove sampler border color from Dawn to match WebGPU
Bug: chromium:877147 Change-Id: I9760b3c6cb67a3ffa08feeaff8e8b24b80ec4200 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6380 Commit-Queue: Austin Eng <enga@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
865cad89b9
commit
5f1d2e1c8d
14
dawn.json
14
dawn.json
@ -19,8 +19,7 @@
|
|||||||
"values": [
|
"values": [
|
||||||
{"value": 0, "name": "repeat"},
|
{"value": 0, "name": "repeat"},
|
||||||
{"value": 1, "name": "mirrored repeat"},
|
{"value": 1, "name": "mirrored repeat"},
|
||||||
{"value": 2, "name": "clamp to edge"},
|
{"value": 2, "name": "clamp to edge"}
|
||||||
{"value": 3, "name": "clamp to border color"}
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"bind group": {
|
"bind group": {
|
||||||
@ -128,14 +127,6 @@
|
|||||||
"bool": {
|
"bool": {
|
||||||
"category": "native"
|
"category": "native"
|
||||||
},
|
},
|
||||||
"border color": {
|
|
||||||
"category": "enum",
|
|
||||||
"values": [
|
|
||||||
{"value": 0, "name": "transparent black"},
|
|
||||||
{"value": 1, "name": "opaque black"},
|
|
||||||
{"value": 2, "name": "opaque white"}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"buffer": {
|
"buffer": {
|
||||||
"category": "object",
|
"category": "object",
|
||||||
"methods": [
|
"methods": [
|
||||||
@ -855,8 +846,7 @@
|
|||||||
{"name": "mipmap filter", "type": "filter mode"},
|
{"name": "mipmap filter", "type": "filter mode"},
|
||||||
{"name": "lod min clamp", "type": "float"},
|
{"name": "lod min clamp", "type": "float"},
|
||||||
{"name": "lod max clamp", "type": "float"},
|
{"name": "lod max clamp", "type": "float"},
|
||||||
{"name": "compare function", "type": "compare function"},
|
{"name": "compare function", "type": "compare function"}
|
||||||
{"name": "border color", "type": "border color"}
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"shader module": {
|
"shader module": {
|
||||||
|
@ -40,7 +40,6 @@ namespace dawn_native {
|
|||||||
DAWN_TRY(ValidateAddressMode(descriptor->addressModeV));
|
DAWN_TRY(ValidateAddressMode(descriptor->addressModeV));
|
||||||
DAWN_TRY(ValidateAddressMode(descriptor->addressModeW));
|
DAWN_TRY(ValidateAddressMode(descriptor->addressModeW));
|
||||||
DAWN_TRY(ValidateCompareFunction(descriptor->compareFunction));
|
DAWN_TRY(ValidateCompareFunction(descriptor->compareFunction));
|
||||||
DAWN_TRY(ValidateBorderColor(descriptor->borderColor));
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,8 +28,6 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
return D3D12_TEXTURE_ADDRESS_MODE_MIRROR;
|
return D3D12_TEXTURE_ADDRESS_MODE_MIRROR;
|
||||||
case dawn::AddressMode::ClampToEdge:
|
case dawn::AddressMode::ClampToEdge:
|
||||||
return D3D12_TEXTURE_ADDRESS_MODE_CLAMP;
|
return D3D12_TEXTURE_ADDRESS_MODE_CLAMP;
|
||||||
case dawn::AddressMode::ClampToBorderColor:
|
|
||||||
return D3D12_TEXTURE_ADDRESS_MODE_BORDER;
|
|
||||||
default:
|
default:
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
@ -88,24 +86,6 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
mSamplerDesc.ComparisonFunc = ToD3D12ComparisonFunc(descriptor->compareFunction);
|
mSamplerDesc.ComparisonFunc = ToD3D12ComparisonFunc(descriptor->compareFunction);
|
||||||
mSamplerDesc.MinLOD = descriptor->lodMinClamp;
|
mSamplerDesc.MinLOD = descriptor->lodMinClamp;
|
||||||
mSamplerDesc.MaxLOD = descriptor->lodMaxClamp;
|
mSamplerDesc.MaxLOD = descriptor->lodMaxClamp;
|
||||||
|
|
||||||
switch (descriptor->borderColor) {
|
|
||||||
case dawn::BorderColor::TransparentBlack:
|
|
||||||
mSamplerDesc.BorderColor[0] = mSamplerDesc.BorderColor[1] =
|
|
||||||
mSamplerDesc.BorderColor[2] = mSamplerDesc.BorderColor[3] = 0;
|
|
||||||
break;
|
|
||||||
case dawn::BorderColor::OpaqueBlack:
|
|
||||||
mSamplerDesc.BorderColor[0] = mSamplerDesc.BorderColor[1] =
|
|
||||||
mSamplerDesc.BorderColor[2] = 0;
|
|
||||||
mSamplerDesc.BorderColor[3] = 1;
|
|
||||||
break;
|
|
||||||
case dawn::BorderColor::OpaqueWhite:
|
|
||||||
mSamplerDesc.BorderColor[0] = mSamplerDesc.BorderColor[1] =
|
|
||||||
mSamplerDesc.BorderColor[2] = mSamplerDesc.BorderColor[3] = 1;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
UNREACHABLE();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const D3D12_SAMPLER_DESC& Sampler::GetSamplerDescriptor() const {
|
const D3D12_SAMPLER_DESC& Sampler::GetSamplerDescriptor() const {
|
||||||
|
@ -30,7 +30,7 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
const D3D12_SAMPLER_DESC& GetSamplerDescriptor() const;
|
const D3D12_SAMPLER_DESC& GetSamplerDescriptor() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
D3D12_SAMPLER_DESC mSamplerDesc;
|
D3D12_SAMPLER_DESC mSamplerDesc = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
}} // namespace dawn_native::d3d12
|
}} // namespace dawn_native::d3d12
|
||||||
|
@ -46,19 +46,6 @@ namespace dawn_native { namespace metal {
|
|||||||
return MTLSamplerAddressModeMirrorRepeat;
|
return MTLSamplerAddressModeMirrorRepeat;
|
||||||
case dawn::AddressMode::ClampToEdge:
|
case dawn::AddressMode::ClampToEdge:
|
||||||
return MTLSamplerAddressModeClampToEdge;
|
return MTLSamplerAddressModeClampToEdge;
|
||||||
case dawn::AddressMode::ClampToBorderColor:
|
|
||||||
return MTLSamplerAddressModeClampToBorderColor;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MTLSamplerBorderColor BorderColor(dawn::BorderColor color) {
|
|
||||||
switch (color) {
|
|
||||||
case dawn::BorderColor::TransparentBlack:
|
|
||||||
return MTLSamplerBorderColorTransparentBlack;
|
|
||||||
case dawn::BorderColor::OpaqueBlack:
|
|
||||||
return MTLSamplerBorderColorOpaqueBlack;
|
|
||||||
case dawn::BorderColor::OpaqueWhite:
|
|
||||||
return MTLSamplerBorderColorOpaqueWhite;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -78,7 +65,6 @@ namespace dawn_native { namespace metal {
|
|||||||
mtlDesc.lodMinClamp = descriptor->lodMinClamp;
|
mtlDesc.lodMinClamp = descriptor->lodMinClamp;
|
||||||
mtlDesc.lodMaxClamp = descriptor->lodMaxClamp;
|
mtlDesc.lodMaxClamp = descriptor->lodMaxClamp;
|
||||||
mtlDesc.compareFunction = ToMetalCompareFunction(descriptor->compareFunction);
|
mtlDesc.compareFunction = ToMetalCompareFunction(descriptor->compareFunction);
|
||||||
mtlDesc.borderColor = BorderColor(descriptor->borderColor);
|
|
||||||
|
|
||||||
mMtlSamplerState = [device->GetMTLDevice() newSamplerStateWithDescriptor:mtlDesc];
|
mMtlSamplerState = [device->GetMTLDevice() newSamplerStateWithDescriptor:mtlDesc];
|
||||||
|
|
||||||
|
@ -65,17 +65,11 @@ namespace dawn_native { namespace opengl {
|
|||||||
return GL_MIRRORED_REPEAT;
|
return GL_MIRRORED_REPEAT;
|
||||||
case dawn::AddressMode::ClampToEdge:
|
case dawn::AddressMode::ClampToEdge:
|
||||||
return GL_CLAMP_TO_EDGE;
|
return GL_CLAMP_TO_EDGE;
|
||||||
case dawn::AddressMode::ClampToBorderColor:
|
|
||||||
return GL_CLAMP_TO_BORDER;
|
|
||||||
default:
|
default:
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const float kTransparentBlack[4] = {0.0, 0.0, 0.0, 0.0};
|
|
||||||
static const float kOpaqueBlack[4] = {0.0, 0.0, 0.0, 1.0};
|
|
||||||
static const float kOpaqueWhite[4] = {1.0, 1.0, 1.0, 1.0};
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
Sampler::Sampler(Device* device, const SamplerDescriptor* descriptor)
|
Sampler::Sampler(Device* device, const SamplerDescriptor* descriptor)
|
||||||
@ -96,20 +90,6 @@ namespace dawn_native { namespace opengl {
|
|||||||
glSamplerParameteri(mHandle, GL_TEXTURE_COMPARE_FUNC,
|
glSamplerParameteri(mHandle, GL_TEXTURE_COMPARE_FUNC,
|
||||||
ToOpenGLCompareFunction(descriptor->compareFunction));
|
ToOpenGLCompareFunction(descriptor->compareFunction));
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (descriptor->borderColor) {
|
|
||||||
case dawn::BorderColor::TransparentBlack:
|
|
||||||
glSamplerParameterfv(mHandle, GL_TEXTURE_BORDER_COLOR, kTransparentBlack);
|
|
||||||
break;
|
|
||||||
case dawn::BorderColor::OpaqueBlack:
|
|
||||||
glSamplerParameterfv(mHandle, GL_TEXTURE_BORDER_COLOR, kOpaqueBlack);
|
|
||||||
break;
|
|
||||||
case dawn::BorderColor::OpaqueWhite:
|
|
||||||
glSamplerParameterfv(mHandle, GL_TEXTURE_BORDER_COLOR, kOpaqueWhite);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
UNREACHABLE();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GLuint Sampler::GetHandle() const {
|
GLuint Sampler::GetHandle() const {
|
||||||
|
@ -29,8 +29,6 @@ namespace dawn_native { namespace vulkan {
|
|||||||
return VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT;
|
return VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT;
|
||||||
case dawn::AddressMode::ClampToEdge:
|
case dawn::AddressMode::ClampToEdge:
|
||||||
return VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE;
|
return VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE;
|
||||||
case dawn::AddressMode::ClampToBorderColor:
|
|
||||||
return VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER;
|
|
||||||
default:
|
default:
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
@ -57,24 +55,11 @@ namespace dawn_native { namespace vulkan {
|
|||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VkBorderColor VulkanBorderColor(dawn::BorderColor color) {
|
|
||||||
switch (color) {
|
|
||||||
case dawn::BorderColor::TransparentBlack:
|
|
||||||
return VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK;
|
|
||||||
case dawn::BorderColor::OpaqueBlack:
|
|
||||||
return VK_BORDER_COLOR_FLOAT_OPAQUE_BLACK;
|
|
||||||
case dawn::BorderColor::OpaqueWhite:
|
|
||||||
return VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE;
|
|
||||||
default:
|
|
||||||
UNREACHABLE();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
||||||
Sampler::Sampler(Device* device, const SamplerDescriptor* descriptor)
|
Sampler::Sampler(Device* device, const SamplerDescriptor* descriptor)
|
||||||
: SamplerBase(device, descriptor), mDevice(device) {
|
: SamplerBase(device, descriptor), mDevice(device) {
|
||||||
VkSamplerCreateInfo createInfo;
|
VkSamplerCreateInfo createInfo = {};
|
||||||
createInfo.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
|
createInfo.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
|
||||||
createInfo.pNext = nullptr;
|
createInfo.pNext = nullptr;
|
||||||
createInfo.flags = 0;
|
createInfo.flags = 0;
|
||||||
@ -91,7 +76,6 @@ namespace dawn_native { namespace vulkan {
|
|||||||
createInfo.compareEnable = createInfo.compareOp == VK_COMPARE_OP_NEVER ? VK_FALSE : VK_TRUE;
|
createInfo.compareEnable = createInfo.compareOp == VK_COMPARE_OP_NEVER ? VK_FALSE : VK_TRUE;
|
||||||
createInfo.minLod = descriptor->lodMinClamp;
|
createInfo.minLod = descriptor->lodMinClamp;
|
||||||
createInfo.maxLod = descriptor->lodMaxClamp;
|
createInfo.maxLod = descriptor->lodMaxClamp;
|
||||||
createInfo.borderColor = VulkanBorderColor(descriptor->borderColor);
|
|
||||||
createInfo.unnormalizedCoordinates = VK_FALSE;
|
createInfo.unnormalizedCoordinates = VK_FALSE;
|
||||||
|
|
||||||
if (device->fn.CreateSampler(device->GetVkDevice(), &createInfo, nullptr, &mHandle) !=
|
if (device->fn.CreateSampler(device->GetVkDevice(), &createInfo, nullptr, &mHandle) !=
|
||||||
|
@ -233,7 +233,6 @@ TEST_P(BindGroupTests, UBOSamplerAndTexture) {
|
|||||||
samplerDescriptor.lodMinClamp = kLodMin;
|
samplerDescriptor.lodMinClamp = kLodMin;
|
||||||
samplerDescriptor.lodMaxClamp = kLodMax;
|
samplerDescriptor.lodMaxClamp = kLodMax;
|
||||||
samplerDescriptor.compareFunction = dawn::CompareFunction::Never;
|
samplerDescriptor.compareFunction = dawn::CompareFunction::Never;
|
||||||
samplerDescriptor.borderColor = dawn::BorderColor::TransparentBlack;
|
|
||||||
|
|
||||||
dawn::Sampler sampler = device.CreateSampler(&samplerDescriptor);
|
dawn::Sampler sampler = device.CreateSampler(&samplerDescriptor);
|
||||||
|
|
||||||
|
@ -129,7 +129,6 @@ protected:
|
|||||||
descriptor.lodMinClamp = kLodMin;
|
descriptor.lodMinClamp = kLodMin;
|
||||||
descriptor.lodMaxClamp = kLodMax;
|
descriptor.lodMaxClamp = kLodMax;
|
||||||
descriptor.compareFunction = dawn::CompareFunction::Never;
|
descriptor.compareFunction = dawn::CompareFunction::Never;
|
||||||
descriptor.borderColor = dawn::BorderColor::TransparentBlack;
|
|
||||||
sampler = device.CreateSampler(&descriptor);
|
sampler = device.CreateSampler(&descriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,7 +102,6 @@ protected:
|
|||||||
samplerDescriptor.lodMinClamp = kLodMin;
|
samplerDescriptor.lodMinClamp = kLodMin;
|
||||||
samplerDescriptor.lodMaxClamp = kLodMax;
|
samplerDescriptor.lodMaxClamp = kLodMax;
|
||||||
samplerDescriptor.compareFunction = dawn::CompareFunction::Never;
|
samplerDescriptor.compareFunction = dawn::CompareFunction::Never;
|
||||||
samplerDescriptor.borderColor = dawn::BorderColor::TransparentBlack;
|
|
||||||
mSampler = device.CreateSampler(&samplerDescriptor);
|
mSampler = device.CreateSampler(&samplerDescriptor);
|
||||||
|
|
||||||
mPipelineLayout = utils::MakeBasicPipelineLayout(device, &mBindGroupLayout);
|
mPipelineLayout = utils::MakeBasicPipelineLayout(device, &mBindGroupLayout);
|
||||||
|
@ -246,7 +246,6 @@ TEST_F(WireArgumentTests, StructureOfValuesArgument) {
|
|||||||
descriptor.lodMinClamp = kLodMin;
|
descriptor.lodMinClamp = kLodMin;
|
||||||
descriptor.lodMaxClamp = kLodMax;
|
descriptor.lodMaxClamp = kLodMax;
|
||||||
descriptor.compareFunction = DAWN_COMPARE_FUNCTION_NEVER;
|
descriptor.compareFunction = DAWN_COMPARE_FUNCTION_NEVER;
|
||||||
descriptor.borderColor = DAWN_BORDER_COLOR_TRANSPARENT_BLACK;
|
|
||||||
|
|
||||||
dawnDeviceCreateSampler(device, &descriptor);
|
dawnDeviceCreateSampler(device, &descriptor);
|
||||||
|
|
||||||
@ -261,7 +260,6 @@ TEST_F(WireArgumentTests, StructureOfValuesArgument) {
|
|||||||
desc->addressModeV == DAWN_ADDRESS_MODE_REPEAT &&
|
desc->addressModeV == DAWN_ADDRESS_MODE_REPEAT &&
|
||||||
desc->addressModeW == DAWN_ADDRESS_MODE_MIRRORED_REPEAT &&
|
desc->addressModeW == DAWN_ADDRESS_MODE_MIRRORED_REPEAT &&
|
||||||
desc->compareFunction == DAWN_COMPARE_FUNCTION_NEVER &&
|
desc->compareFunction == DAWN_COMPARE_FUNCTION_NEVER &&
|
||||||
desc->borderColor == DAWN_BORDER_COLOR_TRANSPARENT_BLACK &&
|
|
||||||
desc->lodMinClamp == kLodMin && desc->lodMaxClamp == kLodMax;
|
desc->lodMinClamp == kLodMin && desc->lodMaxClamp == kLodMax;
|
||||||
})))
|
})))
|
||||||
.WillOnce(Return(apiDummySampler));
|
.WillOnce(Return(apiDummySampler));
|
||||||
|
@ -271,7 +271,6 @@ namespace utils {
|
|||||||
desc.lodMinClamp = kLodMin;
|
desc.lodMinClamp = kLodMin;
|
||||||
desc.lodMaxClamp = kLodMax;
|
desc.lodMaxClamp = kLodMax;
|
||||||
desc.compareFunction = dawn::CompareFunction::Never;
|
desc.compareFunction = dawn::CompareFunction::Never;
|
||||||
desc.borderColor = dawn::BorderColor::TransparentBlack;
|
|
||||||
|
|
||||||
return desc;
|
return desc;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user