Deprecates use of filter mode for mipmap filters.

Change-Id: I77044ee7f0ce1b066dd8c8a1ee1b34e07f5e9766
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/128660
Commit-Queue: Loko Kung <lokokung@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
Loko Kung 2023-04-26 08:03:20 +00:00 committed by Dawn LUCI CQ
parent fd87e9d676
commit abfa45baa4
21 changed files with 49 additions and 56 deletions

View File

@ -1593,7 +1593,6 @@
},
"mipmap filter mode": {
"category": "enum",
"tags": ["upstream"],
"values": [
{"value": 0, "name": "nearest"},
{"value": 1, "name": "linear"}
@ -2359,8 +2358,7 @@
{"name": "address mode w", "type": "address mode", "default": "clamp to edge"},
{"name": "mag filter", "type": "filter mode", "default": "nearest"},
{"name": "min filter", "type": "filter mode", "default": "nearest"},
{"name": "mipmap filter", "type": "filter mode", "default": "nearest", "tags": ["dawn", "emscripten"]},
{"name": "mipmap filter", "type": "mipmap filter mode", "default": "nearest", "tags": ["upstream"]},
{"name": "mipmap filter", "type": "mipmap filter mode", "default": "nearest"},
{"name": "lod min clamp", "type": "float", "default": "0.0f"},
{"name": "lod max clamp", "type": "float", "default": "1000.0f"},
{"name": "compare", "type": "compare function", "default": "undefined"},

View File

@ -69,9 +69,6 @@ typedef uint32_t {{c_prefix}}Flags;
typedef enum {{as_cType(type.name)}} {
{% for value in type.values %}
{{as_cEnum(type.name, value.name)}} = 0x{{format(value.value, "08X")}},
{% if ("dawn" in enabled_tags) and (type == types["filter mode"]) %}
WGPUMipmapFilterMode_{{value.name.CamelCase()}} = 0x{{format(value.value, "08X")}},
{% endif %}
{% endfor %}
{{as_cEnum(type.name, Name("force32"))}} = 0x7FFFFFFF
} {{as_cType(type.name)}};
@ -81,12 +78,6 @@ typedef uint32_t {{c_prefix}}Flags;
{% endfor -%}
// Special case definition of MipmapFilterMode for Dawn side.
// TODO(lokokung) Remove once Chromium side is updated.
{% if 'dawn' in enabled_tags %}
typedef WGPUFilterMode WGPUMipmapFilterMode;
{% endif %}
typedef struct {{c_prefix}}ChainedStruct {
struct {{c_prefix}}ChainedStruct const * next;
{{c_prefix}}SType sType;

View File

@ -49,12 +49,6 @@ namespace {{metadata.namespace}} {
{% endfor %}
// Special case definition of MipmapFilterMode for Dawn side.
// TODO(lokokung) Remove once Chromium side is updated.
{% if 'dawn' in enabled_tags %}
using MipmapFilterMode = FilterMode;
{% endif %}
{% for type in by_category["bitmask"] %}
enum class {{as_cppType(type.name)}} : uint32_t {
{% for value in type.values %}

View File

@ -40,7 +40,7 @@ MaybeError ValidateSamplerDescriptor(DeviceBase*, const SamplerDescriptor* descr
if (descriptor->maxAnisotropy > 1) {
DAWN_INVALID_IF(descriptor->minFilter != wgpu::FilterMode::Linear ||
descriptor->magFilter != wgpu::FilterMode::Linear ||
descriptor->mipmapFilter != wgpu::FilterMode::Linear,
descriptor->mipmapFilter != wgpu::MipmapFilterMode::Linear,
"One of minFilter (%s), magFilter (%s) or mipmapFilter (%s) is not %s "
"while using anisotropic filter (maxAnisotropy is %f)",
descriptor->magFilter, descriptor->minFilter, descriptor->mipmapFilter,
@ -52,7 +52,7 @@ MaybeError ValidateSamplerDescriptor(DeviceBase*, const SamplerDescriptor* descr
DAWN_TRY(ValidateFilterMode(descriptor->minFilter));
DAWN_TRY(ValidateFilterMode(descriptor->magFilter));
DAWN_TRY(ValidateFilterMode(descriptor->mipmapFilter));
DAWN_TRY(ValidateMipmapFilterMode(descriptor->mipmapFilter));
DAWN_TRY(ValidateAddressMode(descriptor->addressModeU));
DAWN_TRY(ValidateAddressMode(descriptor->addressModeV));
DAWN_TRY(ValidateAddressMode(descriptor->addressModeW));
@ -116,7 +116,7 @@ bool SamplerBase::IsComparison() const {
bool SamplerBase::IsFiltering() const {
return mMinFilter == wgpu::FilterMode::Linear || mMagFilter == wgpu::FilterMode::Linear ||
mMipmapFilter == wgpu::FilterMode::Linear;
mMipmapFilter == wgpu::MipmapFilterMode::Linear;
}
size_t SamplerBase::ComputeContentHash() {

View File

@ -64,7 +64,7 @@ class SamplerBase : public ApiObjectBase, public CachedObject {
wgpu::AddressMode mAddressModeW;
wgpu::FilterMode mMagFilter;
wgpu::FilterMode mMinFilter;
wgpu::FilterMode mMipmapFilter;
wgpu::MipmapFilterMode mMipmapFilter;
float mLodMinClamp;
float mLodMaxClamp;
wgpu::CompareFunction mCompareFunction;

View File

@ -44,6 +44,15 @@ D3D11_FILTER_TYPE D3D11FilterType(wgpu::FilterMode mode) {
}
}
D3D11_FILTER_TYPE D3D11MipmapFilterType(wgpu::MipmapFilterMode mode) {
switch (mode) {
case wgpu::MipmapFilterMode::Nearest:
return D3D11_FILTER_TYPE_POINT;
case wgpu::MipmapFilterMode::Linear:
return D3D11_FILTER_TYPE_LINEAR;
}
}
} // namespace
// static
@ -57,7 +66,7 @@ MaybeError Sampler::Initialize(const SamplerDescriptor* descriptor) {
D3D11_SAMPLER_DESC samplerDesc = {};
D3D11_FILTER_TYPE minFilter = D3D11FilterType(descriptor->minFilter);
D3D11_FILTER_TYPE magFilter = D3D11FilterType(descriptor->magFilter);
D3D11_FILTER_TYPE mipmapFilter = D3D11FilterType(descriptor->mipmapFilter);
D3D11_FILTER_TYPE mipmapFilter = D3D11MipmapFilterType(descriptor->mipmapFilter);
D3D11_FILTER_REDUCTION_TYPE reduction = descriptor->compare == wgpu::CompareFunction::Undefined
? D3D11_FILTER_REDUCTION_TYPE_STANDARD

View File

@ -63,10 +63,10 @@ Sampler::Sampler(Device* device, const SamplerDescriptor* descriptor)
D3D12_FILTER_TYPE mipmapFilter;
switch (descriptor->mipmapFilter) {
case wgpu::FilterMode::Nearest:
case wgpu::MipmapFilterMode::Nearest:
mipmapFilter = D3D12_FILTER_TYPE_POINT;
break;
case wgpu::FilterMode::Linear:
case wgpu::MipmapFilterMode::Linear:
mipmapFilter = D3D12_FILTER_TYPE_LINEAR;
break;
}

View File

@ -29,11 +29,11 @@ MTLSamplerMinMagFilter FilterModeToMinMagFilter(wgpu::FilterMode mode) {
}
}
MTLSamplerMipFilter FilterModeToMipFilter(wgpu::FilterMode mode) {
MTLSamplerMipFilter FilterModeToMipFilter(wgpu::MipmapFilterMode mode) {
switch (mode) {
case wgpu::FilterMode::Nearest:
case wgpu::MipmapFilterMode::Nearest:
return MTLSamplerMipFilterNearest;
case wgpu::FilterMode::Linear:
case wgpu::MipmapFilterMode::Linear:
return MTLSamplerMipFilterLinear;
}
}

View File

@ -65,7 +65,7 @@ MaybeError PipelineGL::InitializeBase(const OpenGLFunctions& gl,
SamplerDescriptor desc = {};
ASSERT(desc.minFilter == wgpu::FilterMode::Nearest);
ASSERT(desc.magFilter == wgpu::FilterMode::Nearest);
ASSERT(desc.mipmapFilter == wgpu::FilterMode::Nearest);
ASSERT(desc.mipmapFilter == wgpu::MipmapFilterMode::Nearest);
mPlaceholderSampler =
ToBackend(layout->GetDevice()->GetOrCreateSampler(&desc).AcquireSuccess());
}

View File

@ -31,20 +31,20 @@ GLenum MagFilterMode(wgpu::FilterMode filter) {
UNREACHABLE();
}
GLenum MinFilterMode(wgpu::FilterMode minFilter, wgpu::FilterMode mipMapFilter) {
GLenum MinFilterMode(wgpu::FilterMode minFilter, wgpu::MipmapFilterMode mipMapFilter) {
switch (minFilter) {
case wgpu::FilterMode::Nearest:
switch (mipMapFilter) {
case wgpu::FilterMode::Nearest:
case wgpu::MipmapFilterMode::Nearest:
return GL_NEAREST_MIPMAP_NEAREST;
case wgpu::FilterMode::Linear:
case wgpu::MipmapFilterMode::Linear:
return GL_NEAREST_MIPMAP_LINEAR;
}
case wgpu::FilterMode::Linear:
switch (mipMapFilter) {
case wgpu::FilterMode::Nearest:
case wgpu::MipmapFilterMode::Nearest:
return GL_LINEAR_MIPMAP_NEAREST;
case wgpu::FilterMode::Linear:
case wgpu::MipmapFilterMode::Linear:
return GL_LINEAR_MIPMAP_LINEAR;
}
}

View File

@ -46,11 +46,11 @@ VkFilter VulkanSamplerFilter(wgpu::FilterMode filter) {
UNREACHABLE();
}
VkSamplerMipmapMode VulkanMipMapMode(wgpu::FilterMode filter) {
VkSamplerMipmapMode VulkanMipMapMode(wgpu::MipmapFilterMode filter) {
switch (filter) {
case wgpu::FilterMode::Linear:
case wgpu::MipmapFilterMode::Linear:
return VK_SAMPLER_MIPMAP_MODE_LINEAR;
case wgpu::FilterMode::Nearest:
case wgpu::MipmapFilterMode::Nearest:
return VK_SAMPLER_MIPMAP_MODE_NEAREST;
}
UNREACHABLE();

View File

@ -1770,17 +1770,17 @@ bool Converter::Convert(wgpu::FilterMode& out, const interop::GPUFilterMode& in)
return false;
}
bool Converter::Convert(wgpu::FilterMode& out, const interop::GPUMipmapFilterMode& in) {
out = wgpu::FilterMode::Nearest;
bool Converter::Convert(wgpu::MipmapFilterMode& out, const interop::GPUMipmapFilterMode& in) {
out = wgpu::MipmapFilterMode::Nearest;
switch (in) {
case interop::GPUMipmapFilterMode::kNearest:
out = wgpu::FilterMode::Nearest;
out = wgpu::MipmapFilterMode::Nearest;
return true;
case interop::GPUMipmapFilterMode::kLinear:
out = wgpu::FilterMode::Linear;
out = wgpu::MipmapFilterMode::Linear;
return true;
}
Napi::Error::New(env, "invalid value for GPUFilterMode").ThrowAsJavaScriptException();
Napi::Error::New(env, "invalid value for GPUMipmapFilterMode").ThrowAsJavaScriptException();
return false;
}

View File

@ -249,7 +249,7 @@ class Converter {
[[nodiscard]] bool Convert(wgpu::FilterMode& out, const interop::GPUFilterMode& in);
[[nodiscard]] bool Convert(wgpu::FilterMode& out, const interop::GPUMipmapFilterMode& in);
[[nodiscard]] bool Convert(wgpu::MipmapFilterMode& out, const interop::GPUMipmapFilterMode& in);
[[nodiscard]] bool Convert(wgpu::ComputePipelineDescriptor& out,
const interop::GPUComputePipelineDescriptor& in);

View File

@ -284,7 +284,7 @@ TEST_P(BindGroupTests, UBOSamplerAndTexture) {
wgpu::SamplerDescriptor samplerDescriptor = {};
samplerDescriptor.minFilter = wgpu::FilterMode::Nearest;
samplerDescriptor.magFilter = wgpu::FilterMode::Nearest;
samplerDescriptor.mipmapFilter = wgpu::FilterMode::Nearest;
samplerDescriptor.mipmapFilter = wgpu::MipmapFilterMode::Nearest;
samplerDescriptor.addressModeU = wgpu::AddressMode::ClampToEdge;
samplerDescriptor.addressModeV = wgpu::AddressMode::ClampToEdge;
samplerDescriptor.addressModeW = wgpu::AddressMode::ClampToEdge;

View File

@ -416,7 +416,7 @@ TEST_P(ObjectCachingTest, SamplerDeduplication) {
wgpu::Sampler otherSamplerMinFilter = device.CreateSampler(&otherSamplerDescMinFilter);
wgpu::SamplerDescriptor otherSamplerDescMipmapFilter;
otherSamplerDescMipmapFilter.mipmapFilter = wgpu::FilterMode::Linear;
otherSamplerDescMipmapFilter.mipmapFilter = wgpu::MipmapFilterMode::Linear;
wgpu::Sampler otherSamplerMipmapFilter = device.CreateSampler(&otherSamplerDescMipmapFilter);
wgpu::SamplerDescriptor otherSamplerDescLodMinClamp;

View File

@ -147,7 +147,7 @@ class SamplerFilterAnisotropicTest : public DawnTest {
wgpu::SamplerDescriptor descriptor = {};
descriptor.minFilter = wgpu::FilterMode::Linear;
descriptor.magFilter = wgpu::FilterMode::Linear;
descriptor.mipmapFilter = wgpu::FilterMode::Linear;
descriptor.mipmapFilter = wgpu::MipmapFilterMode::Linear;
descriptor.maxAnisotropy = maxAnisotropy;
sampler = device.CreateSampler(&descriptor);
}

View File

@ -125,7 +125,7 @@ class SamplerTest : public DawnTest {
wgpu::SamplerDescriptor descriptor = {};
descriptor.minFilter = wgpu::FilterMode::Nearest;
descriptor.magFilter = wgpu::FilterMode::Nearest;
descriptor.mipmapFilter = wgpu::FilterMode::Nearest;
descriptor.mipmapFilter = wgpu::MipmapFilterMode::Nearest;
descriptor.addressModeU = u.mMode;
descriptor.addressModeV = v.mMode;
descriptor.addressModeW = w.mMode;

View File

@ -107,12 +107,13 @@ class TextureViewSamplingTest : public DawnTest {
mRenderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
wgpu::FilterMode kFilterMode = wgpu::FilterMode::Nearest;
wgpu::MipmapFilterMode kMipmapFilterMode = wgpu::MipmapFilterMode::Nearest;
wgpu::AddressMode kAddressMode = wgpu::AddressMode::ClampToEdge;
wgpu::SamplerDescriptor samplerDescriptor = {};
samplerDescriptor.minFilter = kFilterMode;
samplerDescriptor.magFilter = kFilterMode;
samplerDescriptor.mipmapFilter = kFilterMode;
samplerDescriptor.mipmapFilter = kMipmapFilterMode;
samplerDescriptor.addressModeU = kAddressMode;
samplerDescriptor.addressModeV = kAddressMode;
samplerDescriptor.addressModeW = kAddressMode;

View File

@ -3033,7 +3033,7 @@ TEST_F(SamplerTypeBindingTest, SamplerAndBindGroupMatches) {
}
{
wgpu::SamplerDescriptor desc;
desc.mipmapFilter = wgpu::FilterMode::Linear;
desc.mipmapFilter = wgpu::MipmapFilterMode::Linear;
utils::MakeBindGroup(device, bindGroupLayout, {{0, device.CreateSampler(&desc)}});
}
@ -3061,7 +3061,7 @@ TEST_F(SamplerTypeBindingTest, SamplerAndBindGroupMatches) {
}
{
wgpu::SamplerDescriptor desc;
desc.mipmapFilter = wgpu::FilterMode::Linear;
desc.mipmapFilter = wgpu::MipmapFilterMode::Linear;
ASSERT_DEVICE_ERROR(
utils::MakeBindGroup(device, bindGroupLayout, {{0, device.CreateSampler(&desc)}}));
}

View File

@ -53,7 +53,7 @@ TEST_F(SamplerValidationTest, InvalidFilterAnisotropic) {
kValidAnisoSamplerDesc.maxAnisotropy = 2;
kValidAnisoSamplerDesc.minFilter = wgpu::FilterMode::Linear;
kValidAnisoSamplerDesc.magFilter = wgpu::FilterMode::Linear;
kValidAnisoSamplerDesc.mipmapFilter = wgpu::FilterMode::Linear;
kValidAnisoSamplerDesc.mipmapFilter = wgpu::MipmapFilterMode::Linear;
{
// when maxAnisotropy > 1, min, mag, mipmap filter should be linear
device.CreateSampler(&kValidAnisoSamplerDesc);
@ -67,7 +67,7 @@ TEST_F(SamplerValidationTest, InvalidFilterAnisotropic) {
wgpu::SamplerDescriptor samplerDesc = kValidAnisoSamplerDesc;
samplerDesc.minFilter = wgpu::FilterMode::Nearest;
samplerDesc.magFilter = wgpu::FilterMode::Nearest;
samplerDesc.mipmapFilter = wgpu::FilterMode::Nearest;
samplerDesc.mipmapFilter = wgpu::MipmapFilterMode::Nearest;
ASSERT_DEVICE_ERROR(device.CreateSampler(&samplerDesc));
}
{
@ -82,7 +82,7 @@ TEST_F(SamplerValidationTest, InvalidFilterAnisotropic) {
}
{
wgpu::SamplerDescriptor samplerDesc = kValidAnisoSamplerDesc;
samplerDesc.mipmapFilter = wgpu::FilterMode::Nearest;
samplerDesc.mipmapFilter = wgpu::MipmapFilterMode::Nearest;
ASSERT_DEVICE_ERROR(device.CreateSampler(&samplerDesc));
}
}
@ -92,7 +92,7 @@ TEST_F(SamplerValidationTest, ValidFilterAnisotropic) {
kValidAnisoSamplerDesc.maxAnisotropy = 2;
kValidAnisoSamplerDesc.minFilter = wgpu::FilterMode::Linear;
kValidAnisoSamplerDesc.magFilter = wgpu::FilterMode::Linear;
kValidAnisoSamplerDesc.mipmapFilter = wgpu::FilterMode::Linear;
kValidAnisoSamplerDesc.mipmapFilter = wgpu::MipmapFilterMode::Linear;
{ device.CreateSampler(); }
{
wgpu::SamplerDescriptor samplerDesc = kValidAnisoSamplerDesc;

View File

@ -240,7 +240,7 @@ TEST_F(WireArgumentTests, StructureOfValuesArgument) {
WGPUSamplerDescriptor descriptor = {};
descriptor.magFilter = WGPUFilterMode_Linear;
descriptor.minFilter = WGPUFilterMode_Nearest;
descriptor.mipmapFilter = WGPUFilterMode_Linear;
descriptor.mipmapFilter = WGPUMipmapFilterMode_Linear;
descriptor.addressModeU = WGPUAddressMode_ClampToEdge;
descriptor.addressModeV = WGPUAddressMode_Repeat;
descriptor.addressModeW = WGPUAddressMode_MirrorRepeat;
@ -256,7 +256,7 @@ TEST_F(WireArgumentTests, StructureOfValuesArgument) {
return desc->nextInChain == nullptr &&
desc->magFilter == WGPUFilterMode_Linear &&
desc->minFilter == WGPUFilterMode_Nearest &&
desc->mipmapFilter == WGPUFilterMode_Linear &&
desc->mipmapFilter == WGPUMipmapFilterMode_Linear &&
desc->addressModeU == WGPUAddressMode_ClampToEdge &&
desc->addressModeV == WGPUAddressMode_Repeat &&
desc->addressModeW == WGPUAddressMode_MirrorRepeat &&