mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-05-13 19:01:24 +00:00
writer/msl: Output constant 0 lod for 1d texture builtins
The MSL headers have annotations that requires that the lod for 1D textures is a constexpr with value 0. This affects .get_width() and .read(). Bug: dawn:814 Change-Id: Ic21d32067061afe67a16fbbeee222ab695b53066 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/79301 Reviewed-by: Ben Clayton <bclayton@chromium.org> Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Corentin Wallez <cwallez@chromium.org> Auto-Submit: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
a924ffe70c
commit
b3c99ddfae
@ -885,6 +885,10 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& out,
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// MSL requires that `lod` is a constant 0 for 1D textures.
|
||||||
|
bool level_is_constant_zero =
|
||||||
|
texture_type->dim() == ast::TextureDimension::k1d;
|
||||||
|
|
||||||
switch (builtin->Type()) {
|
switch (builtin->Type()) {
|
||||||
case sem::BuiltinType::kTextureDimensions: {
|
case sem::BuiltinType::kTextureDimensions: {
|
||||||
std::vector<const char*> dims;
|
std::vector<const char*> dims;
|
||||||
@ -912,9 +916,13 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& out,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
out << ".get_" << name << "(";
|
out << ".get_" << name << "(";
|
||||||
if (auto* level = arg(Usage::kLevel)) {
|
if (level_is_constant_zero) {
|
||||||
if (!EmitExpression(out, level->Declaration())) {
|
out << "0";
|
||||||
return false;
|
} else {
|
||||||
|
if (auto* level = arg(Usage::kLevel)) {
|
||||||
|
if (!EmitExpression(out, level->Declaration())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
out << ")";
|
out << ")";
|
||||||
@ -1061,8 +1069,12 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& out,
|
|||||||
if (lod_param_is_named) {
|
if (lod_param_is_named) {
|
||||||
out << "level(";
|
out << "level(";
|
||||||
}
|
}
|
||||||
if (!EmitExpression(out, level->Declaration())) {
|
if (level_is_constant_zero) {
|
||||||
return false;
|
out << "0";
|
||||||
|
} else {
|
||||||
|
if (!EmitExpression(out, level->Declaration())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (lod_param_is_named) {
|
if (lod_param_is_named) {
|
||||||
out << ")";
|
out << ")";
|
||||||
|
@ -27,7 +27,7 @@ std::string expected_texture_overload(
|
|||||||
switch (overload) {
|
switch (overload) {
|
||||||
case ValidTextureOverload::kDimensions1d:
|
case ValidTextureOverload::kDimensions1d:
|
||||||
case ValidTextureOverload::kDimensionsStorageWO1d:
|
case ValidTextureOverload::kDimensionsStorageWO1d:
|
||||||
return R"(int(texture.get_width()))";
|
return R"(int(texture.get_width(0)))";
|
||||||
case ValidTextureOverload::kDimensions2d:
|
case ValidTextureOverload::kDimensions2d:
|
||||||
case ValidTextureOverload::kDimensions2dArray:
|
case ValidTextureOverload::kDimensions2dArray:
|
||||||
case ValidTextureOverload::kDimensionsCube:
|
case ValidTextureOverload::kDimensionsCube:
|
||||||
@ -225,11 +225,11 @@ std::string expected_texture_overload(
|
|||||||
case ValidTextureOverload::kSampleCompareLevelDepthCubeArrayF32:
|
case ValidTextureOverload::kSampleCompareLevelDepthCubeArrayF32:
|
||||||
return R"(texture.sample_compare(sampler, float3(1.0f, 2.0f, 3.0f), 4, 5.0f))";
|
return R"(texture.sample_compare(sampler, float3(1.0f, 2.0f, 3.0f), 4, 5.0f))";
|
||||||
case ValidTextureOverload::kLoad1dLevelF32:
|
case ValidTextureOverload::kLoad1dLevelF32:
|
||||||
return R"(texture.read(uint(1), 3))";
|
return R"(texture.read(uint(1), 0))";
|
||||||
case ValidTextureOverload::kLoad1dLevelU32:
|
case ValidTextureOverload::kLoad1dLevelU32:
|
||||||
return R"(texture.read(uint(1), 3))";
|
return R"(texture.read(uint(1), 0))";
|
||||||
case ValidTextureOverload::kLoad1dLevelI32:
|
case ValidTextureOverload::kLoad1dLevelI32:
|
||||||
return R"(texture.read(uint(1), 3))";
|
return R"(texture.read(uint(1), 0))";
|
||||||
case ValidTextureOverload::kLoad2dLevelF32:
|
case ValidTextureOverload::kLoad2dLevelF32:
|
||||||
return R"(texture.read(uint2(int2(1, 2)), 3))";
|
return R"(texture.read(uint2(int2(1, 2)), 3))";
|
||||||
case ValidTextureOverload::kLoad2dLevelU32:
|
case ValidTextureOverload::kLoad2dLevelU32:
|
||||||
|
@ -6,7 +6,7 @@ struct tint_symbol {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void textureDimensions_002b2a(texture1d<float, access::sample> tint_symbol_1) {
|
void textureDimensions_002b2a(texture1d<float, access::sample> tint_symbol_1) {
|
||||||
int res = int(tint_symbol_1.get_width());
|
int res = int(tint_symbol_1.get_width(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
float4 vertex_main_inner(texture1d<float, access::sample> tint_symbol_2) {
|
float4 vertex_main_inner(texture1d<float, access::sample> tint_symbol_2) {
|
||||||
|
@ -6,7 +6,7 @@ struct tint_symbol {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void textureDimensions_08753d(texture1d<int, access::write> tint_symbol_1) {
|
void textureDimensions_08753d(texture1d<int, access::write> tint_symbol_1) {
|
||||||
int res = int(tint_symbol_1.get_width());
|
int res = int(tint_symbol_1.get_width(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
float4 vertex_main_inner(texture1d<int, access::write> tint_symbol_2) {
|
float4 vertex_main_inner(texture1d<int, access::write> tint_symbol_2) {
|
||||||
|
@ -6,7 +6,7 @@ struct tint_symbol {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void textureDimensions_0cce40(texture1d<int, access::write> tint_symbol_1) {
|
void textureDimensions_0cce40(texture1d<int, access::write> tint_symbol_1) {
|
||||||
int res = int(tint_symbol_1.get_width());
|
int res = int(tint_symbol_1.get_width(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
float4 vertex_main_inner(texture1d<int, access::write> tint_symbol_2) {
|
float4 vertex_main_inner(texture1d<int, access::write> tint_symbol_2) {
|
||||||
|
@ -6,7 +6,7 @@ struct tint_symbol {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void textureDimensions_1e9e39(texture1d<float, access::write> tint_symbol_1) {
|
void textureDimensions_1e9e39(texture1d<float, access::write> tint_symbol_1) {
|
||||||
int res = int(tint_symbol_1.get_width());
|
int res = int(tint_symbol_1.get_width(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
float4 vertex_main_inner(texture1d<float, access::write> tint_symbol_2) {
|
float4 vertex_main_inner(texture1d<float, access::write> tint_symbol_2) {
|
||||||
|
@ -6,7 +6,7 @@ struct tint_symbol {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void textureDimensions_318ecc(texture1d<uint, access::write> tint_symbol_1) {
|
void textureDimensions_318ecc(texture1d<uint, access::write> tint_symbol_1) {
|
||||||
int res = int(tint_symbol_1.get_width());
|
int res = int(tint_symbol_1.get_width(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
float4 vertex_main_inner(texture1d<uint, access::write> tint_symbol_2) {
|
float4 vertex_main_inner(texture1d<uint, access::write> tint_symbol_2) {
|
||||||
|
@ -6,7 +6,7 @@ struct tint_symbol {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void textureDimensions_3aca08(texture1d<float, access::write> tint_symbol_1) {
|
void textureDimensions_3aca08(texture1d<float, access::write> tint_symbol_1) {
|
||||||
int res = int(tint_symbol_1.get_width());
|
int res = int(tint_symbol_1.get_width(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
float4 vertex_main_inner(texture1d<float, access::write> tint_symbol_2) {
|
float4 vertex_main_inner(texture1d<float, access::write> tint_symbol_2) {
|
||||||
|
@ -6,7 +6,7 @@ struct tint_symbol {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void textureDimensions_423f99(texture1d<int, access::sample> tint_symbol_1) {
|
void textureDimensions_423f99(texture1d<int, access::sample> tint_symbol_1) {
|
||||||
int res = int(tint_symbol_1.get_width());
|
int res = int(tint_symbol_1.get_width(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
float4 vertex_main_inner(texture1d<int, access::sample> tint_symbol_2) {
|
float4 vertex_main_inner(texture1d<int, access::sample> tint_symbol_2) {
|
||||||
|
@ -6,7 +6,7 @@ struct tint_symbol {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void textureDimensions_42d4e6(texture1d<float, access::write> tint_symbol_1) {
|
void textureDimensions_42d4e6(texture1d<float, access::write> tint_symbol_1) {
|
||||||
int res = int(tint_symbol_1.get_width());
|
int res = int(tint_symbol_1.get_width(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
float4 vertex_main_inner(texture1d<float, access::write> tint_symbol_2) {
|
float4 vertex_main_inner(texture1d<float, access::write> tint_symbol_2) {
|
||||||
|
@ -6,7 +6,7 @@ struct tint_symbol {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void textureDimensions_4df9a8(texture1d<uint, access::write> tint_symbol_1) {
|
void textureDimensions_4df9a8(texture1d<uint, access::write> tint_symbol_1) {
|
||||||
int res = int(tint_symbol_1.get_width());
|
int res = int(tint_symbol_1.get_width(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
float4 vertex_main_inner(texture1d<uint, access::write> tint_symbol_2) {
|
float4 vertex_main_inner(texture1d<uint, access::write> tint_symbol_2) {
|
||||||
|
@ -6,7 +6,7 @@ struct tint_symbol {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void textureDimensions_55b23e(texture1d<float, access::write> tint_symbol_1) {
|
void textureDimensions_55b23e(texture1d<float, access::write> tint_symbol_1) {
|
||||||
int res = int(tint_symbol_1.get_width());
|
int res = int(tint_symbol_1.get_width(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
float4 vertex_main_inner(texture1d<float, access::write> tint_symbol_2) {
|
float4 vertex_main_inner(texture1d<float, access::write> tint_symbol_2) {
|
||||||
|
@ -6,7 +6,7 @@ struct tint_symbol {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void textureDimensions_57da0b(texture1d<uint, access::write> tint_symbol_1) {
|
void textureDimensions_57da0b(texture1d<uint, access::write> tint_symbol_1) {
|
||||||
int res = int(tint_symbol_1.get_width());
|
int res = int(tint_symbol_1.get_width(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
float4 vertex_main_inner(texture1d<uint, access::write> tint_symbol_2) {
|
float4 vertex_main_inner(texture1d<uint, access::write> tint_symbol_2) {
|
||||||
|
@ -6,7 +6,7 @@ struct tint_symbol {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void textureDimensions_5caa5e(texture1d<uint, access::write> tint_symbol_1) {
|
void textureDimensions_5caa5e(texture1d<uint, access::write> tint_symbol_1) {
|
||||||
int res = int(tint_symbol_1.get_width());
|
int res = int(tint_symbol_1.get_width(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
float4 vertex_main_inner(texture1d<uint, access::write> tint_symbol_2) {
|
float4 vertex_main_inner(texture1d<uint, access::write> tint_symbol_2) {
|
||||||
|
@ -6,7 +6,7 @@ struct tint_symbol {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void textureDimensions_6adac6(texture1d<int, access::write> tint_symbol_1) {
|
void textureDimensions_6adac6(texture1d<int, access::write> tint_symbol_1) {
|
||||||
int res = int(tint_symbol_1.get_width());
|
int res = int(tint_symbol_1.get_width(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
float4 vertex_main_inner(texture1d<int, access::write> tint_symbol_2) {
|
float4 vertex_main_inner(texture1d<int, access::write> tint_symbol_2) {
|
||||||
|
@ -6,7 +6,7 @@ struct tint_symbol {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void textureDimensions_9da9e2(texture1d<int, access::write> tint_symbol_1) {
|
void textureDimensions_9da9e2(texture1d<int, access::write> tint_symbol_1) {
|
||||||
int res = int(tint_symbol_1.get_width());
|
int res = int(tint_symbol_1.get_width(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
float4 vertex_main_inner(texture1d<int, access::write> tint_symbol_2) {
|
float4 vertex_main_inner(texture1d<int, access::write> tint_symbol_2) {
|
||||||
|
@ -6,7 +6,7 @@ struct tint_symbol {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void textureDimensions_a7d565(texture1d<uint, access::sample> tint_symbol_1) {
|
void textureDimensions_a7d565(texture1d<uint, access::sample> tint_symbol_1) {
|
||||||
int res = int(tint_symbol_1.get_width());
|
int res = int(tint_symbol_1.get_width(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
float4 vertex_main_inner(texture1d<uint, access::sample> tint_symbol_2) {
|
float4 vertex_main_inner(texture1d<uint, access::sample> tint_symbol_2) {
|
||||||
|
@ -6,7 +6,7 @@ struct tint_symbol {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void textureDimensions_a863f2(texture1d<float, access::write> tint_symbol_1) {
|
void textureDimensions_a863f2(texture1d<float, access::write> tint_symbol_1) {
|
||||||
int res = int(tint_symbol_1.get_width());
|
int res = int(tint_symbol_1.get_width(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
float4 vertex_main_inner(texture1d<float, access::write> tint_symbol_2) {
|
float4 vertex_main_inner(texture1d<float, access::write> tint_symbol_2) {
|
||||||
|
@ -6,7 +6,7 @@ struct tint_symbol {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void textureDimensions_cc968c(texture1d<int, access::write> tint_symbol_1) {
|
void textureDimensions_cc968c(texture1d<int, access::write> tint_symbol_1) {
|
||||||
int res = int(tint_symbol_1.get_width());
|
int res = int(tint_symbol_1.get_width(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
float4 vertex_main_inner(texture1d<int, access::write> tint_symbol_2) {
|
float4 vertex_main_inner(texture1d<int, access::write> tint_symbol_2) {
|
||||||
|
@ -6,7 +6,7 @@ struct tint_symbol {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void textureDimensions_cccc8f(texture1d<float, access::write> tint_symbol_1) {
|
void textureDimensions_cccc8f(texture1d<float, access::write> tint_symbol_1) {
|
||||||
int res = int(tint_symbol_1.get_width());
|
int res = int(tint_symbol_1.get_width(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
float4 vertex_main_inner(texture1d<float, access::write> tint_symbol_2) {
|
float4 vertex_main_inner(texture1d<float, access::write> tint_symbol_2) {
|
||||||
|
@ -6,7 +6,7 @@ struct tint_symbol {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void textureDimensions_dc2dd0(texture1d<uint, access::write> tint_symbol_1) {
|
void textureDimensions_dc2dd0(texture1d<uint, access::write> tint_symbol_1) {
|
||||||
int res = int(tint_symbol_1.get_width());
|
int res = int(tint_symbol_1.get_width(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
float4 vertex_main_inner(texture1d<uint, access::write> tint_symbol_2) {
|
float4 vertex_main_inner(texture1d<uint, access::write> tint_symbol_2) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user