mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-04 17:10:47 +00:00
Don't allow direct == or != on SPIRVIterator, use <
* The reason is if comparing directly against the end of a section, we could skip over it if the section ends in a nop and the next section starts in a nop. Instead < will always work as expected.
This commit is contained in:
@@ -325,7 +325,7 @@ SPIRVIterator SPIRVEditor::GetEntry(SPIRVId id)
|
||||
SPIRVIterator it(spirv, entryPointSection.startOffset);
|
||||
SPIRVIterator end(spirv, entryPointSection.endOffset);
|
||||
|
||||
while(it && it != end)
|
||||
while(it && it < end)
|
||||
{
|
||||
if(it.word(2) == id)
|
||||
return it;
|
||||
|
||||
@@ -77,11 +77,9 @@ public:
|
||||
|
||||
return *this;
|
||||
}
|
||||
bool operator==(const SPIRVIterator &it) const
|
||||
{
|
||||
return words == it.words && offset == it.offset;
|
||||
}
|
||||
bool operator!=(const SPIRVIterator &it) const { return !(*this == it); }
|
||||
bool operator==(const SPIRVIterator &it) const = delete;
|
||||
bool operator!=(const SPIRVIterator &it) const = delete;
|
||||
bool operator<(const SPIRVIterator &it) const { return words == it.words && offset < it.offset; }
|
||||
// utility functions
|
||||
explicit operator bool() const { return words != NULL && offset < words->size(); }
|
||||
uint32_t &operator*() { return cur(); }
|
||||
|
||||
@@ -49,7 +49,7 @@ static void ConvertToMeshOutputCompute(const ShaderReflection &refl, const SPIRV
|
||||
|
||||
descSet = 0;
|
||||
|
||||
for(SPIRVIterator it = editor.BeginDecorations(), end = editor.EndDecorations(); it != end; ++it)
|
||||
for(SPIRVIterator it = editor.BeginDecorations(), end = editor.EndDecorations(); it < end; ++it)
|
||||
{
|
||||
// we will use the descriptor set immediately after the last set statically used by the shader.
|
||||
// This means we don't have to worry about if the descriptor set layout declares more sets which
|
||||
@@ -103,7 +103,7 @@ static void ConvertToMeshOutputCompute(const ShaderReflection &refl, const SPIRV
|
||||
std::map<SPIRVId, SPIRVId> typeReplacements;
|
||||
|
||||
// rewrite any inputs and outputs to be private storage class
|
||||
for(SPIRVIterator it = editor.BeginTypes(), end = editor.EndTypes(); it != end; ++it)
|
||||
for(SPIRVIterator it = editor.BeginTypes(), end = editor.EndTypes(); it < end; ++it)
|
||||
{
|
||||
// rewrite any input/output variables to private, and build up inputs/outputs list
|
||||
if(it.opcode() == spv::OpTypePointer)
|
||||
@@ -246,7 +246,7 @@ static void ConvertToMeshOutputCompute(const ShaderReflection &refl, const SPIRV
|
||||
}
|
||||
|
||||
// detect builtin inputs or outputs, and remove builtin decorations
|
||||
for(SPIRVIterator it = editor.BeginDecorations(), end = editor.EndDecorations(); it != end; ++it)
|
||||
for(SPIRVIterator it = editor.BeginDecorations(), end = editor.EndDecorations(); it < end; ++it)
|
||||
{
|
||||
// remove any builtin decorations
|
||||
if(it.opcode() == spv::OpDecorate && it.word(2) == spv::DecorationBuiltIn)
|
||||
@@ -335,7 +335,7 @@ static void ConvertToMeshOutputCompute(const ShaderReflection &refl, const SPIRV
|
||||
|
||||
RDCASSERT(entryID);
|
||||
|
||||
for(SPIRVIterator it = editor.BeginDebug(), end2 = editor.EndDebug(); it != end2; ++it)
|
||||
for(SPIRVIterator it = editor.BeginDebug(), end2 = editor.EndDebug(); it < end2; ++it)
|
||||
{
|
||||
if(it.opcode() == spv::OpName &&
|
||||
(inputs.find(it.word(1)) != inputs.end() || outputs.find(it.word(1)) != outputs.end()))
|
||||
@@ -659,7 +659,7 @@ static void ConvertToMeshOutputCompute(const ShaderReflection &refl, const SPIRV
|
||||
++it;
|
||||
}
|
||||
|
||||
for(SPIRVIterator end = editor.EndEntries(); it != end; ++it)
|
||||
for(SPIRVIterator end = editor.EndEntries(); it < end; ++it)
|
||||
editor.Remove(it);
|
||||
|
||||
editor.AddOperation(
|
||||
|
||||
Reference in New Issue
Block a user