File: ray_query.cpp

package info (click to toggle)
vulkan-validationlayers 1.4.341.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 54,356 kB
  • sloc: cpp: 675,478; python: 12,311; sh: 24; makefile: 24; xml: 14
file content (110 lines) | stat: -rw-r--r-- 5,832 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/* Copyright (c) 2024-2026 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.
 */

#include "gpuav/core/gpuav.h"
#include "gpuav/resources/gpuav_state_trackers.h"
#include "gpuav/shaders/gpuav_error_codes.h"
#include "gpuav/shaders/gpuav_error_header.h"

namespace gpuav {

void RegisterRayQueryValidation(Validator &gpuav, CommandBufferSubState &cb) {
    if (!gpuav.gpuav_settings.shader_instrumentation.ray_query) {
        return;
    }

    cb.on_instrumentation_error_logger_register_functions.emplace_back([](Validator &gpuav, CommandBufferSubState &cb,
                                                                          const LastBound &last_bound) {
        CommandBufferSubState::InstrumentationErrorLogger inst_error_logger = [](Validator &gpuav, const Location &loc,
                                                                                 const uint32_t *error_record,
                                                                                 std::string &out_error_msg,
                                                                                 std::string &out_vuid_msg) {
            using namespace glsl;
            bool error_found = false;
            if (GetErrorGroup(error_record) != kErrorGroup_InstRayQuery) {
                return error_found;
            }
            error_found = true;

            std::ostringstream strm;

            const uint32_t error_sub_code = GetSubError(error_record);

            switch (error_sub_code) {
                case kErrorSubCode_RayQuery_NegativeMin: {
                    // TODO - Figure a way to properly use GLSL floatBitsToUint and print the float values
                    strm << "OpRayQueryInitializeKHR operand Ray Tmin value is negative. ";
                    out_vuid_msg = "VUID-RuntimeSpirv-OpRayQueryInitializeKHR-06349";
                } break;
                case kErrorSubCode_RayQuery_NegativeMax: {
                    strm << "OpRayQueryInitializeKHR operand Ray Tmax value is negative. ";
                    out_vuid_msg = "VUID-RuntimeSpirv-OpRayQueryInitializeKHR-06349";
                } break;
                case kErrorSubCode_RayQuery_MinMax: {
                    strm << "OpRayQueryInitializeKHR operand Ray Tmax is less than RayTmin. ";
                    out_vuid_msg = "VUID-RuntimeSpirv-OpRayQueryInitializeKHR-06350";
                } break;
                case kErrorSubCode_RayQuery_MinNaN: {
                    strm << "OpRayQueryInitializeKHR operand Ray Tmin is NaN. ";
                    out_vuid_msg = "VUID-RuntimeSpirv-OpRayQueryInitializeKHR-06351";
                } break;
                case kErrorSubCode_RayQuery_MaxNaN: {
                    strm << "OpRayQueryInitializeKHR operand Ray Tmax is NaN. ";
                    out_vuid_msg = "VUID-RuntimeSpirv-OpRayQueryInitializeKHR-06351";
                } break;
                case kErrorSubCode_RayQuery_OriginNaN: {
                    strm << "OpRayQueryInitializeKHR operand Ray Origin contains a NaN. ";
                    out_vuid_msg = "VUID-RuntimeSpirv-OpRayQueryInitializeKHR-06351";
                } break;
                case kErrorSubCode_RayQuery_DirectionNaN: {
                    strm << "OpRayQueryInitializeKHR operand Ray Direction contains a NaN. ";
                    out_vuid_msg = "VUID-RuntimeSpirv-OpRayQueryInitializeKHR-06351";
                } break;
                case kErrorSubCode_RayQuery_OriginFinite: {
                    strm << "OpRayQueryInitializeKHR operand Ray Origin contains a non-finite value. ";
                    out_vuid_msg = "VUID-RuntimeSpirv-OpRayQueryInitializeKHR-06348";
                } break;
                case kErrorSubCode_RayQuery_DirectionFinite: {
                    strm << "OpRayQueryInitializeKHR operand Ray Direction contains a non-finite value. ";
                    out_vuid_msg = "VUID-RuntimeSpirv-OpRayQueryInitializeKHR-06348";
                } break;
                case kErrorSubCode_RayQuery_BothSkip: {
                    const uint32_t value = error_record[kInst_LogError_ParameterOffset_0];
                    strm << "OpRayQueryInitializeKHR operand Ray Flags is 0x" << std::hex << value << ". ";
                    out_vuid_msg = "VUID-RuntimeSpirv-OpRayQueryInitializeKHR-06889";
                } break;
                case kErrorSubCode_RayQuery_SkipCull: {
                    const uint32_t value = error_record[kInst_LogError_ParameterOffset_0];
                    strm << "OpRayQueryInitializeKHR operand Ray Flags is 0x" << std::hex << value << ". ";
                    out_vuid_msg = "VUID-RuntimeSpirv-OpRayQueryInitializeKHR-06890";
                } break;
                case kErrorSubCode_RayQuery_Opaque: {
                    const uint32_t value = error_record[kInst_LogError_ParameterOffset_0];
                    strm << "OpRayQueryInitializeKHR operand Ray Flags is 0x" << std::hex << value << ". ";
                    out_vuid_msg = "VUID-RuntimeSpirv-OpRayQueryInitializeKHR-06891";
                } break;
                default:
                    error_found = false;
                    break;
            }
            out_error_msg += strm.str();
            return error_found;
        };

        return inst_error_logger;
    });
}

}  // namespace gpuav