Skip to content

Commit

Permalink
Cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
solidpixel committed Jan 23, 2025
1 parent 6c489d6 commit 06ffb25
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
14 changes: 10 additions & 4 deletions layer_gpu_support/source/layer_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ void LayerConfig::parse_serialization_options(
bool s_stream_tx_pre = s_stream.at("transfer").at("pre");
bool s_stream_tx_post = s_stream.at("transfer").at("post");

// Write after all options read from JSON so we know it parsed correctly
serialize_queues = (!s_none) && (s_all || s_queue);
serialize_dispatch_pre = (!s_none) && (s_all || s_stream_c_pre);
serialize_dispatch_post = (!s_none) && (s_all || s_stream_c_post);
Expand Down Expand Up @@ -93,15 +94,20 @@ void LayerConfig::parse_shader_options(
// Decode serialization state
json shader = config.at("shader");

shader_disable_program_cache = shader.at("disable_cache");
shader_disable_program_relaxed_precision = shader.at("disable_relaxed_precision");
shader_enable_program_fuzz_spirv_hash = shader.at("enable_spirv_fuzz");
bool disable_program_cache = shader.at("disable_cache");
bool disable_program_relaxed_precision = shader.at("disable_relaxed_precision");
bool enable_program_fuzz_spirv_hash = shader.at("enable_spirv_fuzz");

// Write after all options read from JSON so we know it parsed correctly
shader_disable_program_cache = disable_program_cache;
shader_disable_program_relaxed_precision = disable_program_relaxed_precision;
shader_enable_program_fuzz_spirv_hash = enable_program_fuzz_spirv_hash;

LAYER_LOG("Layer shader configuration");
LAYER_LOG("==========================");
LAYER_LOG(" - Disable binary cache: %d", shader_disable_program_cache);
LAYER_LOG(" - Disable relaxed precision %d", shader_disable_program_relaxed_precision);
LAYER_LOG(" - Enable SPIR-V fuzzer: %d", shader_enable_program_fuzz_spirv_hash);
LAYER_LOG(" - Enable SPIR-V hash fuzzer: %d", shader_enable_program_fuzz_spirv_hash);
}

/* See header for documentation. */
Expand Down
19 changes: 16 additions & 3 deletions layer_gpu_support/source/layer_device_functions_pipelines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,14 @@ static const std::map<uint32_t, size_t> SPIRV_DECORATE_OPCODES {
// Decoration IDs for interesting SPIR-V decorations
static const uint32_t SPIRV_DECORATE_RELAXED_PRECISION { 0 };

std::vector<uint32_t> remove_relaxed_precision(
/**
* @brief Modify a SPIR-V module to remove all use of relaxed precision.
*
* @param originalCode The original binary.
*
* @return The modified binary.
*/
static std::vector<uint32_t> remove_relaxed_precision(
const std::vector<uint32_t>& originalCode
) {
// This module assumes the input SPIR-V is valid
Expand Down Expand Up @@ -104,7 +111,14 @@ std::vector<uint32_t> remove_relaxed_precision(
return code;
}

std::vector<uint32_t> fuzz_spirv(
/**
* @brief Modify a SPIR-V module so it functionally the same with a different hash.
*
* @param originalCode The original binary.
*
* @return The modified binary.
*/
static std::vector<uint32_t> fuzz_spirv(
const std::vector<uint32_t>& originalCode
) {
// This module assumes the input SPIR-V is valid
Expand All @@ -117,7 +131,6 @@ std::vector<uint32_t> fuzz_spirv(
return code;
}


/* See Vulkan API for documentation. */
template<>
VKAPI_ATTR VkResult VKAPI_CALL layer_vkCreateShaderModule<user_tag>(
Expand Down

0 comments on commit 06ffb25

Please sign in to comment.