Commit d1bded59 by John Kessenich

Merge branch GitHub 'master' into GitLab master

parents 70e057a4 712ecb96
...@@ -1884,6 +1884,14 @@ void TGlslangToSpvTraverser::handleFunctionEntry(const glslang::TIntermAggregate ...@@ -1884,6 +1884,14 @@ void TGlslangToSpvTraverser::handleFunctionEntry(const glslang::TIntermAggregate
void TGlslangToSpvTraverser::translateArguments(const glslang::TIntermAggregate& node, std::vector<spv::Id>& arguments) void TGlslangToSpvTraverser::translateArguments(const glslang::TIntermAggregate& node, std::vector<spv::Id>& arguments)
{ {
const glslang::TIntermSequence& glslangArguments = node.getSequence(); const glslang::TIntermSequence& glslangArguments = node.getSequence();
glslang::TSampler sampler = {};
bool cubeCompare = false;
if (node.isTexture()) {
sampler = glslangArguments[0]->getAsTyped()->getType().getSampler();
cubeCompare = sampler.dim == glslang::EsdCube && sampler.arrayed && sampler.shadow;
}
for (int i = 0; i < (int)glslangArguments.size(); ++i) { for (int i = 0; i < (int)glslangArguments.size(); ++i) {
builder.clearAccessChain(); builder.clearAccessChain();
glslangArguments[i]->traverse(this); glslangArguments[i]->traverse(this);
...@@ -1902,6 +1910,51 @@ void TGlslangToSpvTraverser::translateArguments(const glslang::TIntermAggregate& ...@@ -1902,6 +1910,51 @@ void TGlslangToSpvTraverser::translateArguments(const glslang::TIntermAggregate&
if (i == 0) if (i == 0)
lvalue = true; lvalue = true;
break; break;
case glslang::EOpSparseTexture:
if ((cubeCompare && i == 3) || (! cubeCompare && i == 2))
lvalue = true;
break;
case glslang::EOpSparseTextureClamp:
if ((cubeCompare && i == 4) || (! cubeCompare && i == 3))
lvalue = true;
break;
case glslang::EOpSparseTextureLod:
case glslang::EOpSparseTextureOffset:
if (i == 3)
lvalue = true;
break;
case glslang::EOpSparseTextureFetch:
if ((sampler.dim != glslang::EsdRect && i == 3) || (sampler.dim == glslang::EsdRect && i == 2))
lvalue = true;
break;
case glslang::EOpSparseTextureFetchOffset:
if ((sampler.dim != glslang::EsdRect && i == 4) || (sampler.dim == glslang::EsdRect && i == 3))
lvalue = true;
break;
case glslang::EOpSparseTextureLodOffset:
case glslang::EOpSparseTextureGrad:
case glslang::EOpSparseTextureOffsetClamp:
if (i == 4)
lvalue = true;
break;
case glslang::EOpSparseTextureGradOffset:
case glslang::EOpSparseTextureGradClamp:
if (i == 5)
lvalue = true;
break;
case glslang::EOpSparseTextureGradOffsetClamp:
if (i == 6)
lvalue = true;
break;
case glslang::EOpSparseTextureGather:
if ((sampler.shadow && i == 3) || (! sampler.shadow && i == 2))
lvalue = true;
break;
case glslang::EOpSparseTextureGatherOffset:
case glslang::EOpSparseTextureGatherOffsets:
if ((sampler.shadow && i == 4) || (! sampler.shadow && i == 3))
lvalue = true;
break;
default: default:
break; break;
} }
...@@ -1963,6 +2016,8 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO ...@@ -1963,6 +2016,8 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO
return builder.createTextureQueryCall(spv::OpImageQueryLod, params); return builder.createTextureQueryCall(spv::OpImageQueryLod, params);
case glslang::EOpTextureQueryLevels: case glslang::EOpTextureQueryLevels:
return builder.createTextureQueryCall(spv::OpImageQueryLevels, params); return builder.createTextureQueryCall(spv::OpImageQueryLevels, params);
case glslang::EOpSparseTexelsResident:
return builder.createUnaryOp(spv::OpImageSparseTexelsResident, builder.makeBoolType(), arguments[0]);
default: default:
assert(0); assert(0);
break; break;
...@@ -1990,7 +2045,11 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO ...@@ -1990,7 +2045,11 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO
operands.push_back(*opIt); operands.push_back(*opIt);
builder.createNoResultOp(spv::OpImageWrite, operands); builder.createNoResultOp(spv::OpImageWrite, operands);
return spv::NoResult; return spv::NoResult;
} else { } else if (node->isSparseImage()) {
spv::MissingFunctionality("sparse image functions");
return spv::NoResult;
}
else {
// Process image atomic operations // Process image atomic operations
// GLSL "IMAGE_PARAMS" will involve in constructing an image texel pointer and this pointer, // GLSL "IMAGE_PARAMS" will involve in constructing an image texel pointer and this pointer,
...@@ -2010,7 +2069,7 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO ...@@ -2010,7 +2069,7 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO
} }
// Check for texture functions other than queries // Check for texture functions other than queries
bool sparse = node->isSparseTexture();
bool cubeCompare = sampler.dim == glslang::EsdCube && sampler.arrayed && sampler.shadow; bool cubeCompare = sampler.dim == glslang::EsdCube && sampler.arrayed && sampler.shadow;
// check for bias argument // check for bias argument
...@@ -2021,6 +2080,10 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO ...@@ -2021,6 +2080,10 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO
++nonBiasArgCount; ++nonBiasArgCount;
if (cracked.grad) if (cracked.grad)
nonBiasArgCount += 2; nonBiasArgCount += 2;
if (cracked.lodClamp)
++nonBiasArgCount;
if (sparse)
++nonBiasArgCount;
if ((int)arguments.size() > nonBiasArgCount) if ((int)arguments.size() > nonBiasArgCount)
bias = true; bias = true;
...@@ -2032,9 +2095,10 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO ...@@ -2032,9 +2095,10 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO
int extraArgs = 0; int extraArgs = 0;
// sort out where Dref is coming from // sort out where Dref is coming from
if (sampler.shadow && sampler.dim == glslang::EsdCube && sampler.arrayed) if (cubeCompare) {
params.Dref = arguments[2]; params.Dref = arguments[2];
else if (sampler.shadow && cracked.gather) { ++extraArgs;
} else if (sampler.shadow && cracked.gather) {
params.Dref = arguments[2]; params.Dref = arguments[2];
++extraArgs; ++extraArgs;
} else if (sampler.shadow) { } else if (sampler.shadow) {
...@@ -2066,6 +2130,14 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO ...@@ -2066,6 +2130,14 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO
params.offsets = arguments[2 + extraArgs]; params.offsets = arguments[2 + extraArgs];
++extraArgs; ++extraArgs;
} }
if (cracked.lodClamp) {
params.lodClamp = arguments[2 + extraArgs];
++extraArgs;
}
if (sparse) {
params.texelOut = arguments[2 + extraArgs];
++extraArgs;
}
if (bias) { if (bias) {
params.bias = arguments[2 + extraArgs]; params.bias = arguments[2 + extraArgs];
++extraArgs; ++extraArgs;
...@@ -2080,7 +2152,7 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO ...@@ -2080,7 +2152,7 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO
} }
} }
return builder.createTextureCall(precision, convertGlslangToSpvType(node->getType()), cracked.fetch, cracked.proj, cracked.gather, params); return builder.createTextureCall(precision, convertGlslangToSpvType(node->getType()), sparse, cracked.fetch, cracked.proj, cracked.gather, params);
} }
spv::Id TGlslangToSpvTraverser::handleUserFunctionCall(const glslang::TIntermAggregate* node) spv::Id TGlslangToSpvTraverser::handleUserFunctionCall(const glslang::TIntermAggregate* node)
......
...@@ -1222,7 +1222,7 @@ Id Builder::createBuiltinCall(Decoration /*precision*/, Id resultType, Id builti ...@@ -1222,7 +1222,7 @@ Id Builder::createBuiltinCall(Decoration /*precision*/, Id resultType, Id builti
// Accept all parameters needed to create a texture instruction. // Accept all parameters needed to create a texture instruction.
// Create the correct instruction based on the inputs, and make the call. // Create the correct instruction based on the inputs, and make the call.
Id Builder::createTextureCall(Decoration precision, Id resultType, bool fetch, bool proj, bool gather, const TextureParameters& parameters) Id Builder::createTextureCall(Decoration precision, Id resultType, bool sparse, bool fetch, bool proj, bool gather, const TextureParameters& parameters)
{ {
static const int maxTextureArgs = 10; static const int maxTextureArgs = 10;
Id texArgs[maxTextureArgs] = {}; Id texArgs[maxTextureArgs] = {};
...@@ -1275,6 +1275,10 @@ Id Builder::createTextureCall(Decoration precision, Id resultType, bool fetch, b ...@@ -1275,6 +1275,10 @@ Id Builder::createTextureCall(Decoration precision, Id resultType, bool fetch, b
mask = (ImageOperandsMask)(mask | ImageOperandsSampleMask); mask = (ImageOperandsMask)(mask | ImageOperandsSampleMask);
texArgs[numArgs++] = parameters.sample; texArgs[numArgs++] = parameters.sample;
} }
if (parameters.lodClamp) {
mask = (ImageOperandsMask)(mask | ImageOperandsMinLodMask);
texArgs[numArgs++] = parameters.lodClamp;
}
if (mask == ImageOperandsMaskNone) if (mask == ImageOperandsMaskNone)
--numArgs; // undo speculative reservation for the mask argument --numArgs; // undo speculative reservation for the mask argument
else else
...@@ -1286,35 +1290,68 @@ Id Builder::createTextureCall(Decoration precision, Id resultType, bool fetch, b ...@@ -1286,35 +1290,68 @@ Id Builder::createTextureCall(Decoration precision, Id resultType, bool fetch, b
Op opCode; Op opCode;
opCode = OpImageSampleImplicitLod; opCode = OpImageSampleImplicitLod;
if (fetch) { if (fetch) {
opCode = OpImageFetch; if (sparse)
opCode = OpImageSparseFetch;
else
opCode = OpImageFetch;
} else if (gather) { } else if (gather) {
if (parameters.Dref) if (parameters.Dref)
opCode = OpImageDrefGather; if (sparse)
opCode = OpImageSparseDrefGather;
else
opCode = OpImageDrefGather;
else else
opCode = OpImageGather; if (sparse)
opCode = OpImageSparseGather;
else
opCode = OpImageGather;
} else if (xplicit) { } else if (xplicit) {
if (parameters.Dref) { if (parameters.Dref) {
if (proj) if (proj)
opCode = OpImageSampleProjDrefExplicitLod; if (sparse)
opCode = OpImageSparseSampleProjDrefExplicitLod;
else
opCode = OpImageSampleProjDrefExplicitLod;
else else
opCode = OpImageSampleDrefExplicitLod; if (sparse)
opCode = OpImageSparseSampleDrefExplicitLod;
else
opCode = OpImageSampleDrefExplicitLod;
} else { } else {
if (proj) if (proj)
opCode = OpImageSampleProjExplicitLod; if (sparse)
opCode = OpImageSparseSampleProjExplicitLod;
else
opCode = OpImageSampleProjExplicitLod;
else else
opCode = OpImageSampleExplicitLod; if (sparse)
opCode = OpImageSparseSampleExplicitLod;
else
opCode = OpImageSampleExplicitLod;
} }
} else { } else {
if (parameters.Dref) { if (parameters.Dref) {
if (proj) if (proj)
opCode = OpImageSampleProjDrefImplicitLod; if (sparse)
opCode = OpImageSparseSampleProjDrefImplicitLod;
else
opCode = OpImageSampleProjDrefImplicitLod;
else else
opCode = OpImageSampleDrefImplicitLod; if (sparse)
opCode = OpImageSparseSampleDrefImplicitLod;
else
opCode = OpImageSampleDrefImplicitLod;
} else { } else {
if (proj) if (proj)
opCode = OpImageSampleProjImplicitLod; if (sparse)
opCode = OpImageSparseSampleProjImplicitLod;
else
opCode = OpImageSampleProjImplicitLod;
else else
opCode = OpImageSampleImplicitLod; if (sparse)
opCode = OpImageSparseSampleImplicitLod;
else
opCode = OpImageSampleImplicitLod;
} }
} }
...@@ -1335,6 +1372,15 @@ Id Builder::createTextureCall(Decoration precision, Id resultType, bool fetch, b ...@@ -1335,6 +1372,15 @@ Id Builder::createTextureCall(Decoration precision, Id resultType, bool fetch, b
} }
} }
Id typeId0 = 0;
Id typeId1 = 0;
if (sparse) {
typeId0 = resultType;
typeId1 = getDerefTypeId(parameters.texelOut);
resultType = makeStructResultType(typeId0, typeId1);
}
// Build the SPIR-V instruction // Build the SPIR-V instruction
Instruction* textureInst = new Instruction(getUniqueId(), resultType, opCode); Instruction* textureInst = new Instruction(getUniqueId(), resultType, opCode);
for (int op = 0; op < optArgNum; ++op) for (int op = 0; op < optArgNum; ++op)
...@@ -1348,10 +1394,16 @@ Id Builder::createTextureCall(Decoration precision, Id resultType, bool fetch, b ...@@ -1348,10 +1394,16 @@ Id Builder::createTextureCall(Decoration precision, Id resultType, bool fetch, b
Id resultId = textureInst->getResultId(); Id resultId = textureInst->getResultId();
// When a smear is needed, do it, as per what was computed if (sparse) {
// above when resultType was changed to a scalar type. // Decode the return type that was a special structure
if (resultType != smearedType) createStore(createCompositeExtract(resultId, typeId1, 1), parameters.texelOut);
resultId = smearScalar(precision, resultId, smearedType); resultId = createCompositeExtract(resultId, typeId0, 0);
} else {
// When a smear is needed, do it, as per what was computed
// above when resultType was changed to a scalar type.
if (resultType != smearedType)
resultId = smearScalar(precision, resultId, smearedType);
}
return resultId; return resultId;
} }
......
...@@ -310,10 +310,12 @@ public: ...@@ -310,10 +310,12 @@ public:
Id gradY; Id gradY;
Id sample; Id sample;
Id comp; Id comp;
Id texelOut;
Id lodClamp;
}; };
// Select the correct texture operation based on all inputs, and emit the correct instruction // Select the correct texture operation based on all inputs, and emit the correct instruction
Id createTextureCall(Decoration precision, Id resultType, bool fetch, bool proj, bool gather, const TextureParameters&); Id createTextureCall(Decoration precision, Id resultType, bool sparse, bool fetch, bool proj, bool gather, const TextureParameters&);
// Emit the OpTextureQuery* instruction that was passed in. // Emit the OpTextureQuery* instruction that was passed in.
// Figure out the right return value and type, and return it. // Figure out the right return value and type, and return it.
......
...@@ -658,17 +658,27 @@ void StderrIfNonEmpty(const char* str) ...@@ -658,17 +658,27 @@ void StderrIfNonEmpty(const char* str)
} }
} }
// Simple bundling of what makes a compilation unit for ease in passing around,
// and separation of handling file IO versus API (programmatic) compilation.
struct ShaderCompUnit {
EShLanguage stage;
std::string fileName;
char** text; // memory owned/managed externally
};
// //
// For linking mode: Will independently parse each item in the worklist, but then put them // For linking mode: Will independently parse each compilation unit, but then put them
// in the same program and link them together. // in the same program and link them together, making at most one linked module per
// pipeline stage.
// //
// Uses the new C++ interface instead of the old handle-based interface. // Uses the new C++ interface instead of the old handle-based interface.
// //
void CompileAndLinkShaders()
void CompileAndLinkShaderUnits(std::vector<ShaderCompUnit> compUnits)
{ {
// keep track of what to free // keep track of what to free
std::list<glslang::TShader*> shaders; std::list<glslang::TShader*> shaders;
EShMessages messages = EShMsgDefault; EShMessages messages = EShMsgDefault;
SetMessageOptions(messages); SetMessageOptions(messages);
...@@ -677,22 +687,13 @@ void CompileAndLinkShaders() ...@@ -677,22 +687,13 @@ void CompileAndLinkShaders()
// //
glslang::TProgram& program = *new glslang::TProgram; glslang::TProgram& program = *new glslang::TProgram;
glslang::TWorkItem* workItem; for (auto compUnit : compUnits) {
while (Worklist.remove(workItem)) { glslang::TShader* shader = new glslang::TShader(compUnit.stage);
EShLanguage stage = FindLanguage(workItem->name); shader->setStrings(compUnit.text, 1);
glslang::TShader* shader = new glslang::TShader(stage);
shaders.push_back(shader); shaders.push_back(shader);
char** shaderStrings = ReadFileData(workItem->name.c_str());
if (! shaderStrings) {
usage();
delete &program;
return;
}
const int defaultVersion = Options & EOptionDefaultDesktop? 110: 100; const int defaultVersion = Options & EOptionDefaultDesktop? 110: 100;
shader->setStrings(shaderStrings, 1);
if (Options & EOptionOutputPreprocessed) { if (Options & EOptionOutputPreprocessed) {
std::string str; std::string str;
if (shader->preprocess(&Resources, defaultVersion, ENoProfile, false, false, if (shader->preprocess(&Resources, defaultVersion, ENoProfile, false, false,
...@@ -703,7 +704,6 @@ void CompileAndLinkShaders() ...@@ -703,7 +704,6 @@ void CompileAndLinkShaders()
} }
StderrIfNonEmpty(shader->getInfoLog()); StderrIfNonEmpty(shader->getInfoLog());
StderrIfNonEmpty(shader->getInfoDebugLog()); StderrIfNonEmpty(shader->getInfoDebugLog());
FreeFileData(shaderStrings);
continue; continue;
} }
if (! shader->parse(&Resources, defaultVersion, false, messages)) if (! shader->parse(&Resources, defaultVersion, false, messages))
...@@ -711,13 +711,12 @@ void CompileAndLinkShaders() ...@@ -711,13 +711,12 @@ void CompileAndLinkShaders()
program.addShader(shader); program.addShader(shader);
if (! (Options & EOptionSuppressInfolog)) { if (! (Options & EOptionSuppressInfolog) &&
PutsIfNonEmpty(workItem->name.c_str()); ! (Options & EOptionMemoryLeakMode)) {
PutsIfNonEmpty(compUnit.fileName.c_str());
PutsIfNonEmpty(shader->getInfoLog()); PutsIfNonEmpty(shader->getInfoLog());
PutsIfNonEmpty(shader->getInfoDebugLog()); PutsIfNonEmpty(shader->getInfoDebugLog());
} }
FreeFileData(shaderStrings);
} }
// //
...@@ -727,7 +726,8 @@ void CompileAndLinkShaders() ...@@ -727,7 +726,8 @@ void CompileAndLinkShaders()
if (! (Options & EOptionOutputPreprocessed) && ! program.link(messages)) if (! (Options & EOptionOutputPreprocessed) && ! program.link(messages))
LinkFailed = true; LinkFailed = true;
if (! (Options & EOptionSuppressInfolog)) { if (! (Options & EOptionSuppressInfolog) &&
! (Options & EOptionMemoryLeakMode)) {
PutsIfNonEmpty(program.getInfoLog()); PutsIfNonEmpty(program.getInfoLog());
PutsIfNonEmpty(program.getInfoDebugLog()); PutsIfNonEmpty(program.getInfoDebugLog());
} }
...@@ -745,10 +745,15 @@ void CompileAndLinkShaders() ...@@ -745,10 +745,15 @@ void CompileAndLinkShaders()
if (program.getIntermediate((EShLanguage)stage)) { if (program.getIntermediate((EShLanguage)stage)) {
std::vector<unsigned int> spirv; std::vector<unsigned int> spirv;
glslang::GlslangToSpv(*program.getIntermediate((EShLanguage)stage), spirv); glslang::GlslangToSpv(*program.getIntermediate((EShLanguage)stage), spirv);
glslang::OutputSpv(spirv, GetBinaryName((EShLanguage)stage));
if (Options & EOptionHumanReadableSpv) { // Dump the spv to a file or stdout, etc., but only if not doing
spv::Parameterize(); // memory/perf testing, as it's not internal to programmatic use.
spv::Disassemble(std::cout, spirv); if (! (Options & EOptionMemoryLeakMode)) {
glslang::OutputSpv(spirv, GetBinaryName((EShLanguage)stage));
if (Options & EOptionHumanReadableSpv) {
spv::Parameterize();
spv::Disassemble(std::cout, spirv);
}
} }
} }
} }
...@@ -766,6 +771,59 @@ void CompileAndLinkShaders() ...@@ -766,6 +771,59 @@ void CompileAndLinkShaders()
} }
} }
//
// Do file IO part of compile and link, handing off the pure
// API/programmatic mode to CompileAndLinkShaderUnits(), which can
// be put in a loop for testing memory footprint and performance.
//
// This is just for linking mode: meaning all the shaders will be put into the
// the same program linked together.
//
// This means there are a limited number of work items (not multi-threading mode)
// and that the point is testing at the linking level. Hence, to enable
// performance and memory testing, the actual compile/link can be put in
// a loop, independent of processing the work items and file IO.
//
void CompileAndLinkShaderFiles()
{
std::vector<ShaderCompUnit> compUnits;
// Transfer all the work items from to a simple list of
// of compilation units. (We don't care about the thread
// work-item distribution properties in this path, which
// is okay due to the limited number of shaders, know since
// they are all getting linked together.)
glslang::TWorkItem* workItem;
while (Worklist.remove(workItem)) {
ShaderCompUnit compUnit = {
FindLanguage(workItem->name),
workItem->name,
ReadFileData(workItem->name.c_str())
};
if (! compUnit.text) {
usage();
return;
}
compUnits.push_back(compUnit);
}
// Actual call to programmatic processing of compile and link,
// in a loop for testing memory and performance. This part contains
// all the perf/memory that a programmatic consumer will care about.
for (int i = 0; i < ((Options & EOptionMemoryLeakMode) ? 100 : 1); ++i) {
for (int j = 0; j < ((Options & EOptionMemoryLeakMode) ? 100 : 1); ++j)
CompileAndLinkShaderUnits(compUnits);
if (Options & EOptionMemoryLeakMode)
glslang::OS_DumpMemoryCounters();
}
for (auto c : compUnits)
FreeFileData(c.text);
}
int C_DECL main(int argc, char* argv[]) int C_DECL main(int argc, char* argv[])
{ {
ProcessArguments(argc, argv); ProcessArguments(argc, argv);
...@@ -803,7 +861,7 @@ int C_DECL main(int argc, char* argv[]) ...@@ -803,7 +861,7 @@ int C_DECL main(int argc, char* argv[])
if (Options & EOptionLinkProgram || if (Options & EOptionLinkProgram ||
Options & EOptionOutputPreprocessed) { Options & EOptionOutputPreprocessed) {
glslang::InitializeProcess(); glslang::InitializeProcess();
CompileAndLinkShaders(); CompileAndLinkShaderFiles();
glslang::FinalizeProcess(); glslang::FinalizeProcess();
} else { } else {
ShInitialize(); ShInitialize();
......
...@@ -60,7 +60,7 @@ patch out vec4 patchOut; // ERROR ...@@ -60,7 +60,7 @@ patch out vec4 patchOut; // ERROR
void foo24() void foo24()
{ {
dvec3 df, di; dvec3 df, di;
df = modf(outp.xyz, di); df = modf(dvec3(outp.xyz), di);
} }
in float in1; in float in1;
......
...@@ -115,3 +115,216 @@ void qlod() ...@@ -115,3 +115,216 @@ void qlod()
lod = textureQueryLod(samp1D, pf); // ERROR, only in fragment lod = textureQueryLod(samp1D, pf); // ERROR, only in fragment
lod = textureQueryLod(samp2Ds, pf2); // ERROR, only in fragment lod = textureQueryLod(samp2Ds, pf2); // ERROR, only in fragment
} }
void doubles()
{
double doublev;
dvec2 dvec2v;
dvec3 dvec3v;
dvec4 dvec4v;
bool boolv;
bvec2 bvec2v;
bvec3 bvec3v;
bvec4 bvec4v;
doublev = sqrt(2.9);
dvec2v = sqrt(dvec2(2.7));
dvec3v = sqrt(dvec3(2.0));
dvec4v = sqrt(dvec4(2.1));
doublev += inversesqrt(doublev);
dvec2v += inversesqrt(dvec2v);
dvec3v += inversesqrt(dvec3v);
dvec4v += inversesqrt(dvec4v);
doublev += abs(doublev);
dvec2v += abs(dvec2v);
dvec3v += abs(dvec3v);
dvec4v += abs(dvec4v);
doublev += sign(doublev);
dvec2v += sign(dvec2v);
dvec3v += sign(dvec3v);
dvec4v += sign(dvec4v);
doublev += floor(doublev);
dvec2v += floor(dvec2v);
dvec3v += floor(dvec3v);
dvec4v += floor(dvec4v);
doublev += trunc(doublev);
dvec2v += trunc(dvec2v);
dvec3v += trunc(dvec3v);
dvec4v += trunc(dvec4v);
doublev += round(doublev);
dvec2v += round(dvec2v);
dvec3v += round(dvec3v);
dvec4v += round(dvec4v);
doublev += roundEven(doublev);
dvec2v += roundEven(dvec2v);
dvec3v += roundEven(dvec3v);
dvec4v += roundEven(dvec4v);
doublev += ceil(doublev);
dvec2v += ceil(dvec2v);
dvec3v += ceil(dvec3v);
dvec4v += ceil(dvec4v);
doublev += fract(doublev);
dvec2v += fract(dvec2v);
dvec3v += fract(dvec3v);
dvec4v += fract(dvec4v);
doublev += mod(doublev, doublev);
dvec2v += mod(dvec2v, doublev);
dvec3v += mod(dvec3v, doublev);
dvec4v += mod(dvec4v, doublev);
dvec2v += mod(dvec2v, dvec2v);
dvec3v += mod(dvec3v, dvec3v);
dvec4v += mod(dvec4v, dvec4v);
doublev += modf(doublev, doublev);
dvec2v += modf(dvec2v, dvec2v);
dvec3v += modf(dvec3v, dvec3v);
dvec4v += modf(dvec4v, dvec4v);
doublev += min(doublev, doublev);
dvec2v += min(dvec2v, doublev);
dvec3v += min(dvec3v, doublev);
dvec4v += min(dvec4v, doublev);
dvec2v += min(dvec2v, dvec2v);
dvec3v += min(dvec3v, dvec3v);
dvec4v += min(dvec4v, dvec4v);
doublev += max(doublev, doublev);
dvec2v += max(dvec2v, doublev);
dvec3v += max(dvec3v, doublev);
dvec4v += max(dvec4v, doublev);
dvec2v += max(dvec2v, dvec2v);
dvec3v += max(dvec3v, dvec3v);
dvec4v += max(dvec4v, dvec4v);
doublev += clamp(doublev, doublev, doublev);
dvec2v += clamp(dvec2v, doublev, doublev);
dvec3v += clamp(dvec3v, doublev, doublev);
dvec4v += clamp(dvec4v, doublev, doublev);
dvec2v += clamp(dvec2v, dvec2v, dvec2v);
dvec3v += clamp(dvec3v, dvec3v, dvec3v);
dvec4v += clamp(dvec4v, dvec4v, dvec4v);
doublev += mix(doublev, doublev, doublev);
dvec2v += mix(dvec2v, dvec2v, doublev);
dvec3v += mix(dvec3v, dvec3v, doublev);
dvec4v += mix(dvec4v, dvec4v, doublev);
dvec2v += mix(dvec2v, dvec2v, dvec2v);
dvec3v += mix(dvec3v, dvec3v, dvec3v);
dvec4v += mix(dvec4v, dvec4v, dvec4v);
doublev += mix(doublev, doublev, boolv);
dvec2v += mix(dvec2v, dvec2v, bvec2v);
dvec3v += mix(dvec3v, dvec3v, bvec3v);
dvec4v += mix(dvec4v, dvec4v, bvec4v);
doublev += step(doublev, doublev);
dvec2v += step(dvec2v, dvec2v);
dvec3v += step(dvec3v, dvec3v);
dvec4v += step(dvec4v, dvec4v);
dvec2v += step(doublev, dvec2v);
dvec3v += step(doublev, dvec3v);
dvec4v += step(doublev, dvec4v);
doublev += smoothstep(doublev, doublev, doublev);
dvec2v += smoothstep(dvec2v, dvec2v, dvec2v);
dvec3v += smoothstep(dvec3v, dvec3v, dvec3v);
dvec4v += smoothstep(dvec4v, dvec4v, dvec4v);
dvec2v += smoothstep(doublev, doublev, dvec2v);
dvec3v += smoothstep(doublev, doublev, dvec3v);
dvec4v += smoothstep(doublev, doublev, dvec4v);
boolv = isnan(doublev);
bvec2v = isnan(dvec2v);
bvec3v = isnan(dvec3v);
bvec4v = isnan(dvec4v);
boolv = boolv ? isinf(doublev) : false;
bvec2v = boolv ? isinf(dvec2v) : bvec2(false);
bvec3v = boolv ? isinf(dvec3v) : bvec3(false);
bvec4v = boolv ? isinf(dvec4v) : bvec4(false);
doublev += length(doublev);
doublev += length(dvec2v);
doublev += length(dvec3v);
doublev += length(dvec4v);
doublev += distance(doublev, doublev);
doublev += distance(dvec2v, dvec2v);
doublev += distance(dvec3v, dvec3v);
doublev += distance(dvec4v, dvec4v);
doublev += dot(doublev, doublev);
doublev += dot(dvec2v, dvec2v);
doublev += dot(dvec3v, dvec3v);
doublev += dot(dvec4v, dvec4v);
dvec3v += cross(dvec3v, dvec3v);
doublev += normalize(doublev);
dvec2v += normalize(dvec2v);
dvec3v += normalize(dvec3v);
dvec4v += normalize(dvec4v);
doublev += faceforward(doublev, doublev, doublev);
dvec2v += faceforward(dvec2v, dvec2v, dvec2v);
dvec3v += faceforward(dvec3v, dvec3v, dvec3v);
dvec4v += faceforward(dvec4v, dvec4v, dvec4v);
doublev += reflect(doublev, doublev);
dvec2v += reflect(dvec2v, dvec2v);
dvec3v += reflect(dvec3v, dvec3v);
dvec4v += reflect(dvec4v, dvec4v);
doublev += refract(doublev, doublev, doublev);
dvec2v += refract(dvec2v, dvec2v, doublev);
dvec3v += refract(dvec3v, dvec3v, doublev);
dvec4v += refract(dvec4v, dvec4v, doublev);
dmat2 dmat2v = outerProduct(dvec2v, dvec2v);
dmat3 dmat3v = outerProduct(dvec3v, dvec3v);
dmat4 dmat4v = outerProduct(dvec4v, dvec4v);
dmat2x3 dmat2x3v = outerProduct(dvec3v, dvec2v);
dmat3x2 dmat3x2v = outerProduct(dvec2v, dvec3v);
dmat2x4 dmat2x4v = outerProduct(dvec4v, dvec2v);
dmat4x2 dmat4x2v = outerProduct(dvec2v, dvec4v);
dmat3x4 dmat3x4v = outerProduct(dvec4v, dvec3v);
dmat4x3 dmat4x3v = outerProduct(dvec3v, dvec4v);
dmat2v *= matrixCompMult(dmat2v, dmat2v);
dmat3v *= matrixCompMult(dmat3v, dmat3v);
dmat4v *= matrixCompMult(dmat4v, dmat4v);
dmat2x3v = matrixCompMult(dmat2x3v, dmat2x3v);
dmat2x4v = matrixCompMult(dmat2x4v, dmat2x4v);
dmat3x2v = matrixCompMult(dmat3x2v, dmat3x2v);
dmat3x4v = matrixCompMult(dmat3x4v, dmat3x4v);
dmat4x2v = matrixCompMult(dmat4x2v, dmat4x2v);
dmat4x3v = matrixCompMult(dmat4x3v, dmat4x3v);
dmat2v *= transpose(dmat2v);
dmat3v *= transpose(dmat3v);
dmat4v *= transpose(dmat4v);
dmat2x3v = transpose(dmat3x2v);
dmat3x2v = transpose(dmat2x3v);
dmat2x4v = transpose(dmat4x2v);
dmat4x2v = transpose(dmat2x4v);
dmat3x4v = transpose(dmat4x3v);
dmat4x3v = transpose(dmat3x4v);
doublev += determinant(dmat2v);
doublev += determinant(dmat3v);
doublev += determinant(dmat4v);
dmat2v *= inverse(dmat2v);
dmat3v *= inverse(dmat3v);
dmat4v *= inverse(dmat4v);
}
...@@ -218,26 +218,18 @@ ERROR: node is still EOpNull! ...@@ -218,26 +218,18 @@ ERROR: node is still EOpNull!
0:? Sequence 0:? Sequence
0:63 move second child to first child (temp 3-component vector of double) 0:63 move second child to first child (temp 3-component vector of double)
0:63 'df' (temp 3-component vector of double) 0:63 'df' (temp 3-component vector of double)
0:63 Convert float to double (temp 3-component vector of double) 0:63 modf (global 3-component vector of double)
0:63 Comma (global 3-component vector of float) 0:63 Convert float to double (temp 3-component vector of double)
0:63 move second child to first child (temp 3-component vector of float) 0:63 vector swizzle (temp 3-component vector of float)
0:63 'tempReturn' (global 3-component vector of float) 0:63 'outp' (out 4-component vector of float)
0:63 modf (global 3-component vector of float) 0:63 Sequence
0:63 vector swizzle (temp 3-component vector of float) 0:63 Constant:
0:63 'outp' (out 4-component vector of float) 0:63 0 (const int)
0:63 Sequence 0:63 Constant:
0:63 Constant: 0:63 1 (const int)
0:63 0 (const int) 0:63 Constant:
0:63 Constant: 0:63 2 (const int)
0:63 1 (const int) 0:63 'di' (temp 3-component vector of double)
0:63 Constant:
0:63 2 (const int)
0:63 'tempArg' (temp 3-component vector of float)
0:63 move second child to first child (temp 3-component vector of double)
0:63 'di' (temp 3-component vector of double)
0:63 Convert float to double (temp 3-component vector of double)
0:63 'tempArg' (temp 3-component vector of float)
0:63 'tempReturn' (global 3-component vector of float)
0:71 Function Definition: foodc1( (global void) 0:71 Function Definition: foodc1( (global void)
0:71 Function Parameters: 0:71 Function Parameters:
0:73 Sequence 0:73 Sequence
...@@ -707,26 +699,18 @@ ERROR: node is still EOpNull! ...@@ -707,26 +699,18 @@ ERROR: node is still EOpNull!
0:? Sequence 0:? Sequence
0:63 move second child to first child (temp 3-component vector of double) 0:63 move second child to first child (temp 3-component vector of double)
0:63 'df' (temp 3-component vector of double) 0:63 'df' (temp 3-component vector of double)
0:63 Convert float to double (temp 3-component vector of double) 0:63 modf (global 3-component vector of double)
0:63 Comma (global 3-component vector of float) 0:63 Convert float to double (temp 3-component vector of double)
0:63 move second child to first child (temp 3-component vector of float) 0:63 vector swizzle (temp 3-component vector of float)
0:63 'tempReturn' (global 3-component vector of float) 0:63 'outp' (out 4-component vector of float)
0:63 modf (global 3-component vector of float) 0:63 Sequence
0:63 vector swizzle (temp 3-component vector of float) 0:63 Constant:
0:63 'outp' (out 4-component vector of float) 0:63 0 (const int)
0:63 Sequence 0:63 Constant:
0:63 Constant: 0:63 1 (const int)
0:63 0 (const int) 0:63 Constant:
0:63 Constant: 0:63 2 (const int)
0:63 1 (const int) 0:63 'di' (temp 3-component vector of double)
0:63 Constant:
0:63 2 (const int)
0:63 'tempArg' (temp 3-component vector of float)
0:63 move second child to first child (temp 3-component vector of double)
0:63 'di' (temp 3-component vector of double)
0:63 Convert float to double (temp 3-component vector of double)
0:63 'tempArg' (temp 3-component vector of float)
0:63 'tempReturn' (global 3-component vector of float)
0:71 Function Definition: foodc1( (global void) 0:71 Function Definition: foodc1( (global void)
0:71 Function Parameters: 0:71 Function Parameters:
0:73 Sequence 0:73 Sequence
......
...@@ -21,6 +21,223 @@ void foo23() ...@@ -21,6 +21,223 @@ void foo23()
outp.x += textureProjGradOffset(u2drs, outp, vec2(0.0), vec2(0.0), offsets[1]); outp.x += textureProjGradOffset(u2drs, outp, vec2(0.0), vec2(0.0), offsets[1]);
} }
void doubles()
{
double doublev;
dvec2 dvec2v;
dvec3 dvec3v;
dvec4 dvec4v;
bool boolv;
bvec2 bvec2v;
bvec3 bvec3v;
bvec4 bvec4v;
doublev = sqrt(2.9);
dvec2v = sqrt(dvec2(2.7));
dvec3v = sqrt(dvec3(2.0));
dvec4v = sqrt(dvec4(doublev));
doublev += inversesqrt(doublev);
dvec2v += inversesqrt(dvec2v);
dvec3v += inversesqrt(dvec3v);
dvec4v += inversesqrt(dvec4v);
doublev += abs(doublev);
dvec2v += abs(dvec2v);
dvec3v += abs(dvec3v);
dvec4v += abs(dvec4v);
doublev += sign(doublev);
dvec2v += sign(dvec2v);
dvec3v += sign(dvec3v);
dvec4v += sign(dvec4v);
doublev += floor(doublev);
dvec2v += floor(dvec2v);
dvec3v += floor(dvec3v);
dvec4v += floor(dvec4v);
doublev += trunc(doublev);
dvec2v += trunc(dvec2v);
dvec3v += trunc(dvec3v);
dvec4v += trunc(dvec4v);
doublev += round(doublev);
dvec2v += round(dvec2v);
dvec3v += round(dvec3v);
dvec4v += round(dvec4v);
doublev += roundEven(doublev);
dvec2v += roundEven(dvec2v);
dvec3v += roundEven(dvec3v);
dvec4v += roundEven(dvec4v);
doublev += ceil(doublev);
dvec2v += ceil(dvec2v);
dvec3v += ceil(dvec3v);
dvec4v += ceil(dvec4v);
doublev += fract(doublev);
dvec2v += fract(dvec2v);
dvec3v += fract(dvec3v);
dvec4v += fract(dvec4v);
doublev += mod(doublev, doublev);
dvec2v += mod(dvec2v, doublev);
dvec3v += mod(dvec3v, doublev);
dvec4v += mod(dvec4v, doublev);
dvec2v += mod(dvec2v, dvec2v);
dvec3v += mod(dvec3v, dvec3v);
dvec4v += mod(dvec4v, dvec4v);
doublev += modf(doublev, doublev);
dvec2v += modf(dvec2v, dvec2v);
dvec3v += modf(dvec3v, dvec3v);
dvec4v += modf(dvec4v, dvec4v);
doublev += min(doublev, doublev);
dvec2v += min(dvec2v, doublev);
dvec3v += min(dvec3v, doublev);
dvec4v += min(dvec4v, doublev);
dvec2v += min(dvec2v, dvec2v);
dvec3v += min(dvec3v, dvec3v);
dvec4v += min(dvec4v, dvec4v);
doublev += max(doublev, doublev);
dvec2v += max(dvec2v, doublev);
dvec3v += max(dvec3v, doublev);
dvec4v += max(dvec4v, doublev);
dvec2v += max(dvec2v, dvec2v);
dvec3v += max(dvec3v, dvec3v);
dvec4v += max(dvec4v, dvec4v);
doublev += clamp(doublev, doublev, doublev);
dvec2v += clamp(dvec2v, doublev, doublev);
dvec3v += clamp(dvec3v, doublev, doublev);
dvec4v += clamp(dvec4v, doublev, doublev);
dvec2v += clamp(dvec2v, dvec2v, dvec2v);
dvec3v += clamp(dvec3v, dvec3v, dvec3v);
dvec4v += clamp(dvec4v, dvec4v, dvec4v);
doublev += mix(doublev, doublev, doublev);
dvec2v += mix(dvec2v, dvec2v, doublev);
dvec3v += mix(dvec3v, dvec3v, doublev);
dvec4v += mix(dvec4v, dvec4v, doublev);
dvec2v += mix(dvec2v, dvec2v, dvec2v);
dvec3v += mix(dvec3v, dvec3v, dvec3v);
dvec4v += mix(dvec4v, dvec4v, dvec4v);
doublev += mix(doublev, doublev, boolv);
dvec2v += mix(dvec2v, dvec2v, bvec2v);
dvec3v += mix(dvec3v, dvec3v, bvec3v);
dvec4v += mix(dvec4v, dvec4v, bvec4v);
doublev += step(doublev, doublev);
dvec2v += step(dvec2v, dvec2v);
dvec3v += step(dvec3v, dvec3v);
dvec4v += step(dvec4v, dvec4v);
dvec2v += step(doublev, dvec2v);
dvec3v += step(doublev, dvec3v);
dvec4v += step(doublev, dvec4v);
doublev += smoothstep(doublev, doublev, doublev);
dvec2v += smoothstep(dvec2v, dvec2v, dvec2v);
dvec3v += smoothstep(dvec3v, dvec3v, dvec3v);
dvec4v += smoothstep(dvec4v, dvec4v, dvec4v);
dvec2v += smoothstep(doublev, doublev, dvec2v);
dvec3v += smoothstep(doublev, doublev, dvec3v);
dvec4v += smoothstep(doublev, doublev, dvec4v);
boolv = isnan(doublev);
bvec2v = isnan(dvec2v);
bvec3v = isnan(dvec3v);
bvec4v = isnan(dvec4v);
boolv = boolv ? isinf(doublev) : false;
bvec2v = boolv ? isinf(dvec2v) : bvec2(false);
bvec3v = boolv ? isinf(dvec3v) : bvec3(false);
bvec4v = boolv ? isinf(dvec4v) : bvec4(false);
doublev += length(doublev);
doublev += length(dvec2v);
doublev += length(dvec3v);
doublev += length(dvec4v);
doublev += distance(doublev, doublev);
doublev += distance(dvec2v, dvec2v);
doublev += distance(dvec3v, dvec3v);
doublev += distance(dvec4v, dvec4v);
doublev += dot(doublev, doublev);
doublev += dot(dvec2v, dvec2v);
doublev += dot(dvec3v, dvec3v);
doublev += dot(dvec4v, dvec4v);
dvec3v += cross(dvec3v, dvec3v);
doublev += normalize(doublev);
dvec2v += normalize(dvec2v);
dvec3v += normalize(dvec3v);
dvec4v += normalize(dvec4v);
doublev += faceforward(doublev, doublev, doublev);
dvec2v += faceforward(dvec2v, dvec2v, dvec2v);
dvec3v += faceforward(dvec3v, dvec3v, dvec3v);
dvec4v += faceforward(dvec4v, dvec4v, dvec4v);
doublev += reflect(doublev, doublev);
dvec2v += reflect(dvec2v, dvec2v);
dvec3v += reflect(dvec3v, dvec3v);
dvec4v += reflect(dvec4v, dvec4v);
doublev += refract(doublev, doublev, doublev);
dvec2v += refract(dvec2v, dvec2v, doublev);
dvec3v += refract(dvec3v, dvec3v, doublev);
dvec4v += refract(dvec4v, dvec4v, doublev);
dmat2 dmat2v = outerProduct(dvec2v, dvec2v);
dmat3 dmat3v = outerProduct(dvec3v, dvec3v);
dmat4 dmat4v = outerProduct(dvec4v, dvec4v);
dmat2x3 dmat2x3v = outerProduct(dvec3v, dvec2v);
dmat3x2 dmat3x2v = outerProduct(dvec2v, dvec3v);
dmat2x4 dmat2x4v = outerProduct(dvec4v, dvec2v);
dmat4x2 dmat4x2v = outerProduct(dvec2v, dvec4v);
dmat3x4 dmat3x4v = outerProduct(dvec4v, dvec3v);
dmat4x3 dmat4x3v = outerProduct(dvec3v, dvec4v);
dmat2v *= matrixCompMult(dmat2v, dmat2v);
dmat3v *= matrixCompMult(dmat3v, dmat3v);
dmat4v *= matrixCompMult(dmat4v, dmat4v);
dmat2x3v = matrixCompMult(dmat2x3v, dmat2x3v); // For now, relying on no dead-code elimination
dmat2x4v = matrixCompMult(dmat2x4v, dmat2x4v);
dmat3x2v = matrixCompMult(dmat3x2v, dmat3x2v);
dmat3x4v = matrixCompMult(dmat3x4v, dmat3x4v);
dmat4x2v = matrixCompMult(dmat4x2v, dmat4x2v);
dmat4x3v = matrixCompMult(dmat4x3v, dmat4x3v);
dmat2v *= transpose(dmat2v);
dmat3v *= transpose(dmat3v);
dmat4v *= transpose(dmat4v);
dmat2x3v = transpose(dmat3x2v); // For now, relying on no dead-code elimination
dmat3x2v = transpose(dmat2x3v);
dmat2x4v = transpose(dmat4x2v);
dmat4x2v = transpose(dmat2x4v);
dmat3x4v = transpose(dmat4x3v);
dmat4x3v = transpose(dmat3x4v);
doublev += determinant(dmat2v);
doublev += determinant(dmat3v);
doublev += determinant(dmat4v);
dmat2v *= inverse(dmat2v);
dmat3v *= inverse(dmat3v);
dmat4v *= inverse(dmat4v);
outp *= float(doublev + dvec2v.y + dvec3v.z + dvec4v.w +
dmat2v[1][1] + dmat3v[2][2] + dmat4v[3][3] + dmat2x3v[1][1] + dmat3x2v[1][1] + dmat3x4v[2][2] + dmat4x3v[2][2] + dmat2x4v[1][1] + dmat4x2v[1][1] +
float(boolv) + float(bvec2v.x) + float(bvec3v.x) + float(bvec4v.x));
}
void main() void main()
{ {
vec4 v; vec4 v;
...@@ -38,5 +255,6 @@ void main() ...@@ -38,5 +255,6 @@ void main()
outp += gl_FragCoord + vl2; outp += gl_FragCoord + vl2;
foo23(); foo23();
doubles();
} }
#version 450
#extension GL_ARB_sparse_texture2: enable
uniform sampler2D s2D;
uniform sampler3D s3D;
uniform sampler2DShadow s2DShadow;
uniform samplerCubeShadow sCubeShadow;
uniform sampler2DArrayShadow s2DArrayShadow;
uniform sampler2DRectShadow s2DRectShadow;
uniform samplerCubeArrayShadow sCubeArrayShadow;
uniform sampler2DMS s2DMS;
uniform isamplerCube isCube;
uniform isampler2DArray is2DArray;
uniform usamplerCubeArray usCubeArray;
uniform usampler2DRect us2DRect;
uniform vec2 c2;
uniform vec3 c3;
uniform vec4 c4;
uniform ivec2 offsets[4];
out vec4 outColor;
void main()
{
int resident = 0;
vec4 texel = vec4(0.0);
ivec4 itexel = ivec4(0);
uvec4 utexel = uvec4(0);
resident |= sparseTextureARB(s2D, c2, texel);
resident |= sparseTextureARB(s3D, c3, texel, 2.0);
resident |= sparseTextureARB(isCube, c3, itexel);
resident |= sparseTextureARB(s2DShadow, c3, texel.x);
resident |= sparseTextureARB(sCubeArrayShadow, c4, 1.0, texel.x);
resident |= sparseTextureLodARB(s2D, c2, 2.0, texel);
resident |= sparseTextureLodARB(usCubeArray, c4, 1.0, utexel);
resident |= sparseTextureLodARB(s2DShadow, c3, 2.0, texel.y);
resident |= sparseTextureOffsetARB(s3D, c3, ivec3(2), texel, 2.0);
resident |= sparseTextureOffsetARB(us2DRect, c2, ivec2(3), utexel);
resident |= sparseTextureOffsetARB(s2DArrayShadow, c4, ivec2(5), texel.z);
resident |= sparseTexelFetchARB(s2D, ivec2(c2), 2, texel);
resident |= sparseTexelFetchARB(us2DRect, ivec2(c2), utexel);
resident |= sparseTexelFetchARB(s2DMS, ivec2(c2), 4, texel);
resident |= sparseTexelFetchOffsetARB(s3D, ivec3(c3), 2, ivec3(4), texel);
resident |= sparseTexelFetchOffsetARB(us2DRect, ivec2(c2), ivec2(3), utexel);
resident |= sparseTextureLodOffsetARB(s2D, c2, 2.0, ivec2(5), texel);
resident |= sparseTextureLodOffsetARB(is2DArray, c3, 2.0, ivec2(6), itexel);
resident |= sparseTextureLodOffsetARB(s2DShadow, c3, 2.0, ivec2(7), texel.z);
resident |= sparseTextureGradARB(s3D, c3, c3, c3, texel);
resident |= sparseTextureGradARB(sCubeShadow, c4, c3, c3, texel.y);
resident |= sparseTextureGradARB(usCubeArray, c4, c3, c3, utexel);
resident |= sparseTextureGradOffsetARB(s2D, c2, c2, c2, ivec2(5), texel);
resident |= sparseTextureGradOffsetARB(s2DRectShadow, c3, c2, c2, ivec2(6), texel.w);
resident |= sparseTextureGradOffsetARB(is2DArray, c3, c2, c2, ivec2(2), itexel);
resident |= sparseTextureGatherARB(s2D, c2, texel);
resident |= sparseTextureGatherARB(is2DArray, c3, itexel, 2);
resident |= sparseTextureGatherARB(s2DArrayShadow, c3, 2.0, texel);
resident |= sparseTextureGatherOffsetARB(s2D, c2, ivec2(4), texel);
resident |= sparseTextureGatherOffsetARB(is2DArray, c3, ivec2(5), itexel, 2);
resident |= sparseTextureGatherOffsetARB(s2DRectShadow, c2, 2.0, ivec2(7), texel);
resident |= sparseTextureGatherOffsetsARB(s2D, c2, offsets, texel);
resident |= sparseTextureGatherOffsetsARB(is2DArray, c3, offsets, itexel, 2);
resident |= sparseTextureGatherOffsetsARB(s2DRectShadow, c2, 2.0, offsets, texel);
outColor = sparseTexelsResidentARB(resident) ? texel : vec4(itexel) + vec4(utexel);
}
\ No newline at end of file
#version 450
#extension GL_ARB_sparse_texture_clamp: enable
uniform sampler2D s2D;
uniform sampler3D s3D;
uniform sampler2DShadow s2DShadow;
uniform samplerCubeShadow sCubeShadow;
uniform sampler2DArrayShadow s2DArrayShadow;
uniform sampler2DRectShadow s2DRectShadow;
uniform samplerCubeArrayShadow sCubeArrayShadow;
uniform isamplerCube isCube;
uniform isampler2DArray is2DArray;
uniform usamplerCubeArray usCubeArray;
uniform usampler2DRect us2DRect;
uniform vec2 c2;
uniform vec3 c3;
uniform vec4 c4;
uniform float lodClamp;
out vec4 outColor;
void main()
{
int resident = 0;
vec4 texel = vec4(0.0);
ivec4 itexel = ivec4(0);
uvec4 utexel = uvec4(0);
resident |= sparseTextureClampARB(s2D, c2, lodClamp, texel);
resident |= sparseTextureClampARB(s3D, c3, lodClamp, texel, 2.0);
resident |= sparseTextureClampARB(isCube, c3, lodClamp, itexel);
resident |= sparseTextureClampARB(s2DShadow, c3, lodClamp, texel.x);
resident |= sparseTextureClampARB(sCubeArrayShadow, c4, 1.0, lodClamp, texel.x);
texel += textureClampARB(s2D, c2, lodClamp);
texel += textureClampARB(s3D, c3, lodClamp, 2.0);
itexel += textureClampARB(isCube, c3, lodClamp);
texel.x += textureClampARB(s2DShadow, c3, lodClamp);
texel.x += textureClampARB(sCubeArrayShadow, c4, 1.0, lodClamp);
resident |= sparseTextureOffsetClampARB(s3D, c3, ivec3(2), lodClamp, texel, 2.0);
resident |= sparseTextureOffsetClampARB(us2DRect, c2, ivec2(3), lodClamp, utexel);
resident |= sparseTextureOffsetClampARB(s2DArrayShadow, c4, ivec2(5), lodClamp, texel.z);
texel += textureOffsetClampARB(s3D, c3, ivec3(2), lodClamp, 2.0);
utexel += textureOffsetClampARB(us2DRect, c2, ivec2(3), lodClamp);
texel.z += textureOffsetClampARB(s2DArrayShadow, c4, ivec2(5), lodClamp);
resident |= sparseTextureGradClampARB(s3D, c3, c3, c3, lodClamp, texel);
resident |= sparseTextureGradClampARB(sCubeShadow, c4, c3, c3, lodClamp, texel.y);
resident |= sparseTextureGradClampARB(usCubeArray, c4, c3, c3, lodClamp, utexel);
texel += textureGradClampARB(s3D, c3, c3, c3, lodClamp);
texel.y += textureGradClampARB(sCubeShadow, c4, c3, c3, lodClamp);
utexel += textureGradClampARB(usCubeArray, c4, c3, c3, lodClamp);
resident |= sparseTextureGradOffsetClampARB(s2D, c2, c2, c2, ivec2(5), lodClamp, texel);
resident |= sparseTextureGradOffsetClampARB(s2DRectShadow, c3, c2, c2, ivec2(6), lodClamp, texel.w);
resident |= sparseTextureGradOffsetClampARB(is2DArray, c3, c2, c2, ivec2(2), lodClamp, itexel);
texel += textureGradOffsetClampARB(s2D, c2, c2, c2, ivec2(5), lodClamp);
texel.w += textureGradOffsetClampARB(s2DRectShadow, c3, c2, c2, ivec2(6), lodClamp);
itexel += textureGradOffsetClampARB(is2DArray, c3, c2, c2, ivec2(2), lodClamp);
outColor = sparseTexelsResidentARB(resident) ? texel : vec4(itexel) + vec4(utexel);
}
\ No newline at end of file
...@@ -66,6 +66,8 @@ spv.qualifiers.vert ...@@ -66,6 +66,8 @@ spv.qualifiers.vert
spv.shiftOps.frag spv.shiftOps.frag
spv.simpleFunctionCall.frag spv.simpleFunctionCall.frag
spv.simpleMat.vert spv.simpleMat.vert
spv.sparseTexture.frag
spv.sparseTextureClamp.frag
spv.structAssignment.frag spv.structAssignment.frag
spv.structDeref.frag spv.structDeref.frag
spv.structure.frag spv.structure.frag
......
...@@ -369,6 +369,8 @@ enum TOperator { ...@@ -369,6 +369,8 @@ enum TOperator {
EOpImageAtomicExchange, EOpImageAtomicExchange,
EOpImageAtomicCompSwap, EOpImageAtomicCompSwap,
EOpSparseImageLoad,
EOpImageGuardEnd, EOpImageGuardEnd,
// //
...@@ -398,6 +400,31 @@ enum TOperator { ...@@ -398,6 +400,31 @@ enum TOperator {
EOpTextureGather, EOpTextureGather,
EOpTextureGatherOffset, EOpTextureGatherOffset,
EOpTextureGatherOffsets, EOpTextureGatherOffsets,
EOpTextureClamp,
EOpTextureOffsetClamp,
EOpTextureGradClamp,
EOpTextureGradOffsetClamp,
EOpSparseTextureGuardBegin,
EOpSparseTexture,
EOpSparseTextureLod,
EOpSparseTextureOffset,
EOpSparseTextureFetch,
EOpSparseTextureFetchOffset,
EOpSparseTextureLodOffset,
EOpSparseTextureGrad,
EOpSparseTextureGradOffset,
EOpSparseTextureGather,
EOpSparseTextureGatherOffset,
EOpSparseTextureGatherOffsets,
EOpSparseTexelsResident,
EOpSparseTextureClamp,
EOpSparseTextureOffsetClamp,
EOpSparseTextureGradClamp,
EOpSparseTextureGradOffsetClamp,
EOpSparseTextureGuardEnd,
EOpTextureGuardEnd, EOpTextureGuardEnd,
...@@ -622,6 +649,7 @@ struct TCrackedTextureOp { ...@@ -622,6 +649,7 @@ struct TCrackedTextureOp {
bool offsets; bool offsets;
bool gather; bool gather;
bool grad; bool grad;
bool lodClamp;
}; };
// //
...@@ -637,6 +665,8 @@ public: ...@@ -637,6 +665,8 @@ public:
bool isConstructor() const; bool isConstructor() const;
bool isTexture() const { return op > EOpTextureGuardBegin && op < EOpTextureGuardEnd; } bool isTexture() const { return op > EOpTextureGuardBegin && op < EOpTextureGuardEnd; }
bool isImage() const { return op > EOpImageGuardBegin && op < EOpImageGuardEnd; } bool isImage() const { return op > EOpImageGuardBegin && op < EOpImageGuardEnd; }
bool isSparseTexture() const { return op > EOpSparseTextureGuardBegin && op < EOpSparseTextureGuardEnd; }
bool isSparseImage() const { return op == EOpSparseImageLoad; }
// Crack the op into the individual dimensions of texturing operation. // Crack the op into the individual dimensions of texturing operation.
void crackTexture(TSampler sampler, TCrackedTextureOp& cracked) const void crackTexture(TSampler sampler, TCrackedTextureOp& cracked) const
...@@ -649,6 +679,7 @@ public: ...@@ -649,6 +679,7 @@ public:
cracked.offsets = false; cracked.offsets = false;
cracked.gather = false; cracked.gather = false;
cracked.grad = false; cracked.grad = false;
cracked.lodClamp = false;
switch (op) { switch (op) {
case EOpImageQuerySize: case EOpImageQuerySize:
...@@ -657,25 +688,40 @@ public: ...@@ -657,25 +688,40 @@ public:
case EOpTextureQueryLod: case EOpTextureQueryLod:
case EOpTextureQueryLevels: case EOpTextureQueryLevels:
case EOpTextureQuerySamples: case EOpTextureQuerySamples:
case EOpSparseTexelsResident:
cracked.query = true; cracked.query = true;
break; break;
case EOpTexture: case EOpTexture:
case EOpSparseTexture:
break;
case EOpTextureClamp:
case EOpSparseTextureClamp:
cracked.lodClamp = true;
break; break;
case EOpTextureProj: case EOpTextureProj:
cracked.proj = true; cracked.proj = true;
break; break;
case EOpTextureLod: case EOpTextureLod:
case EOpSparseTextureLod:
cracked.lod = true; cracked.lod = true;
break; break;
case EOpTextureOffset: case EOpTextureOffset:
case EOpSparseTextureOffset:
cracked.offset = true; cracked.offset = true;
break; break;
case EOpTextureOffsetClamp:
case EOpSparseTextureOffsetClamp:
cracked.offset = true;
cracked.lodClamp = true;
break;
case EOpTextureFetch: case EOpTextureFetch:
case EOpSparseTextureFetch:
cracked.fetch = true; cracked.fetch = true;
if (sampler.dim == Esd1D || (sampler.dim == Esd2D && ! sampler.ms) || sampler.dim == Esd3D) if (sampler.dim == Esd1D || (sampler.dim == Esd2D && ! sampler.ms) || sampler.dim == Esd3D)
cracked.lod = true; cracked.lod = true;
break; break;
case EOpTextureFetchOffset: case EOpTextureFetchOffset:
case EOpSparseTextureFetchOffset:
cracked.fetch = true; cracked.fetch = true;
cracked.offset = true; cracked.offset = true;
if (sampler.dim == Esd1D || (sampler.dim == Esd2D && ! sampler.ms) || sampler.dim == Esd3D) if (sampler.dim == Esd1D || (sampler.dim == Esd2D && ! sampler.ms) || sampler.dim == Esd3D)
...@@ -686,6 +732,7 @@ public: ...@@ -686,6 +732,7 @@ public:
cracked.proj = true; cracked.proj = true;
break; break;
case EOpTextureLodOffset: case EOpTextureLodOffset:
case EOpSparseTextureLodOffset:
cracked.offset = true; cracked.offset = true;
cracked.lod = true; cracked.lod = true;
break; break;
...@@ -699,9 +746,16 @@ public: ...@@ -699,9 +746,16 @@ public:
cracked.proj = true; cracked.proj = true;
break; break;
case EOpTextureGrad: case EOpTextureGrad:
case EOpSparseTextureGrad:
cracked.grad = true; cracked.grad = true;
break; break;
case EOpTextureGradClamp:
case EOpSparseTextureGradClamp:
cracked.grad = true;
cracked.lodClamp = true;
break;
case EOpTextureGradOffset: case EOpTextureGradOffset:
case EOpSparseTextureGradOffset:
cracked.grad = true; cracked.grad = true;
cracked.offset = true; cracked.offset = true;
break; break;
...@@ -714,14 +768,23 @@ public: ...@@ -714,14 +768,23 @@ public:
cracked.offset = true; cracked.offset = true;
cracked.proj = true; cracked.proj = true;
break; break;
case EOpTextureGradOffsetClamp:
case EOpSparseTextureGradOffsetClamp:
cracked.grad = true;
cracked.offset = true;
cracked.lodClamp = true;
break;
case EOpTextureGather: case EOpTextureGather:
case EOpSparseTextureGather:
cracked.gather = true; cracked.gather = true;
break; break;
case EOpTextureGatherOffset: case EOpTextureGatherOffset:
case EOpSparseTextureGatherOffset:
cracked.gather = true; cracked.gather = true;
cracked.offset = true; cracked.offset = true;
break; break;
case EOpTextureGatherOffsets: case EOpTextureGatherOffsets:
case EOpSparseTextureGatherOffsets:
cracked.gather = true; cracked.gather = true;
cracked.offsets = true; cracked.offsets = true;
break; break;
......
...@@ -173,6 +173,8 @@ void TParseContext::initializeExtensionBehavior() ...@@ -173,6 +173,8 @@ void TParseContext::initializeExtensionBehavior()
extensionBehavior[E_GL_ARB_derivative_control] = EBhDisable; extensionBehavior[E_GL_ARB_derivative_control] = EBhDisable;
extensionBehavior[E_GL_ARB_shader_texture_image_samples] = EBhDisable; extensionBehavior[E_GL_ARB_shader_texture_image_samples] = EBhDisable;
extensionBehavior[E_GL_ARB_viewport_array] = EBhDisable; extensionBehavior[E_GL_ARB_viewport_array] = EBhDisable;
extensionBehavior[E_GL_ARB_sparse_texture2] = EBhDisable;
extensionBehavior[E_GL_ARB_sparse_texture_clamp] = EBhDisable;
// extensionBehavior[E_GL_ARB_cull_distance] = EBhDisable; // present for 4.5, but need extension control over block members // extensionBehavior[E_GL_ARB_cull_distance] = EBhDisable; // present for 4.5, but need extension control over block members
// #line and #include // #line and #include
...@@ -274,6 +276,8 @@ const char* TParseContext::getPreamble() ...@@ -274,6 +276,8 @@ const char* TParseContext::getPreamble()
"#define GL_ARB_derivative_control 1\n" "#define GL_ARB_derivative_control 1\n"
"#define GL_ARB_shader_texture_image_samples 1\n" "#define GL_ARB_shader_texture_image_samples 1\n"
"#define GL_ARB_viewport_array 1\n" "#define GL_ARB_viewport_array 1\n"
"#define GL_ARB_sparse_texture2 1\n"
"#define GL_ARB_sparse_texture_clamp 1\n"
"#define GL_GOOGLE_cpp_style_line_directive 1\n" "#define GL_GOOGLE_cpp_style_line_directive 1\n"
"#define GL_GOOGLE_include_directive 1\n" "#define GL_GOOGLE_include_directive 1\n"
......
...@@ -111,6 +111,8 @@ const char* const E_GL_ARB_shader_draw_parameters = "GL_ARB_shader_draw_pa ...@@ -111,6 +111,8 @@ const char* const E_GL_ARB_shader_draw_parameters = "GL_ARB_shader_draw_pa
const char* const E_GL_ARB_derivative_control = "GL_ARB_derivative_control"; const char* const E_GL_ARB_derivative_control = "GL_ARB_derivative_control";
const char* const E_GL_ARB_shader_texture_image_samples = "GL_ARB_shader_texture_image_samples"; const char* const E_GL_ARB_shader_texture_image_samples = "GL_ARB_shader_texture_image_samples";
const char* const E_GL_ARB_viewport_array = "GL_ARB_viewport_array"; const char* const E_GL_ARB_viewport_array = "GL_ARB_viewport_array";
const char* const E_GL_ARB_sparse_texture2 = "GL_ARB_sparse_texture2";
const char* const E_GL_ARB_sparse_texture_clamp = "GL_ARB_sparse_texture_clamp";
//const char* const E_GL_ARB_cull_distance = "GL_ARB_cull_distance"; // present for 4.5, but need extension control over block members //const char* const E_GL_ARB_cull_distance = "GL_ARB_cull_distance"; // present for 4.5, but need extension control over block members
// #line and #include // #line and #include
......
...@@ -147,6 +147,8 @@ void OS_Sleep(int milliseconds) ...@@ -147,6 +147,8 @@ void OS_Sleep(int milliseconds)
Sleep(milliseconds); Sleep(milliseconds);
} }
//#define DUMP_COUNTERS
void OS_DumpMemoryCounters() void OS_DumpMemoryCounters()
{ {
#ifdef DUMP_COUNTERS #ifdef DUMP_COUNTERS
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment