mirror of
https://github.com/johndoe6345789/SDL3CPlusPlus.git
synced 2026-04-26 22:54:59 +00:00
feat(render): Implement compatibility render graph with tonemapping options and logging enhancements
This commit is contained in:
@@ -1046,6 +1046,44 @@ local function resolve_boolean(value, fallback)
|
||||
return fallback
|
||||
end
|
||||
|
||||
local function build_compat_render_graph(enable_tonemap, exposure, gamma)
|
||||
local resources = {}
|
||||
local passes = {}
|
||||
|
||||
if enable_tonemap then
|
||||
resources.scene_hdr = {type = "color", format = "rgba16f", size = "swapchain"}
|
||||
table.insert(passes, {
|
||||
name = "scene",
|
||||
kind = "forward_plus",
|
||||
output = "scene_hdr",
|
||||
})
|
||||
table.insert(passes, {
|
||||
name = "tonemap",
|
||||
kind = "fullscreen",
|
||||
shader = "tonemap_fallback",
|
||||
input = "scene_hdr",
|
||||
output = "swapchain",
|
||||
settings = {
|
||||
exposure = exposure,
|
||||
gamma = gamma,
|
||||
curve = "aces",
|
||||
highlight_rolloff = 0.85,
|
||||
},
|
||||
})
|
||||
else
|
||||
table.insert(passes, {
|
||||
name = "scene",
|
||||
kind = "forward_plus",
|
||||
output = "swapchain",
|
||||
})
|
||||
end
|
||||
|
||||
return {
|
||||
resources = resources,
|
||||
passes = passes,
|
||||
}
|
||||
end
|
||||
|
||||
function get_render_graph()
|
||||
local atmospherics = {}
|
||||
local rendering = {}
|
||||
@@ -1070,11 +1108,17 @@ function get_render_graph()
|
||||
local enable_vxgi = resolve_boolean(rendering.enable_vxgi, false)
|
||||
local enable_depth_of_field = resolve_boolean(rendering.enable_depth_of_field, true)
|
||||
local enable_motion_blur = resolve_boolean(rendering.enable_motion_blur, true)
|
||||
local render_graph_profile = resolve_string(rendering.render_graph_profile, "compat")
|
||||
local pipeline_mode = resolve_string(rendering.pipeline, "deferred")
|
||||
local use_forward_plus = pipeline_mode == "forward_plus"
|
||||
or pipeline_mode == "forward+"
|
||||
or pipeline_mode == "forward"
|
||||
|
||||
if render_graph_profile ~= "full" then
|
||||
log_debug("Render graph profile '%s' using compatibility graph", render_graph_profile)
|
||||
return build_compat_render_graph(enable_tonemap, exposure, gamma)
|
||||
end
|
||||
|
||||
local passes = {
|
||||
{
|
||||
name = "shadow_csm",
|
||||
|
||||
@@ -360,6 +360,14 @@ void RenderCommandService::RecordRenderGraph(uint32_t imageIndex,
|
||||
}
|
||||
|
||||
std::string outputName = ResolvePassOutput(pass);
|
||||
if (logger_) {
|
||||
logger_->Trace("RenderCommandService", "RecordRenderGraph",
|
||||
"pass=" + pass.name +
|
||||
", kind=" + pass.kind +
|
||||
", scenePass=" + std::string(scenePass ? "true" : "false") +
|
||||
", shaderKey=" + (shaderKey.empty() ? "<none>" : shaderKey) +
|
||||
", output=" + (outputName.empty() ? "<none>" : outputName));
|
||||
}
|
||||
if (outputName.empty()) {
|
||||
if (logger_) {
|
||||
logger_->Warn("RenderCommandService: Render graph pass '" + pass.name + "' has no output");
|
||||
@@ -522,6 +530,11 @@ void RenderCommandService::RecordRenderGraph(uint32_t imageIndex,
|
||||
}
|
||||
} else {
|
||||
std::string inputName = ResolvePassInput(pass);
|
||||
if (logger_) {
|
||||
logger_->Trace("RenderCommandService", "RecordRenderGraph",
|
||||
"pass=" + pass.name +
|
||||
", input=" + (inputName.empty() ? "<none>" : inputName));
|
||||
}
|
||||
if (inputName == "swapchain" && outputSwapchain) {
|
||||
if (logger_) {
|
||||
logger_->Trace("RenderCommandService", "RecordRenderGraph",
|
||||
@@ -1270,7 +1283,7 @@ void main() {
|
||||
|
||||
ShaderPaths paths{};
|
||||
paths.vertexSource = kFullscreenVertex;
|
||||
if (shaderKey == "tonemap") {
|
||||
if (shaderKey == "tonemap" || shaderKey == "tonemap_fallback") {
|
||||
paths.fragmentSource = kTonemapFragment;
|
||||
} else {
|
||||
paths.fragmentSource = kPostProcessFragment;
|
||||
|
||||
Reference in New Issue
Block a user