diff options
author | greg-lunarg <greg@lunarg.com> | 2020-09-16 16:23:46 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-16 16:23:46 +0300 |
commit | 7e28d809c6e07c8171bd2eab7eb94fe9f3cb86ce (patch) | |
tree | 37c370396b311de6c610d92748d0695bcd6bebf8 /include | |
parent | 8fc504110a9bd7672d311bb6bad4b44b0b6b460f (diff) |
Add buffer oob check to bindless instrumentation (#3800)
Diffstat (limited to 'include')
-rw-r--r-- | include/spirv-tools/instrument.hpp | 26 | ||||
-rw-r--r-- | include/spirv-tools/optimizer.hpp | 2 |
2 files changed, 21 insertions, 7 deletions
diff --git a/include/spirv-tools/instrument.hpp b/include/spirv-tools/instrument.hpp index b4f33554d..9c01cb693 100644 --- a/include/spirv-tools/instrument.hpp +++ b/include/spirv-tools/instrument.hpp @@ -24,6 +24,7 @@ // // CreateInstBindlessCheckPass // CreateInstBuffAddrCheckPass +// CreateInstDebugPrintfPass // // More detailed documentation of these routines can be found in optimizer.hpp @@ -33,7 +34,7 @@ namespace spvtools { // // The following values provide offsets into the output buffer struct // generated by InstrumentPass::GenDebugStreamWrite. This method is utilized -// by InstBindlessCheckPass. +// by InstBindlessCheckPass, InstBuffAddrCheckPass, and InstDebugPrintfPass. // // The first member of the debug output buffer contains the next available word // in the data stream to be written. Shaders will atomically read and update @@ -138,12 +139,21 @@ static const int kInstValidationOutError = kInstStageOutCnt; // A bindless bounds error will output the index and the bound. static const int kInstBindlessBoundsOutDescIndex = kInstStageOutCnt + 1; static const int kInstBindlessBoundsOutDescBound = kInstStageOutCnt + 2; -static const int kInstBindlessBoundsOutCnt = kInstStageOutCnt + 3; +static const int kInstBindlessBoundsOutUnused = kInstStageOutCnt + 3; +static const int kInstBindlessBoundsOutCnt = kInstStageOutCnt + 4; -// A bindless uninitialized error will output the index. +// A descriptor uninitialized error will output the index. static const int kInstBindlessUninitOutDescIndex = kInstStageOutCnt + 1; static const int kInstBindlessUninitOutUnused = kInstStageOutCnt + 2; -static const int kInstBindlessUninitOutCnt = kInstStageOutCnt + 3; +static const int kInstBindlessUninitOutUnused2 = kInstStageOutCnt + 3; +static const int kInstBindlessUninitOutCnt = kInstStageOutCnt + 4; + +// A buffer out-of-bounds error will output the descriptor +// index, the buffer offset and the buffer size +static const int kInstBindlessBuffOOBOutDescIndex = kInstStageOutCnt + 1; +static const int kInstBindlessBuffOOBOutBuffOff = kInstStageOutCnt + 2; +static const int kInstBindlessBuffOOBOutBuffSize = kInstStageOutCnt + 3; +static const int kInstBindlessBuffOOBOutCnt = kInstStageOutCnt + 4; // A buffer address unalloc error will output the 64-bit pointer in // two 32-bit pieces, lower bits first. @@ -152,7 +162,7 @@ static const int kInstBuffAddrUnallocOutDescPtrHi = kInstStageOutCnt + 2; static const int kInstBuffAddrUnallocOutCnt = kInstStageOutCnt + 3; // Maximum Output Record Member Count -static const int kInstMaxOutCnt = kInstStageOutCnt + 3; +static const int kInstMaxOutCnt = kInstStageOutCnt + 4; // Validation Error Codes // @@ -160,6 +170,7 @@ static const int kInstMaxOutCnt = kInstStageOutCnt + 3; static const int kInstErrorBindlessBounds = 0; static const int kInstErrorBindlessUninit = 1; static const int kInstErrorBuffAddrUnallocRef = 2; +static const int kInstErrorBindlessBuffOOB = 3; // Direct Input Buffer Offsets // @@ -197,7 +208,10 @@ static const int kDebugOutputPrintfStream = 3; // At offset kDebugInputBindlessInitOffset in Data[] is a single uint which // gives an offset to the start of the bindless initialization data. More // specifically, if the following value is zero, we know that the descriptor at -// (set = s, binding = b, index = i) is not initialized: +// (set = s, binding = b, index = i) is not initialized; if the value is +// non-zero, and the descriptor points to a buffer, the value is the length of +// the buffer in bytes and can be used to check for out-of-bounds buffer +// references: // Data[ i + Data[ b + Data[ s + Data[ kDebugInputBindlessInitOffset ] ] ] ] static const int kDebugInputBindlessInitOffset = 0; diff --git a/include/spirv-tools/optimizer.hpp b/include/spirv-tools/optimizer.hpp index 741f9476d..d89d3b6fc 100644 --- a/include/spirv-tools/optimizer.hpp +++ b/include/spirv-tools/optimizer.hpp @@ -764,7 +764,7 @@ Optimizer::PassToken CreateCombineAccessChainsPass(); // initialization checking, both of which require input buffer support. Optimizer::PassToken CreateInstBindlessCheckPass( uint32_t desc_set, uint32_t shader_id, bool input_length_enable = false, - bool input_init_enable = false); + bool input_init_enable = false, bool input_buff_oob_enable = false); // Create a pass to instrument physical buffer address checking // This pass instruments all physical buffer address references to check that |