[vulkan] Add debug displays for lights and bsp

The lights debug is from the light splat experiment (this is why I kept
the code), and the bsp debug is based on that. Both currently disabled
for now until I get UI controls in.
This commit is contained in:
Bill Currie 2023-07-12 23:30:43 +09:00
parent 0a260129a8
commit 7642ef5758
5 changed files with 76 additions and 15 deletions

View File

@ -326,6 +326,8 @@ bsp_skyf_src = $(vkshaderpath)/bsp_sky.frag
bsp_skyf_c = $(vkshaderpath)/bsp_sky.frag.spvc
bsp_turbf_src = $(vkshaderpath)/bsp_turb.frag
bsp_turbf_c = $(vkshaderpath)/bsp_turb.frag.spvc
debug_src = $(vkshaderpath)/debug.frag
debug_c = $(vkshaderpath)/debug.frag.spvc
light_flat_src = $(vkshaderpath)/light_flat.vert
light_flat_c = $(vkshaderpath)/light_flat.vert.spvc
light_splatv_src = $(vkshaderpath)/light_splat.vert
@ -420,6 +422,8 @@ $(bsp_skyf_c): $(bsp_skyf_src) $(oit_store) $(oit_h)
$(bsp_turbf_c): $(bsp_turbf_src) $(oit_store) $(oit_h)
$(debug_c): $(debug_src) $(lighting_h)
$(light_flat_c): $(light_flat_src) $(lighting_h)
$(light_splatv_c): $(light_splatv_src) $(lighting_h)
@ -488,6 +492,7 @@ vkshader_c = \
$(bsp_shadow_c) \
$(bsp_skyf_c) \
$(bsp_turbf_c) \
$(debug_c) \
$(light_flat_c) \
$(light_splatv_c) \
$(light_splatf_c) \
@ -576,6 +581,7 @@ EXTRA_DIST += \
$(bsp_shadow_src) \
$(bsp_skyf_src) \
$(bsp_turbf_src) \
$(debug_src) \
$(light_flat_src) \
$(light_splatv_src) \
$(light_splatf_src) \

View File

@ -100,6 +100,15 @@ properties = {
depthBiasEnable = false;
lineWidth = 1;
};
debug_poly_lines = {
depthClampEnable = false;
rasterizerDiscardEnable = false;
polygonMode = line;
cullMode = none;
frontFace = clockwise;
depthBiasEnable = false;
lineWidth = 1;
};
cw_cull_back = {
depthClampEnable = false;
rasterizerDiscardEnable = false;
@ -228,6 +237,11 @@ properties = {
name = main;
module = $builtin/bsp_depth.vert;
};
debug_fragment = {
stage = fragment;
name = main;
module = $builtin/debug.frag;
};
gbuf_vertex = {
stage = vertex;
name = main;
@ -1499,8 +1513,44 @@ renderpasses = {
);
layout = $compose.layout;
};
/*debug = {
debug_bsp = {
@inherit = $compose_base;
disabled = true;
color = $color.bsp;
tasks = (
{ func = bsp_draw_queue;
params = (main, solid, 0); },
{ func = bsp_draw_queue;
params = (main, sky, 0); },
{ func = bsp_draw_queue;
params = (main, translucent, 0); },
{ func = bsp_draw_queue;
params = (main, turbulent, 0); },
);
stages = (
$brush.shader.depth_vertex,
$brush.shader.debug_fragment,
);
vertexInput = {
bindings = (
"$brush.vertexInput.bindings[0]",
"$brush.vertexInput.bindings[1]",
);
attributes = (
"$brush.vertexInput.attributes[0]",
"$brush.vertexInput.attributes[2]",
);
};
inputAssembly = $brush.inputAssembly;
layout = $brush.layout;
rasterization = $debug_poly_lines;
depthStencil = $depth_disable;
};
debug_lights = {
@inherit = $compose_base;
disabled = true;
color = $color.lights;
tasks = (
@ -1515,17 +1565,9 @@ renderpasses = {
vertexInput = $lighting.vertexInput_splat;
inputAssembly = $lighting.inputAssembly;
layout = $lighting.layout;
rasterization = {
depthClampEnable = false;
rasterizerDiscardEnable = false;
polygonMode = line;
cullMode = none;
frontFace = clockwise;
depthBiasEnable = false;
lineWidth = 1;
};
rasterization = $debug_poly_lines;
depthStencil = $depth_disable;
};*/
};
};
};
};

View File

@ -89,6 +89,8 @@ static
static
#include "libs/video/renderer/vulkan/shader/bsp_turb.frag.spvc"
static
#include "libs/video/renderer/vulkan/shader/debug.frag.spvc"
static
#include "libs/video/renderer/vulkan/shader/light_flat.vert.spvc"
static
#include "libs/video/renderer/vulkan/shader/light_splat.vert.spvc"
@ -163,6 +165,7 @@ static shaderdata_t builtin_shaders[] = {
{ "bsp_shadow.vert", bsp_shadow_vert, sizeof (bsp_shadow_vert) },
{ "bsp_sky.frag", bsp_sky_frag, sizeof (bsp_sky_frag) },
{ "bsp_turb.frag", bsp_turb_frag, sizeof (bsp_turb_frag) },
{ "debug.frag", debug_frag, sizeof (debug_frag) },
{ "light_flat.vert", light_flat_vert, sizeof (light_flat_vert) },
{ "light_splat.vert", light_splat_vert, sizeof (light_splat_vert) },
{ "light_splat.frag", light_splat_frag, sizeof (light_splat_frag) },

View File

@ -0,0 +1,10 @@
#version 450
#extension GL_GOOGLE_include_directive : enable
layout (location = 0) out vec4 frag_color;
void
main (void)
{
frag_color = gl_FrontFacing ? vec4 (0, 1, 0, 1) : vec4 (1, 0, 0, 1);
}

View File

@ -248,10 +248,10 @@ lighting_update_lights (const exprval_t **params, exprval_t *result,
QFV_PacketCopyBuffer (packet, lframe->data_buffer, 0,
&bufferBarriers[qfv_BB_TransferWrite_to_UniformRead]);
QFV_PacketSubmit (packet);
if (0) {
uint32_t id_count = lframe->ico_count + lframe->cone_count
+ lframe->flat_count;
if (id_count) {
packet = QFV_PacketAcquire (ctx->staging);
uint32_t id_count = lframe->ico_count + lframe->cone_count
+ lframe->flat_count;
uint32_t *ids = QFV_PacketExtend (packet, id_count * sizeof (uint32_t));
memcpy (ids, ico_ids, lframe->ico_count * sizeof (uint32_t));
ids += lframe->ico_count;
@ -335,7 +335,7 @@ lighting_bind_descriptors (const exprval_t **params, exprval_t *result,
};
dfunc->vkCmdBindDescriptorSets (cmd, VK_PIPELINE_BIND_POINT_GRAPHICS,
layout, 0, 3, sets, 0, 0);
if (0) {
if (1) {
VkBuffer buffers[] = {
lframe->id_buffer,
lctx->splat_verts,