Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gpu: More pre-work to combine Printf and GPUAV #8611

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,6 @@ vvl_sources = [
"layers/gpu/cmd_validation/gpuav_trace_rays.h",
"layers/gpu/core/gpu_settings.h",
"layers/gpu/core/gpu_shader_cache_hash.h",
"layers/gpu/core/gpu_state_tracker.cpp",
"layers/gpu/core/gpu_state_tracker.h",
"layers/gpu/core/gpuav.h",
"layers/gpu/core/gpuav_constants.h",
"layers/gpu/core/gpuav_record.cpp",
Expand Down
2 changes: 0 additions & 2 deletions layers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,6 @@ target_sources(vvl PRIVATE
gpu/descriptor_validation/gpuav_image_layout.h
gpu/descriptor_validation/gpuav_image_layout.cpp
gpu/core/gpuav.h
gpu/core/gpu_state_tracker.cpp
gpu/core/gpu_state_tracker.h
gpu/core/gpuav_record.cpp
gpu/core/gpuav_setup.cpp
gpu/debug_printf/debug_printf.cpp
Expand Down
180 changes: 0 additions & 180 deletions layers/gpu/core/gpu_state_tracker.cpp

This file was deleted.

58 changes: 0 additions & 58 deletions layers/gpu/core/gpu_state_tracker.h

This file was deleted.

5 changes: 4 additions & 1 deletion layers/gpu/core/gpuav.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ class Validator : public gpu::GpuShaderInstrumentor {
using Field = vvl::Field;

public:
Validator() { container_type = LayerObjectTypeGpuAssisted; }
Validator() {
container_type = LayerObjectTypeGpuAssisted;
gpuav_enabled = true;
}

// gpuav_setup.cpp
// -------------
Expand Down
8 changes: 0 additions & 8 deletions layers/gpu/debug_printf/debug_printf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "generated/layer_chassis_dispatch.h"
#include "chassis/chassis_modification_state.h"
#include "gpu/shaders/gpu_error_header.h"
#include "vk_layer_config.h"

#include <iostream>

Expand All @@ -40,13 +39,6 @@ void Validator::PostCreateDevice(const VkDeviceCreateInfo *pCreateInfo, const Lo
return;
}

// This option was published when DebugPrintf came out, leave to not break people's flow
// Deprecated right after the 1.3.280 SDK release
if (!GetEnvironment("DEBUG_PRINTF_TO_STDOUT").empty()) {
InternalWarning(device, loc, "DEBUG_PRINTF_TO_STDOUT was set, this is deprecated, please use VK_LAYER_PRINTF_TO_STDOUT");
gpuav_settings.debug_printf_to_stdout = true;
}

debug_printf_binding_slot_ = (uint32_t)instrumentation_bindings_.size(); // get next free binding
instrumentation_bindings_.emplace_back(
VkDescriptorSetLayoutBinding{debug_printf_binding_slot_, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1,
Expand Down
7 changes: 5 additions & 2 deletions layers/gpu/debug_printf/debug_printf.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#pragma once

#include "gpu/core/gpu_state_tracker.h"
#include "gpu/resources/gpuav_subclasses.h"
#include "gpu/instrumentation/gpu_shader_instrumentor.h"
#include "gpu/resources/gpu_resources.h"

Expand Down Expand Up @@ -65,7 +65,10 @@ namespace debug_printf {
class Validator : public gpu::GpuShaderInstrumentor {
public:
using BaseClass = gpu::GpuShaderInstrumentor;
Validator() { container_type = LayerObjectTypeDebugPrintf; }
Validator() {
container_type = LayerObjectTypeDebugPrintf;
debug_printf_enabled = true;
}

void PreCallRecordCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo* pCreateInfo,
const VkAllocationCallbacks* pAllocator, VkDevice* pDevice, const RecordObject& record_obj,
Expand Down
20 changes: 13 additions & 7 deletions layers/gpu/instrumentation/gpu_shader_instrumentor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@

#include "gpu/instrumentation/gpu_shader_instrumentor.h"

#include "gpu/core/gpu_state_tracker.h"
#include "gpu/spirv/module.h"
#include "chassis/chassis_modification_state.h"
#include "gpu/shaders/gpu_error_codes.h"
#include "spirv-tools/optimizer.hpp"
#include "utils/vk_layer_utils.h"
#include "state_tracker/descriptor_sets.h"
#include "state_tracker/shader_object_state.h"
#include "vk_layer_config.h"

#include <cassert>
#include <regex>
Expand Down Expand Up @@ -261,6 +261,13 @@ void GpuShaderInstrumentor::PostCreateDevice(const VkDeviceCreateInfo *pCreateIn
return;
}

// This option was published when DebugPrintf came out, leave to not break people's flow
// Deprecated right after the 1.3.280 SDK release
if (!GetEnvironment("DEBUG_PRINTF_TO_STDOUT").empty()) {
InternalWarning(device, loc, "DEBUG_PRINTF_TO_STDOUT was set, this is deprecated, please use VK_LAYER_PRINTF_TO_STDOUT");
gpuav_settings.debug_printf_to_stdout = true;
}

// If api version 1.1 or later, SetDeviceLoaderData will be in the loader
auto chain_info = GetChainInfo(pCreateInfo, VK_LOADER_DATA_CALLBACK);
assert(chain_info->u.pfnSetDeviceLoaderData);
Expand Down Expand Up @@ -1362,7 +1369,7 @@ bool GpuShaderInstrumentor::InstrumentShader(const vvl::span<const uint32_t> &in
gpu::spirv::Module module(input_spirv, debug_report, module_settings);

// For now, we don't yet support (or have tested) combining GPU-AV and DebugPrintf, so have 2 paths here
const bool is_debug_printf = container_type == LayerObjectTypeDebugPrintf;
Copy link
Contributor

@arno-lunarg arno-lunarg Sep 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could just use debug_printf_enabled directly instead of is_debug_printf

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ya, we are going to need to change this from is_debug_printf to is_only_debug_printf anyways.. basically my main goal was to just remove anyone trying to read from LayerObjectTypeDebugPrintf lol

const bool is_debug_printf = debug_printf_enabled;

bool modified = false;
if (is_debug_printf) {
Expand Down Expand Up @@ -1486,9 +1493,8 @@ void GpuShaderInstrumentor::InternalError(LogObjectList objlist, const Location
vmaFreeStatsString(vma_allocator_, stats_string);
}

char const *layer_name = container_type == LayerObjectTypeDebugPrintf ? "DebugPrintf" : "GPU-AV";
char const *vuid =
container_type == LayerObjectTypeDebugPrintf ? "UNASSIGNED-DEBUG-PRINTF" : "UNASSIGNED-GPU-Assisted-Validation";
char const *layer_name = debug_printf_enabled ? "DebugPrintf" : "GPU-AV";
char const *vuid = debug_printf_enabled ? "UNASSIGNED-DEBUG-PRINTF" : "UNASSIGNED-GPU-Assisted-Validation";

LogError(vuid, objlist, loc, "Internal Error, %s is being disabled. Details:\n%s", layer_name, error_message.c_str());

Expand All @@ -1499,7 +1505,7 @@ void GpuShaderInstrumentor::InternalError(LogObjectList objlist, const Location
}

void GpuShaderInstrumentor::InternalWarning(LogObjectList objlist, const Location &loc, const char *const specific_message) const {
char const *vuid = container_type == LayerObjectTypeDebugPrintf ? "WARNING-DEBUG-PRINTF" : "WARNING-GPU-Assisted-Validation";
char const *vuid = debug_printf_enabled ? "WARNING-DEBUG-PRINTF" : "WARNING-GPU-Assisted-Validation";
LogWarning(vuid, objlist, loc, "Internal Warning: %s", specific_message);
}

Expand Down Expand Up @@ -1750,7 +1756,7 @@ std::string GpuShaderInstrumentor::GenerateDebugInfoMessage(
}

std::string prefix;
if (container_type == LayerObjectTypeDebugPrintf) {
if (debug_printf_enabled) {
prefix = "Debug shader printf message generated ";
} else {
prefix = "Shader validation error occurred ";
Expand Down
Loading
Loading