Add new test case for image functions and fix issues caught by this test
This commit is contained in:
parent
bba5c80957
commit
6b86d496c2
14 changed files with 750 additions and 158 deletions
|
|
@ -1757,11 +1757,10 @@ void TGlslangToSpvTraverser::translateArguments(const glslang::TIntermAggregate&
|
|||
break;
|
||||
}
|
||||
|
||||
if (lvalue) {
|
||||
if (lvalue)
|
||||
arguments.push_back(builder.accessChainGetLValue());
|
||||
} else {
|
||||
else
|
||||
arguments.push_back(builder.accessChainLoad(convertGlslangToSpvType(glslangArguments[i]->getAsTyped()->getType())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1820,16 +1819,37 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO
|
|||
|
||||
// Check for image functions other than queries
|
||||
if (node->isImage()) {
|
||||
if (node->getOp() == glslang::EOpImageLoad) {
|
||||
return builder.createOp(spv::OpImageRead, convertGlslangToSpvType(node->getType()), arguments);
|
||||
}
|
||||
else if (node->getOp() == glslang::EOpImageStore) {
|
||||
builder.createNoResultOp(spv::OpImageWrite, arguments);
|
||||
return spv::NoResult;
|
||||
}
|
||||
else {
|
||||
// Process image atomic operations. GLSL "IMAGE_PARAMS" will involve in constructing an image texel
|
||||
// pointer and this pointer, as the first source operand, is required by SPIR-V atomic operations.
|
||||
// Process image load/store
|
||||
if (node->getOp() == glslang::EOpImageLoad ||
|
||||
node->getOp() == glslang::EOpImageStore) {
|
||||
std::vector<spv::Id> operands;
|
||||
auto opIt = arguments.begin();
|
||||
operands.push_back(*(opIt++));
|
||||
operands.push_back(*(opIt++));
|
||||
if (sampler.ms) {
|
||||
// For MS, image operand mask has to be added to indicate the presence of "sample" operand.
|
||||
spv::Id sample = *(opIt++);
|
||||
for (; opIt != arguments.end(); ++opIt)
|
||||
operands.push_back(*opIt);
|
||||
|
||||
operands.push_back(spv::ImageOperandsSampleMask);
|
||||
operands.push_back(sample);
|
||||
} else {
|
||||
for (; opIt != arguments.end(); ++opIt)
|
||||
operands.push_back(*opIt);
|
||||
}
|
||||
|
||||
if (node->getOp() == glslang::EOpImageLoad)
|
||||
return builder.createOp(spv::OpImageRead, convertGlslangToSpvType(node->getType()), operands);
|
||||
else {
|
||||
builder.createNoResultOp(spv::OpImageWrite, operands);
|
||||
return spv::NoResult;
|
||||
}
|
||||
} else {
|
||||
// Process image atomic operations
|
||||
|
||||
// GLSL "IMAGE_PARAMS" will involve in constructing an image texel pointer and this pointer,
|
||||
// as the first source operand, is required by SPIR-V atomic operations.
|
||||
std::vector<spv::Id> imageParams;
|
||||
auto opIt = arguments.begin();
|
||||
imageParams.push_back(*(opIt++));
|
||||
|
|
@ -1885,8 +1905,8 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO
|
|||
if (cracked.lod) {
|
||||
params.lod = arguments[2];
|
||||
++extraArgs;
|
||||
} else if (cracked.sample) {
|
||||
params.sample = arguments[2]; // For MS, sample should be specified
|
||||
} else if (sampler.ms) {
|
||||
params.sample = arguments[2]; // For MS, "sample" should be specified
|
||||
++extraArgs;
|
||||
}
|
||||
if (cracked.grad) {
|
||||
|
|
|
|||
|
|
@ -159,8 +159,9 @@ public:
|
|||
}
|
||||
Id getImageType(Id resultId) const
|
||||
{
|
||||
assert(isSampledImageType(getTypeId(resultId)));
|
||||
return module.getInstruction(getTypeId(resultId))->getIdOperand(0);
|
||||
Id typeId = getTypeId(resultId);
|
||||
assert(isImageType(typeId) || isSampledImageType(typeId));
|
||||
return isSampledImageType(typeId) ? module.getInstruction(typeId)->getIdOperand(0) : typeId;
|
||||
}
|
||||
bool isArrayedImageType(Id typeId) const
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1635,10 +1635,12 @@ void Parameterize()
|
|||
|
||||
InstructionDesc[OpImageRead].operands.push(OperandId, "'Image'");
|
||||
InstructionDesc[OpImageRead].operands.push(OperandId, "'Coordinate'");
|
||||
InstructionDesc[OpImageRead].operands.push(OperandOptionalImage, "");
|
||||
|
||||
InstructionDesc[OpImageWrite].operands.push(OperandId, "'Image'");
|
||||
InstructionDesc[OpImageWrite].operands.push(OperandId, "'Coordinate'");
|
||||
InstructionDesc[OpImageWrite].operands.push(OperandId, "'Texel'");
|
||||
InstructionDesc[OpImageWrite].operands.push(OperandOptionalImage, "");
|
||||
|
||||
InstructionDesc[OpImageSampleImplicitLod].operands.push(OperandId, "'Sampled Image'");
|
||||
InstructionDesc[OpImageSampleImplicitLod].operands.push(OperandId, "'Coordinate'");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue