Merge branch 'topo' into loopgen-after-readable-order

This commit is contained in:
Dejan Mircevski 2016-01-19 16:47:41 -05:00
commit e7f6cac1bd
48 changed files with 7859 additions and 2573 deletions

View File

@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 2.8)
set(SOURCES
GlslangToSpv.cpp
InReadableOrder.cpp
SpvBuilder.cpp
SPVRemapper.cpp
doc.cpp

View File

@ -1911,6 +1911,14 @@ void TGlslangToSpvTraverser::handleFunctionEntry(const glslang::TIntermAggregate
void TGlslangToSpvTraverser::translateArguments(const glslang::TIntermAggregate& node, std::vector<spv::Id>& arguments)
{
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) {
builder.clearAccessChain();
glslangArguments[i]->traverse(this);
@ -1929,6 +1937,51 @@ void TGlslangToSpvTraverser::translateArguments(const glslang::TIntermAggregate&
if (i == 0)
lvalue = true;
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:
break;
}
@ -1990,6 +2043,8 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO
return builder.createTextureQueryCall(spv::OpImageQueryLod, params);
case glslang::EOpTextureQueryLevels:
return builder.createTextureQueryCall(spv::OpImageQueryLevels, params);
case glslang::EOpSparseTexelsResident:
return builder.createUnaryOp(spv::OpImageSparseTexelsResident, builder.makeBoolType(), arguments[0]);
default:
assert(0);
break;
@ -2017,7 +2072,11 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO
operands.push_back(*opIt);
builder.createNoResultOp(spv::OpImageWrite, operands);
return spv::NoResult;
} else {
} else if (node->isSparseImage()) {
spv::MissingFunctionality("sparse image functions");
return spv::NoResult;
}
else {
// Process image atomic operations
// GLSL "IMAGE_PARAMS" will involve in constructing an image texel pointer and this pointer,
@ -2037,7 +2096,7 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO
}
// Check for texture functions other than queries
bool sparse = node->isSparseTexture();
bool cubeCompare = sampler.dim == glslang::EsdCube && sampler.arrayed && sampler.shadow;
// check for bias argument
@ -2048,6 +2107,10 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO
++nonBiasArgCount;
if (cracked.grad)
nonBiasArgCount += 2;
if (cracked.lodClamp)
++nonBiasArgCount;
if (sparse)
++nonBiasArgCount;
if ((int)arguments.size() > nonBiasArgCount)
bias = true;
@ -2059,9 +2122,10 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO
int extraArgs = 0;
// sort out where Dref is coming from
if (sampler.shadow && sampler.dim == glslang::EsdCube && sampler.arrayed)
if (cubeCompare) {
params.Dref = arguments[2];
else if (sampler.shadow && cracked.gather) {
++extraArgs;
} else if (sampler.shadow && cracked.gather) {
params.Dref = arguments[2];
++extraArgs;
} else if (sampler.shadow) {
@ -2093,6 +2157,14 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO
params.offsets = arguments[2 + extraArgs];
++extraArgs;
}
if (cracked.lodClamp) {
params.lodClamp = arguments[2 + extraArgs];
++extraArgs;
}
if (sparse) {
params.texelOut = arguments[2 + extraArgs];
++extraArgs;
}
if (bias) {
params.bias = arguments[2 + extraArgs];
++extraArgs;
@ -2107,7 +2179,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)
@ -2981,7 +3053,7 @@ spv::Id TGlslangToSpvTraverser::createMiscOperation(glslang::TOperator op, spv::
spv::Op opCode = spv::OpNop;
int libCall = -1;
int consumedOperands = operands.size();
size_t consumedOperands = operands.size();
spv::Id typeId0 = 0;
if (consumedOperands > 0)
typeId0 = builder.getTypeId(operands[0]);

104
SPIRV/InReadableOrder.cpp Normal file
View File

@ -0,0 +1,104 @@
//
//Copyright (C) 2016 Google, Inc.
//
//All rights reserved.
//
//Redistribution and use in source and binary forms, with or without
//modification, are permitted provided that the following conditions
//are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
//
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
//POSSIBILITY OF SUCH DAMAGE.
//
// Author: Dejan Mircevski, Google
//
// The SPIR-V spec requires code blocks to appear in an order satisfying the
// dominator-tree direction (ie, dominator before the dominated). This is,
// actually, easy to achieve: any pre-order CFG traversal algorithm will do it.
// Because such algorithms visit a block only after traversing some path to it
// from the root, they necessarily visit the block's idom first.
//
// But not every graph-traversal algorithm outputs blocks in an order that
// appears logical to human readers. The problem is that unrelated branches may
// be interspersed with each other, and merge blocks may come before some of the
// branches being merged.
//
// A good, human-readable order of blocks may be achieved by performing
// depth-first search but delaying merge nodes until after all their branches
// have been visited. This is implemented below by the inReadableOrder()
// function.
#include "spvIR.h"
#include <cassert>
#include <unordered_map>
using spv::Block;
using spv::Id;
namespace {
// Traverses CFG in a readable order, invoking a pre-set callback on each block.
// Use by calling visit() on the root block.
class ReadableOrderTraverser {
public:
explicit ReadableOrderTraverser(std::function<void(Block*)> callback) : callback_(callback) {}
// Visits the block if it hasn't been visited already and isn't currently
// being delayed. Invokes callback(block), then descends into its successors.
// Delays merge-block processing until all the branches have been completed.
void visit(Block* block)
{
assert(block);
if (visited_[block] || delayed_[block])
return;
callback_(block);
visited_[block] = true;
Block* mergeBlock = nullptr;
auto mergeInst = block->getMergeInstruction();
if (mergeInst) {
Id mergeId = mergeInst->getIdOperand(0);
mergeBlock = block->getParent().getParent().getInstruction(mergeId)->getBlock();
delayed_[mergeBlock] = true;
}
for (const auto succ : block->getSuccessors())
visit(succ);
if (mergeBlock) {
delayed_[mergeBlock] = false;
visit(mergeBlock);
}
}
private:
std::function<void(Block*)> callback_;
// Whether a block has already been visited or is being delayed.
std::unordered_map<Block *, bool> visited_, delayed_;
};
}
void spv::inReadableOrder(Block* root, std::function<void(Block*)> callback)
{
ReadableOrderTraverser(callback).visit(root);
}

View File

@ -77,7 +77,7 @@ Id Builder::import(const char* name)
Instruction* import = new Instruction(getUniqueId(), NoType, OpExtInstImport);
import->addStringOperand(name);
imports.push_back(import);
imports.push_back(std::unique_ptr<Instruction>(import));
return import->getResultId();
}
@ -88,7 +88,7 @@ Id Builder::makeVoidType()
if (groupedTypes[OpTypeVoid].size() == 0) {
type = new Instruction(getUniqueId(), NoType, OpTypeVoid);
groupedTypes[OpTypeVoid].push_back(type);
constantsTypesGlobals.push_back(type);
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
module.mapInstruction(type);
} else
type = groupedTypes[OpTypeVoid].back();
@ -102,7 +102,7 @@ Id Builder::makeBoolType()
if (groupedTypes[OpTypeBool].size() == 0) {
type = new Instruction(getUniqueId(), NoType, OpTypeBool);
groupedTypes[OpTypeBool].push_back(type);
constantsTypesGlobals.push_back(type);
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
module.mapInstruction(type);
} else
type = groupedTypes[OpTypeBool].back();
@ -116,7 +116,7 @@ Id Builder::makeSamplerType()
if (groupedTypes[OpTypeSampler].size() == 0) {
type = new Instruction(getUniqueId(), NoType, OpTypeSampler);
groupedTypes[OpTypeSampler].push_back(type);
constantsTypesGlobals.push_back(type);
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
module.mapInstruction(type);
} else
type = groupedTypes[OpTypeSampler].back();
@ -140,7 +140,7 @@ Id Builder::makePointer(StorageClass storageClass, Id pointee)
type->addImmediateOperand(storageClass);
type->addIdOperand(pointee);
groupedTypes[OpTypePointer].push_back(type);
constantsTypesGlobals.push_back(type);
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
module.mapInstruction(type);
return type->getResultId();
@ -162,7 +162,7 @@ Id Builder::makeIntegerType(int width, bool hasSign)
type->addImmediateOperand(width);
type->addImmediateOperand(hasSign ? 1 : 0);
groupedTypes[OpTypeInt].push_back(type);
constantsTypesGlobals.push_back(type);
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
module.mapInstruction(type);
return type->getResultId();
@ -182,7 +182,7 @@ Id Builder::makeFloatType(int width)
type = new Instruction(getUniqueId(), NoType, OpTypeFloat);
type->addImmediateOperand(width);
groupedTypes[OpTypeFloat].push_back(type);
constantsTypesGlobals.push_back(type);
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
module.mapInstruction(type);
return type->getResultId();
@ -202,7 +202,7 @@ Id Builder::makeStructType(std::vector<Id>& members, const char* name)
for (int op = 0; op < (int)members.size(); ++op)
type->addIdOperand(members[op]);
groupedTypes[OpTypeStruct].push_back(type);
constantsTypesGlobals.push_back(type);
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
module.mapInstruction(type);
addName(type->getResultId(), name);
@ -249,7 +249,7 @@ Id Builder::makeVectorType(Id component, int size)
type->addIdOperand(component);
type->addImmediateOperand(size);
groupedTypes[OpTypeVector].push_back(type);
constantsTypesGlobals.push_back(type);
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
module.mapInstruction(type);
return type->getResultId();
@ -275,7 +275,7 @@ Id Builder::makeMatrixType(Id component, int cols, int rows)
type->addIdOperand(column);
type->addImmediateOperand(cols);
groupedTypes[OpTypeMatrix].push_back(type);
constantsTypesGlobals.push_back(type);
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
module.mapInstruction(type);
return type->getResultId();
@ -305,7 +305,7 @@ Id Builder::makeArrayType(Id element, unsigned size, int stride)
type->addIdOperand(element);
type->addIdOperand(sizeId);
groupedTypes[OpTypeArray].push_back(type);
constantsTypesGlobals.push_back(type);
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
module.mapInstruction(type);
return type->getResultId();
@ -315,7 +315,7 @@ Id Builder::makeRuntimeArray(Id element)
{
Instruction* type = new Instruction(getUniqueId(), NoType, OpTypeRuntimeArray);
type->addIdOperand(element);
constantsTypesGlobals.push_back(type);
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
module.mapInstruction(type);
return type->getResultId();
@ -346,7 +346,7 @@ Id Builder::makeFunctionType(Id returnType, std::vector<Id>& paramTypes)
for (int p = 0; p < (int)paramTypes.size(); ++p)
type->addIdOperand(paramTypes[p]);
groupedTypes[OpTypeFunction].push_back(type);
constantsTypesGlobals.push_back(type);
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
module.mapInstruction(type);
return type->getResultId();
@ -379,7 +379,7 @@ Id Builder::makeImageType(Id sampledType, Dim dim, bool depth, bool arrayed, boo
type->addImmediateOperand((unsigned int)format);
groupedTypes[OpTypeImage].push_back(type);
constantsTypesGlobals.push_back(type);
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
module.mapInstruction(type);
return type->getResultId();
@ -400,7 +400,7 @@ Id Builder::makeSampledImageType(Id imageType)
type->addIdOperand(imageType);
groupedTypes[OpTypeSampledImage].push_back(type);
constantsTypesGlobals.push_back(type);
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
module.mapInstruction(type);
return type->getResultId();
@ -594,7 +594,7 @@ Id Builder::makeBoolConstant(bool b, bool specConstant)
// Make it
Instruction* c = new Instruction(getUniqueId(), typeId, opcode);
constantsTypesGlobals.push_back(c);
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(c));
groupedConstants[OpTypeBool].push_back(c);
module.mapInstruction(c);
@ -610,7 +610,7 @@ Id Builder::makeIntConstant(Id typeId, unsigned value, bool specConstant)
Instruction* c = new Instruction(getUniqueId(), typeId, opcode);
c->addImmediateOperand(value);
constantsTypesGlobals.push_back(c);
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(c));
groupedConstants[OpTypeInt].push_back(c);
module.mapInstruction(c);
@ -628,7 +628,7 @@ Id Builder::makeFloatConstant(float f, bool specConstant)
Instruction* c = new Instruction(getUniqueId(), typeId, opcode);
c->addImmediateOperand(value);
constantsTypesGlobals.push_back(c);
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(c));
groupedConstants[OpTypeFloat].push_back(c);
module.mapInstruction(c);
@ -649,7 +649,7 @@ Id Builder::makeDoubleConstant(double d, bool specConstant)
Instruction* c = new Instruction(getUniqueId(), typeId, opcode);
c->addImmediateOperand(op1);
c->addImmediateOperand(op2);
constantsTypesGlobals.push_back(c);
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(c));
groupedConstants[OpTypeFloat].push_back(c);
module.mapInstruction(c);
@ -708,7 +708,7 @@ Id Builder::makeCompositeConstant(Id typeId, std::vector<Id>& members)
Instruction* c = new Instruction(getUniqueId(), typeId, OpConstantComposite);
for (int op = 0; op < (int)members.size(); ++op)
c->addIdOperand(members[op]);
constantsTypesGlobals.push_back(c);
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(c));
groupedConstants[typeClass].push_back(c);
module.mapInstruction(c);
@ -722,7 +722,7 @@ Instruction* Builder::addEntryPoint(ExecutionModel model, Function* function, co
entryPoint->addIdOperand(function->getId());
entryPoint->addStringOperand(name);
entryPoints.push_back(entryPoint);
entryPoints.push_back(std::unique_ptr<Instruction>(entryPoint));
return entryPoint;
}
@ -740,7 +740,7 @@ void Builder::addExecutionMode(Function* entryPoint, ExecutionMode mode, int val
if (value3 >= 0)
instr->addImmediateOperand(value3);
executionModes.push_back(instr);
executionModes.push_back(std::unique_ptr<Instruction>(instr));
}
void Builder::addName(Id id, const char* string)
@ -749,7 +749,7 @@ void Builder::addName(Id id, const char* string)
name->addIdOperand(id);
name->addStringOperand(string);
names.push_back(name);
names.push_back(std::unique_ptr<Instruction>(name));
}
void Builder::addMemberName(Id id, int memberNumber, const char* string)
@ -759,7 +759,7 @@ void Builder::addMemberName(Id id, int memberNumber, const char* string)
name->addImmediateOperand(memberNumber);
name->addStringOperand(string);
names.push_back(name);
names.push_back(std::unique_ptr<Instruction>(name));
}
void Builder::addLine(Id target, Id fileName, int lineNum, int column)
@ -770,7 +770,7 @@ void Builder::addLine(Id target, Id fileName, int lineNum, int column)
line->addImmediateOperand(lineNum);
line->addImmediateOperand(column);
lines.push_back(line);
lines.push_back(std::unique_ptr<Instruction>(line));
}
void Builder::addDecoration(Id id, Decoration decoration, int num)
@ -783,7 +783,7 @@ void Builder::addDecoration(Id id, Decoration decoration, int num)
if (num >= 0)
dec->addImmediateOperand(num);
decorations.push_back(dec);
decorations.push_back(std::unique_ptr<Instruction>(dec));
}
void Builder::addMemberDecoration(Id id, unsigned int member, Decoration decoration, int num)
@ -795,7 +795,7 @@ void Builder::addMemberDecoration(Id id, unsigned int member, Decoration decorat
if (num >= 0)
dec->addImmediateOperand(num);
decorations.push_back(dec);
decorations.push_back(std::unique_ptr<Instruction>(dec));
}
// Comments in header
@ -827,6 +827,8 @@ Function* Builder::makeFunctionEntry(Id returnType, const char* name, std::vecto
if (name)
addName(function->getId(), name);
functions.push_back(std::unique_ptr<Function>(function));
return function;
}
@ -836,9 +838,9 @@ void Builder::makeReturn(bool implicit, Id retVal)
if (retVal) {
Instruction* inst = new Instruction(NoResult, NoType, OpReturnValue);
inst->addIdOperand(retVal);
buildPoint->addInstruction(inst);
buildPoint->addInstruction(std::unique_ptr<Instruction>(inst));
} else
buildPoint->addInstruction(new Instruction(NoResult, NoType, OpReturn));
buildPoint->addInstruction(std::unique_ptr<Instruction>(new Instruction(NoResult, NoType, OpReturn)));
if (! implicit)
createAndSetNoPredecessorBlock("post-return");
@ -855,7 +857,7 @@ void Builder::leaveFunction()
if (! block->isTerminated()) {
// Whether we're in an unreachable (non-entry) block.
bool unreachable = function.getEntryBlock() != block && block->getNumPredecessors() == 0;
bool unreachable = function.getEntryBlock() != block && block->getPredecessors().empty();
if (unreachable) {
// Given that this block is at the end of a function, it must be right after an
@ -878,7 +880,7 @@ void Builder::leaveFunction()
// Comments in header
void Builder::makeDiscard()
{
buildPoint->addInstruction(new Instruction(OpKill));
buildPoint->addInstruction(std::unique_ptr<Instruction>(new Instruction(OpKill)));
createAndSetNoPredecessorBlock("post-discard");
}
@ -892,11 +894,11 @@ Id Builder::createVariable(StorageClass storageClass, Id type, const char* name)
switch (storageClass) {
case StorageClassFunction:
// Validation rules require the declaration in the entry block
buildPoint->getParent().addLocalVariable(inst);
buildPoint->getParent().addLocalVariable(std::unique_ptr<Instruction>(inst));
break;
default:
constantsTypesGlobals.push_back(inst);
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(inst));
module.mapInstruction(inst);
break;
}
@ -911,7 +913,7 @@ Id Builder::createVariable(StorageClass storageClass, Id type, const char* name)
Id Builder::createUndefined(Id type)
{
Instruction* inst = new Instruction(getUniqueId(), type, OpUndef);
buildPoint->addInstruction(inst);
buildPoint->addInstruction(std::unique_ptr<Instruction>(inst));
return inst->getResultId();
}
@ -921,7 +923,7 @@ void Builder::createStore(Id rValue, Id lValue)
Instruction* store = new Instruction(OpStore);
store->addIdOperand(lValue);
store->addIdOperand(rValue);
buildPoint->addInstruction(store);
buildPoint->addInstruction(std::unique_ptr<Instruction>(store));
}
// Comments in header
@ -929,7 +931,7 @@ Id Builder::createLoad(Id lValue)
{
Instruction* load = new Instruction(getUniqueId(), getDerefTypeId(lValue), OpLoad);
load->addIdOperand(lValue);
buildPoint->addInstruction(load);
buildPoint->addInstruction(std::unique_ptr<Instruction>(load));
return load->getResultId();
}
@ -955,7 +957,7 @@ Id Builder::createAccessChain(StorageClass storageClass, Id base, std::vector<Id
chain->addIdOperand(base);
for (int i = 0; i < (int)offsets.size(); ++i)
chain->addIdOperand(offsets[i]);
buildPoint->addInstruction(chain);
buildPoint->addInstruction(std::unique_ptr<Instruction>(chain));
return chain->getResultId();
}
@ -965,7 +967,7 @@ Id Builder::createArrayLength(Id base, unsigned int member)
Instruction* length = new Instruction(getUniqueId(), makeIntType(32), OpArrayLength);
length->addIdOperand(base);
length->addImmediateOperand(member);
buildPoint->addInstruction(length);
buildPoint->addInstruction(std::unique_ptr<Instruction>(length));
return length->getResultId();
}
@ -975,7 +977,7 @@ Id Builder::createCompositeExtract(Id composite, Id typeId, unsigned index)
Instruction* extract = new Instruction(getUniqueId(), typeId, OpCompositeExtract);
extract->addIdOperand(composite);
extract->addImmediateOperand(index);
buildPoint->addInstruction(extract);
buildPoint->addInstruction(std::unique_ptr<Instruction>(extract));
return extract->getResultId();
}
@ -986,7 +988,7 @@ Id Builder::createCompositeExtract(Id composite, Id typeId, std::vector<unsigned
extract->addIdOperand(composite);
for (int i = 0; i < (int)indexes.size(); ++i)
extract->addImmediateOperand(indexes[i]);
buildPoint->addInstruction(extract);
buildPoint->addInstruction(std::unique_ptr<Instruction>(extract));
return extract->getResultId();
}
@ -997,7 +999,7 @@ Id Builder::createCompositeInsert(Id object, Id composite, Id typeId, unsigned i
insert->addIdOperand(object);
insert->addIdOperand(composite);
insert->addImmediateOperand(index);
buildPoint->addInstruction(insert);
buildPoint->addInstruction(std::unique_ptr<Instruction>(insert));
return insert->getResultId();
}
@ -1009,7 +1011,7 @@ Id Builder::createCompositeInsert(Id object, Id composite, Id typeId, std::vecto
insert->addIdOperand(composite);
for (int i = 0; i < (int)indexes.size(); ++i)
insert->addImmediateOperand(indexes[i]);
buildPoint->addInstruction(insert);
buildPoint->addInstruction(std::unique_ptr<Instruction>(insert));
return insert->getResultId();
}
@ -1019,7 +1021,7 @@ Id Builder::createVectorExtractDynamic(Id vector, Id typeId, Id componentIndex)
Instruction* extract = new Instruction(getUniqueId(), typeId, OpVectorExtractDynamic);
extract->addIdOperand(vector);
extract->addIdOperand(componentIndex);
buildPoint->addInstruction(extract);
buildPoint->addInstruction(std::unique_ptr<Instruction>(extract));
return extract->getResultId();
}
@ -1030,7 +1032,7 @@ Id Builder::createVectorInsertDynamic(Id vector, Id typeId, Id component, Id com
insert->addIdOperand(vector);
insert->addIdOperand(component);
insert->addIdOperand(componentIndex);
buildPoint->addInstruction(insert);
buildPoint->addInstruction(std::unique_ptr<Instruction>(insert));
return insert->getResultId();
}
@ -1039,7 +1041,7 @@ Id Builder::createVectorInsertDynamic(Id vector, Id typeId, Id component, Id com
void Builder::createNoResultOp(Op opCode)
{
Instruction* op = new Instruction(opCode);
buildPoint->addInstruction(op);
buildPoint->addInstruction(std::unique_ptr<Instruction>(op));
}
// An opcode that has one operand, no result id, and no type
@ -1047,7 +1049,7 @@ void Builder::createNoResultOp(Op opCode, Id operand)
{
Instruction* op = new Instruction(opCode);
op->addIdOperand(operand);
buildPoint->addInstruction(op);
buildPoint->addInstruction(std::unique_ptr<Instruction>(op));
}
// An opcode that has one operand, no result id, and no type
@ -1056,7 +1058,7 @@ void Builder::createNoResultOp(Op opCode, const std::vector<Id>& operands)
Instruction* op = new Instruction(opCode);
for (auto operand : operands)
op->addIdOperand(operand);
buildPoint->addInstruction(op);
buildPoint->addInstruction(std::unique_ptr<Instruction>(op));
}
void Builder::createControlBarrier(Scope execution, Scope memory, MemorySemanticsMask semantics)
@ -1065,7 +1067,7 @@ void Builder::createControlBarrier(Scope execution, Scope memory, MemorySemantic
op->addImmediateOperand(makeUintConstant(execution));
op->addImmediateOperand(makeUintConstant(memory));
op->addImmediateOperand(makeUintConstant(semantics));
buildPoint->addInstruction(op);
buildPoint->addInstruction(std::unique_ptr<Instruction>(op));
}
void Builder::createMemoryBarrier(unsigned executionScope, unsigned memorySemantics)
@ -1073,7 +1075,7 @@ void Builder::createMemoryBarrier(unsigned executionScope, unsigned memorySemant
Instruction* op = new Instruction(OpMemoryBarrier);
op->addImmediateOperand(makeUintConstant(executionScope));
op->addImmediateOperand(makeUintConstant(memorySemantics));
buildPoint->addInstruction(op);
buildPoint->addInstruction(std::unique_ptr<Instruction>(op));
}
// An opcode that has one operands, a result id, and a type
@ -1081,7 +1083,7 @@ Id Builder::createUnaryOp(Op opCode, Id typeId, Id operand)
{
Instruction* op = new Instruction(getUniqueId(), typeId, opCode);
op->addIdOperand(operand);
buildPoint->addInstruction(op);
buildPoint->addInstruction(std::unique_ptr<Instruction>(op));
return op->getResultId();
}
@ -1091,7 +1093,7 @@ Id Builder::createBinOp(Op opCode, Id typeId, Id left, Id right)
Instruction* op = new Instruction(getUniqueId(), typeId, opCode);
op->addIdOperand(left);
op->addIdOperand(right);
buildPoint->addInstruction(op);
buildPoint->addInstruction(std::unique_ptr<Instruction>(op));
return op->getResultId();
}
@ -1102,7 +1104,7 @@ Id Builder::createTriOp(Op opCode, Id typeId, Id op1, Id op2, Id op3)
op->addIdOperand(op1);
op->addIdOperand(op2);
op->addIdOperand(op3);
buildPoint->addInstruction(op);
buildPoint->addInstruction(std::unique_ptr<Instruction>(op));
return op->getResultId();
}
@ -1112,7 +1114,7 @@ Id Builder::createOp(Op opCode, Id typeId, const std::vector<Id>& operands)
Instruction* op = new Instruction(getUniqueId(), typeId, opCode);
for (auto operand : operands)
op->addIdOperand(operand);
buildPoint->addInstruction(op);
buildPoint->addInstruction(std::unique_ptr<Instruction>(op));
return op->getResultId();
}
@ -1123,7 +1125,7 @@ Id Builder::createFunctionCall(spv::Function* function, std::vector<spv::Id>& ar
op->addIdOperand(function->getId());
for (int a = 0; a < (int)args.size(); ++a)
op->addIdOperand(args[a]);
buildPoint->addInstruction(op);
buildPoint->addInstruction(std::unique_ptr<Instruction>(op));
return op->getResultId();
}
@ -1140,7 +1142,7 @@ Id Builder::createRvalueSwizzle(Id typeId, Id source, std::vector<unsigned>& cha
swizzle->addIdOperand(source);
for (int i = 0; i < (int)channels.size(); ++i)
swizzle->addImmediateOperand(channels[i]);
buildPoint->addInstruction(swizzle);
buildPoint->addInstruction(std::unique_ptr<Instruction>(swizzle));
return swizzle->getResultId();
}
@ -1171,7 +1173,7 @@ Id Builder::createLvalueSwizzle(Id typeId, Id target, Id source, std::vector<uns
// finish the instruction with these components selectors
for (int i = 0; i < numTargetComponents; ++i)
swizzle->addImmediateOperand(components[i]);
buildPoint->addInstruction(swizzle);
buildPoint->addInstruction(std::unique_ptr<Instruction>(swizzle));
return swizzle->getResultId();
}
@ -1202,7 +1204,7 @@ Id Builder::smearScalar(Decoration /*precision*/, Id scalar, Id vectorType)
Instruction* smear = new Instruction(getUniqueId(), vectorType, OpCompositeConstruct);
for (int c = 0; c < numComponents; ++c)
smear->addIdOperand(scalar);
buildPoint->addInstruction(smear);
buildPoint->addInstruction(std::unique_ptr<Instruction>(smear));
return smear->getResultId();
}
@ -1216,13 +1218,13 @@ Id Builder::createBuiltinCall(Decoration /*precision*/, Id resultType, Id builti
for (int arg = 0; arg < (int)args.size(); ++arg)
inst->addIdOperand(args[arg]);
buildPoint->addInstruction(inst);
buildPoint->addInstruction(std::unique_ptr<Instruction>(inst));
return inst->getResultId();
}
// Accept all parameters needed to create a texture instruction.
// 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;
Id texArgs[maxTextureArgs] = {};
@ -1275,6 +1277,10 @@ Id Builder::createTextureCall(Decoration precision, Id resultType, bool fetch, b
mask = (ImageOperandsMask)(mask | ImageOperandsSampleMask);
texArgs[numArgs++] = parameters.sample;
}
if (parameters.lodClamp) {
mask = (ImageOperandsMask)(mask | ImageOperandsMinLodMask);
texArgs[numArgs++] = parameters.lodClamp;
}
if (mask == ImageOperandsMaskNone)
--numArgs; // undo speculative reservation for the mask argument
else
@ -1286,35 +1292,68 @@ Id Builder::createTextureCall(Decoration precision, Id resultType, bool fetch, b
Op opCode;
opCode = OpImageSampleImplicitLod;
if (fetch) {
opCode = OpImageFetch;
if (sparse)
opCode = OpImageSparseFetch;
else
opCode = OpImageFetch;
} else if (gather) {
if (parameters.Dref)
opCode = OpImageDrefGather;
if (sparse)
opCode = OpImageSparseDrefGather;
else
opCode = OpImageDrefGather;
else
opCode = OpImageGather;
if (sparse)
opCode = OpImageSparseGather;
else
opCode = OpImageGather;
} else if (xplicit) {
if (parameters.Dref) {
if (proj)
opCode = OpImageSampleProjDrefExplicitLod;
if (sparse)
opCode = OpImageSparseSampleProjDrefExplicitLod;
else
opCode = OpImageSampleProjDrefExplicitLod;
else
opCode = OpImageSampleDrefExplicitLod;
if (sparse)
opCode = OpImageSparseSampleDrefExplicitLod;
else
opCode = OpImageSampleDrefExplicitLod;
} else {
if (proj)
opCode = OpImageSampleProjExplicitLod;
if (sparse)
opCode = OpImageSparseSampleProjExplicitLod;
else
opCode = OpImageSampleProjExplicitLod;
else
opCode = OpImageSampleExplicitLod;
if (sparse)
opCode = OpImageSparseSampleExplicitLod;
else
opCode = OpImageSampleExplicitLod;
}
} else {
if (parameters.Dref) {
if (proj)
opCode = OpImageSampleProjDrefImplicitLod;
if (sparse)
opCode = OpImageSparseSampleProjDrefImplicitLod;
else
opCode = OpImageSampleProjDrefImplicitLod;
else
opCode = OpImageSampleDrefImplicitLod;
if (sparse)
opCode = OpImageSparseSampleDrefImplicitLod;
else
opCode = OpImageSampleDrefImplicitLod;
} else {
if (proj)
opCode = OpImageSampleProjImplicitLod;
if (sparse)
opCode = OpImageSparseSampleProjImplicitLod;
else
opCode = OpImageSampleProjImplicitLod;
else
opCode = OpImageSampleImplicitLod;
if (sparse)
opCode = OpImageSparseSampleImplicitLod;
else
opCode = OpImageSampleImplicitLod;
}
}
@ -1335,6 +1374,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
Instruction* textureInst = new Instruction(getUniqueId(), resultType, opCode);
for (int op = 0; op < optArgNum; ++op)
@ -1344,14 +1392,20 @@ Id Builder::createTextureCall(Decoration precision, Id resultType, bool fetch, b
for (int op = optArgNum + 1; op < numArgs; ++op)
textureInst->addIdOperand(texArgs[op]);
setPrecision(textureInst->getResultId(), precision);
buildPoint->addInstruction(textureInst);
buildPoint->addInstruction(std::unique_ptr<Instruction>(textureInst));
Id resultId = textureInst->getResultId();
// 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);
if (sparse) {
// Decode the return type that was a special structure
createStore(createCompositeExtract(resultId, typeId1, 1), parameters.texelOut);
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;
}
@ -1365,7 +1419,7 @@ Id Builder::createTextureQueryCall(Op opCode, const TextureParameters& parameter
case OpImageQuerySize:
case OpImageQuerySizeLod:
{
int numComponents;
int numComponents = 0;
switch (getTypeDimensionality(getImageType(parameters.sampler))) {
case Dim1D:
case DimBuffer:
@ -1412,7 +1466,7 @@ Id Builder::createTextureQueryCall(Op opCode, const TextureParameters& parameter
query->addIdOperand(parameters.coords);
if (parameters.lod)
query->addIdOperand(parameters.lod);
buildPoint->addInstruction(query);
buildPoint->addInstruction(std::unique_ptr<Instruction>(query));
return query->getResultId();
}
@ -1494,7 +1548,7 @@ Id Builder::createCompositeConstruct(Id typeId, std::vector<Id>& constituents)
Instruction* op = new Instruction(getUniqueId(), typeId, OpCompositeConstruct);
for (int c = 0; c < (int)constituents.size(); ++c)
op->addIdOperand(constituents[c]);
buildPoint->addInstruction(op);
buildPoint->addInstruction(std::unique_ptr<Instruction>(op));
return op->getResultId();
}
@ -1705,12 +1759,15 @@ void Builder::makeSwitch(Id selector, int numSegments, std::vector<int>& caseVal
// make the switch instruction
Instruction* switchInst = new Instruction(NoResult, NoType, OpSwitch);
switchInst->addIdOperand(selector);
switchInst->addIdOperand(defaultSegment >= 0 ? segmentBlocks[defaultSegment]->getId() : mergeBlock->getId());
auto defaultOrMerge = (defaultSegment >= 0) ? segmentBlocks[defaultSegment] : mergeBlock;
switchInst->addIdOperand(defaultOrMerge->getId());
defaultOrMerge->addPredecessor(buildPoint);
for (int i = 0; i < (int)caseValues.size(); ++i) {
switchInst->addImmediateOperand(caseValues[i]);
switchInst->addIdOperand(segmentBlocks[valueIndexToSegment[i]]->getId());
segmentBlocks[valueIndexToSegment[i]]->addPredecessor(buildPoint);
}
buildPoint->addInstruction(switchInst);
buildPoint->addInstruction(std::unique_ptr<Instruction>(switchInst));
// push the merge block
switchMerges.push(mergeBlock);
@ -2092,7 +2149,7 @@ void Builder::createBranch(Block* block)
{
Instruction* branch = new Instruction(OpBranch);
branch->addIdOperand(block->getId());
buildPoint->addInstruction(branch);
buildPoint->addInstruction(std::unique_ptr<Instruction>(branch));
block->addPredecessor(buildPoint);
}
@ -2101,7 +2158,7 @@ void Builder::createSelectionMerge(Block* mergeBlock, unsigned int control)
Instruction* merge = new Instruction(OpSelectionMerge);
merge->addIdOperand(mergeBlock->getId());
merge->addImmediateOperand(control);
buildPoint->addInstruction(merge);
buildPoint->addInstruction(std::unique_ptr<Instruction>(merge));
}
void Builder::createLoopMerge(Block* mergeBlock, Block* continueBlock, unsigned int control)
@ -2110,7 +2167,7 @@ void Builder::createLoopMerge(Block* mergeBlock, Block* continueBlock, unsigned
merge->addIdOperand(mergeBlock->getId());
merge->addIdOperand(continueBlock->getId());
merge->addImmediateOperand(control);
buildPoint->addInstruction(merge);
buildPoint->addInstruction(std::unique_ptr<Instruction>(merge));
}
void Builder::createConditionalBranch(Id condition, Block* thenBlock, Block* elseBlock)
@ -2119,12 +2176,12 @@ void Builder::createConditionalBranch(Id condition, Block* thenBlock, Block* els
branch->addIdOperand(condition);
branch->addIdOperand(thenBlock->getId());
branch->addIdOperand(elseBlock->getId());
buildPoint->addInstruction(branch);
buildPoint->addInstruction(std::unique_ptr<Instruction>(branch));
thenBlock->addPredecessor(buildPoint);
elseBlock->addPredecessor(buildPoint);
}
void Builder::dumpInstructions(std::vector<unsigned int>& out, const std::vector<Instruction*>& instructions) const
void Builder::dumpInstructions(std::vector<unsigned int>& out, const std::vector<std::unique_ptr<Instruction> >& instructions) const
{
for (int i = 0; i < (int)instructions.size(); ++i) {
instructions[i]->dump(out);

View File

@ -52,6 +52,7 @@
#include "spvIR.h"
#include <algorithm>
#include <memory>
#include <stack>
#include <map>
@ -201,11 +202,13 @@ public:
void setBuildPoint(Block* bp) { buildPoint = bp; }
Block* getBuildPoint() const { return buildPoint; }
// Make the main function.
// Make the main function. The returned pointer is only valid
// for the lifetime of this builder.
Function* makeMain();
// Make a shader-style function, and create its entry block if entry is non-zero.
// Return the function, pass back the entry.
// The returned pointer is only valid for the lifetime of this builder.
Function* makeFunctionEntry(Id returnType, const char* name, std::vector<Id>& paramTypes, Block **entry = 0);
// Create a return. An 'implicit' return is one not appearing in the source
@ -310,10 +313,12 @@ public:
Id gradY;
Id sample;
Id comp;
Id texelOut;
Id lodClamp;
};
// 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.
// Figure out the right return value and type, and return it.
@ -513,7 +518,7 @@ public:
void simplifyAccessChainSwizzle();
void createAndSetNoPredecessorBlock(const char*);
void createSelectionMerge(Block* mergeBlock, unsigned int control);
void dumpInstructions(std::vector<unsigned int>&, const std::vector<Instruction*>&) const;
void dumpInstructions(std::vector<unsigned int>&, const std::vector<std::unique_ptr<Instruction> >&) const;
SourceLanguage source;
int sourceVersion;
@ -529,14 +534,15 @@ public:
AccessChain accessChain;
// special blocks of instructions for output
std::vector<Instruction*> imports;
std::vector<Instruction*> entryPoints;
std::vector<Instruction*> executionModes;
std::vector<Instruction*> names;
std::vector<Instruction*> lines;
std::vector<Instruction*> decorations;
std::vector<Instruction*> constantsTypesGlobals;
std::vector<Instruction*> externals;
std::vector<std::unique_ptr<Instruction> > imports;
std::vector<std::unique_ptr<Instruction> > entryPoints;
std::vector<std::unique_ptr<Instruction> > executionModes;
std::vector<std::unique_ptr<Instruction> > names;
std::vector<std::unique_ptr<Instruction> > lines;
std::vector<std::unique_ptr<Instruction> > decorations;
std::vector<std::unique_ptr<Instruction> > constantsTypesGlobals;
std::vector<std::unique_ptr<Instruction> > externals;
std::vector<std::unique_ptr<Function> > functions;
// not output, internally used for quick & dirty canonical (unique) creation
std::vector<Instruction*> groupedConstants[OpConstant]; // all types appear before OpConstant

File diff suppressed because it is too large Load Diff

View File

@ -53,12 +53,15 @@
#include "spirv.hpp"
#include <algorithm>
#include <vector>
#include <cassert>
#include <functional>
#include <iostream>
#include <assert.h>
#include <memory>
#include <vector>
namespace spv {
class Block;
class Function;
class Module;
@ -75,8 +78,8 @@ const MemorySemanticsMask MemorySemanticsAllMemory = (MemorySemanticsMask)0x3FF;
class Instruction {
public:
Instruction(Id resultId, Id typeId, Op opCode) : resultId(resultId), typeId(typeId), opCode(opCode) { }
explicit Instruction(Op opCode) : resultId(NoResult), typeId(NoType), opCode(opCode) { }
Instruction(Id resultId, Id typeId, Op opCode) : resultId(resultId), typeId(typeId), opCode(opCode), block(nullptr) { }
explicit Instruction(Op opCode) : resultId(NoResult), typeId(NoType), opCode(opCode), block(nullptr) { }
virtual ~Instruction() {}
void addIdOperand(Id id) { operands.push_back(id); }
void addImmediateOperand(unsigned int immediate) { operands.push_back(immediate); }
@ -107,6 +110,8 @@ public:
addImmediateOperand(word);
}
}
void setBlock(Block* b) { block = b; }
Block* getBlock() const { return block; }
Op getOpCode() const { return opCode; }
int getNumOperands() const { return (int)operands.size(); }
Id getResultId() const { return resultId; }
@ -145,6 +150,7 @@ protected:
Op opCode;
std::vector<Id> operands;
std::string originalString; // could be optimized away; convenience for getting string operand
Block* block;
};
//
@ -156,18 +162,31 @@ public:
Block(Id id, Function& parent);
virtual ~Block()
{
// TODO: free instructions
}
Id getId() { return instructions.front()->getResultId(); }
Function& getParent() const { return parent; }
void addInstruction(Instruction* inst);
void addPredecessor(Block* pred) { predecessors.push_back(pred); }
void addLocalVariable(Instruction* inst) { localVariables.push_back(inst); }
int getNumPredecessors() const { return (int)predecessors.size(); }
void addInstruction(std::unique_ptr<Instruction> inst);
void addPredecessor(Block* pred) { predecessors.push_back(pred); pred->successors.push_back(this);}
void addLocalVariable(std::unique_ptr<Instruction> inst) { localVariables.push_back(std::move(inst)); }
const std::vector<Block*>& getPredecessors() const { return predecessors; }
const std::vector<Block*>& getSuccessors() const { return successors; }
void setUnreachable() { unreachable = true; }
bool isUnreachable() const { return unreachable; }
// Returns the block's merge instruction, if one exists (otherwise null).
const Instruction* getMergeInstruction() const {
if (instructions.size() < 2) return nullptr;
const Instruction* nextToLast = (instructions.cend() - 2)->get();
switch (nextToLast->getOpCode()) {
case OpSelectionMerge:
case OpLoopMerge:
return nextToLast;
default:
return nullptr;
}
return nullptr;
}
bool isTerminated() const
{
@ -206,9 +225,9 @@ protected:
// To enforce keeping parent and ownership in sync:
friend Function;
std::vector<Instruction*> instructions;
std::vector<Block*> predecessors;
std::vector<Instruction*> localVariables;
std::vector<std::unique_ptr<Instruction> > instructions;
std::vector<Block*> predecessors, successors;
std::vector<std::unique_ptr<Instruction> > localVariables;
Function& parent;
// track whether this block is known to be uncreachable (not necessarily
@ -217,6 +236,11 @@ protected:
bool unreachable;
};
// Traverses the control-flow graph rooted at root in an order suited for
// readable code generation. Invokes callback at every node in the traversal
// order.
void inReadableOrder(Block* root, std::function<void(Block*)> callback);
//
// SPIR-V IR Function.
//
@ -247,7 +271,7 @@ public:
Module& getParent() const { return parent; }
Block* getEntryBlock() const { return blocks.front(); }
Block* getLastBlock() const { return blocks.back(); }
void addLocalVariable(Instruction* inst);
void addLocalVariable(std::unique_ptr<Instruction> inst);
Id getReturnType() const { return functionInstruction.getTypeId(); }
void dump(std::vector<unsigned int>& out) const
{
@ -259,8 +283,7 @@ public:
parameterInstructions[p]->dump(out);
// Blocks
for (int b = 0; b < (int)blocks.size(); ++b)
blocks[b]->dump(out);
inReadableOrder(blocks[0], [&out](const Block* b) { b->dump(out); });
Instruction end(0, 0, OpFunctionEnd);
end.dump(out);
}
@ -348,22 +371,27 @@ __inline Function::Function(Id id, Id resultType, Id functionType, Id firstParam
}
}
__inline void Function::addLocalVariable(Instruction* inst)
__inline void Function::addLocalVariable(std::unique_ptr<Instruction> inst)
{
blocks[0]->addLocalVariable(inst);
parent.mapInstruction(inst);
Instruction* raw_instruction = inst.get();
blocks[0]->addLocalVariable(std::move(inst));
parent.mapInstruction(raw_instruction);
}
__inline Block::Block(Id id, Function& parent) : parent(parent), unreachable(false)
{
instructions.push_back(new Instruction(id, NoType, OpLabel));
instructions.push_back(std::unique_ptr<Instruction>(new Instruction(id, NoType, OpLabel)));
instructions.back()->setBlock(this);
parent.getParent().mapInstruction(instructions.back().get());
}
__inline void Block::addInstruction(Instruction* inst)
__inline void Block::addInstruction(std::unique_ptr<Instruction> inst)
{
instructions.push_back(inst);
if (inst->getResultId())
parent.getParent().mapInstruction(inst);
Instruction* raw_instruction = inst.get();
instructions.push_back(std::move(inst));
raw_instruction->setBlock(this);
if (raw_instruction->getResultId())
parent.getParent().mapInstruction(raw_instruction);
}
}; // end spv namespace

View File

@ -435,6 +435,8 @@ void ProcessConfigFile()
}
if (configStrings)
FreeFileData(configStrings);
else
delete[] config;
}
// thread-safe list of shaders to asynchronously grab and compile
@ -658,17 +660,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
// in the same program and link them together.
// For linking mode: Will independently parse each compilation unit, but then put them
// 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.
//
void CompileAndLinkShaders()
void CompileAndLinkShaderUnits(std::vector<ShaderCompUnit> compUnits)
{
// keep track of what to free
std::list<glslang::TShader*> shaders;
EShMessages messages = EShMsgDefault;
SetMessageOptions(messages);
@ -677,22 +689,13 @@ void CompileAndLinkShaders()
//
glslang::TProgram& program = *new glslang::TProgram;
glslang::TWorkItem* workItem;
while (Worklist.remove(workItem)) {
EShLanguage stage = FindLanguage(workItem->name);
glslang::TShader* shader = new glslang::TShader(stage);
for (auto compUnit : compUnits) {
glslang::TShader* shader = new glslang::TShader(compUnit.stage);
shader->setStrings(compUnit.text, 1);
shaders.push_back(shader);
char** shaderStrings = ReadFileData(workItem->name.c_str());
if (! shaderStrings) {
usage();
delete &program;
return;
}
const int defaultVersion = Options & EOptionDefaultDesktop? 110: 100;
shader->setStrings(shaderStrings, 1);
if (Options & EOptionOutputPreprocessed) {
std::string str;
if (shader->preprocess(&Resources, defaultVersion, ENoProfile, false, false,
@ -703,7 +706,6 @@ void CompileAndLinkShaders()
}
StderrIfNonEmpty(shader->getInfoLog());
StderrIfNonEmpty(shader->getInfoDebugLog());
FreeFileData(shaderStrings);
continue;
}
if (! shader->parse(&Resources, defaultVersion, false, messages))
@ -711,13 +713,12 @@ void CompileAndLinkShaders()
program.addShader(shader);
if (! (Options & EOptionSuppressInfolog)) {
PutsIfNonEmpty(workItem->name.c_str());
if (! (Options & EOptionSuppressInfolog) &&
! (Options & EOptionMemoryLeakMode)) {
PutsIfNonEmpty(compUnit.fileName.c_str());
PutsIfNonEmpty(shader->getInfoLog());
PutsIfNonEmpty(shader->getInfoDebugLog());
}
FreeFileData(shaderStrings);
}
//
@ -727,7 +728,8 @@ void CompileAndLinkShaders()
if (! (Options & EOptionOutputPreprocessed) && ! program.link(messages))
LinkFailed = true;
if (! (Options & EOptionSuppressInfolog)) {
if (! (Options & EOptionSuppressInfolog) &&
! (Options & EOptionMemoryLeakMode)) {
PutsIfNonEmpty(program.getInfoLog());
PutsIfNonEmpty(program.getInfoDebugLog());
}
@ -745,10 +747,15 @@ void CompileAndLinkShaders()
if (program.getIntermediate((EShLanguage)stage)) {
std::vector<unsigned int> spirv;
glslang::GlslangToSpv(*program.getIntermediate((EShLanguage)stage), spirv);
glslang::OutputSpv(spirv, GetBinaryName((EShLanguage)stage));
if (Options & EOptionHumanReadableSpv) {
spv::Parameterize();
spv::Disassemble(std::cout, spirv);
// Dump the spv to a file or stdout, etc., but only if not doing
// memory/perf testing, as it's not internal to programmatic use.
if (! (Options & EOptionMemoryLeakMode)) {
glslang::OutputSpv(spirv, GetBinaryName((EShLanguage)stage));
if (Options & EOptionHumanReadableSpv) {
spv::Parameterize();
spv::Disassemble(std::cout, spirv);
}
}
}
}
@ -766,6 +773,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[])
{
ProcessArguments(argc, argv);
@ -803,8 +863,13 @@ int C_DECL main(int argc, char* argv[])
if (Options & EOptionLinkProgram ||
Options & EOptionOutputPreprocessed) {
glslang::InitializeProcess();
CompileAndLinkShaders();
CompileAndLinkShaderFiles();
glslang::FinalizeProcess();
for (int w = 0; w < NumWorkItems; ++w) {
if (Work[w]) {
delete Work[w];
}
}
} else {
ShInitialize();
@ -837,6 +902,8 @@ int C_DECL main(int argc, char* argv[])
ShFinalize();
}
delete[] Work;
if (CompileFailed)
return EFailCompile;
if (LinkFailed)

View File

@ -60,7 +60,7 @@ patch out vec4 patchOut; // ERROR
void foo24()
{
dvec3 df, di;
df = modf(outp.xyz, di);
df = modf(dvec3(outp.xyz), di);
}
in float in1;

View File

@ -115,3 +115,216 @@ void qlod()
lod = textureQueryLod(samp1D, pf); // 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);
}

View File

@ -218,26 +218,18 @@ ERROR: node is still EOpNull!
0:? Sequence
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 Convert float to double (temp 3-component vector of double)
0:63 Comma (global 3-component vector of float)
0:63 move second child to first child (temp 3-component vector of float)
0:63 'tempReturn' (global 3-component vector of float)
0:63 modf (global 3-component vector of float)
0:63 vector swizzle (temp 3-component vector of float)
0:63 'outp' (out 4-component vector of float)
0:63 Sequence
0:63 Constant:
0:63 0 (const int)
0:63 Constant:
0:63 1 (const int)
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:63 modf (global 3-component vector of double)
0:63 Convert float to double (temp 3-component vector of double)
0:63 vector swizzle (temp 3-component vector of float)
0:63 'outp' (out 4-component vector of float)
0:63 Sequence
0:63 Constant:
0:63 0 (const int)
0:63 Constant:
0:63 1 (const int)
0:63 Constant:
0:63 2 (const int)
0:63 'di' (temp 3-component vector of double)
0:71 Function Definition: foodc1( (global void)
0:71 Function Parameters:
0:73 Sequence
@ -707,26 +699,18 @@ ERROR: node is still EOpNull!
0:? Sequence
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 Convert float to double (temp 3-component vector of double)
0:63 Comma (global 3-component vector of float)
0:63 move second child to first child (temp 3-component vector of float)
0:63 'tempReturn' (global 3-component vector of float)
0:63 modf (global 3-component vector of float)
0:63 vector swizzle (temp 3-component vector of float)
0:63 'outp' (out 4-component vector of float)
0:63 Sequence
0:63 Constant:
0:63 0 (const int)
0:63 Constant:
0:63 1 (const int)
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:63 modf (global 3-component vector of double)
0:63 Convert float to double (temp 3-component vector of double)
0:63 vector swizzle (temp 3-component vector of float)
0:63 'outp' (out 4-component vector of float)
0:63 Sequence
0:63 Constant:
0:63 0 (const int)
0:63 Constant:
0:63 1 (const int)
0:63 Constant:
0:63 2 (const int)
0:63 'di' (temp 3-component vector of double)
0:71 Function Definition: foodc1( (global void)
0:71 Function Parameters:
0:73 Sequence

File diff suppressed because it is too large Load Diff

View File

@ -85,7 +85,7 @@ Uniform block reflection:
nameless: offset -1, type ffffffff, size 496, index -1
named: offset -1, type ffffffff, size 304, index -1
c_nameless: offset -1, type ffffffff, size 112, index -1
nested: offset -1, type ffffffff, size 28, index -1
nested: offset -1, type ffffffff, size 32, index -1
abl[0]: offset -1, type ffffffff, size 4, index -1
abl[1]: offset -1, type ffffffff, size 4, index -1
abl[2]: offset -1, type ffffffff, size 4, index -1

File diff suppressed because it is too large Load Diff

19
Test/baseResults/spv.always-discard.frag.out Executable file → Normal file
View File

@ -110,23 +110,4 @@ Linked fragment stage:
Branch 49
49: Label
Kill
69: Label
70: 6(float) Load 36(radius)
72: 46(bool) FOrdGreaterThanEqual 70 71
SelectionMerge 74 None
BranchConditional 72 73 74
73: Label
75: 6(float) Load 36(radius)
77: 6(float) ExtInst 1(GLSL.std.450) 26(Pow) 75 76
78: 6(float) FDiv 77 27
79: 6(float) ExtInst 1(GLSL.std.450) 4(FAbs) 78
80: 7(fvec4) Load 15(color)
81: 7(fvec4) CompositeConstruct 79 79 79 79
82: 7(fvec4) FSub 80 81
Store 15(color) 82
Branch 74
74: Label
83: 7(fvec4) Load 15(color)
Store 59(gl_FragColor) 83
Return
FunctionEnd

View File

@ -0,0 +1,63 @@
spv.branch-return.vert
Linked vertex stage:
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 35
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Vertex 4 "main" 8 19 34
Source ESSL 300
Name 4 "main"
Name 8 "gl_InstanceID"
Name 19 "gl_Position"
Name 34 "gl_VertexID"
Decorate 8(gl_InstanceID) BuiltIn InstanceId
Decorate 19(gl_Position) BuiltIn Position
Decorate 34(gl_VertexID) BuiltIn VertexId
2: TypeVoid
3: TypeFunction 2
6: TypeInt 32 1
7: TypePointer Input 6(int)
8(gl_InstanceID): 7(ptr) Variable Input
16: TypeFloat 32
17: TypeVector 16(float) 4
18: TypePointer Output 17(fvec4)
19(gl_Position): 18(ptr) Variable Output
20: 16(float) Constant 0
21: 17(fvec4) ConstantComposite 20 20 20 20
26: 16(float) Constant 1039918957
27: TypeInt 32 0
28: 27(int) Constant 0
29: TypePointer Output 16(float)
34(gl_VertexID): 7(ptr) Variable Input
4(main): 2 Function None 3
5: Label
9: 6(int) Load 8(gl_InstanceID)
SelectionMerge 14 None
Switch 9 14
case 0: 10
case 1: 11
case 2: 12
case 3: 13
10: Label
Return
11: Label
Store 19(gl_Position) 21
Branch 14
12: Label
Return
13: Label
Return
14: Label
30: 29(ptr) AccessChain 19(gl_Position) 28
31: 16(float) Load 30
32: 16(float) FAdd 31 26
33: 29(ptr) AccessChain 19(gl_Position) 28
Store 33 32
Return
FunctionEnd

View File

@ -60,14 +60,14 @@ Linked vertex stage:
30: 29(ptr) AccessChain 24(colorOut) 25
Store 30 28
Branch 13
13: Label
31: 6(int) Load 8(i)
32: 6(int) IAdd 31 9
Store 8(i) 32
Branch 10
12: Label
35: 29(ptr) AccessChain 24(colorOut) 34
36: 19(fvec4) Load 35
Store 33(gl_Position) 36
Return
13: Label
31: 6(int) Load 8(i)
32: 6(int) IAdd 31 9
Store 8(i) 32
Branch 10
FunctionEnd

View File

@ -42,10 +42,10 @@ Linked vertex stage:
16: 6(int) IAdd 14 15
Store 8(i) 16
Branch 13
12: Label
Return
13: Label
17: 6(int) Load 8(i)
20: 19(bool) SLessThan 17 18
BranchConditional 20 10 12
FunctionEnd
12: Label
Return
FunctionEnd

18
Test/baseResults/spv.do-while-continue-break.vert.out Executable file → Normal file
View File

@ -63,21 +63,15 @@ Linked vertex stage:
18: 17(bool) IEqual 15 16
SelectionMerge 20 None
BranchConditional 18 19 20
12: Label
Store 41(G) 42
Return
19: Label
Store 21(B) 22
Branch 13
13: Label
37: 6(int) Load 8(i)
38: 6(int) IAdd 37 22
Store 8(i) 38
40: 17(bool) SLessThan 38 39
BranchConditional 40 10 12
19: Label
Store 21(B) 22
Branch 13
23: Label
Store 24(C) 16
Branch 20
20: Label
25: 6(int) Load 8(i)
27: 17(bool) IEqual 25 26
@ -86,10 +80,10 @@ Linked vertex stage:
28: Label
Store 30(D) 31
Branch 12
32: Label
Store 33(E) 34
Branch 29
29: Label
Store 35(F) 36
Branch 13
12: Label
Store 41(G) 42
Return
FunctionEnd

View File

@ -51,14 +51,14 @@ Linked fragment stage:
21: 7(fvec4) FAdd 20 19
Store 9(color) 21
Branch 16
15: Label
34: 7(fvec4) Load 9(color)
Store 33(gl_FragColor) 34
Return
16: Label
25: 24(ptr) AccessChain 9(color) 23
26: 6(float) Load 25
29: 6(float) Load 28(d)
31: 30(bool) FOrdLessThan 26 29
BranchConditional 31 13 15
FunctionEnd
15: Label
34: 7(fvec4) Load 9(color)
Store 33(gl_FragColor) 34
Return
FunctionEnd

20
Test/baseResults/spv.for-continue-break.vert.out Executable file → Normal file
View File

@ -64,20 +64,14 @@ Linked vertex stage:
23: 16(bool) IEqual 22 9
SelectionMerge 25 None
BranchConditional 23 24 25
12: Label
Store 42(G) 43
Return
24: Label
Store 26(B) 19
Branch 13
13: Label
40: 6(int) Load 8(i)
41: 6(int) IAdd 40 19
Store 8(i) 41
Branch 10
24: Label
Store 26(B) 19
Branch 13
27: Label
Store 28(C) 19
Branch 25
25: Label
29: 6(int) Load 8(i)
31: 6(int) SMod 29 30
@ -87,10 +81,10 @@ Linked vertex stage:
33: Label
Store 35(D) 19
Branch 12
36: Label
Store 37(E) 19
Branch 34
34: Label
Store 38(F) 39
Branch 13
FunctionEnd
12: Label
Store 42(G) 43
Return
FunctionEnd

View File

@ -47,13 +47,13 @@ Linked vertex stage:
BranchConditional 17 11 12
11: Label
Branch 13
13: Label
18: 6(int) Load 8(i)
20: 6(int) IAdd 18 19
Store 8(i) 20
Branch 10
12: Label
23: 6(int) Load 8(i)
Store 22(r) 23
Return
13: Label
18: 6(int) Load 8(i)
20: 6(int) IAdd 18 19
Store 8(i) 20
Branch 10
FunctionEnd

View File

@ -45,11 +45,11 @@ Linked vertex stage:
11: Label
Store 18(j) 19
Branch 13
13: Label
20: 6(int) Load 8(i)
22: 6(int) IAdd 20 21
Store 8(i) 22
Branch 10
12: Label
Return
13: Label
20: 6(int) Load 8(i)
22: 6(int) IAdd 20 21
Store 8(i) 22
Branch 10
FunctionEnd

View File

@ -88,17 +88,17 @@ Linked fragment stage:
31: 7(fvec4) FAdd 30 29
Store 9(color) 31
Branch 20
20: Label
32: 13(int) Load 15(i)
34: 13(int) IAdd 32 33
Store 15(i) 34
Branch 17
19: Label
37: 7(fvec4) Load 9(color)
Store 36(gl_FragColor) 37
Store 39(sum) 40
Store 41(i) 16
Branch 42
20: Label
32: 13(int) Load 15(i)
34: 13(int) IAdd 32 33
Store 15(i) 34
Branch 17
42: Label
46: 13(int) Load 41(i)
48: 25(bool) SLessThan 46 47
@ -113,14 +113,14 @@ Linked fragment stage:
59: 6(float) FAdd 58 57
Store 39(sum) 59
Branch 45
45: Label
60: 13(int) Load 41(i)
61: 13(int) IAdd 60 33
Store 41(i) 61
Branch 42
44: Label
Store 62(i) 16
Branch 63
45: Label
60: 13(int) Load 41(i)
61: 13(int) IAdd 60 33
Store 41(i) 61
Branch 42
63: Label
67: 13(int) Load 62(i)
68: 25(bool) SLessThan 67 47
@ -136,6 +136,11 @@ Linked fragment stage:
77: 38(ptr) AccessChain 69(tv4) 70
Store 77 76
Branch 66
66: Label
78: 13(int) Load 62(i)
79: 13(int) IAdd 78 33
Store 62(i) 79
Branch 63
65: Label
80: 6(float) Load 39(sum)
81: 7(fvec4) CompositeConstruct 80 80 80 80
@ -151,11 +156,6 @@ Linked fragment stage:
Store 86(r) 91
Store 92(i) 16
Branch 93
66: Label
78: 13(int) Load 62(i)
79: 13(int) IAdd 78 33
Store 62(i) 79
Branch 63
93: Label
97: 13(int) Load 92(i)
98: 13(int) Load 23(Count)
@ -167,6 +167,11 @@ Linked fragment stage:
104: 38(ptr) AccessChain 86(r) 103
Store 104 102
Branch 96
96: Label
105: 13(int) Load 92(i)
106: 13(int) IAdd 105 33
Store 92(i) 106
Branch 93
95: Label
107: 7(fvec4) Load 86(r)
108: 87(fvec3) VectorShuffle 107 107 0 1 2
@ -178,11 +183,6 @@ Linked fragment stage:
Store 36(gl_FragColor) 113
Store 114(i) 16
Branch 115
96: Label
105: 13(int) Load 92(i)
106: 13(int) IAdd 105 33
Store 92(i) 106
Branch 93
115: Label
119: 13(int) Load 114(i)
121: 25(bool) SLessThan 119 120
@ -194,11 +194,11 @@ Linked fragment stage:
124: 7(fvec4) VectorTimesScalar 123 122
Store 36(gl_FragColor) 124
Branch 118
118: Label
125: 13(int) Load 114(i)
126: 13(int) IAdd 125 47
Store 114(i) 126
Branch 115
117: Label
Return
118: Label
125: 13(int) Load 114(i)
126: 13(int) IAdd 125 47
Store 114(i) 126
Branch 115
FunctionEnd

View File

@ -170,16 +170,16 @@ Linked fragment stage:
86: 30(ptr) AccessChain 83(a) 84
Store 86 85
Branch 79
78: Label
90: 6(int) Load 89(condition)
91: 23(bool) IEqual 90 28
SelectionMerge 93 None
BranchConditional 91 92 93
79: Label
87: 6(int) Load 75(i)
88: 6(int) IAdd 87 28
Store 75(i) 88
Branch 76
78: Label
90: 6(int) Load 89(condition)
91: 23(bool) IEqual 90 28
SelectionMerge 93 None
BranchConditional 91 92 93
92: Label
94: 34 Load 70(localArray)
Store 83(a) 94

File diff suppressed because it is too large Load Diff

View File

@ -153,14 +153,6 @@ Linked fragment stage:
31: 30(bool) FOrdLessThan 26 29
SelectionMerge 33 None
BranchConditional 31 32 33
15: Label
Branch 73
16: Label
69: 24(ptr) AccessChain 9(color) 35
70: 6(float) Load 69
71: 6(float) Load 28(d4)
72: 30(bool) FOrdLessThan 70 71
BranchConditional 72 13 15
32: Label
36: 24(ptr) AccessChain 9(color) 35
37: 6(float) Load 36
@ -179,6 +171,12 @@ Linked fragment stage:
49: 6(float) FAdd 47 48
Store 46 49
Branch 16
16: Label
69: 24(ptr) AccessChain 9(color) 35
70: 6(float) Load 69
71: 6(float) Load 28(d4)
72: 30(bool) FOrdLessThan 70 71
BranchConditional 72 13 15
45: Label
Branch 33
33: Label
@ -206,6 +204,8 @@ Linked fragment stage:
Branch 57
57: Label
Branch 16
15: Label
Branch 73
73: Label
78: 24(ptr) AccessChain 9(color) 77
79: 6(float) Load 78
@ -220,16 +220,6 @@ Linked fragment stage:
86: 30(bool) FOrdLessThan 84 85
SelectionMerge 88 None
BranchConditional 86 87 92
75: Label
136: 7(fvec4) Load 9(color)
137: 7(fvec4) CompositeConstruct 48 48 48 48
138: 7(fvec4) FAdd 136 137
Store 9(color) 138
141: 7(fvec4) Load 9(color)
Store 140(gl_FragColor) 141
Return
76: Label
Branch 73
87: Label
89: 7(fvec4) Load 9(color)
90: 7(fvec4) CompositeConstruct 48 48 48 48
@ -271,6 +261,8 @@ Linked fragment stage:
117: 6(float) FAdd 116 48
Store 115 117
Branch 76
76: Label
Branch 73
114: Label
Branch 104
104: Label
@ -298,4 +290,12 @@ Linked fragment stage:
Branch 124
124: Label
Branch 76
FunctionEnd
75: Label
136: 7(fvec4) Load 9(color)
137: 7(fvec4) CompositeConstruct 48 48 48 48
138: 7(fvec4) FAdd 136 137
Store 9(color) 138
141: 7(fvec4) Load 9(color)
Store 140(gl_FragColor) 141
Return
FunctionEnd

View File

@ -0,0 +1,47 @@
spv.merge-unreachable.frag
Warning, version 450 is not yet complete; most version-specific features are present, but some are missing.
Linked fragment stage:
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 25
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 9
ExecutionMode 4 OriginLowerLeft
Source GLSL 450
Name 4 "main"
Name 9 "v"
Decorate 9(v) Location 1
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
7: TypeVector 6(float) 4
8: TypePointer Input 7(fvec4)
9(v): 8(ptr) Variable Input
11: 6(float) Constant 1036831949
12: 6(float) Constant 1045220557
13: 6(float) Constant 1050253722
14: 6(float) Constant 1053609165
15: 7(fvec4) ConstantComposite 11 12 13 14
16: TypeBool
17: TypeVector 16(bool) 4
4(main): 2 Function None 3
5: Label
10: 7(fvec4) Load 9(v)
18: 17(bvec4) FOrdEqual 10 15
19: 16(bool) All 18
SelectionMerge 21 None
BranchConditional 19 20 23
20: Label
Kill
23: Label
Return
21: Label
Return
FunctionEnd

View File

@ -0,0 +1,522 @@
spv.sparseTexture.frag
Warning, version 450 is not yet complete; most version-specific features are present, but some are missing.
Linked fragment stage:
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 399
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 384
ExecutionMode 4 OriginLowerLeft
Source GLSL 450
SourceExtension "GL_ARB_sparse_texture2"
Name 4 "main"
Name 8 "resident"
Name 13 "texel"
Name 18 "itexel"
Name 23 "utexel"
Name 29 "s2D"
Name 33 "c2"
Name 35 "ResType"
Name 44 "s3D"
Name 48 "c3"
Name 59 "isCube"
Name 62 "ResType"
Name 71 "s2DShadow"
Name 77 "ResType"
Name 86 "sCubeArrayShadow"
Name 89 "c4"
Name 108 "usCubeArray"
Name 111 "ResType"
Name 140 "us2DRect"
Name 154 "s2DArrayShadow"
Name 186 "s2DMS"
Name 223 "is2DArray"
Name 256 "sCubeShadow"
Name 289 "s2DRectShadow"
Name 360 "offsets"
Name 384 "outColor"
2: TypeVoid
3: TypeFunction 2
6: TypeInt 32 1
7: TypePointer Function 6(int)
9: 6(int) Constant 0
10: TypeFloat 32
11: TypeVector 10(float) 4
12: TypePointer Function 11(fvec4)
14: 10(float) Constant 0
15: 11(fvec4) ConstantComposite 14 14 14 14
16: TypeVector 6(int) 4
17: TypePointer Function 16(ivec4)
19: 16(ivec4) ConstantComposite 9 9 9 9
20: TypeInt 32 0
21: TypeVector 20(int) 4
22: TypePointer Function 21(ivec4)
24: 20(int) Constant 0
25: 21(ivec4) ConstantComposite 24 24 24 24
26: TypeImage 10(float) 2D sampled format:Unknown
27: TypeSampledImage 26
28: TypePointer UniformConstant 27
29(s2D): 28(ptr) Variable UniformConstant
31: TypeVector 10(float) 2
32: TypePointer UniformConstant 31(fvec2)
33(c2): 32(ptr) Variable UniformConstant
35(ResType): TypeStruct 6(int) 11(fvec4)
41: TypeImage 10(float) 3D sampled format:Unknown
42: TypeSampledImage 41
43: TypePointer UniformConstant 42
44(s3D): 43(ptr) Variable UniformConstant
46: TypeVector 10(float) 3
47: TypePointer UniformConstant 46(fvec3)
48(c3): 47(ptr) Variable UniformConstant
50: 10(float) Constant 1073741824
56: TypeImage 6(int) Cube sampled format:Unknown
57: TypeSampledImage 56
58: TypePointer UniformConstant 57
59(isCube): 58(ptr) Variable UniformConstant
62(ResType): TypeStruct 6(int) 16(ivec4)
68: TypeImage 10(float) 2D depth sampled format:Unknown
69: TypeSampledImage 68
70: TypePointer UniformConstant 69
71(s2DShadow): 70(ptr) Variable UniformConstant
74: TypePointer Function 10(float)
77(ResType): TypeStruct 6(int) 10(float)
83: TypeImage 10(float) Cube depth array sampled format:Unknown
84: TypeSampledImage 83
85: TypePointer UniformConstant 84
86(sCubeArrayShadow): 85(ptr) Variable UniformConstant
88: TypePointer UniformConstant 11(fvec4)
89(c4): 88(ptr) Variable UniformConstant
91: 10(float) Constant 1065353216
105: TypeImage 20(int) Cube array sampled format:Unknown
106: TypeSampledImage 105
107: TypePointer UniformConstant 106
108(usCubeArray): 107(ptr) Variable UniformConstant
111(ResType): TypeStruct 6(int) 21(ivec4)
119: 20(int) Constant 1
129: TypeVector 6(int) 3
130: 6(int) Constant 2
131: 129(ivec3) ConstantComposite 130 130 130
137: TypeImage 20(int) Rect sampled format:Unknown
138: TypeSampledImage 137
139: TypePointer UniformConstant 138
140(us2DRect): 139(ptr) Variable UniformConstant
143: TypeVector 6(int) 2
144: 6(int) Constant 3
145: 143(ivec2) ConstantComposite 144 144
151: TypeImage 10(float) 2D depth array sampled format:Unknown
152: TypeSampledImage 151
153: TypePointer UniformConstant 152
154(s2DArrayShadow): 153(ptr) Variable UniformConstant
157: 6(int) Constant 5
158: 143(ivec2) ConstantComposite 157 157
159: 20(int) Constant 2
183: TypeImage 10(float) 2D multi-sampled sampled format:Unknown
184: TypeSampledImage 183
185: TypePointer UniformConstant 184
186(s2DMS): 185(ptr) Variable UniformConstant
190: 6(int) Constant 4
199: 129(ivec3) ConstantComposite 190 190 190
220: TypeImage 6(int) 2D array sampled format:Unknown
221: TypeSampledImage 220
222: TypePointer UniformConstant 221
223(is2DArray): 222(ptr) Variable UniformConstant
226: 6(int) Constant 6
227: 143(ivec2) ConstantComposite 226 226
235: 6(int) Constant 7
236: 143(ivec2) ConstantComposite 235 235
253: TypeImage 10(float) Cube depth sampled format:Unknown
254: TypeSampledImage 253
255: TypePointer UniformConstant 254
256(sCubeShadow): 255(ptr) Variable UniformConstant
286: TypeImage 10(float) Rect depth sampled format:Unknown
287: TypeSampledImage 286
288: TypePointer UniformConstant 287
289(s2DRectShadow): 288(ptr) Variable UniformConstant
294: 20(int) Constant 3
306: 143(ivec2) ConstantComposite 130 130
335: 143(ivec2) ConstantComposite 190 190
357: 20(int) Constant 4
358: TypeArray 143(ivec2) 357
359: TypePointer UniformConstant 358
360(offsets): 359(ptr) Variable UniformConstant
383: TypePointer Output 11(fvec4)
384(outColor): 383(ptr) Variable Output
387: TypeBool
4(main): 2 Function None 3
5: Label
8(resident): 7(ptr) Variable Function
13(texel): 12(ptr) Variable Function
18(itexel): 17(ptr) Variable Function
23(utexel): 22(ptr) Variable Function
385: 12(ptr) Variable Function
Store 8(resident) 9
Store 13(texel) 15
Store 18(itexel) 19
Store 23(utexel) 25
30: 27 Load 29(s2D)
34: 31(fvec2) Load 33(c2)
36: 35(ResType) ImageSparseSampleImplicitLod 30 34
37: 11(fvec4) CompositeExtract 36 1
Store 13(texel) 37
38: 6(int) CompositeExtract 36 0
39: 6(int) Load 8(resident)
40: 6(int) BitwiseOr 39 38
Store 8(resident) 40
45: 42 Load 44(s3D)
49: 46(fvec3) Load 48(c3)
51: 35(ResType) ImageSparseSampleImplicitLod 45 49 Bias 50
52: 11(fvec4) CompositeExtract 51 1
Store 13(texel) 52
53: 6(int) CompositeExtract 51 0
54: 6(int) Load 8(resident)
55: 6(int) BitwiseOr 54 53
Store 8(resident) 55
60: 57 Load 59(isCube)
61: 46(fvec3) Load 48(c3)
63: 62(ResType) ImageSparseSampleImplicitLod 60 61
64: 16(ivec4) CompositeExtract 63 1
Store 18(itexel) 64
65: 6(int) CompositeExtract 63 0
66: 6(int) Load 8(resident)
67: 6(int) BitwiseOr 66 65
Store 8(resident) 67
72: 69 Load 71(s2DShadow)
73: 46(fvec3) Load 48(c3)
75: 74(ptr) AccessChain 13(texel) 24
76: 10(float) CompositeExtract 73 2
78: 77(ResType) ImageSparseSampleDrefImplicitLod 72 73 76
79: 10(float) CompositeExtract 78 1
Store 75 79
80: 6(int) CompositeExtract 78 0
81: 6(int) Load 8(resident)
82: 6(int) BitwiseOr 81 80
Store 8(resident) 82
87: 84 Load 86(sCubeArrayShadow)
90: 11(fvec4) Load 89(c4)
92: 74(ptr) AccessChain 13(texel) 24
93: 77(ResType) ImageSparseSampleDrefImplicitLod 87 90 91
94: 10(float) CompositeExtract 93 1
Store 92 94
95: 6(int) CompositeExtract 93 0
96: 6(int) Load 8(resident)
97: 6(int) BitwiseOr 96 95
Store 8(resident) 97
98: 27 Load 29(s2D)
99: 31(fvec2) Load 33(c2)
100: 35(ResType) ImageSparseSampleExplicitLod 98 99 Lod 50
101: 11(fvec4) CompositeExtract 100 1
Store 13(texel) 101
102: 6(int) CompositeExtract 100 0
103: 6(int) Load 8(resident)
104: 6(int) BitwiseOr 103 102
Store 8(resident) 104
109: 106 Load 108(usCubeArray)
110: 11(fvec4) Load 89(c4)
112:111(ResType) ImageSparseSampleExplicitLod 109 110 Lod 91
113: 21(ivec4) CompositeExtract 112 1
Store 23(utexel) 113
114: 6(int) CompositeExtract 112 0
115: 6(int) Load 8(resident)
116: 6(int) BitwiseOr 115 114
Store 8(resident) 116
117: 69 Load 71(s2DShadow)
118: 46(fvec3) Load 48(c3)
120: 74(ptr) AccessChain 13(texel) 119
121: 10(float) CompositeExtract 118 2
122: 77(ResType) ImageSparseSampleDrefExplicitLod 117 118 121 Lod 50
123: 10(float) CompositeExtract 122 1
Store 120 123
124: 6(int) CompositeExtract 122 0
125: 6(int) Load 8(resident)
126: 6(int) BitwiseOr 125 124
Store 8(resident) 126
127: 42 Load 44(s3D)
128: 46(fvec3) Load 48(c3)
132: 35(ResType) ImageSparseSampleImplicitLod 127 128 Bias ConstOffset 50 131
133: 11(fvec4) CompositeExtract 132 1
Store 13(texel) 133
134: 6(int) CompositeExtract 132 0
135: 6(int) Load 8(resident)
136: 6(int) BitwiseOr 135 134
Store 8(resident) 136
141: 138 Load 140(us2DRect)
142: 31(fvec2) Load 33(c2)
146:111(ResType) ImageSparseSampleImplicitLod 141 142 ConstOffset 145
147: 21(ivec4) CompositeExtract 146 1
Store 23(utexel) 147
148: 6(int) CompositeExtract 146 0
149: 6(int) Load 8(resident)
150: 6(int) BitwiseOr 149 148
Store 8(resident) 150
155: 152 Load 154(s2DArrayShadow)
156: 11(fvec4) Load 89(c4)
160: 74(ptr) AccessChain 13(texel) 159
161: 10(float) CompositeExtract 156 3
162: 77(ResType) ImageSparseSampleDrefImplicitLod 155 156 161 ConstOffset 158
163: 10(float) CompositeExtract 162 1
Store 160 163
164: 6(int) CompositeExtract 162 0
165: 6(int) Load 8(resident)
166: 6(int) BitwiseOr 165 164
Store 8(resident) 166
167: 27 Load 29(s2D)
168: 31(fvec2) Load 33(c2)
169: 143(ivec2) ConvertFToS 168
170: 35(ResType) ImageSparseFetch 167 169 Lod 130
171: 11(fvec4) CompositeExtract 170 1
Store 13(texel) 171
172: 6(int) CompositeExtract 170 0
173: 6(int) Load 8(resident)
174: 6(int) BitwiseOr 173 172
Store 8(resident) 174
175: 138 Load 140(us2DRect)
176: 31(fvec2) Load 33(c2)
177: 143(ivec2) ConvertFToS 176
178:111(ResType) ImageSparseFetch 175 177
179: 21(ivec4) CompositeExtract 178 1
Store 23(utexel) 179
180: 6(int) CompositeExtract 178 0
181: 6(int) Load 8(resident)
182: 6(int) BitwiseOr 181 180
Store 8(resident) 182
187: 184 Load 186(s2DMS)
188: 31(fvec2) Load 33(c2)
189: 143(ivec2) ConvertFToS 188
191: 35(ResType) ImageSparseFetch 187 189 Sample 190
192: 11(fvec4) CompositeExtract 191 1
Store 13(texel) 192
193: 6(int) CompositeExtract 191 0
194: 6(int) Load 8(resident)
195: 6(int) BitwiseOr 194 193
Store 8(resident) 195
196: 42 Load 44(s3D)
197: 46(fvec3) Load 48(c3)
198: 129(ivec3) ConvertFToS 197
200: 35(ResType) ImageSparseFetch 196 198 Lod ConstOffset 130 199
201: 11(fvec4) CompositeExtract 200 1
Store 13(texel) 201
202: 6(int) CompositeExtract 200 0
203: 6(int) Load 8(resident)
204: 6(int) BitwiseOr 203 202
Store 8(resident) 204
205: 138 Load 140(us2DRect)
206: 31(fvec2) Load 33(c2)
207: 143(ivec2) ConvertFToS 206
208:111(ResType) ImageSparseFetch 205 207 ConstOffset 145
209: 21(ivec4) CompositeExtract 208 1
Store 23(utexel) 209
210: 6(int) CompositeExtract 208 0
211: 6(int) Load 8(resident)
212: 6(int) BitwiseOr 211 210
Store 8(resident) 212
213: 27 Load 29(s2D)
214: 31(fvec2) Load 33(c2)
215: 35(ResType) ImageSparseSampleExplicitLod 213 214 Lod ConstOffset 50 158
216: 11(fvec4) CompositeExtract 215 1
Store 13(texel) 216
217: 6(int) CompositeExtract 215 0
218: 6(int) Load 8(resident)
219: 6(int) BitwiseOr 218 217
Store 8(resident) 219
224: 221 Load 223(is2DArray)
225: 46(fvec3) Load 48(c3)
228: 62(ResType) ImageSparseSampleExplicitLod 224 225 Lod ConstOffset 50 227
229: 16(ivec4) CompositeExtract 228 1
Store 18(itexel) 229
230: 6(int) CompositeExtract 228 0
231: 6(int) Load 8(resident)
232: 6(int) BitwiseOr 231 230
Store 8(resident) 232
233: 69 Load 71(s2DShadow)
234: 46(fvec3) Load 48(c3)
237: 74(ptr) AccessChain 13(texel) 159
238: 10(float) CompositeExtract 234 2
239: 77(ResType) ImageSparseSampleDrefExplicitLod 233 234 238 Lod ConstOffset 50 236
240: 10(float) CompositeExtract 239 1
Store 237 240
241: 6(int) CompositeExtract 239 0
242: 6(int) Load 8(resident)
243: 6(int) BitwiseOr 242 241
Store 8(resident) 243
244: 42 Load 44(s3D)
245: 46(fvec3) Load 48(c3)
246: 46(fvec3) Load 48(c3)
247: 46(fvec3) Load 48(c3)
248: 35(ResType) ImageSparseSampleExplicitLod 244 245 Grad 246 247
249: 11(fvec4) CompositeExtract 248 1
Store 13(texel) 249
250: 6(int) CompositeExtract 248 0
251: 6(int) Load 8(resident)
252: 6(int) BitwiseOr 251 250
Store 8(resident) 252
257: 254 Load 256(sCubeShadow)
258: 11(fvec4) Load 89(c4)
259: 46(fvec3) Load 48(c3)
260: 46(fvec3) Load 48(c3)
261: 74(ptr) AccessChain 13(texel) 119
262: 10(float) CompositeExtract 258 3
263: 77(ResType) ImageSparseSampleDrefExplicitLod 257 258 262 Grad 259 260
264: 10(float) CompositeExtract 263 1
Store 261 264
265: 6(int) CompositeExtract 263 0
266: 6(int) Load 8(resident)
267: 6(int) BitwiseOr 266 265
Store 8(resident) 267
268: 106 Load 108(usCubeArray)
269: 11(fvec4) Load 89(c4)
270: 46(fvec3) Load 48(c3)
271: 46(fvec3) Load 48(c3)
272:111(ResType) ImageSparseSampleExplicitLod 268 269 Grad 270 271
273: 21(ivec4) CompositeExtract 272 1
Store 23(utexel) 273
274: 6(int) CompositeExtract 272 0
275: 6(int) Load 8(resident)
276: 6(int) BitwiseOr 275 274
Store 8(resident) 276
277: 27 Load 29(s2D)
278: 31(fvec2) Load 33(c2)
279: 31(fvec2) Load 33(c2)
280: 31(fvec2) Load 33(c2)
281: 35(ResType) ImageSparseSampleExplicitLod 277 278 Grad ConstOffset 279 280 158
282: 11(fvec4) CompositeExtract 281 1
Store 13(texel) 282
283: 6(int) CompositeExtract 281 0
284: 6(int) Load 8(resident)
285: 6(int) BitwiseOr 284 283
Store 8(resident) 285
290: 287 Load 289(s2DRectShadow)
291: 46(fvec3) Load 48(c3)
292: 31(fvec2) Load 33(c2)
293: 31(fvec2) Load 33(c2)
295: 74(ptr) AccessChain 13(texel) 294
296: 10(float) CompositeExtract 291 2
297: 77(ResType) ImageSparseSampleDrefExplicitLod 290 291 296 Grad ConstOffset 292 293 227
298: 10(float) CompositeExtract 297 1
Store 295 298
299: 6(int) CompositeExtract 297 0
300: 6(int) Load 8(resident)
301: 6(int) BitwiseOr 300 299
Store 8(resident) 301
302: 221 Load 223(is2DArray)
303: 46(fvec3) Load 48(c3)
304: 31(fvec2) Load 33(c2)
305: 31(fvec2) Load 33(c2)
307: 62(ResType) ImageSparseSampleExplicitLod 302 303 Grad ConstOffset 304 305 306
308: 16(ivec4) CompositeExtract 307 1
Store 18(itexel) 308
309: 6(int) CompositeExtract 307 0
310: 6(int) Load 8(resident)
311: 6(int) BitwiseOr 310 309
Store 8(resident) 311
312: 27 Load 29(s2D)
313: 31(fvec2) Load 33(c2)
314: 35(ResType) ImageSparseGather 312 313 9
315: 11(fvec4) CompositeExtract 314 1
Store 13(texel) 315
316: 6(int) CompositeExtract 314 0
317: 6(int) Load 8(resident)
318: 6(int) BitwiseOr 317 316
Store 8(resident) 318
319: 221 Load 223(is2DArray)
320: 46(fvec3) Load 48(c3)
321: 62(ResType) ImageSparseGather 319 320 130
322: 16(ivec4) CompositeExtract 321 1
Store 18(itexel) 322
323: 6(int) CompositeExtract 321 0
324: 6(int) Load 8(resident)
325: 6(int) BitwiseOr 324 323
Store 8(resident) 325
326: 152 Load 154(s2DArrayShadow)
327: 46(fvec3) Load 48(c3)
328: 35(ResType) ImageSparseDrefGather 326 327 50
329: 11(fvec4) CompositeExtract 328 1
Store 13(texel) 329
330: 6(int) CompositeExtract 328 0
331: 6(int) Load 8(resident)
332: 6(int) BitwiseOr 331 330
Store 8(resident) 332
333: 27 Load 29(s2D)
334: 31(fvec2) Load 33(c2)
336: 35(ResType) ImageSparseGather 333 334 9 ConstOffset 335
337: 11(fvec4) CompositeExtract 336 1
Store 13(texel) 337
338: 6(int) CompositeExtract 336 0
339: 6(int) Load 8(resident)
340: 6(int) BitwiseOr 339 338
Store 8(resident) 340
341: 221 Load 223(is2DArray)
342: 46(fvec3) Load 48(c3)
343: 62(ResType) ImageSparseGather 341 342 130 ConstOffset 158
344: 16(ivec4) CompositeExtract 343 1
Store 18(itexel) 344
345: 6(int) CompositeExtract 343 0
346: 6(int) Load 8(resident)
347: 6(int) BitwiseOr 346 345
Store 8(resident) 347
348: 287 Load 289(s2DRectShadow)
349: 31(fvec2) Load 33(c2)
350: 35(ResType) ImageSparseDrefGather 348 349 50 ConstOffset 236
351: 11(fvec4) CompositeExtract 350 1
Store 13(texel) 351
352: 6(int) CompositeExtract 350 0
353: 6(int) Load 8(resident)
354: 6(int) BitwiseOr 353 352
Store 8(resident) 354
355: 27 Load 29(s2D)
356: 31(fvec2) Load 33(c2)
361: 358 Load 360(offsets)
362: 35(ResType) ImageSparseGather 355 356 9 ConstOffsets 361
363: 11(fvec4) CompositeExtract 362 1
Store 13(texel) 363
364: 6(int) CompositeExtract 362 0
365: 6(int) Load 8(resident)
366: 6(int) BitwiseOr 365 364
Store 8(resident) 366
367: 221 Load 223(is2DArray)
368: 46(fvec3) Load 48(c3)
369: 358 Load 360(offsets)
370: 62(ResType) ImageSparseGather 367 368 130 ConstOffsets 369
371: 16(ivec4) CompositeExtract 370 1
Store 18(itexel) 371
372: 6(int) CompositeExtract 370 0
373: 6(int) Load 8(resident)
374: 6(int) BitwiseOr 373 372
Store 8(resident) 374
375: 287 Load 289(s2DRectShadow)
376: 31(fvec2) Load 33(c2)
377: 358 Load 360(offsets)
378: 35(ResType) ImageSparseDrefGather 375 376 50 ConstOffsets 377
379: 11(fvec4) CompositeExtract 378 1
Store 13(texel) 379
380: 6(int) CompositeExtract 378 0
381: 6(int) Load 8(resident)
382: 6(int) BitwiseOr 381 380
Store 8(resident) 382
386: 6(int) Load 8(resident)
388: 387(bool) ImageSparseTexelsResident 386
SelectionMerge 390 None
BranchConditional 388 389 392
389: Label
391: 11(fvec4) Load 13(texel)
Store 385 391
Branch 390
392: Label
393: 16(ivec4) Load 18(itexel)
394: 11(fvec4) ConvertSToF 393
395: 21(ivec4) Load 23(utexel)
396: 11(fvec4) ConvertUToF 395
397: 11(fvec4) FAdd 394 396
Store 385 397
Branch 390
390: Label
398: 11(fvec4) Load 385
Store 384(outColor) 398
Return
FunctionEnd

View File

@ -0,0 +1,456 @@
spv.sparseTextureClamp.frag
Warning, version 450 is not yet complete; most version-specific features are present, but some are missing.
Linked fragment stage:
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 360
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 345
ExecutionMode 4 OriginLowerLeft
Source GLSL 450
SourceExtension "GL_ARB_sparse_texture_clamp"
Name 4 "main"
Name 8 "resident"
Name 13 "texel"
Name 18 "itexel"
Name 23 "utexel"
Name 29 "s2D"
Name 33 "c2"
Name 36 "lodClamp"
Name 38 "ResType"
Name 47 "s3D"
Name 51 "c3"
Name 63 "isCube"
Name 67 "ResType"
Name 76 "s2DShadow"
Name 83 "ResType"
Name 92 "sCubeArrayShadow"
Name 95 "c4"
Name 154 "us2DRect"
Name 161 "ResType"
Name 170 "s2DArrayShadow"
Name 218 "sCubeShadow"
Name 235 "usCubeArray"
Name 286 "s2DRectShadow"
Name 305 "is2DArray"
Name 345 "outColor"
2: TypeVoid
3: TypeFunction 2
6: TypeInt 32 1
7: TypePointer Function 6(int)
9: 6(int) Constant 0
10: TypeFloat 32
11: TypeVector 10(float) 4
12: TypePointer Function 11(fvec4)
14: 10(float) Constant 0
15: 11(fvec4) ConstantComposite 14 14 14 14
16: TypeVector 6(int) 4
17: TypePointer Function 16(ivec4)
19: 16(ivec4) ConstantComposite 9 9 9 9
20: TypeInt 32 0
21: TypeVector 20(int) 4
22: TypePointer Function 21(ivec4)
24: 20(int) Constant 0
25: 21(ivec4) ConstantComposite 24 24 24 24
26: TypeImage 10(float) 2D sampled format:Unknown
27: TypeSampledImage 26
28: TypePointer UniformConstant 27
29(s2D): 28(ptr) Variable UniformConstant
31: TypeVector 10(float) 2
32: TypePointer UniformConstant 31(fvec2)
33(c2): 32(ptr) Variable UniformConstant
35: TypePointer UniformConstant 10(float)
36(lodClamp): 35(ptr) Variable UniformConstant
38(ResType): TypeStruct 6(int) 11(fvec4)
44: TypeImage 10(float) 3D sampled format:Unknown
45: TypeSampledImage 44
46: TypePointer UniformConstant 45
47(s3D): 46(ptr) Variable UniformConstant
49: TypeVector 10(float) 3
50: TypePointer UniformConstant 49(fvec3)
51(c3): 50(ptr) Variable UniformConstant
54: 10(float) Constant 1073741824
60: TypeImage 6(int) Cube sampled format:Unknown
61: TypeSampledImage 60
62: TypePointer UniformConstant 61
63(isCube): 62(ptr) Variable UniformConstant
67(ResType): TypeStruct 6(int) 16(ivec4)
73: TypeImage 10(float) 2D depth sampled format:Unknown
74: TypeSampledImage 73
75: TypePointer UniformConstant 74
76(s2DShadow): 75(ptr) Variable UniformConstant
80: TypePointer Function 10(float)
83(ResType): TypeStruct 6(int) 10(float)
89: TypeImage 10(float) Cube depth array sampled format:Unknown
90: TypeSampledImage 89
91: TypePointer UniformConstant 90
92(sCubeArrayShadow): 91(ptr) Variable UniformConstant
94: TypePointer UniformConstant 11(fvec4)
95(c4): 94(ptr) Variable UniformConstant
97: 10(float) Constant 1065353216
142: TypeVector 6(int) 3
143: 6(int) Constant 2
144: 142(ivec3) ConstantComposite 143 143 143
151: TypeImage 20(int) Rect sampled format:Unknown
152: TypeSampledImage 151
153: TypePointer UniformConstant 152
154(us2DRect): 153(ptr) Variable UniformConstant
157: TypeVector 6(int) 2
158: 6(int) Constant 3
159: 157(ivec2) ConstantComposite 158 158
161(ResType): TypeStruct 6(int) 21(ivec4)
167: TypeImage 10(float) 2D depth array sampled format:Unknown
168: TypeSampledImage 167
169: TypePointer UniformConstant 168
170(s2DArrayShadow): 169(ptr) Variable UniformConstant
173: 6(int) Constant 5
174: 157(ivec2) ConstantComposite 173 173
176: 20(int) Constant 2
215: TypeImage 10(float) Cube depth sampled format:Unknown
216: TypeSampledImage 215
217: TypePointer UniformConstant 216
218(sCubeShadow): 217(ptr) Variable UniformConstant
224: 20(int) Constant 1
232: TypeImage 20(int) Cube array sampled format:Unknown
233: TypeSampledImage 232
234: TypePointer UniformConstant 233
235(usCubeArray): 234(ptr) Variable UniformConstant
283: TypeImage 10(float) Rect depth sampled format:Unknown
284: TypeSampledImage 283
285: TypePointer UniformConstant 284
286(s2DRectShadow): 285(ptr) Variable UniformConstant
291: 6(int) Constant 6
292: 157(ivec2) ConstantComposite 291 291
294: 20(int) Constant 3
302: TypeImage 6(int) 2D array sampled format:Unknown
303: TypeSampledImage 302
304: TypePointer UniformConstant 303
305(is2DArray): 304(ptr) Variable UniformConstant
310: 157(ivec2) ConstantComposite 143 143
344: TypePointer Output 11(fvec4)
345(outColor): 344(ptr) Variable Output
348: TypeBool
4(main): 2 Function None 3
5: Label
8(resident): 7(ptr) Variable Function
13(texel): 12(ptr) Variable Function
18(itexel): 17(ptr) Variable Function
23(utexel): 22(ptr) Variable Function
346: 12(ptr) Variable Function
Store 8(resident) 9
Store 13(texel) 15
Store 18(itexel) 19
Store 23(utexel) 25
30: 27 Load 29(s2D)
34: 31(fvec2) Load 33(c2)
37: 10(float) Load 36(lodClamp)
39: 38(ResType) ImageSparseSampleImplicitLod 30 34 MinLod 37
40: 11(fvec4) CompositeExtract 39 1
Store 13(texel) 40
41: 6(int) CompositeExtract 39 0
42: 6(int) Load 8(resident)
43: 6(int) BitwiseOr 42 41
Store 8(resident) 43
48: 45 Load 47(s3D)
52: 49(fvec3) Load 51(c3)
53: 10(float) Load 36(lodClamp)
55: 38(ResType) ImageSparseSampleImplicitLod 48 52 Bias MinLod 54 53
56: 11(fvec4) CompositeExtract 55 1
Store 13(texel) 56
57: 6(int) CompositeExtract 55 0
58: 6(int) Load 8(resident)
59: 6(int) BitwiseOr 58 57
Store 8(resident) 59
64: 61 Load 63(isCube)
65: 49(fvec3) Load 51(c3)
66: 10(float) Load 36(lodClamp)
68: 67(ResType) ImageSparseSampleImplicitLod 64 65 MinLod 66
69: 16(ivec4) CompositeExtract 68 1
Store 18(itexel) 69
70: 6(int) CompositeExtract 68 0
71: 6(int) Load 8(resident)
72: 6(int) BitwiseOr 71 70
Store 8(resident) 72
77: 74 Load 76(s2DShadow)
78: 49(fvec3) Load 51(c3)
79: 10(float) Load 36(lodClamp)
81: 80(ptr) AccessChain 13(texel) 24
82: 10(float) CompositeExtract 78 2
84: 83(ResType) ImageSparseSampleDrefImplicitLod 77 78 82 MinLod 79
85: 10(float) CompositeExtract 84 1
Store 81 85
86: 6(int) CompositeExtract 84 0
87: 6(int) Load 8(resident)
88: 6(int) BitwiseOr 87 86
Store 8(resident) 88
93: 90 Load 92(sCubeArrayShadow)
96: 11(fvec4) Load 95(c4)
98: 10(float) Load 36(lodClamp)
99: 80(ptr) AccessChain 13(texel) 24
100: 83(ResType) ImageSparseSampleDrefImplicitLod 93 96 97 MinLod 98
101: 10(float) CompositeExtract 100 1
Store 99 101
102: 6(int) CompositeExtract 100 0
103: 6(int) Load 8(resident)
104: 6(int) BitwiseOr 103 102
Store 8(resident) 104
105: 27 Load 29(s2D)
106: 31(fvec2) Load 33(c2)
107: 10(float) Load 36(lodClamp)
108: 11(fvec4) ImageSampleImplicitLod 105 106 MinLod 107
109: 11(fvec4) Load 13(texel)
110: 11(fvec4) FAdd 109 108
Store 13(texel) 110
111: 45 Load 47(s3D)
112: 49(fvec3) Load 51(c3)
113: 10(float) Load 36(lodClamp)
114: 11(fvec4) ImageSampleImplicitLod 111 112 Bias MinLod 54 113
115: 11(fvec4) Load 13(texel)
116: 11(fvec4) FAdd 115 114
Store 13(texel) 116
117: 61 Load 63(isCube)
118: 49(fvec3) Load 51(c3)
119: 10(float) Load 36(lodClamp)
120: 16(ivec4) ImageSampleImplicitLod 117 118 MinLod 119
121: 16(ivec4) Load 18(itexel)
122: 16(ivec4) IAdd 121 120
Store 18(itexel) 122
123: 74 Load 76(s2DShadow)
124: 49(fvec3) Load 51(c3)
125: 10(float) Load 36(lodClamp)
126: 10(float) CompositeExtract 124 2
127: 10(float) ImageSampleDrefImplicitLod 123 124 126 MinLod 125
128: 80(ptr) AccessChain 13(texel) 24
129: 10(float) Load 128
130: 10(float) FAdd 129 127
131: 80(ptr) AccessChain 13(texel) 24
Store 131 130
132: 90 Load 92(sCubeArrayShadow)
133: 11(fvec4) Load 95(c4)
134: 10(float) Load 36(lodClamp)
135: 10(float) ImageSampleDrefImplicitLod 132 133 97 MinLod 134
136: 80(ptr) AccessChain 13(texel) 24
137: 10(float) Load 136
138: 10(float) FAdd 137 135
139: 80(ptr) AccessChain 13(texel) 24
Store 139 138
140: 45 Load 47(s3D)
141: 49(fvec3) Load 51(c3)
145: 10(float) Load 36(lodClamp)
146: 38(ResType) ImageSparseSampleImplicitLod 140 141 Bias ConstOffset MinLod 54 144 145
147: 11(fvec4) CompositeExtract 146 1
Store 13(texel) 147
148: 6(int) CompositeExtract 146 0
149: 6(int) Load 8(resident)
150: 6(int) BitwiseOr 149 148
Store 8(resident) 150
155: 152 Load 154(us2DRect)
156: 31(fvec2) Load 33(c2)
160: 10(float) Load 36(lodClamp)
162:161(ResType) ImageSparseSampleImplicitLod 155 156 ConstOffset MinLod 159 160
163: 21(ivec4) CompositeExtract 162 1
Store 23(utexel) 163
164: 6(int) CompositeExtract 162 0
165: 6(int) Load 8(resident)
166: 6(int) BitwiseOr 165 164
Store 8(resident) 166
171: 168 Load 170(s2DArrayShadow)
172: 11(fvec4) Load 95(c4)
175: 10(float) Load 36(lodClamp)
177: 80(ptr) AccessChain 13(texel) 176
178: 10(float) CompositeExtract 172 3
179: 83(ResType) ImageSparseSampleDrefImplicitLod 171 172 178 ConstOffset MinLod 174 175
180: 10(float) CompositeExtract 179 1
Store 177 180
181: 6(int) CompositeExtract 179 0
182: 6(int) Load 8(resident)
183: 6(int) BitwiseOr 182 181
Store 8(resident) 183
184: 45 Load 47(s3D)
185: 49(fvec3) Load 51(c3)
186: 10(float) Load 36(lodClamp)
187: 11(fvec4) ImageSampleImplicitLod 184 185 Bias ConstOffset MinLod 54 144 186
188: 11(fvec4) Load 13(texel)
189: 11(fvec4) FAdd 188 187
Store 13(texel) 189
190: 152 Load 154(us2DRect)
191: 31(fvec2) Load 33(c2)
192: 10(float) Load 36(lodClamp)
193: 21(ivec4) ImageSampleImplicitLod 190 191 ConstOffset MinLod 159 192
194: 21(ivec4) Load 23(utexel)
195: 21(ivec4) IAdd 194 193
Store 23(utexel) 195
196: 168 Load 170(s2DArrayShadow)
197: 11(fvec4) Load 95(c4)
198: 10(float) Load 36(lodClamp)
199: 10(float) CompositeExtract 197 3
200: 10(float) ImageSampleDrefImplicitLod 196 197 199 ConstOffset MinLod 174 198
201: 80(ptr) AccessChain 13(texel) 176
202: 10(float) Load 201
203: 10(float) FAdd 202 200
204: 80(ptr) AccessChain 13(texel) 176
Store 204 203
205: 45 Load 47(s3D)
206: 49(fvec3) Load 51(c3)
207: 49(fvec3) Load 51(c3)
208: 49(fvec3) Load 51(c3)
209: 10(float) Load 36(lodClamp)
210: 38(ResType) ImageSparseSampleExplicitLod 205 206 Grad MinLod 207 208 209
211: 11(fvec4) CompositeExtract 210 1
Store 13(texel) 211
212: 6(int) CompositeExtract 210 0
213: 6(int) Load 8(resident)
214: 6(int) BitwiseOr 213 212
Store 8(resident) 214
219: 216 Load 218(sCubeShadow)
220: 11(fvec4) Load 95(c4)
221: 49(fvec3) Load 51(c3)
222: 49(fvec3) Load 51(c3)
223: 10(float) Load 36(lodClamp)
225: 80(ptr) AccessChain 13(texel) 224
226: 10(float) CompositeExtract 220 3
227: 83(ResType) ImageSparseSampleDrefExplicitLod 219 220 226 Grad MinLod 221 222 223
228: 10(float) CompositeExtract 227 1
Store 225 228
229: 6(int) CompositeExtract 227 0
230: 6(int) Load 8(resident)
231: 6(int) BitwiseOr 230 229
Store 8(resident) 231
236: 233 Load 235(usCubeArray)
237: 11(fvec4) Load 95(c4)
238: 49(fvec3) Load 51(c3)
239: 49(fvec3) Load 51(c3)
240: 10(float) Load 36(lodClamp)
241:161(ResType) ImageSparseSampleExplicitLod 236 237 Grad MinLod 238 239 240
242: 21(ivec4) CompositeExtract 241 1
Store 23(utexel) 242
243: 6(int) CompositeExtract 241 0
244: 6(int) Load 8(resident)
245: 6(int) BitwiseOr 244 243
Store 8(resident) 245
246: 45 Load 47(s3D)
247: 49(fvec3) Load 51(c3)
248: 49(fvec3) Load 51(c3)
249: 49(fvec3) Load 51(c3)
250: 10(float) Load 36(lodClamp)
251: 11(fvec4) ImageSampleExplicitLod 246 247 Grad MinLod 248 249 250
252: 11(fvec4) Load 13(texel)
253: 11(fvec4) FAdd 252 251
Store 13(texel) 253
254: 216 Load 218(sCubeShadow)
255: 11(fvec4) Load 95(c4)
256: 49(fvec3) Load 51(c3)
257: 49(fvec3) Load 51(c3)
258: 10(float) Load 36(lodClamp)
259: 10(float) CompositeExtract 255 3
260: 10(float) ImageSampleDrefExplicitLod 254 255 259 Grad MinLod 256 257 258
261: 80(ptr) AccessChain 13(texel) 224
262: 10(float) Load 261
263: 10(float) FAdd 262 260
264: 80(ptr) AccessChain 13(texel) 224
Store 264 263
265: 233 Load 235(usCubeArray)
266: 11(fvec4) Load 95(c4)
267: 49(fvec3) Load 51(c3)
268: 49(fvec3) Load 51(c3)
269: 10(float) Load 36(lodClamp)
270: 21(ivec4) ImageSampleExplicitLod 265 266 Grad MinLod 267 268 269
271: 21(ivec4) Load 23(utexel)
272: 21(ivec4) IAdd 271 270
Store 23(utexel) 272
273: 27 Load 29(s2D)
274: 31(fvec2) Load 33(c2)
275: 31(fvec2) Load 33(c2)
276: 31(fvec2) Load 33(c2)
277: 10(float) Load 36(lodClamp)
278: 38(ResType) ImageSparseSampleExplicitLod 273 274 Grad ConstOffset MinLod 275 276 174 277
279: 11(fvec4) CompositeExtract 278 1
Store 13(texel) 279
280: 6(int) CompositeExtract 278 0
281: 6(int) Load 8(resident)
282: 6(int) BitwiseOr 281 280
Store 8(resident) 282
287: 284 Load 286(s2DRectShadow)
288: 49(fvec3) Load 51(c3)
289: 31(fvec2) Load 33(c2)
290: 31(fvec2) Load 33(c2)
293: 10(float) Load 36(lodClamp)
295: 80(ptr) AccessChain 13(texel) 294
296: 10(float) CompositeExtract 288 2
297: 83(ResType) ImageSparseSampleDrefExplicitLod 287 288 296 Grad ConstOffset MinLod 289 290 292 293
298: 10(float) CompositeExtract 297 1
Store 295 298
299: 6(int) CompositeExtract 297 0
300: 6(int) Load 8(resident)
301: 6(int) BitwiseOr 300 299
Store 8(resident) 301
306: 303 Load 305(is2DArray)
307: 49(fvec3) Load 51(c3)
308: 31(fvec2) Load 33(c2)
309: 31(fvec2) Load 33(c2)
311: 10(float) Load 36(lodClamp)
312: 67(ResType) ImageSparseSampleExplicitLod 306 307 Grad ConstOffset MinLod 308 309 310 311
313: 16(ivec4) CompositeExtract 312 1
Store 18(itexel) 313
314: 6(int) CompositeExtract 312 0
315: 6(int) Load 8(resident)
316: 6(int) BitwiseOr 315 314
Store 8(resident) 316
317: 27 Load 29(s2D)
318: 31(fvec2) Load 33(c2)
319: 31(fvec2) Load 33(c2)
320: 31(fvec2) Load 33(c2)
321: 10(float) Load 36(lodClamp)
322: 11(fvec4) ImageSampleExplicitLod 317 318 Grad ConstOffset MinLod 319 320 174 321
323: 11(fvec4) Load 13(texel)
324: 11(fvec4) FAdd 323 322
Store 13(texel) 324
325: 284 Load 286(s2DRectShadow)
326: 49(fvec3) Load 51(c3)
327: 31(fvec2) Load 33(c2)
328: 31(fvec2) Load 33(c2)
329: 10(float) Load 36(lodClamp)
330: 10(float) CompositeExtract 326 2
331: 10(float) ImageSampleDrefExplicitLod 325 326 330 Grad ConstOffset MinLod 327 328 292 329
332: 80(ptr) AccessChain 13(texel) 294
333: 10(float) Load 332
334: 10(float) FAdd 333 331
335: 80(ptr) AccessChain 13(texel) 294
Store 335 334
336: 303 Load 305(is2DArray)
337: 49(fvec3) Load 51(c3)
338: 31(fvec2) Load 33(c2)
339: 31(fvec2) Load 33(c2)
340: 10(float) Load 36(lodClamp)
341: 16(ivec4) ImageSampleExplicitLod 336 337 Grad ConstOffset MinLod 338 339 310 340
342: 16(ivec4) Load 18(itexel)
343: 16(ivec4) IAdd 342 341
Store 18(itexel) 343
347: 6(int) Load 8(resident)
349: 348(bool) ImageSparseTexelsResident 347
SelectionMerge 351 None
BranchConditional 349 350 353
350: Label
352: 11(fvec4) Load 13(texel)
Store 346 352
Branch 351
353: Label
354: 16(ivec4) Load 18(itexel)
355: 11(fvec4) ConvertSToF 354
356: 21(ivec4) Load 23(utexel)
357: 11(fvec4) ConvertUToF 356
358: 11(fvec4) FAdd 355 357
Store 346 358
Branch 351
351: Label
359: 11(fvec4) Load 346
Store 345(outColor) 359
Return
FunctionEnd

View File

@ -106,6 +106,11 @@ Linked fragment stage:
Switch 65 68
case 1: 66
case 2: 67
68: Label
80: 6(float) Load 73(x)
81: 6(float) ExtInst 1(GLSL.std.450) 15(Tan) 80
Store 71(f) 81
Branch 69
66: Label
74: 6(float) Load 73(x)
75: 6(float) ExtInst 1(GLSL.std.450) 13(Sin) 74
@ -116,17 +121,19 @@ Linked fragment stage:
78: 6(float) ExtInst 1(GLSL.std.450) 14(Cos) 77
Store 71(f) 78
Branch 69
68: Label
80: 6(float) Load 73(x)
81: 6(float) ExtInst 1(GLSL.std.450) 15(Tan) 80
Store 71(f) 81
Branch 69
69: Label
83: 9(int) Load 60(c)
SelectionMerge 87 None
Switch 83 86
case 1: 84
case 2: 85
86: Label
97: 6(float) Load 73(x)
98: 6(float) ExtInst 1(GLSL.std.450) 15(Tan) 97
99: 6(float) Load 71(f)
100: 6(float) FAdd 99 98
Store 71(f) 100
Branch 87
84: Label
88: 6(float) Load 73(x)
89: 6(float) ExtInst 1(GLSL.std.450) 13(Sin) 88
@ -141,13 +148,6 @@ Linked fragment stage:
95: 6(float) FAdd 94 93
Store 71(f) 95
Branch 87
86: Label
97: 6(float) Load 73(x)
98: 6(float) ExtInst 1(GLSL.std.450) 15(Tan) 97
99: 6(float) Load 71(f)
100: 6(float) FAdd 99 98
Store 71(f) 100
Branch 87
87: Label
102: 9(int) Load 60(c)
SelectionMerge 105 None
@ -174,6 +174,13 @@ Linked fragment stage:
Switch 117 120
case 1: 118
case 2: 119
120: Label
148: 6(float) Load 73(x)
149: 6(float) ExtInst 1(GLSL.std.450) 15(Tan) 148
150: 6(float) Load 71(f)
151: 6(float) FAdd 150 149
Store 71(f) 151
Branch 121
118: Label
122: 6(float) Load 73(x)
123: 6(float) ExtInst 1(GLSL.std.450) 13(Sin) 122
@ -207,13 +214,6 @@ Linked fragment stage:
Branch 131
131: Label
Branch 121
120: Label
148: 6(float) Load 73(x)
149: 6(float) ExtInst 1(GLSL.std.450) 15(Tan) 148
150: 6(float) Load 71(f)
151: 6(float) FAdd 150 149
Store 71(f) 151
Branch 121
121: Label
Store 153(i) 154
Branch 155
@ -228,177 +228,177 @@ Linked fragment stage:
Switch 163 166
case 1: 164
case 2: 165
157: Label
211: 9(int) Load 60(c)
SelectionMerge 214 None
Switch 211 214
case 1: 212
case 2: 213
158: Label
209: 9(int) Load 153(i)
210: 9(int) IAdd 209 63
Store 153(i) 210
Branch 155
164: Label
168: 6(float) Load 73(x)
169: 6(float) ExtInst 1(GLSL.std.450) 13(Sin) 168
170: 6(float) Load 71(f)
171: 6(float) FAdd 170 169
Store 71(f) 171
Store 172(j) 173
166: Label
198: 6(float) Load 73(x)
199: 6(float) ExtInst 1(GLSL.std.450) 15(Tan) 198
200: 6(float) Load 71(f)
201: 6(float) FAdd 200 199
Store 71(f) 201
Branch 167
164: Label
168: 6(float) Load 73(x)
169: 6(float) ExtInst 1(GLSL.std.450) 13(Sin) 168
170: 6(float) Load 71(f)
171: 6(float) FAdd 170 169
Store 71(f) 171
Store 172(j) 173
Branch 174
174: Label
178: 9(int) Load 172(j)
180: 161(bool) SLessThan 178 179
LoopMerge 176 177 None
BranchConditional 180 175 176
175: Label
181: 6(float) Load 71(f)
182: 6(float) FAdd 181 47
Store 71(f) 182
183: 6(float) Load 71(f)
185: 161(bool) FOrdLessThan 183 184
SelectionMerge 187 None
BranchConditional 185 186 187
186: Label
Branch 176
187: Label
Branch 177
177: Label
189: 9(int) Load 172(j)
190: 9(int) IAdd 189 63
Store 172(j) 190
Branch 174
174: Label
178: 9(int) Load 172(j)
180: 161(bool) SLessThan 178 179
LoopMerge 176 177 None
BranchConditional 180 175 176
175: Label
181: 6(float) Load 71(f)
182: 6(float) FAdd 181 47
Store 71(f) 182
183: 6(float) Load 71(f)
185: 161(bool) FOrdLessThan 183 184
SelectionMerge 187 None
BranchConditional 185 186 187
176: Label
Branch 167
177: Label
189: 9(int) Load 172(j)
190: 9(int) IAdd 189 63
Store 172(j) 190
Branch 174
186: Label
Branch 176
187: Label
Branch 177
165: Label
192: 6(float) Load 73(x)
193: 6(float) ExtInst 1(GLSL.std.450) 14(Cos) 192
194: 6(float) Load 71(f)
195: 6(float) FAdd 194 193
Store 71(f) 195
Branch 167
166: Label
198: 6(float) Load 73(x)
199: 6(float) ExtInst 1(GLSL.std.450) 15(Tan) 198
200: 6(float) Load 71(f)
201: 6(float) FAdd 200 199
Store 71(f) 201
Branch 167
167: Label
203: 6(float) Load 71(f)
205: 161(bool) FOrdLessThan 203 204
SelectionMerge 207 None
BranchConditional 205 206 207
206: Label
Branch 157
207: Label
Branch 158
212: Label
215: 6(float) Load 73(x)
216: 6(float) ExtInst 1(GLSL.std.450) 13(Sin) 215
217: 6(float) Load 71(f)
218: 6(float) FAdd 217 216
Store 71(f) 218
Branch 214
213: Label
Branch 214
214: Label
224: 6(float) Load 71(f)
225: 9(int) Load 58(local)
226: 6(float) ConvertSToF 225
227: 6(float) FAdd 224 226
Store 223(color) 227
231: 7(fvec4) Load 229(v)
Store 230(param) 231
233: 7(fvec4) Load 229(v)
Store 232(param) 233
235: 9(int) Load 60(c)
Store 234(param) 235
236: 7(fvec4) FunctionCall 15(foo1(vf4;vf4;i1;) 230(param) 232(param) 234(param)
239: 6(float) CompositeExtract 236 1
240: 6(float) Load 223(color)
241: 6(float) FAdd 240 239
Store 223(color) 241
243: 7(fvec4) Load 229(v)
Store 242(param) 243
245: 7(fvec4) Load 229(v)
Store 244(param) 245
247: 9(int) Load 60(c)
Store 246(param) 247
248: 7(fvec4) FunctionCall 20(foo2(vf4;vf4;i1;) 242(param) 244(param) 246(param)
250: 6(float) CompositeExtract 248 2
251: 6(float) Load 223(color)
252: 6(float) FAdd 251 250
Store 223(color) 252
253: 9(int) Load 60(c)
SelectionMerge 256 None
Switch 253 255
case 0: 254
254: Label
Branch 256
255: Label
Branch 256
256: Label
260: 9(int) Load 60(c)
SelectionMerge 262 None
Switch 260 261
261: Label
Branch 262
262: Label
Return
FunctionEnd
15(foo1(vf4;vf4;i1;): 7(fvec4) Function None 11
12(v1): 8(ptr) FunctionParameter
13(v2): 8(ptr) FunctionParameter
14(i1): 10(ptr) FunctionParameter
16: Label
22: 9(int) Load 14(i1)
SelectionMerge 26 None
Switch 22 26
case 0: 23
case 2: 24
case 1: 24
case 3: 25
23: Label
27: 7(fvec4) Load 12(v1)
ReturnValue 27
24: Label
29: 7(fvec4) Load 13(v2)
ReturnValue 29
25: Label
31: 7(fvec4) Load 12(v1)
32: 7(fvec4) Load 13(v2)
33: 7(fvec4) FMul 31 32
ReturnValue 33
26: Label
ReturnValue 37
FunctionEnd
20(foo2(vf4;vf4;i1;): 7(fvec4) Function None 11
17(v1): 8(ptr) FunctionParameter
18(v2): 8(ptr) FunctionParameter
19(i1): 10(ptr) FunctionParameter
21: Label
39: 9(int) Load 19(i1)
SelectionMerge 44 None
Switch 39 44
case 0: 40
case 2: 41
case 1: 42
case 3: 43
40: Label
45: 7(fvec4) Load 17(v1)
ReturnValue 45
41: Label
ReturnValue 48
42: Label
50: 7(fvec4) Load 18(v2)
ReturnValue 50
43: Label
52: 7(fvec4) Load 17(v1)
53: 7(fvec4) Load 18(v2)
54: 7(fvec4) FMul 52 53
ReturnValue 54
44: Label
ReturnValue 37
FunctionEnd
176: Label
Branch 167
165: Label
192: 6(float) Load 73(x)
193: 6(float) ExtInst 1(GLSL.std.450) 14(Cos) 192
194: 6(float) Load 71(f)
195: 6(float) FAdd 194 193
Store 71(f) 195
Branch 167
167: Label
203: 6(float) Load 71(f)
205: 161(bool) FOrdLessThan 203 204
SelectionMerge 207 None
BranchConditional 205 206 207
206: Label
Branch 157
207: Label
Branch 158
158: Label
209: 9(int) Load 153(i)
210: 9(int) IAdd 209 63
Store 153(i) 210
Branch 155
157: Label
211: 9(int) Load 60(c)
SelectionMerge 214 None
Switch 211 214
case 1: 212
case 2: 213
212: Label
215: 6(float) Load 73(x)
216: 6(float) ExtInst 1(GLSL.std.450) 13(Sin) 215
217: 6(float) Load 71(f)
218: 6(float) FAdd 217 216
Store 71(f) 218
Branch 214
213: Label
Branch 214
214: Label
224: 6(float) Load 71(f)
225: 9(int) Load 58(local)
226: 6(float) ConvertSToF 225
227: 6(float) FAdd 224 226
Store 223(color) 227
231: 7(fvec4) Load 229(v)
Store 230(param) 231
233: 7(fvec4) Load 229(v)
Store 232(param) 233
235: 9(int) Load 60(c)
Store 234(param) 235
236: 7(fvec4) FunctionCall 15(foo1(vf4;vf4;i1;) 230(param) 232(param) 234(param)
239: 6(float) CompositeExtract 236 1
240: 6(float) Load 223(color)
241: 6(float) FAdd 240 239
Store 223(color) 241
243: 7(fvec4) Load 229(v)
Store 242(param) 243
245: 7(fvec4) Load 229(v)
Store 244(param) 245
247: 9(int) Load 60(c)
Store 246(param) 247
248: 7(fvec4) FunctionCall 20(foo2(vf4;vf4;i1;) 242(param) 244(param) 246(param)
250: 6(float) CompositeExtract 248 2
251: 6(float) Load 223(color)
252: 6(float) FAdd 251 250
Store 223(color) 252
253: 9(int) Load 60(c)
SelectionMerge 256 None
Switch 253 255
case 0: 254
255: Label
Branch 256
254: Label
Branch 256
256: Label
260: 9(int) Load 60(c)
SelectionMerge 262 None
Switch 260 261
261: Label
Branch 262
262: Label
Return
FunctionEnd
15(foo1(vf4;vf4;i1;): 7(fvec4) Function None 11
12(v1): 8(ptr) FunctionParameter
13(v2): 8(ptr) FunctionParameter
14(i1): 10(ptr) FunctionParameter
16: Label
22: 9(int) Load 14(i1)
SelectionMerge 26 None
Switch 22 26
case 0: 23
case 2: 24
case 1: 24
case 3: 25
23: Label
27: 7(fvec4) Load 12(v1)
ReturnValue 27
24: Label
29: 7(fvec4) Load 13(v2)
ReturnValue 29
25: Label
31: 7(fvec4) Load 12(v1)
32: 7(fvec4) Load 13(v2)
33: 7(fvec4) FMul 31 32
ReturnValue 33
26: Label
ReturnValue 37
FunctionEnd
20(foo2(vf4;vf4;i1;): 7(fvec4) Function None 11
17(v1): 8(ptr) FunctionParameter
18(v2): 8(ptr) FunctionParameter
19(i1): 10(ptr) FunctionParameter
21: Label
39: 9(int) Load 19(i1)
SelectionMerge 44 None
Switch 39 44
case 0: 40
case 2: 41
case 1: 42
case 3: 43
40: Label
45: 7(fvec4) Load 17(v1)
ReturnValue 45
41: Label
ReturnValue 48
42: Label
50: 7(fvec4) Load 18(v2)
ReturnValue 50
43: Label
52: 7(fvec4) Load 17(v1)
53: 7(fvec4) Load 18(v2)
54: 7(fvec4) FMul 52 53
ReturnValue 54
44: Label
ReturnValue 37
FunctionEnd

18
Test/baseResults/spv.while-continue-break.vert.out Executable file → Normal file
View File

@ -57,17 +57,11 @@ Linked vertex stage:
23: 16(bool) IEqual 22 9
SelectionMerge 25 None
BranchConditional 23 24 25
12: Label
Store 38(D) 39
Return
13: Label
Branch 10
24: Label
Store 26(B) 21
Branch 13
27: Label
Store 28(C) 21
Branch 25
13: Label
Branch 10
25: Label
29: 6(int) Load 8(i)
31: 6(int) SMod 29 30
@ -77,12 +71,12 @@ Linked vertex stage:
33: Label
Store 26(B) 21
Branch 12
35: Label
Store 28(C) 21
Branch 34
34: Label
36: 6(int) Load 8(i)
37: 6(int) IAdd 36 19
Store 8(i) 37
Branch 13
FunctionEnd
12: Label
Store 38(D) 39
Return
FunctionEnd

View File

@ -44,8 +44,8 @@ Linked vertex stage:
20: 6(int) IAdd 18 19
Store 8(i) 20
Branch 13
13: Label
Branch 10
12: Label
Return
13: Label
Branch 10
FunctionEnd

View File

@ -55,10 +55,10 @@ Linked fragment stage:
31: 7(fvec4) FAdd 30 29
Store 9(color) 31
Branch 16
16: Label
Branch 13
15: Label
34: 7(fvec4) Load 9(color)
Store 33(gl_FragColor) 34
Return
16: Label
Branch 13
FunctionEnd

View File

@ -21,6 +21,223 @@ void foo23()
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()
{
vec4 v;
@ -38,5 +255,6 @@ void main()
outp += gl_FragCoord + vl2;
foo23();
doubles();
}

View File

@ -0,0 +1,10 @@
#version 300 es
void main() {
switch (gl_InstanceID) {
case 0: return;
case 1: gl_Position = vec4(0.0); break;
case 2: return;
case 3: return;
}
gl_Position.x += 0.123;
}

View File

@ -0,0 +1,7 @@
#version 450
layout(location=1) in highp vec4 v;
void main (void)
{
if (v == vec4(0.1,0.2,0.3,0.4)) discard;
else return;
}

View File

@ -0,0 +1,80 @@
#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);
}

View File

@ -0,0 +1,70 @@
#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);
}

View File

@ -34,6 +34,7 @@ spv.always-discard.frag
spv.always-discard2.frag
spv.bitCast.frag
spv.bool.vert
spv.branch-return.vert
spv.conditionalDiscard.frag
spv.conversion.frag
spv.dataOut.frag
@ -58,6 +59,7 @@ spv.loopsArtificial.frag
spv.matFun.vert
spv.matrix.frag
spv.matrix2.frag
spv.merge-unreachable.frag
spv.newTexture.frag
spv.nonSquare.vert
spv.Operations.frag
@ -68,6 +70,8 @@ spv.qualifiers.vert
spv.shiftOps.frag
spv.simpleFunctionCall.frag
spv.simpleMat.vert
spv.sparseTexture.frag
spv.sparseTextureClamp.frag
spv.structAssignment.frag
spv.structDeref.frag
spv.structure.frag

View File

@ -369,6 +369,8 @@ enum TOperator {
EOpImageAtomicExchange,
EOpImageAtomicCompSwap,
EOpSparseImageLoad,
EOpImageGuardEnd,
//
@ -398,6 +400,31 @@ enum TOperator {
EOpTextureGather,
EOpTextureGatherOffset,
EOpTextureGatherOffsets,
EOpTextureClamp,
EOpTextureOffsetClamp,
EOpTextureGradClamp,
EOpTextureGradOffsetClamp,
EOpSparseTextureGuardBegin,
EOpSparseTexture,
EOpSparseTextureLod,
EOpSparseTextureOffset,
EOpSparseTextureFetch,
EOpSparseTextureFetchOffset,
EOpSparseTextureLodOffset,
EOpSparseTextureGrad,
EOpSparseTextureGradOffset,
EOpSparseTextureGather,
EOpSparseTextureGatherOffset,
EOpSparseTextureGatherOffsets,
EOpSparseTexelsResident,
EOpSparseTextureClamp,
EOpSparseTextureOffsetClamp,
EOpSparseTextureGradClamp,
EOpSparseTextureGradOffsetClamp,
EOpSparseTextureGuardEnd,
EOpTextureGuardEnd,
@ -622,6 +649,7 @@ struct TCrackedTextureOp {
bool offsets;
bool gather;
bool grad;
bool lodClamp;
};
//
@ -637,6 +665,8 @@ public:
bool isConstructor() const;
bool isTexture() const { return op > EOpTextureGuardBegin && op < EOpTextureGuardEnd; }
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.
void crackTexture(TSampler sampler, TCrackedTextureOp& cracked) const
@ -649,6 +679,7 @@ public:
cracked.offsets = false;
cracked.gather = false;
cracked.grad = false;
cracked.lodClamp = false;
switch (op) {
case EOpImageQuerySize:
@ -657,25 +688,40 @@ public:
case EOpTextureQueryLod:
case EOpTextureQueryLevels:
case EOpTextureQuerySamples:
case EOpSparseTexelsResident:
cracked.query = true;
break;
case EOpTexture:
case EOpSparseTexture:
break;
case EOpTextureClamp:
case EOpSparseTextureClamp:
cracked.lodClamp = true;
break;
case EOpTextureProj:
cracked.proj = true;
break;
case EOpTextureLod:
case EOpSparseTextureLod:
cracked.lod = true;
break;
case EOpTextureOffset:
case EOpSparseTextureOffset:
cracked.offset = true;
break;
case EOpTextureOffsetClamp:
case EOpSparseTextureOffsetClamp:
cracked.offset = true;
cracked.lodClamp = true;
break;
case EOpTextureFetch:
case EOpSparseTextureFetch:
cracked.fetch = true;
if (sampler.dim == Esd1D || (sampler.dim == Esd2D && ! sampler.ms) || sampler.dim == Esd3D)
cracked.lod = true;
break;
case EOpTextureFetchOffset:
case EOpSparseTextureFetchOffset:
cracked.fetch = true;
cracked.offset = true;
if (sampler.dim == Esd1D || (sampler.dim == Esd2D && ! sampler.ms) || sampler.dim == Esd3D)
@ -686,6 +732,7 @@ public:
cracked.proj = true;
break;
case EOpTextureLodOffset:
case EOpSparseTextureLodOffset:
cracked.offset = true;
cracked.lod = true;
break;
@ -699,9 +746,16 @@ public:
cracked.proj = true;
break;
case EOpTextureGrad:
case EOpSparseTextureGrad:
cracked.grad = true;
break;
case EOpTextureGradClamp:
case EOpSparseTextureGradClamp:
cracked.grad = true;
cracked.lodClamp = true;
break;
case EOpTextureGradOffset:
case EOpSparseTextureGradOffset:
cracked.grad = true;
cracked.offset = true;
break;
@ -714,14 +768,23 @@ public:
cracked.offset = true;
cracked.proj = true;
break;
case EOpTextureGradOffsetClamp:
case EOpSparseTextureGradOffsetClamp:
cracked.grad = true;
cracked.offset = true;
cracked.lodClamp = true;
break;
case EOpTextureGather:
case EOpSparseTextureGather:
cracked.gather = true;
break;
case EOpTextureGatherOffset:
case EOpSparseTextureGatherOffset:
cracked.gather = true;
cracked.offset = true;
break;
case EOpTextureGatherOffsets:
case EOpSparseTextureGatherOffsets:
cracked.gather = true;
cracked.offsets = true;
break;

View File

@ -419,6 +419,214 @@ void TBuiltIns::initialize(int version, EProfile profile, int spv)
"\n");
}
//
// double functions added to desktop 4.00, but not fma, frexp, ldexp, or pack/unpack
//
if (profile != EEsProfile && version >= 400) {
commonBuiltins.append(
"double sqrt(double);"
"dvec2 sqrt(dvec2);"
"dvec3 sqrt(dvec3);"
"dvec4 sqrt(dvec4);"
"double inversesqrt(double);"
"dvec2 inversesqrt(dvec2);"
"dvec3 inversesqrt(dvec3);"
"dvec4 inversesqrt(dvec4);"
"double abs(double);"
"dvec2 abs(dvec2);"
"dvec3 abs(dvec3);"
"dvec4 abs(dvec4);"
"double sign(double);"
"dvec2 sign(dvec2);"
"dvec3 sign(dvec3);"
"dvec4 sign(dvec4);"
"double floor(double);"
"dvec2 floor(dvec2);"
"dvec3 floor(dvec3);"
"dvec4 floor(dvec4);"
"double trunc(double);"
"dvec2 trunc(dvec2);"
"dvec3 trunc(dvec3);"
"dvec4 trunc(dvec4);"
"double round(double);"
"dvec2 round(dvec2);"
"dvec3 round(dvec3);"
"dvec4 round(dvec4);"
"double roundEven(double);"
"dvec2 roundEven(dvec2);"
"dvec3 roundEven(dvec3);"
"dvec4 roundEven(dvec4);"
"double ceil(double);"
"dvec2 ceil(dvec2);"
"dvec3 ceil(dvec3);"
"dvec4 ceil(dvec4);"
"double fract(double);"
"dvec2 fract(dvec2);"
"dvec3 fract(dvec3);"
"dvec4 fract(dvec4);"
"double mod(double, double);"
"dvec2 mod(dvec2 , double);"
"dvec3 mod(dvec3 , double);"
"dvec4 mod(dvec4 , double);"
"dvec2 mod(dvec2 , dvec2);"
"dvec3 mod(dvec3 , dvec3);"
"dvec4 mod(dvec4 , dvec4);"
"double modf(double, out double);"
"dvec2 modf(dvec2, out dvec2);"
"dvec3 modf(dvec3, out dvec3);"
"dvec4 modf(dvec4, out dvec4);"
"double min(double, double);"
"dvec2 min(dvec2, double);"
"dvec3 min(dvec3, double);"
"dvec4 min(dvec4, double);"
"dvec2 min(dvec2, dvec2);"
"dvec3 min(dvec3, dvec3);"
"dvec4 min(dvec4, dvec4);"
"double max(double, double);"
"dvec2 max(dvec2 , double);"
"dvec3 max(dvec3 , double);"
"dvec4 max(dvec4 , double);"
"dvec2 max(dvec2 , dvec2);"
"dvec3 max(dvec3 , dvec3);"
"dvec4 max(dvec4 , dvec4);"
"double clamp(double, double, double);"
"dvec2 clamp(dvec2 , double, double);"
"dvec3 clamp(dvec3 , double, double);"
"dvec4 clamp(dvec4 , double, double);"
"dvec2 clamp(dvec2 , dvec2 , dvec2);"
"dvec3 clamp(dvec3 , dvec3 , dvec3);"
"dvec4 clamp(dvec4 , dvec4 , dvec4);"
"double mix(double, double, double);"
"dvec2 mix(dvec2, dvec2, double);"
"dvec3 mix(dvec3, dvec3, double);"
"dvec4 mix(dvec4, dvec4, double);"
"dvec2 mix(dvec2, dvec2, dvec2);"
"dvec3 mix(dvec3, dvec3, dvec3);"
"dvec4 mix(dvec4, dvec4, dvec4);"
"double mix(double, double, bool);"
"dvec2 mix(dvec2, dvec2, bvec2);"
"dvec3 mix(dvec3, dvec3, bvec3);"
"dvec4 mix(dvec4, dvec4, bvec4);"
"double step(double, double);"
"dvec2 step(dvec2 , dvec2);"
"dvec3 step(dvec3 , dvec3);"
"dvec4 step(dvec4 , dvec4);"
"dvec2 step(double, dvec2);"
"dvec3 step(double, dvec3);"
"dvec4 step(double, dvec4);"
"double smoothstep(double, double, double);"
"dvec2 smoothstep(dvec2 , dvec2 , dvec2);"
"dvec3 smoothstep(dvec3 , dvec3 , dvec3);"
"dvec4 smoothstep(dvec4 , dvec4 , dvec4);"
"dvec2 smoothstep(double, double, dvec2);"
"dvec3 smoothstep(double, double, dvec3);"
"dvec4 smoothstep(double, double, dvec4);"
"bool isnan(double);"
"bvec2 isnan(dvec2);"
"bvec3 isnan(dvec3);"
"bvec4 isnan(dvec4);"
"bool isinf(double);"
"bvec2 isinf(dvec2);"
"bvec3 isinf(dvec3);"
"bvec4 isinf(dvec4);"
"double length(double);"
"double length(dvec2);"
"double length(dvec3);"
"double length(dvec4);"
"double distance(double, double);"
"double distance(dvec2 , dvec2);"
"double distance(dvec3 , dvec3);"
"double distance(dvec4 , dvec4);"
"double dot(double, double);"
"double dot(dvec2 , dvec2);"
"double dot(dvec3 , dvec3);"
"double dot(dvec4 , dvec4);"
"dvec3 cross(dvec3, dvec3);"
"double normalize(double);"
"dvec2 normalize(dvec2);"
"dvec3 normalize(dvec3);"
"dvec4 normalize(dvec4);"
"double faceforward(double, double, double);"
"dvec2 faceforward(dvec2, dvec2, dvec2);"
"dvec3 faceforward(dvec3, dvec3, dvec3);"
"dvec4 faceforward(dvec4, dvec4, dvec4);"
"double reflect(double, double);"
"dvec2 reflect(dvec2 , dvec2 );"
"dvec3 reflect(dvec3 , dvec3 );"
"dvec4 reflect(dvec4 , dvec4 );"
"double refract(double, double, double);"
"dvec2 refract(dvec2 , dvec2 , double);"
"dvec3 refract(dvec3 , dvec3 , double);"
"dvec4 refract(dvec4 , dvec4 , double);"
"dmat2 matrixCompMult(dmat2, dmat2);"
"dmat3 matrixCompMult(dmat3, dmat3);"
"dmat4 matrixCompMult(dmat4, dmat4);"
"dmat2x3 matrixCompMult(dmat2x3, dmat2x3);"
"dmat2x4 matrixCompMult(dmat2x4, dmat2x4);"
"dmat3x2 matrixCompMult(dmat3x2, dmat3x2);"
"dmat3x4 matrixCompMult(dmat3x4, dmat3x4);"
"dmat4x2 matrixCompMult(dmat4x2, dmat4x2);"
"dmat4x3 matrixCompMult(dmat4x3, dmat4x3);"
"dmat2 outerProduct(dvec2, dvec2);"
"dmat3 outerProduct(dvec3, dvec3);"
"dmat4 outerProduct(dvec4, dvec4);"
"dmat2x3 outerProduct(dvec3, dvec2);"
"dmat3x2 outerProduct(dvec2, dvec3);"
"dmat2x4 outerProduct(dvec4, dvec2);"
"dmat4x2 outerProduct(dvec2, dvec4);"
"dmat3x4 outerProduct(dvec4, dvec3);"
"dmat4x3 outerProduct(dvec3, dvec4);"
"dmat2 transpose(dmat2);"
"dmat3 transpose(dmat3);"
"dmat4 transpose(dmat4);"
"dmat2x3 transpose(dmat3x2);"
"dmat3x2 transpose(dmat2x3);"
"dmat2x4 transpose(dmat4x2);"
"dmat4x2 transpose(dmat2x4);"
"dmat3x4 transpose(dmat4x3);"
"dmat4x3 transpose(dmat3x4);"
"double determinant(dmat2);"
"double determinant(dmat3);"
"double determinant(dmat4);"
"dmat2 inverse(dmat2);"
"dmat3 inverse(dmat3);"
"dmat4 inverse(dmat4);"
);
}
if ((profile == EEsProfile && version >= 310) ||
(profile != EEsProfile && version >= 430)) {
commonBuiltins.append(
@ -1956,6 +2164,14 @@ void TBuiltIns::add2ndGenerationSamplingImaging(int version, EProfile profile, i
}
}
}
//
// sparseTexelsResidentARB()
//
if (profile != EEsProfile && version >= 450) {
commonBuiltins.append("bool sparseTexelsResidentARB(int code);\n");
}
}
//
@ -2069,6 +2285,15 @@ void TBuiltIns::addImageFunctions(TSampler sampler, TString& typeName, int versi
commonBuiltins.append(prefixes[sampler.type]);
commonBuiltins.append("vec4);\n");
if (sampler.dim != Esd1D && sampler.dim != EsdBuffer && profile != EEsProfile && version >= 450) {
commonBuiltins.append("int sparseImageLoadARB(readonly volatile coherent ");
commonBuiltins.append(imageParams);
commonBuiltins.append(", out ");
commonBuiltins.append(prefixes[sampler.type]);
commonBuiltins.append("vec4");
commonBuiltins.append(");\n");
}
if ( profile != EEsProfile ||
(profile == EEsProfile && version >= 310)) {
if (sampler.type == EbtInt || sampler.type == EbtUint) {
@ -2123,7 +2348,7 @@ void TBuiltIns::addImageFunctions(TSampler sampler, TString& typeName, int versi
//
// Add all the texture lookup functions for the given type.
//
void TBuiltIns::addSamplingFunctions(TSampler sampler, TString& typeName, int /*version*/, EProfile /*profile*/)
void TBuiltIns::addSamplingFunctions(TSampler sampler, TString& typeName, int version, EProfile profile)
{
//
// texturing
@ -2196,97 +2421,148 @@ void TBuiltIns::addSamplingFunctions(TSampler sampler, TString& typeName, int /*
if (extraProj && (sampler.dim == Esd3D || sampler.shadow))
continue;
TString s;
for (int lodClamp = 0; lodClamp <= 1 ;++lodClamp) { // loop over "bool" lod clamp
// return type
if (sampler.shadow)
s.append("float ");
else {
s.append(prefixes[sampler.type]);
s.append("vec4 ");
}
if (lodClamp && (profile == EEsProfile || version < 450))
continue;
if (lodClamp && (proj || lod || fetch))
continue;
// name
if (fetch)
s.append("texel");
else
s.append("texture");
if (proj)
s.append("Proj");
if (lod)
s.append("Lod");
if (grad)
s.append("Grad");
if (fetch)
s.append("Fetch");
if (offset)
s.append("Offset");
s.append("(");
for (int sparse = 0; sparse <= 1; ++sparse) { // loop over "bool" sparse or not
// sampler type
s.append(typeName);
if (sparse && (profile == EEsProfile || version < 450))
continue;
// Sparse sampling is not for 1D/1D array texture, buffer texture, and projective texture
if (sparse && (sampler.dim == Esd1D || sampler.dim == EsdBuffer || proj))
continue;
// P coordinate
if (extraProj)
s.append(",vec4");
else {
s.append(",");
TBasicType t = fetch ? EbtInt : EbtFloat;
if (totalDims == 1)
s.append(TType::getBasicString(t));
else {
s.append(prefixes[t]);
s.append("vec");
s.append(postfixes[totalDims]);
TString s;
// return type
if (sparse)
s.append("int ");
else {
if (sampler.shadow)
s.append("float ");
else {
s.append(prefixes[sampler.type]);
s.append("vec4 ");
}
}
// name
if (sparse) {
if (fetch)
s.append("sparseTexel");
else
s.append("sparseTexture");
} else {
if (fetch)
s.append("texel");
else
s.append("texture");
}
if (proj)
s.append("Proj");
if (lod)
s.append("Lod");
if (grad)
s.append("Grad");
if (fetch)
s.append("Fetch");
if (offset)
s.append("Offset");
if (lodClamp)
s.append("Clamp");
if (lodClamp || sparse)
s.append("ARB");
s.append("(");
// sampler type
s.append(typeName);
// P coordinate
if (extraProj)
s.append(",vec4");
else {
s.append(",");
TBasicType t = fetch ? EbtInt : EbtFloat;
if (totalDims == 1)
s.append(TType::getBasicString(t));
else {
s.append(prefixes[t]);
s.append("vec");
s.append(postfixes[totalDims]);
}
}
if (bias && compare)
continue;
// non-optional lod argument (lod that's not driven by lod loop) or sample
if ((fetch && sampler.dim != EsdBuffer && sampler.dim != EsdRect && !sampler.ms) ||
(sampler.ms && fetch))
s.append(",int");
// non-optional lod
if (lod)
s.append(",float");
// gradient arguments
if (grad) {
if (dimMap[sampler.dim] == 1)
s.append(",float,float");
else {
s.append(",vec");
s.append(postfixes[dimMap[sampler.dim]]);
s.append(",vec");
s.append(postfixes[dimMap[sampler.dim]]);
}
}
// offset
if (offset) {
if (dimMap[sampler.dim] == 1)
s.append(",int");
else {
s.append(",ivec");
s.append(postfixes[dimMap[sampler.dim]]);
}
}
// non-optional compare
if (compare)
s.append(",float");
// lod clamp
if (lodClamp)
s.append(",float");
// texel out (for sparse texture)
if (sparse) {
s.append(",out ");
if (sampler.shadow)
s.append("float ");
else {
s.append(prefixes[sampler.type]);
s.append("vec4 ");
}
}
// optional bias
if (bias)
s.append(",float");
s.append(");\n");
// Add to the per-language set of built-ins
if (bias)
stageBuiltins[EShLangFragment].append(s);
else
commonBuiltins.append(s);
}
}
if (bias && compare)
continue;
// non-optional lod argument (lod that's not driven by lod loop) or sample
if ((fetch && sampler.dim != EsdBuffer && sampler.dim != EsdRect && !sampler.ms) ||
(sampler.ms && fetch))
s.append(",int");
// non-optional lod
if (lod)
s.append(",float");
// gradient arguments
if (grad) {
if (dimMap[sampler.dim] == 1)
s.append(",float,float");
else {
s.append(",vec");
s.append(postfixes[dimMap[sampler.dim]]);
s.append(",vec");
s.append(postfixes[dimMap[sampler.dim]]);
}
}
// offset
if (offset) {
if (dimMap[sampler.dim] == 1)
s.append(",int");
else {
s.append(",ivec");
s.append(postfixes[dimMap[sampler.dim]]);
}
}
// optional bias or non-optional compare
if (bias || compare)
s.append(",float");
s.append(");\n");
// Add to the per-language set of built-ins
if (bias)
stageBuiltins[EShLangFragment].append(s);
else
commonBuiltins.append(s);
}
}
}
@ -2303,7 +2579,7 @@ void TBuiltIns::addSamplingFunctions(TSampler sampler, TString& typeName, int /*
//
// Add all the texture gather functions for the given type.
//
void TBuiltIns::addGatherFunctions(TSampler sampler, TString& typeName, int version, EProfile /* profile */)
void TBuiltIns::addGatherFunctions(TSampler sampler, TString& typeName, int version, EProfile profile)
{
switch (sampler.dim) {
case Esd2D:
@ -2330,51 +2606,71 @@ void TBuiltIns::addGatherFunctions(TSampler sampler, TString& typeName, int vers
if (offset > 0 && sampler.dim == EsdCube)
continue;
TString s;
for (int sparse = 0; sparse <= 1; ++sparse) { // loop over "bool" sparse or not
if (sparse && (profile == EEsProfile || version < 450))
continue;
// return type
s.append(prefixes[sampler.type]);
s.append("vec4 ");
TString s;
// name
s.append("textureGather");
switch (offset) {
case 1:
s.append("Offset");
break;
case 2:
s.append("Offsets");
default:
break;
// return type
if (sparse)
s.append("int ");
else {
s.append(prefixes[sampler.type]);
s.append("vec4 ");
}
// name
if (sparse)
s.append("sparseTextureGather");
else
s.append("textureGather");
switch (offset) {
case 1:
s.append("Offset");
break;
case 2:
s.append("Offsets");
default:
break;
}
if (sparse)
s.append("ARB");
s.append("(");
// sampler type argument
s.append(typeName);
// P coordinate argument
s.append(",vec");
int totalDims = dimMap[sampler.dim] + (sampler.arrayed ? 1 : 0);
s.append(postfixes[totalDims]);
// refZ argument
if (sampler.shadow)
s.append(",float");
// offset argument
if (offset > 0) {
s.append(",ivec2");
if (offset == 2)
s.append("[4]");
}
// texel out (for sparse texture)
if (sparse) {
s.append(",out ");
s.append(prefixes[sampler.type]);
s.append("vec4 ");
}
// comp argument
if (comp)
s.append(",int");
s.append(");\n");
commonBuiltins.append(s);
}
s.append("(");
// sampler type argument
s.append(typeName);
// P coordinate argument
s.append(",vec");
int totalDims = dimMap[sampler.dim] + (sampler.arrayed ? 1 : 0);
s.append(postfixes[totalDims]);
// refZ argument
if (sampler.shadow)
s.append(",float");
// offset argument
if (offset > 0) {
s.append(",ivec2");
if (offset == 2)
s.append("[4]");
}
// comp argument
if (comp)
s.append(",int");
s.append(");\n");
commonBuiltins.append(s);
//printf("%s", s.c_str());
}
}
}
@ -3164,6 +3460,37 @@ void IdentifyBuiltIns(int version, EProfile profile, int spv, EShLanguage langua
symbolTable.setFunctionExtensions("fwidthCoarse", 1, &E_GL_ARB_derivative_control);
}
// E_GL_ARB_sparse_texture2
if (profile != EEsProfile)
{
symbolTable.setFunctionExtensions("sparseTextureARB", 1, &E_GL_ARB_sparse_texture2);
symbolTable.setFunctionExtensions("sparseTextureLodARB", 1, &E_GL_ARB_sparse_texture2);
symbolTable.setFunctionExtensions("sparseTextureOffsetARB", 1, &E_GL_ARB_sparse_texture2);
symbolTable.setFunctionExtensions("sparseTexelFetchARB", 1, &E_GL_ARB_sparse_texture2);
symbolTable.setFunctionExtensions("sparseTexelFetchOffsetARB", 1, &E_GL_ARB_sparse_texture2);
symbolTable.setFunctionExtensions("sparseTextureLodOffsetARB", 1, &E_GL_ARB_sparse_texture2);
symbolTable.setFunctionExtensions("sparseTextureGradARB", 1, &E_GL_ARB_sparse_texture2);
symbolTable.setFunctionExtensions("sparseTextureGradOffsetARB", 1, &E_GL_ARB_sparse_texture2);
symbolTable.setFunctionExtensions("sparseTextureGatherARB", 1, &E_GL_ARB_sparse_texture2);
symbolTable.setFunctionExtensions("sparseTextureGatherOffsetARB", 1, &E_GL_ARB_sparse_texture2);
symbolTable.setFunctionExtensions("sparseTextureGatherOffsetsARB", 1, &E_GL_ARB_sparse_texture2);
symbolTable.setFunctionExtensions("sparseImageLoadARB", 1, &E_GL_ARB_sparse_texture2);
symbolTable.setFunctionExtensions("sparseTexelsResident", 1, &E_GL_ARB_sparse_texture2);
}
// E_GL_ARB_sparse_texture_clamp
if (profile != EEsProfile)
{
symbolTable.setFunctionExtensions("sparseTextureClampARB", 1, &E_GL_ARB_sparse_texture_clamp);
symbolTable.setFunctionExtensions("sparseTextureOffsetClampARB", 1, &E_GL_ARB_sparse_texture_clamp);
symbolTable.setFunctionExtensions("sparseTextureGradClampARB", 1, &E_GL_ARB_sparse_texture_clamp);
symbolTable.setFunctionExtensions("sparseTextureGradOffsetClampARB", 1, &E_GL_ARB_sparse_texture_clamp);
symbolTable.setFunctionExtensions("textureClampARB", 1, &E_GL_ARB_sparse_texture_clamp);
symbolTable.setFunctionExtensions("textureOffsetClampARB", 1, &E_GL_ARB_sparse_texture_clamp);
symbolTable.setFunctionExtensions("textureGradClampARB", 1, &E_GL_ARB_sparse_texture_clamp);
symbolTable.setFunctionExtensions("textureGradOffsetClampARB", 1, &E_GL_ARB_sparse_texture_clamp);
}
symbolTable.setVariableExtensions("gl_FragDepthEXT", 1, &E_GL_EXT_frag_depth);
if (profile == EEsProfile) {
@ -3423,6 +3750,32 @@ void IdentifyBuiltIns(int version, EProfile profile, int spv, EShLanguage langua
symbolTable.relateToOperator("shadow1DProjLod", EOpTextureProjLod);
symbolTable.relateToOperator("shadow2DProjLod", EOpTextureProjLod);
}
if (profile != EEsProfile)
{
symbolTable.relateToOperator("sparseTextureARB", EOpSparseTexture);
symbolTable.relateToOperator("sparseTextureLodARB", EOpSparseTextureLod);
symbolTable.relateToOperator("sparseTextureOffsetARB", EOpSparseTextureOffset);
symbolTable.relateToOperator("sparseTexelFetchARB", EOpSparseTextureFetch);
symbolTable.relateToOperator("sparseTexelFetchOffsetARB", EOpSparseTextureFetchOffset);
symbolTable.relateToOperator("sparseTextureLodOffsetARB", EOpSparseTextureLodOffset);
symbolTable.relateToOperator("sparseTextureGradARB", EOpSparseTextureGrad);
symbolTable.relateToOperator("sparseTextureGradOffsetARB", EOpSparseTextureGradOffset);
symbolTable.relateToOperator("sparseTextureGatherARB", EOpSparseTextureGather);
symbolTable.relateToOperator("sparseTextureGatherOffsetARB", EOpSparseTextureGatherOffset);
symbolTable.relateToOperator("sparseTextureGatherOffsetsARB", EOpSparseTextureGatherOffsets);
symbolTable.relateToOperator("sparseImageLoadARB", EOpSparseImageLoad);
symbolTable.relateToOperator("sparseTexelsResidentARB", EOpSparseTexelsResident);
symbolTable.relateToOperator("sparseTextureClampARB", EOpSparseTextureClamp);
symbolTable.relateToOperator("sparseTextureOffsetClampARB", EOpSparseTextureOffsetClamp);
symbolTable.relateToOperator("sparseTextureGradClampARB", EOpSparseTextureGradClamp);
symbolTable.relateToOperator("sparseTextureGradOffsetClampARB", EOpSparseTextureGradOffsetClamp);
symbolTable.relateToOperator("textureClampARB", EOpTextureClamp);
symbolTable.relateToOperator("textureOffsetClampARB", EOpTextureOffsetClamp);
symbolTable.relateToOperator("textureGradClampARB", EOpTextureGradClamp);
symbolTable.relateToOperator("textureGradOffsetClampARB", EOpTextureGradOffsetClamp);
}
}
switch(language) {

View File

@ -309,7 +309,7 @@ struct str_hash
unsigned long hash = 5381;
int c;
while ((c = *str++))
while ((c = *str++) != 0)
hash = ((hash << 5) + hash) + c;
return hash;

View File

@ -173,6 +173,8 @@ void TParseContext::initializeExtensionBehavior()
extensionBehavior[E_GL_ARB_derivative_control] = EBhDisable;
extensionBehavior[E_GL_ARB_shader_texture_image_samples] = 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
// #line and #include
@ -274,6 +276,8 @@ const char* TParseContext::getPreamble()
"#define GL_ARB_derivative_control 1\n"
"#define GL_ARB_shader_texture_image_samples 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_include_directive 1\n"

View File

@ -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_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_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
// #line and #include

View File

@ -959,6 +959,11 @@ int TIntermediate::getBaseAlignment(const TType& type, int& size, int& stride, b
size += memberSize;
}
// The structure may have padding at the end; the base offset of
// the member following the sub-structure is rounded up to the next
// multiple of the base alignment of the structure.
RoundToPow2(size, maxAlignment);
return maxAlignment;
}
@ -982,7 +987,7 @@ int TIntermediate::getBaseAlignment(const TType& type, int& size, int& stride, b
// rules 5 and 7
if (type.isMatrix()) {
// rule 5: deref to row, not to column, meaning the size of vector is num columns instead of num rows
TType derefType(type, 0, type.getQualifier().layoutMatrix == ElmRowMajor);
TType derefType(type, 0, rowMajor);
alignment = getBaseAlignment(derefType, size, dummyStride, std140, rowMajor);
if (std140)

View File

@ -195,7 +195,7 @@ int TPpContext::ReadToken(TokenStream *pTok, TPpToken *ppToken)
case PpAtomConstUint:
len = 0;
ch = lReadByte(pTok);
while (ch != 0) {
while (ch != 0 && ch != EndOfInput) {
if (len < MaxTokenLength) {
tokenText[len] = (char)ch;
len++;
@ -215,12 +215,10 @@ int TPpContext::ReadToken(TokenStream *pTok, TPpToken *ppToken)
break;
case PpAtomConstFloat:
case PpAtomConstDouble:
strcpy(ppToken->name, tokenText);
ppToken->dval = atof(ppToken->name);
break;
case PpAtomConstInt:
case PpAtomConstUint:
strcpy(ppToken->name, tokenText);
if (len > 0 && tokenText[0] == '0') {
if (len > 1 && (tokenText[1] == 'x' || tokenText[1] == 'X'))
ppToken->ival = strtol(ppToken->name, 0, 16);

View File

@ -147,6 +147,8 @@ void OS_Sleep(int milliseconds)
Sleep(milliseconds);
}
//#define DUMP_COUNTERS
void OS_DumpMemoryCounters()
{
#ifdef DUMP_COUNTERS