Skip to content

Commit

Permalink
swizzle fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tly000 committed Mar 24, 2019
1 parent 62dce70 commit 57bd4b7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions spirv_glsl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5632,6 +5632,10 @@ const char *CompilerGLSL::index_to_swizzle(uint32_t index)
return "z";
case 3:
return "w";
case 0xFFFFFFFF:
//A Component literal may also be FFFFFFFF, which means the corresponding
// result component has no source and is undefined (just use first component)
return "x";
default:
SPIRV_CROSS_THROW("Swizzle index out of range");
}
Expand Down Expand Up @@ -7390,7 +7394,7 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction)

bool shuffle = false;
for (uint32_t i = 0; i < length; i++)
if (elems[i] >= type0.vecsize)
if (elems[i] >= type0.vecsize && elems[i] != 0xFFFFFFFF)
shuffle = true;

// Cannot use swizzles with packed expressions, force shuffle path.
Expand All @@ -7410,7 +7414,7 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction)
for (uint32_t i = 0; i < length; i++)
{
if (elems[i] >= type0.vecsize)
args.push_back(to_extract_component_expression(vec1, elems[i] - type0.vecsize));
args.push_back(to_extract_component_expression(vec1, elems[i] == 0xFFFFFFFF ? elems[i] : elems[i] - type0.vecsize));
else
args.push_back(to_extract_component_expression(vec0, elems[i]));
}
Expand Down

0 comments on commit 57bd4b7

Please sign in to comment.