Skip to content

Commit

Permalink
HLSL: Catch error cases earlier, preventing a later assert.
Browse files Browse the repository at this point in the history
Related to KhronosGroup/SPIRV-Cross#1414.
The real problem is either using DX10 semantics for DX9 or missing
functionality in DX10 parsing.
  • Loading branch information
johnkslang committed Jul 1, 2020
1 parent 8d3f3b7 commit b112fac
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions glslang/HLSL/hlslParseHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3924,6 +3924,7 @@ void HlslParseContext::decomposeSampleMethods(const TSourceLoc& loc, TIntermType
case Esd3D: constructOp = EOpConstructVec3; coordSize = 3; break; // 3D
case EsdCube: constructOp = EOpConstructVec3; coordSize = 3; break; // also 3D
default:
error(loc, "unhandled DX9 texture LoD dimension", "", "");
break;
}

Expand Down Expand Up @@ -3960,7 +3961,9 @@ void HlslParseContext::decomposeSampleMethods(const TSourceLoc& loc, TIntermType
case Esd2D: constructOp = EOpConstructVec2; break; // 2D
case Esd3D: constructOp = EOpConstructVec3; break; // 3D
case EsdCube: constructOp = EOpConstructVec3; break; // also 3D
default: break;
default:
error(loc, "unhandled DX9 texture bias dimension", "", "");
break;
}

TIntermAggregate* constructCoord = new TIntermAggregate(constructOp);
Expand Down Expand Up @@ -4084,7 +4087,8 @@ void HlslParseContext::decomposeSampleMethods(const TSourceLoc& loc, TIntermType
case EsdBuffer: numDims = 1; break; // W (buffers)
case EsdRect: numDims = 2; break; // W, H (rect)
default:
assert(0 && "unhandled texture dimension");
error(loc, "unhandled DX10 MethodGet dimension", "", "");
break;
}

// Arrayed adds another dimension for the number of array elements
Expand Down Expand Up @@ -4220,7 +4224,9 @@ void HlslParseContext::decomposeSampleMethods(const TSourceLoc& loc, TIntermType
case 3: constructOp = EOpConstructVec3; break;
case 4: constructOp = EOpConstructVec4; break;
case 5: constructOp = EOpConstructVec4; break; // cubeArrayShadow, cmp value is separate arg.
default: assert(0); break;
default:
error(loc, "unhandled DX10 MethodSample dimension", "", "");
break;
}

TIntermAggregate* coordWithCmp = new TIntermAggregate(constructOp);
Expand Down

0 comments on commit b112fac

Please sign in to comment.