mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2024-11-30 06:50:06 +00:00
3d62cb8148
New version has additional word in stage-specific section. Also some changes in content for tesselation and compute shaders. Either version can be invoked at pass creation. This is done to ease integration and updating of validation layers. Version 1 is deprecated and eventually will go away. Also sneaking in fix to version 1 compute shaders.
217 lines
9.0 KiB
C++
217 lines
9.0 KiB
C++
// Copyright (c) 2018 The Khronos Group Inc.
|
|
// Copyright (c) 2018 Valve Corporation
|
|
// Copyright (c) 2018 LunarG Inc.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
#ifndef INCLUDE_SPIRV_TOOLS_INSTRUMENT_HPP_
|
|
#define INCLUDE_SPIRV_TOOLS_INSTRUMENT_HPP_
|
|
|
|
// Shader Instrumentation Interface
|
|
//
|
|
// This file provides an external interface for applications that wish to
|
|
// communicate with shaders instrumented by passes created by:
|
|
//
|
|
// CreateInstBindlessCheckPass
|
|
//
|
|
// More detailed documentation of this routine can be found in optimizer.hpp
|
|
|
|
namespace spvtools {
|
|
|
|
// Stream Output Buffer Offsets
|
|
//
|
|
// The following values provide offsets into the output buffer struct
|
|
// generated by InstrumentPass::GenDebugStreamWrite. This method is utilized
|
|
// by InstBindlessCheckPass.
|
|
//
|
|
// kInst2* values support version 2 of the output record format. These should
|
|
// be used if available and version 2 is enabled. Version 1 is DEPRECATED.
|
|
// Specifically, version 1 uses two words for the stage-specific section of
|
|
// the output record; version 2 uses three words.
|
|
//
|
|
// 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
|
|
// this value so as not to overwrite each others records. This value must be
|
|
// initialized to zero
|
|
static const int kDebugOutputSizeOffset = 0;
|
|
|
|
// The second member of the output buffer is the start of the stream of records
|
|
// written by the instrumented shaders. Each record represents a validation
|
|
// error. The format of the records is documented below.
|
|
static const int kDebugOutputDataOffset = 1;
|
|
|
|
// Common Stream Record Offsets
|
|
//
|
|
// The following are offsets to fields which are common to all records written
|
|
// to the output stream.
|
|
//
|
|
// Each record first contains the size of the record in 32-bit words, including
|
|
// the size word.
|
|
static const int kInstCommonOutSize = 0;
|
|
|
|
// This is the shader id passed by the layer when the instrumentation pass is
|
|
// created.
|
|
static const int kInstCommonOutShaderId = 1;
|
|
|
|
// This is the ordinal position of the instruction within the SPIR-V shader
|
|
// which generated the validation error.
|
|
static const int kInstCommonOutInstructionIdx = 2;
|
|
|
|
// This is the stage which generated the validation error. This word is used
|
|
// to determine the contents of the next two words in the record.
|
|
// 0:Vert, 1:TessCtrl, 2:TessEval, 3:Geom, 4:Frag, 5:Compute
|
|
static const int kInstCommonOutStageIdx = 3;
|
|
static const int kInstCommonOutCnt = 4;
|
|
|
|
// Stage-specific Stream Record Offsets
|
|
//
|
|
// Each stage will contain different values in the next set of words of the
|
|
// record used to identify which instantiation of the shader generated the
|
|
// validation error.
|
|
//
|
|
// Vertex Shader Output Record Offsets
|
|
static const int kInstVertOutVertexIndex = kInstCommonOutCnt;
|
|
static const int kInstVertOutInstanceIndex = kInstCommonOutCnt + 1;
|
|
static const int kInstVertOutUnused = kInstCommonOutCnt + 2;
|
|
|
|
// Frag Shader Output Record Offsets
|
|
static const int kInstFragOutFragCoordX = kInstCommonOutCnt;
|
|
static const int kInstFragOutFragCoordY = kInstCommonOutCnt + 1;
|
|
static const int kInstFragOutUnused = kInstCommonOutCnt + 2;
|
|
|
|
// Compute Shader Output Record Offsets
|
|
static const int kInstCompOutGlobalInvocationIdX = kInstCommonOutCnt;
|
|
static const int kInstCompOutGlobalInvocationIdY = kInstCommonOutCnt + 1;
|
|
static const int kInstCompOutGlobalInvocationIdZ = kInstCommonOutCnt + 2;
|
|
|
|
// Compute Shader Output Record Offsets - Version 1 (DEPRECATED)
|
|
static const int kInstCompOutGlobalInvocationId = kInstCommonOutCnt;
|
|
static const int kInstCompOutUnused = kInstCommonOutCnt + 1;
|
|
|
|
// Tessellation Control Shader Output Record Offsets
|
|
static const int kInstTessCtlOutInvocationId = kInstCommonOutCnt;
|
|
static const int kInstTessCtlOutPrimitiveId = kInstCommonOutCnt + 1;
|
|
static const int kInstTessCtlOutUnused = kInstCommonOutCnt + 2;
|
|
|
|
// Tessellation Eval Shader Output Record Offsets
|
|
static const int kInstTessEvalOutPrimitiveId = kInstCommonOutCnt;
|
|
static const int kInstTessEvalOutTessCoordU = kInstCommonOutCnt + 1;
|
|
static const int kInstTessEvalOutTessCoordV = kInstCommonOutCnt + 2;
|
|
|
|
// Tessellation Shader Output Record Offsets - Version 1 (DEPRECATED)
|
|
static const int kInstTessOutInvocationId = kInstCommonOutCnt;
|
|
static const int kInstTessOutUnused = kInstCommonOutCnt + 1;
|
|
|
|
// Geometry Shader Output Record Offsets
|
|
static const int kInstGeomOutPrimitiveId = kInstCommonOutCnt;
|
|
static const int kInstGeomOutInvocationId = kInstCommonOutCnt + 1;
|
|
static const int kInstGeomOutUnused = kInstCommonOutCnt + 2;
|
|
|
|
// Size of Common and Stage-specific Members
|
|
static const int kInstStageOutCnt = kInstCommonOutCnt + 2;
|
|
static const int kInst2StageOutCnt = kInstCommonOutCnt + 3;
|
|
|
|
// Validation Error Code Offset
|
|
//
|
|
// This identifies the validation error. It also helps to identify
|
|
// how many words follow in the record and their meaning.
|
|
static const int kInstValidationOutError = kInstStageOutCnt;
|
|
static const int kInst2ValidationOutError = kInst2StageOutCnt;
|
|
|
|
// Validation-specific Output Record Offsets
|
|
//
|
|
// Each different validation will generate a potentially different
|
|
// number of words at the end of the record giving more specifics
|
|
// about the validation error.
|
|
//
|
|
// 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 kInst2BindlessBoundsOutDescIndex = kInst2StageOutCnt + 1;
|
|
static const int kInst2BindlessBoundsOutDescBound = kInst2StageOutCnt + 2;
|
|
static const int kInst2BindlessBoundsOutCnt = kInst2StageOutCnt + 3;
|
|
|
|
// A bindless 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 kInst2BindlessUninitOutDescIndex = kInst2StageOutCnt + 1;
|
|
static const int kInst2BindlessUninitOutUnused = kInst2StageOutCnt + 2;
|
|
static const int kInst2BindlessUninitOutCnt = kInst2StageOutCnt + 3;
|
|
|
|
// DEPRECATED
|
|
static const int kInstBindlessOutDescIndex = kInstStageOutCnt + 1;
|
|
static const int kInstBindlessOutDescBound = kInstStageOutCnt + 2;
|
|
static const int kInstBindlessOutCnt = kInstStageOutCnt + 3;
|
|
|
|
// Maximum Output Record Member Count
|
|
static const int kInstMaxOutCnt = kInstStageOutCnt + 3;
|
|
static const int kInst2MaxOutCnt = kInst2StageOutCnt + 3;
|
|
|
|
// Validation Error Codes
|
|
//
|
|
// These are the possible validation error codes.
|
|
static const int kInstErrorBindlessBounds = 0;
|
|
static const int kInstErrorBindlessUninit = 1;
|
|
|
|
// Direct Input Buffer Offsets
|
|
//
|
|
// The following values provide member offsets into the input buffers
|
|
// consumed by InstrumentPass::GenDebugDirectRead(). This method is utilized
|
|
// by InstBindlessCheckPass.
|
|
//
|
|
// The only object in an input buffer is a runtime array of unsigned
|
|
// integers. Each validation will have its own formatting of this array.
|
|
static const int kDebugInputDataOffset = 0;
|
|
|
|
// Debug Buffer Bindings
|
|
//
|
|
// These are the bindings for the different buffers which are
|
|
// read or written by the instrumentation passes.
|
|
//
|
|
// This is the output buffer written by InstBindlessCheckPass
|
|
// and possibly other future validations.
|
|
static const int kDebugOutputBindingStream = 0;
|
|
|
|
// The binding for the input buffer read by InstBindlessCheckPass and
|
|
// possibly other future validations.
|
|
static const int kDebugInputBindingBindless = 1;
|
|
|
|
// Bindless Validation Input Buffer Format
|
|
//
|
|
// An input buffer for bindless validation consists of a single array of
|
|
// unsigned integers we will call Data[]. This array is formatted as follows.
|
|
//
|
|
// 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:
|
|
// Data[ i + Data[ b + Data[ s + Data[ kDebugInputBindlessInitOffset ] ] ] ]
|
|
static const int kDebugInputBindlessInitOffset = 0;
|
|
|
|
// DEPRECATED
|
|
static const int kDebugInputBindlessOffsetReserved = 0;
|
|
|
|
// At offset kDebugInputBindlessOffsetLengths is some number of uints which
|
|
// provide the bindless length data. More specifically, the number of
|
|
// descriptors at (set=s, binding=b) is:
|
|
// Data[ Data[ s + kDebugInputBindlessOffsetLengths ] + b ]
|
|
static const int kDebugInputBindlessOffsetLengths = 1;
|
|
|
|
} // namespace spvtools
|
|
|
|
#endif // INCLUDE_SPIRV_TOOLS_INSTRUMENT_HPP_
|