Merge pull request #101 from asimplestray/feat/rt-miss-config

feat(shader): configurable ray tracing miss fallback
This commit is contained in:
boykopovar
2026-09-30 20:40:33 +03:00
committed by GitHub
6 changed files with 53 additions and 0 deletions
+8
View File
@@ -186,6 +186,14 @@ if(BUILD_TESTING)
set_tests_properties(shader_buffer_address PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
endif()
add_executable(ray_tracing_miss_tests tests/RayTracingMiss.cpp)
target_link_libraries(ray_tracing_miss_tests PRIVATE shader_recompiler_agc_driver libc)
configure_windows_unwind(ray_tracing_miss_tests)
add_test(NAME ray_tracing_miss COMMAND ray_tracing_miss_tests)
if(WIN32)
set_tests_properties(ray_tracing_miss PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
endif()
target_include_directories(guest_indexed_draw_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_indexed_draw_tests PRIVATE libSceAgc libSceAgcDriver libc)
configure_windows_unwind(guest_indexed_draw_tests)
+30
View File
@@ -0,0 +1,30 @@
#include "Translation/TranslationContext.hpp"
#include "RdnaDecoder/RdnaImageOpDecoder.hpp"
#include "Recompiler.hpp"
#include <array>
#include <stdexcept>
using namespace ShaderRecompiler;
static void Require(bool value) { if (!value) throw std::runtime_error("ray tracing miss regression"); }
int main() {
const std::array<std::uint32_t, 2> code{0xF1981F01u, 0x00000000u};
const RdnaInstruction instruction = DecodeRdnaMimg(0u, code, 0u);
Require(instruction.op == RdnaOpcode::ImageBvhIntersectRay);
Require(instruction.family == RdnaInstructionFamily::MIMG);
Require(IsImageOpcode(instruction.op));
IrProgram program;
auto& block = program.CreateBlock();
program.SetEntryBlock(block);
TranslationContext context(program, block, 256);
if (RayTracingStrict()) {
bool thrown = false;
try {
context.TranslateInstruction(instruction);
} catch (const std::runtime_error&) {
thrown = true;
}
Require(thrown);
} else {
context.TranslateInstruction(instruction);
}
}
+1
View File
@@ -33,6 +33,7 @@ public:
appendMesh(key, request);
append(key, request.target);
append(key, DebugProbeActive());
append(key, RayTracingStrict());
}
// A hash over every field Build appends except the code, the target and the probe flag: the
+1
View File
@@ -364,6 +364,7 @@ struct ResourceCapture;
// cache keys on it.
void SetDebugProbeActive(bool active);
[[nodiscard]] bool DebugProbeActive();
[[nodiscard]] bool RayTracingStrict();
struct RectListShaders {
RecompileResult control;
@@ -3,6 +3,7 @@
#include "Recompiler.hpp"
#include <atomic>
#include <cstdlib>
#include <cstring>
#include <stdexcept>
#include <string>
@@ -83,6 +84,14 @@ bool DebugProbeActive() {
return g_debugProbeActive.load();
}
bool RayTracingStrict() {
static const bool strict = [] {
const char* text = std::getenv("APS5_RAYTRACING");
return text != nullptr && std::strcmp(text, "strict") == 0;
}();
return strict;
}
DebugProbe DebugProbeConfig() {
static const DebugProbe parsed = [] {
DebugProbe result;
@@ -1,5 +1,6 @@
#include "Translation/MemoryInstructions.hpp"
#include "Translation/TranslationContext.hpp"
#include "Recompiler.hpp"
#include <stdexcept>
namespace ShaderRecompiler {
@@ -41,6 +42,9 @@ MemoryInfo imageMemoryInfoFromInstruction(const RdnaInstruction& inst) {
}
bool TranslationContext::imageBvhIntersectRay(const RdnaInstruction& inst) {
if (RayTracingStrict()) {
throw std::runtime_error("ray tracing is not implemented");
}
if (inst.dataDwordCount != 4u || inst.imageD16) {
throw std::runtime_error("image_bvh_intersect_ray returns four dwords");
}