spirv-reader: Reject dref sampling with Bias or Grad
Bias and Grad image operands are not supported for depth-referencde sampling. Fixed: tint:440 Change-Id: Ic2bf995f7c7b791b8e3a7ceb3514b10220dda8a7 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37062 Auto-Submit: David Neto <dneto@google.com> Commit-Queue: Ben Clayton <bclayton@google.com> Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
parent
9bacbe1b34
commit
f51d965bef
|
@ -4078,6 +4078,7 @@ bool FunctionEmitter::EmitImageAccess(const spvtools::opt::Instruction& inst) {
|
||||||
|
|
||||||
std::string builtin_name;
|
std::string builtin_name;
|
||||||
bool use_level_of_detail_suffix = true;
|
bool use_level_of_detail_suffix = true;
|
||||||
|
bool is_dref = false;
|
||||||
switch (opcode) {
|
switch (opcode) {
|
||||||
case SpvOpImageSampleImplicitLod:
|
case SpvOpImageSampleImplicitLod:
|
||||||
case SpvOpImageSampleExplicitLod:
|
case SpvOpImageSampleExplicitLod:
|
||||||
|
@ -4085,6 +4086,7 @@ bool FunctionEmitter::EmitImageAccess(const spvtools::opt::Instruction& inst) {
|
||||||
break;
|
break;
|
||||||
case SpvOpImageSampleDrefImplicitLod:
|
case SpvOpImageSampleDrefImplicitLod:
|
||||||
case SpvOpImageSampleDrefExplicitLod:
|
case SpvOpImageSampleDrefExplicitLod:
|
||||||
|
is_dref = true;
|
||||||
builtin_name = "textureSampleCompare";
|
builtin_name = "textureSampleCompare";
|
||||||
if (arg_index < num_args) {
|
if (arg_index < num_args) {
|
||||||
params.push_back(MakeOperand(inst, arg_index).expr);
|
params.push_back(MakeOperand(inst, arg_index).expr);
|
||||||
|
@ -4141,6 +4143,11 @@ bool FunctionEmitter::EmitImageAccess(const spvtools::opt::Instruction& inst) {
|
||||||
}
|
}
|
||||||
if (arg_index < num_args &&
|
if (arg_index < num_args &&
|
||||||
(image_operands_mask & SpvImageOperandsBiasMask)) {
|
(image_operands_mask & SpvImageOperandsBiasMask)) {
|
||||||
|
if (is_dref) {
|
||||||
|
return Fail() << "WGSL does not support depth-reference sampling with "
|
||||||
|
"level-of-detail bias: "
|
||||||
|
<< inst.PrettyPrint();
|
||||||
|
}
|
||||||
builtin_name += "Bias";
|
builtin_name += "Bias";
|
||||||
params.push_back(MakeOperand(inst, arg_index).expr);
|
params.push_back(MakeOperand(inst, arg_index).expr);
|
||||||
image_operands_mask ^= SpvImageOperandsBiasMask;
|
image_operands_mask ^= SpvImageOperandsBiasMask;
|
||||||
|
@ -4162,6 +4169,11 @@ bool FunctionEmitter::EmitImageAccess(const spvtools::opt::Instruction& inst) {
|
||||||
}
|
}
|
||||||
if (arg_index + 1 < num_args &&
|
if (arg_index + 1 < num_args &&
|
||||||
(image_operands_mask & SpvImageOperandsGradMask)) {
|
(image_operands_mask & SpvImageOperandsGradMask)) {
|
||||||
|
if (is_dref) {
|
||||||
|
return Fail() << "WGSL does not support depth-reference sampling with "
|
||||||
|
"explicit gradient: "
|
||||||
|
<< inst.PrettyPrint();
|
||||||
|
}
|
||||||
builtin_name += "Grad";
|
builtin_name += "Grad";
|
||||||
params.push_back(MakeOperand(inst, arg_index).expr);
|
params.push_back(MakeOperand(inst, arg_index).expr);
|
||||||
params.push_back(MakeOperand(inst, arg_index + 1).expr);
|
params.push_back(MakeOperand(inst, arg_index + 1).expr);
|
||||||
|
|
|
@ -1702,7 +1702,7 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
|
|
||||||
INSTANTIATE_TEST_SUITE_P(
|
INSTANTIATE_TEST_SUITE_P(
|
||||||
// This test shows the use of a sampled image used with both regular
|
// This test shows the use of a sampled image used with both regular
|
||||||
// sampling and depth-refernce sampling. The texture is a depth-texture,
|
// sampling and depth-reference sampling. The texture is a depth-texture,
|
||||||
// and we use builtins textureSample and textureSampleCompare
|
// and we use builtins textureSample and textureSampleCompare
|
||||||
ImageSampleImplicitLod_BothDrefAndNonDref,
|
ImageSampleImplicitLod_BothDrefAndNonDref,
|
||||||
SpvParserTest_SampledImageAccessTest,
|
SpvParserTest_SampledImageAccessTest,
|
||||||
|
@ -4428,6 +4428,44 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
"ConstOffset is only permitted for 2D, 2D Arrayed, and 3D textures: ",
|
"ConstOffset is only permitted for 2D, 2D Arrayed, and 3D textures: ",
|
||||||
{}}}));
|
{}}}));
|
||||||
|
|
||||||
|
INSTANTIATE_TEST_SUITE_P(
|
||||||
|
ImageSampleDref_Bias_IsError,
|
||||||
|
SpvParserTest_ImageCoordsTest,
|
||||||
|
::testing::ValuesIn(std::vector<ImageCoordsCase>{
|
||||||
|
// Implicit Lod
|
||||||
|
{"%float 2D 1 0 0 1 Unknown",
|
||||||
|
"%result = OpImageSampleDrefImplicitLod %float %sampled_image %vf1234 "
|
||||||
|
"%depth Bias %float_null",
|
||||||
|
"WGSL does not support depth-reference sampling with level-of-detail "
|
||||||
|
"bias: ",
|
||||||
|
{}},
|
||||||
|
// Explicit Lod
|
||||||
|
{"%float 2D 1 0 0 1 Unknown",
|
||||||
|
"%result = OpImageSampleDrefExplicitLod %float %sampled_image %vf1234 "
|
||||||
|
"%depth Lod|Bias %float_null %float_null",
|
||||||
|
"WGSL does not support depth-reference sampling with level-of-detail "
|
||||||
|
"bias: ",
|
||||||
|
{}}}));
|
||||||
|
|
||||||
|
INSTANTIATE_TEST_SUITE_P(
|
||||||
|
ImageSampleDref_Grad_IsError,
|
||||||
|
SpvParserTest_ImageCoordsTest,
|
||||||
|
::testing::ValuesIn(std::vector<ImageCoordsCase>{
|
||||||
|
// Implicit Lod
|
||||||
|
{"%float 2D 1 0 0 1 Unknown",
|
||||||
|
"%result = OpImageSampleDrefImplicitLod %float %sampled_image %vf1234 "
|
||||||
|
"%depth Grad %float_1 %float_2",
|
||||||
|
"WGSL does not support depth-reference sampling with explicit "
|
||||||
|
"gradient: ",
|
||||||
|
{}},
|
||||||
|
// Explicit Lod
|
||||||
|
{"%float 2D 1 0 0 1 Unknown",
|
||||||
|
"%result = OpImageSampleDrefExplicitLod %float %sampled_image %vf1234 "
|
||||||
|
"%depth Lod|Grad %float_null %float_1 %float_2",
|
||||||
|
"WGSL does not support depth-reference sampling with explicit "
|
||||||
|
"gradient: ",
|
||||||
|
{}}}));
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace spirv
|
} // namespace spirv
|
||||||
} // namespace reader
|
} // namespace reader
|
||||||
|
|
Loading…
Reference in New Issue