chromium/third_party/vulkan-validation-layers/src/layers/gpu/shaders/gpu_error_header.h

// Copyright (c) 2021-2024 The Khronos Group Inc.
// Copyright (c) 2021-2024 Valve Corporation
// Copyright (c) 2021-2024 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.
// Values used between the GLSL shaders and the GPU-AV logic

// NOTE: This header is included by the instrumentation shaders and glslang doesn't support #pragma once
#ifndef GPU_ERROR_HEADER_H
#define GPU_ERROR_HEADER_H

#include "gpu_error_codes.h"

#ifdef __cplusplus
namespace gpuav {
namespace glsl {
#endif

// GPU-AV Error record structure:
// ------------------------------

// /---------------------------------
// | Error header
// | 	- Record size
// |	- Shader Id
// |	- Instruction Id
// |	- Shader stage Id
// |	- Shader stage info (3 integers)
// |	- Action command index in command buffer
// |    - Command resources index
// | 	- Error group (Id unique to the shader/instrumentation code that wrote the error)
// |	- subcode (maps to VUIDs)
// | --------------------------------
// | Error specific parameters
// \---------------------------------

// Error Header offsets:
// ---------------------
// The following are offsets to fields common to all records

// Each record first contains the size of the record in 32-bit words, including
// the size word.
const int kHeaderErrorRecordSizeOffset =;

// This is the shader id passed by the layer when the instrumentation pass is
// created.
const int kHeaderShaderIdOffset =;

// This is the ordinal position of the instruction within the SPIR-V shader
// which generated the validation error.
const int kHeaderInstructionIdOffset =;

// 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.
const int kHeaderStageIdOffset =;  // Values come from SpvExecutionModel (See spirv.h):
// 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.
const int kHeaderStageInfoOffset_0 =;
const int kHeaderStageInfoOffset_1 =;
const int kHeaderStageInfoOffset_2 =;

const int kHeaderActionIdOffset =;
const int kHeaderCommandResourceIdOffset =;

// This identifies the validation error
// We use groups to more easily manage the many int values not conflicting
const int kHeaderErrorGroupOffset =;
const int kHeaderErrorSubCodeOffset =;

const int kHeaderSize =;

// Error specific parameters offsets:
// ----------------------------------

// Bindless
// ---

const int kInstBindlessDescSetOffset =;
const int kInstBindlessDescBindingOffset =;
const int kInstBindlessDescIndexOffset =;
const int kInstBindlessCustomOffset_0 =;
const int kInstBindlessCustomOffset_1 =;

// A bindless bounds error will output the index and the bound.
const int kInstBindlessBoundsDescSetOffset =;
const int kInstBindlessBoundsDescBindingOffset =;
const int kInstBindlessBoundsDescIndexOffset =;
const int kInstBindlessBoundsDescBoundOffset =;

// A descriptor uninitialized error will output the index.
const int kInstBindlessUninitDescSetOffset =;
const int kInstBindlessUninitBindingOffset =;
const int kInstBindlessUninitDescIndexOffset =;

// A buffer out-of-bounds error will output the descriptor
// index, the buffer offset and the buffer size
const int kInstBindlessBuffOOBDescSetOffset =;
const int kInstBindlessBuffOOBDescBindingOffset =;
const int kInstBindlessBuffOOBDescIndexOffset =;
const int kInstBindlessBuffOOBBuffOffOffset =;
const int kInstBindlessBuffOOBBuffSizeOffset =;

// Non-Bindless OOB
// ---

const int kInstNonBindlessOOBDescSetOffset =;
const int kInstNonBindlessOOBDescBindingOffset =;
const int kInstNonBindlessOOBDescIndexOffset =;
const int kInstNonBindlessOOBParamOffset0 =;
const int kInstNonBindlessOOBParamOffset1 =;

// Buffer device addresses
// ---
// A buffer address unalloc error will output the 64-bit pointer in
// two 32-bit pieces, lower bits first.
const int kInstBuffAddrUnallocDescPtrLoOffset =;
const int kInstBuffAddrUnallocDescPtrHiOffset =;
const int kInstBuffAddrAccessByteSizeOffset =;
const int kInstBuffAddrAccessInstructionOffset =;

// Ray query
// ---
const int kInstRayQueryParamOffset_0 =;

// Pre shaders
// ---
const int kPreActionParamOffset_0 =;
const int kPreActionParamOffset_1 =;

// Sizes/Counts
// -------------------
const int kErrorRecordSize =;
const int kErrorRecordCounts =;  // Maximum number of errors a command buffer can hold. Arbitrary value
const int kErrorBufferByteSize =;  // 2 * 4 bytes to store flags and errors count

#ifdef __cplusplus
}  // namespace glsl
#endif

// DebugPrintf
// ---
const int kDebugPrintfOutputBufferSize =;
const int kDebugPrintfOutputBufferData =;

#ifdef __cplusplus
}  // namespace gpuav
#endif
#endif