mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-05-15 03:41:34 +00:00
spirv-reader: Fix texture[Load|Store] with lod
Don't suffix texture intrinsics with `Load` unless it's a `textureSample`.
Discussion:
d46b4fa3ca (diff-709b5c343d59ae10cbabe69f9df1eee9e2dbb6e9d848632fa94357083d6e0a34)
Bug: tint:109
Bug: dawn:399
Change-Id: Ic42ef9f8681dd04bd8f4c901c6d4cdc5f4166d26
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35423
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
parent
0b930237ec
commit
11276ef97d
@ -3948,6 +3948,7 @@ bool FunctionEmitter::EmitImageAccess(const spvtools::opt::Instruction& inst) {
|
|||||||
const auto num_args = inst.NumInOperands();
|
const auto num_args = inst.NumInOperands();
|
||||||
|
|
||||||
std::string builtin_name;
|
std::string builtin_name;
|
||||||
|
bool use_load_suffix = true;
|
||||||
switch (inst.opcode()) {
|
switch (inst.opcode()) {
|
||||||
case SpvOpImageSampleImplicitLod:
|
case SpvOpImageSampleImplicitLod:
|
||||||
case SpvOpImageSampleExplicitLod:
|
case SpvOpImageSampleExplicitLod:
|
||||||
@ -3973,13 +3974,16 @@ bool FunctionEmitter::EmitImageAccess(const spvtools::opt::Instruction& inst) {
|
|||||||
case SpvOpImageFetch:
|
case SpvOpImageFetch:
|
||||||
// Read a single texel from a sampled image.
|
// Read a single texel from a sampled image.
|
||||||
builtin_name = "textureLoad";
|
builtin_name = "textureLoad";
|
||||||
|
use_load_suffix = false;
|
||||||
break;
|
break;
|
||||||
case SpvOpImageRead:
|
case SpvOpImageRead:
|
||||||
// Read a single texel from a storage image.
|
// Read a single texel from a storage image.
|
||||||
builtin_name = "textureLoad";
|
builtin_name = "textureLoad";
|
||||||
|
use_load_suffix = false;
|
||||||
break;
|
break;
|
||||||
case SpvOpImageWrite:
|
case SpvOpImageWrite:
|
||||||
builtin_name = "textureStore";
|
builtin_name = "textureStore";
|
||||||
|
use_load_suffix = false;
|
||||||
if (arg_index < num_args) {
|
if (arg_index < num_args) {
|
||||||
auto texel = MakeOperand(inst, arg_index);
|
auto texel = MakeOperand(inst, arg_index);
|
||||||
auto* converted_texel =
|
auto* converted_texel =
|
||||||
@ -4014,7 +4018,9 @@ bool FunctionEmitter::EmitImageAccess(const spvtools::opt::Instruction& inst) {
|
|||||||
arg_index++;
|
arg_index++;
|
||||||
}
|
}
|
||||||
if (arg_index < num_args && (image_operands_mask & SpvImageOperandsLodMask)) {
|
if (arg_index < num_args && (image_operands_mask & SpvImageOperandsLodMask)) {
|
||||||
|
if (use_load_suffix) {
|
||||||
builtin_name += "Level";
|
builtin_name += "Level";
|
||||||
|
}
|
||||||
TypedExpression lod = MakeOperand(inst, arg_index);
|
TypedExpression lod = MakeOperand(inst, arg_index);
|
||||||
// When sampling from a depth texture, the Lod operand must be an I32.
|
// When sampling from a depth texture, the Lod operand must be an I32.
|
||||||
if (texture_type->Is<ast::type::DepthTexture>()) {
|
if (texture_type->Is<ast::type::DepthTexture>()) {
|
||||||
|
@ -3134,6 +3134,35 @@ INSTANTIATE_TEST_SUITE_P(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
})"},
|
||||||
|
// OpImageFetch with explicit level
|
||||||
|
{"%float 2D 0 0 0 1 Unknown",
|
||||||
|
"%99 = OpImageFetch %v4float %im %vi12 Lod %int_3",
|
||||||
|
R"(Variable{
|
||||||
|
Decorations{
|
||||||
|
SetDecoration{2}
|
||||||
|
BindingDecoration{1}
|
||||||
|
}
|
||||||
|
x_20
|
||||||
|
uniform_constant
|
||||||
|
__sampled_texture_2d__f32
|
||||||
|
})",
|
||||||
|
R"(VariableDeclStatement{
|
||||||
|
VariableConst{
|
||||||
|
x_99
|
||||||
|
none
|
||||||
|
__vec_4__f32
|
||||||
|
{
|
||||||
|
Call[not set]{
|
||||||
|
Identifier[not set]{textureLoad}
|
||||||
|
(
|
||||||
|
Identifier[not set]{x_20}
|
||||||
|
Identifier[not set]{vi12}
|
||||||
|
ScalarConstructor[not set]{3}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
})"}}));
|
})"}}));
|
||||||
|
|
||||||
INSTANTIATE_TEST_SUITE_P(
|
INSTANTIATE_TEST_SUITE_P(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user