From 260a10d75cf31cd252a012d2573a5c37334fd0bb Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sun, 2 Jul 2023 18:31:22 +0900 Subject: [PATCH] [vulkan] Add a very basic forward rendering pass It's not fully compliant yet, but it sorta kinda maybe worked on my pinebook (still slow, but no hardware vulkan :( ) --- libs/video/renderer/Makemodule.am | 4 + libs/video/renderer/vulkan/rp_main_fwd.plist | 1455 ++++++++++++++++++ libs/video/renderer/vulkan/vkparse.c | 4 + 3 files changed, 1463 insertions(+) create mode 100644 libs/video/renderer/vulkan/rp_main_fwd.plist diff --git a/libs/video/renderer/Makemodule.am b/libs/video/renderer/Makemodule.am index 1be6135f0..bf27d7f55 100644 --- a/libs/video/renderer/Makemodule.am +++ b/libs/video/renderer/Makemodule.am @@ -194,6 +194,8 @@ libs_video_renderer_librender_sw_la_SOURCES = \ rp_main_def_src = libs/video/renderer/vulkan/rp_main_def.plist rp_main_def_gen = libs/video/renderer/vulkan/rp_main_def.plc +rp_main_fwd_src = libs/video/renderer/vulkan/rp_main_fwd.plist +rp_main_fwd_gen = libs/video/renderer/vulkan/rp_main_fwd.plc smp_quake_src = libs/video/renderer/vulkan/smp_quake.plist smp_quake_gen = libs/video/renderer/vulkan/smp_quake.plc @@ -254,6 +256,7 @@ libs/video/renderer/vulkan/vkparse.lo: \ libs/video/renderer/vulkan/vkparse.c \ $(vkparse_src) \ $(rp_main_def_gen) \ + $(rp_main_fwd_gen) \ $(smp_quake_gen) libs/video/renderer/vulkan/shader.lo: \ @@ -531,6 +534,7 @@ EXTRA_DIST += \ libs/video/renderer/vulkan/vkparse.plist \ libs/video/renderer/vulkan/vkparse.h \ $(rp_main_def_src) \ + $(rp_main_fwd_src) \ $(smp_quake_src) \ $(oit_blend) \ $(oit_store) \ diff --git a/libs/video/renderer/vulkan/rp_main_fwd.plist b/libs/video/renderer/vulkan/rp_main_fwd.plist new file mode 100644 index 000000000..38c41d315 --- /dev/null +++ b/libs/video/renderer/vulkan/rp_main_fwd.plist @@ -0,0 +1,1455 @@ +properties = { + color = { + bsp = "[0.0, 0.5, 0.6, 1]"; + alias = "[0.6, 0.5, 0.0, 1]"; + iqm = "[0.6, 0.5, 0.0, 1]"; + sprite = "[0.6, 0.5, 0.0, 1]"; + particles = "[0.4, 0.5, 0.8, 1]"; + lights = "[0.8, 0.6, 0.2, 1]"; + compose = "[0.7, 0.7, 0.7, 1]"; + + output = "[0.0, 0.7, 0.7, 1]"; + waterwarp = "[0.0, 0.7, 0.7, 1]"; + fisheye = "[0.0, 0.7, 0.7, 1]"; + slice = "[0.8, 0.7, 0.2, 1]"; + lines = "[0.8, 0.7, 0.4, 1]"; + }; + color_dependency = { + src = { + stage = color_attachment_output; + access = color_attachment_write; + }; + dst = { + stage = fragment_shader; + access = input_attachment_read; + }; + flags = by_region; + }; + depth_dependency = { + src = { + stage = late_fragment_tests; + access = depth_stencil_attachment_write; + }; + dst = { + stage = fragment_shader|early_fragment_tests; + access = input_attachment_read|depth_stencil_attachment_read; + }; + flags = by_region; + }; + image_base = { + imageType = `2d; + samples = 1; + extent = { + width = $render_output.extent.width; + height = $render_output.extent.height; + depth = 1; + }; + mipLevels = 1; + arrayLayers = 1; + tiling = optimal; + usage = color_attachment|input_attachment|transient_attachment; + initialLayout = undefined; + }; + cube_image_base = { + @inherit = $image_base; + extent = { + width = "min($render_output.extent.width,$render_output.extent.height)"; + height = "min($render_output.extent.width,$render_output.extent.height)"; + depth = 1; + }; + arrayLayers = 6; + }; + view_base = { + viewType = `2d; + components = { + r = identity; + g = identity; + b = identity; + a = identity; + }; + subresourceRange = { + aspectMask = color; + levelCount = 1; + layerCount = 1; + }; + }; + cube_view_base = { + @inherit = $view_base; + viewType = `2d_array; + subresourceRange = { + layerCount = 6; + }; + }; + attachment_base = { + samples = 1; + loadOp = dont_care; + storeOp = dont_care; + stencilLoadOp = dont_care; + stencilStoreOp = dont_care; + initialLayout = undefined; + finalLayout = color_attachment_optimal; + clearValue = { color = "[0, 0, 0, 1]"; }; + }; + + no_cull = { + depthClampEnable = false; + rasterizerDiscardEnable = false; + polygonMode = fill; + cullMode = none; + frontFace = counter_clockwise; + depthBiasEnable = false; + lineWidth = 1; + }; + cw_cull_back = { + depthClampEnable = false; + rasterizerDiscardEnable = false; + polygonMode = fill; + cullMode = back; + frontFace = clockwise; + depthBiasEnable = false; + lineWidth = 1; + }; + counter_cw_cull_back = { + depthClampEnable = false; + rasterizerDiscardEnable = false; + polygonMode = fill; + cullMode = back; + frontFace = counter_clockwise; + depthBiasEnable = false; + lineWidth = 1; + }; + depth_test_and_write = { + depthTestEnable = true; + depthWriteEnable = true; + depthCompareOp = less_or_equal; + depthBoundsTestEnable = false; + stencilTestEnable = false; + }; + depth_test_only = { + depthTestEnable = true; + depthWriteEnable = false; + depthCompareOp = less_or_equal; + depthBoundsTestEnable = false; + stencilTestEnable = false; + }; + depth_test_only_reverse = { + depthTestEnable = true; + depthWriteEnable = false; + depthCompareOp = greater; + depthBoundsTestEnable = false; + stencilTestEnable = false; + }; + depth_disable = { + depthTestEnable = false; + depthWriteEnable = false; + depthCompareOp = less_or_equal; + depthBoundsTestEnable = false; + stencilTestEnable = false; + }; + blend_disable = { + blendEnable = false; + srcColorBlendFactor = src_alpha; + dstColorBlendFactor = one_minus_src_alpha; + colorBlendOp = add; + srcAlphaBlendFactor = src_alpha; + dstAlphaBlendFactor = one_minus_src_alpha; + alphaBlendOp = add; + colorWriteMask = r|g|b|a; + }; + alpha_blend = { + blendEnable = true; + srcColorBlendFactor = one; + dstColorBlendFactor = one_minus_src_alpha; + colorBlendOp = add; + srcAlphaBlendFactor = one; + dstAlphaBlendFactor = one_minus_src_alpha; + alphaBlendOp = add; + colorWriteMask = r|g|b|a; + }; + additive_blend = { + blendEnable = true; + srcColorBlendFactor = one; + dstColorBlendFactor = one; + colorBlendOp = add; + srcAlphaBlendFactor = zero; + dstAlphaBlendFactor = one; + alphaBlendOp = add; + colorWriteMask = r|g|b|a; + }; + pipeline_base = { + viewport = { + viewports = ( + { + x = 0; y = 0; + width = 640; height = 480; + minDepth = 0; maxDepth = 1; + } + ); + scissors = ( + { + offset = { x = 0; y = 0; }; + extent = { width = 640; height = 480; }; + }, + ); + }; + rasterization = $cw_cull_back; + multisample = { + rasterizationSamples = $msaaSamples; + sampleShadingEnable = false; + minSampleShading = 0.5f; + alphaToCoverageEnable = false; + alphaToOneEnable = false; + }; + depthStencil = $depth_test_only; + colorBlend = { + logicOpEnable = false; + }; + dynamic = { + dynamicState = ( viewport, scissor ); + }; + }; + compose_base = { + @inherit = $pipeline_base; + rasterization = $counter_cw_cull_back; + vertexInput = { + bindings = (); + attributes = (); + }; + inputAssembly = { + topology = triangle_list; + primitiveRestartEnable = false; + }; + }; + + brush = { + shader = { + depth_vertex = { + stage = vertex; + name = main; + module = $builtin/bsp_depth.vert; + }; + gbuf_vertex = { + stage = vertex; + name = main; + module = $builtin/bsp_gbuf.vert; + }; + gbuf_geometry = { + stage = geometry; + name = main; + module = $builtin/bsp_gbuf.geom; + }; + gbuf_fragment = { + stage = fragment; + name = main; + module = $builtin/bsp_gbuf.frag; + }; + quake_vertex = { + stage = vertex; + name = main; + module = $builtin/quakebsp.vert; + }; + sky_specialization = { + mapEntries = ( + // doSkyBox + { size = 4; offset = 0; constantID = 0; }, + // doSkySheet + { size = 4; offset = 4; constantID = 1; }, + ); + }; + skybox_fragment = { + stage = fragment; + name = main; + module = $builtin/bsp_sky.frag; + specializationInfo = { + @inherit = $brush.shader.sky_specialization; + // doSkyBox, doSkySheet + data = "array(1, 0)"; + }; + }; + skysheet_fragment = { + stage = fragment; + name = main; + module = $builtin/bsp_sky.frag; + specializationInfo = { + @inherit = $brush.shader.sky_specialization; + // doSkyBox, doSkySheet + data = "array(0, 1)"; + }; + }; + turb_fragment = { + stage = fragment; + name = main; + module = $builtin/bsp_turb.frag; + }; + }; + vertexInput = { + bindings = ( + { binding = 0; stride = "2 * 4 * 4"; inputRate = vertex; }, + { binding = 1; stride = "4"; inputRate = instance; }, + ); + attributes = ( + { location = 0; binding = 0; format = r32g32b32a32_sfloat; offset = 0; }, + { location = 1; binding = 0; format = r32g32b32a32_sfloat; offset = 16; }, + { location = 2; binding = 1; format = r32_uint; offset = 0; }, + ); + }; + inputAssembly = { + topology = triangle_fan; + primitiveRestartEnable = true; + }; + layout = { + descriptorSets = (matrix_set, entity_set, oit_set, + // surface skybox + texture_set, texture_set); + pushConstants = { + fragment = { + fog = vec4; + time = float; + alpha = float; + turb_scale = float; + }; + }; + }; + }; + alias = { + shader = { + depth_vertex = { + stage = vertex; + name = main; + module = $builtin/alias_depth.vert; + }; + gbuf_vertex = { + stage = vertex; + name = main; + module = $builtin/alias.vert; + }; + gbuf_fragment = { + stage = fragment; + name = main; + module = $builtin/alias_gbuf.frag; + }; + }; + vertexInput = { + bindings = ( + { binding = 0; stride = "2 * 4 * 4"; inputRate = vertex; }, + { binding = 1; stride = "2 * 4 * 4"; inputRate = vertex; }, + { binding = 2; stride = "2 * 4"; inputRate = vertex; }, + ); + attributes = ( + { location = 0; binding = 0; format = r32g32b32a32_sfloat; offset = 0; }, + { location = 1; binding = 0; format = r32g32b32a32_sfloat; offset = 16; }, + { location = 2; binding = 1; format = r32g32b32a32_sfloat; offset = 0; }, + { location = 3; binding = 1; format = r32g32b32a32_sfloat; offset = 16; }, + { location = 4; binding = 2; format = r32g32_sfloat; offset = 0; }, + ); + }; + inputAssembly = { + topology = triangle_list; + primitiveRestartEnable = false; + }; + layout = { + // palette skin + descriptorSets = (matrix_set, texture_set, texture_set); + pushConstants = { + vertex = { Model = mat4; blend = float; }; + fragment = { colors = uint; base_color = vec4; fog = vec4; }; + }; + }; + }; + iqm = { + shader = { + specialization = { + mapEntries = ( + // IQMDepthOnly + { size = 4; offset = 0; constantID = 0; }, + ); + }; + depth_vertex = { + stage = vertex; + name = main; + module = $builtin/iqm.vert; + specializationInfo = { + @inherit = $iqm.shader.specialization; + // IQMDepthOnly + data = "array(1)"; + }; + }; + gbuf_vertex = { + stage = vertex; + name = main; + module = $builtin/iqm.vert; + specializationInfo = { + @inherit = $iqm.shader.specialization; + // IQMDepthOnly + data = "array(0)"; + }; + }; + gbuf_fragment = { + stage = fragment; + name = main; + module = $builtin/iqm.frag; + }; + }; + vertexInput = { + bindings = ( + { binding = 0; stride = 20; inputRate = vertex; }, + { binding = 1; stride = 40; inputRate = vertex; }, + ); + attributes = ( + { location = 0; binding = 0; format = r32g32b32_sfloat; offset = 0; }, // position + { location = 1; binding = 0; format = r8g8b8a8_uint; offset = 12; }, // bonindices + { location = 2; binding = 0; format = r8g8b8a8_unorm; offset = 16; }, // boneweights + + { location = 3; binding = 1; format = r32g32_sfloat; offset = 0; }, // texcoord + { location = 4; binding = 1; format = r32g32b32_sfloat; offset = 8; }, // normal + { location = 5; binding = 1; format = r32g32b32a32_sfloat; offset = 20; }, // tangent + { location = 6; binding = 1; format = r8g8b8a8_unorm; offset = 36; }, // color + + ); + }; + inputAssembly = { + topology = triangle_list; + primitiveRestartEnable = false; + }; + layout = { + // skin + descriptorSets = (matrix_set, texture_set, bone_set); + pushConstants = { + vertex = { + Model = mat4; + blend = float; + }; + fragment = { + colorA = uint; + colorB = uint; + base_color = vec4; + fog = vec4; + }; + }; + }; + }; + sprite = { + shader = { + depth_vertex = { + stage = vertex; + name = main; + module = $builtin/sprite_depth.vert; + }; + depth_fragment = { + stage = fragment; + name = main; + module = $builtin/sprite_depth.frag; + }; + gbuf_vertex = { + stage = vertex; + name = main; + module = $builtin/sprite_gbuf.vert; + }; + gbuf_fragment = { + stage = fragment; + name = main; + module = $builtin/sprite_gbuf.frag; + }; + }; + vertexInput = { + bindings = (); + attributes = (); + }; + inputAssembly = { + topology = triangle_strip; + // never draw more than 4 verts + primitiveRestartEnable = false; + }; + layout = { + descriptorSets = (matrix_set, sprite_set); + pushConstants = { + vertex = { + Model = mat4; + frame = int; + }; + fragment = { + overlap = { offset = 64; type = int; }; + frame = int; + spriteind = int; + fog = vec4; + }; + }; + }; + }; + particle = { + shader = { + vertex = { + stage = vertex; + name = main; + module = $builtin/particle.vert; + }; + geometry = { + stage = geometry; + name = main; + module = $builtin/particle.geom; + }; + fragment = { + stage = fragment; + name = main; + module = $builtin/particle.frag; + }; + }; + vertexInput = { + bindings = ( + { binding = 0; stride = "4 * 4 * 4"; inputRate = instance; }, + ); + attributes = ( + { location = 0; binding = 0; format = r32g32b32a32_sfloat; offset = 0; }, + { location = 1; binding = 0; format = r32g32b32a32_sfloat; offset = 16; }, + { location = 2; binding = 0; format = r32g32b32a32_sfloat; offset = 32; }, + { location = 3; binding = 0; format = r32g32b32a32_sfloat; offset = 48; }, + ); + }; + inputAssembly = { + topology = point_list; + primitiveRestartEnable = false; + }; + layout = { + draw = { + // palette + descriptorSets = (matrix_set, texture_set, oit_set); + pushConstants = { + vertex = { Model = mat4; }; + }; + }; + physics = { + descriptorSets = (particle_set); + pushConstants = { + compute = { gravity = vec4; dT = float; }; + }; + }; + update = { + // cur in new + descriptorSets = (particle_set, particle_set, particle_set); + }; + }; + }; + fstriangle = { + shader = { + vertex = { + stage = vertex; + name = main; + module = $builtin/fstriangle.vert; + }; + vertexst = { + stage = vertex; + name = main; + module = $builtin/fstrianglest.vert; + }; + }; + }; + lighting = { + shader = { + vertex_splat = { + stage = vertex; + name = main; + module = $builtin/light_splat.vert; + }; + vertex_flat = { + stage = vertex; + name = main; + module = $builtin/light_flat.vert; + }; + fragment_splat = { + stage = fragment; + name = main; + module = $builtin/light_splat.frag; + }; + fragment = { + stage = fragment; + name = main; + module = $builtin/lighting.frag; + }; + debug_fragment = { + stage = fragment; + name = main; + module = $builtin/light_debug.frag; + }; + }; + vertexInput_splat = { + bindings = ( + { binding = 0; stride = "4"; inputRate = instance; }, + { binding = 1; stride = "3 * 4"; inputRate = vertex; }, + ); + attributes = ( + { location = 0; binding = 0; format = r32_uint; offset = 0; }, + { location = 1; binding = 1; format = r32g32b32_sfloat; offset = 0; }, + ); + }; + vertexInput_flat = { + bindings = ( + { binding = 0; stride = "4"; inputRate = instance; }, + ); + attributes = ( + { location = 0; binding = 0; format = r32_uint; offset = 0; }, + ); + }; + inputAssembly = { + topology = triangle_fan; + primitiveRestartEnable = true; + }; + layout = { + descriptorSets = (matrix_set, lighting_lights, + lighting_attach, lighting_shadow); + }; + }; + compose = { + shader = { + fragment = { + stage = fragment; + name = main; + module = $builtin/compose.frag; + }; + }; + layout = { + descriptorSets = (compose_attach, oit_set); + }; + }; + output = { + @inherit = $compose_base; + shader = { + fragment = { + stage = fragment; + name = main; + module = $builtin/output.frag; + }; + }; + layout = { + descriptorSets = (matrix_set, output_set); + }; + }; + waterwarp = { + @inherit = $compose_base; + shader = { + fragment = { + stage = fragment; + name = main; + module = $builtin/waterwarp.frag; + }; + }; + layout = { + descriptorSets = (matrix_set, output_set); + pushConstants = { + fragment = { time = float; }; + }; + }; + }; + fisheye = { + @inherit = $compose_base; + shader = { + fragment = { + stage = fragment; + name = main; + module = $builtin/fisheye.frag; + }; + }; + layout = { + descriptorSets = (matrix_set, output_set); + pushConstants = { + fragment = { fov = float; aspect = float; }; + }; + }; + }; + slice = { + shader = { + vertex = { + stage = vertex; + name = main; + module = $builtin/slice.vert; + }; + fragment = { + stage = fragment; + name = main; + module = $builtin/twod.frag; + }; + }; + vertexInput = { + bindings = ( + { binding = 0; stride = "4 + 4 + 4*4"; inputRate = instance; }, + ); + attributes = ( + // 9-slice index + { location = 0; binding = 0; format = r32_uint; offset = 0; }, + // 9-slice color + { location = 1; binding = 0; format = r8g8b8a8_unorm; offset = 4; }, + // 9-slice position (2d) + { location = 2; binding = 0; format = r32g32_sfloat; offset = 8; }, + // 9-slice size delta (2d) + { location = 3; binding = 0; format = r32g32_sfloat; offset = 16; }, + ); + }; + inputAssembly = { + topology = triangle_strip; + primitiveRestartEnable = true; + }; + layout = { + descriptorSets = (matrix_set, quad_data_set); + }; + }; + lines = { + shader = { + vertex = { + stage = vertex; + name = main; + module = $builtin/line.vert; + }; + fragment = { + stage = fragment; + name = main; + module = $builtin/line.frag; + }; + }; + vertexInput = { + bindings = ( + { binding = 0; stride = "2 * 4 + 4"; inputRate = vertex; }, + ); + attributes = ( + { location = 0; binding = 0; format = r32g32_sfloat; offset = 0; }, + { location = 1; binding = 0; format = r8g8b8a8_unorm; offset = 4; }, + ); + }; + inputAssembly = { + topology = line_list; + primitiveRestartEnable = false; + }; + layout = { + descriptorSets = (matrix_set); + }; + }; +}; +descriptorSetLayouts = { + matrix_set = { + bindings = ( + { + binding = 0; + descriptorType = uniform_buffer; + descriptorCount = 1; + stageFlags = vertex|geometry|fragment; + }, + ); + }; + quad_data_set = { + bindings = ( + { + // glyph texture data + binding = 0; + descriptorType = combined_image_sampler; + descriptorCount = 1; + stageFlags = fragment; + }, + { + // glyph geometry data (offset and uv) + binding = 1; + descriptorType = uniform_texel_buffer; + descriptorCount = 1; + stageFlags = vertex; + }, + ); + }; + texture_set = { + bindings = ( + { + binding = 0; + descriptorType = combined_image_sampler; + descriptorCount = 1; + stageFlags = fragment|vertex; + }, + ); + }; + oit_set = { + bindings = ( + { + binding = 0; + descriptorType = storage_buffer; + descriptorCount = 1; + stageFlags = fragment; + }, + { + binding = 1; + descriptorType = storage_buffer; + descriptorCount = 1; + stageFlags = fragment; + }, + { + binding = 2; + descriptorType = storage_image; + descriptorCount = 1; + stageFlags = fragment; + }, + ); + }; + entity_set = { + bindings = ( + { + binding = 0; + descriptorType = storage_buffer; + descriptorCount = 1; + stageFlags = vertex; + }, + ); + }; + bone_set = { + bindings = ( + { + binding = 0; + descriptorType = storage_buffer; + descriptorCount = 1; + stageFlags = vertex; + }, + ); + }; + sprite_set = { + bindings = ( + { + binding = 0; + descriptorType = uniform_buffer; + descriptorCount = 1; + stageFlags = vertex; + }, + { + binding = 1; + descriptorType = combined_image_sampler; + descriptorCount = 1; + stageFlags = fragment; + }, + ); + }; + lighting_attach = { + bindings = ( + { + binding = 0; + descriptorType = input_attachment; + descriptorCount = 1; + stageFlags = fragment; + }, + { + binding = 1; + descriptorType = input_attachment; + descriptorCount = 1; + stageFlags = fragment; + }, + { + binding = 2; + descriptorType = input_attachment; + descriptorCount = 1; + stageFlags = fragment; + }, + { + binding = 3; + descriptorType = input_attachment; + descriptorCount = 1; + stageFlags = fragment; + }, + { + binding = 4; + descriptorType = input_attachment; + descriptorCount = 1; + stageFlags = fragment; + }, + ); + }; + lighting_lights = { + bindings = ( + { + binding = 0; + descriptorType = uniform_buffer; + descriptorCount = 1; + stageFlags = vertex|fragment; + }, + ); + }; + lighting_shadow = { + bindings = ( + { + binding = 0; + descriptorType = combined_image_sampler; + descriptorCount = 32; + stageFlags = fragment; + }, + ); + }; + compose_attach = { + bindings = ( + { + binding = 0; + descriptorType = input_attachment; + descriptorCount = 1; + stageFlags = fragment; + }, + { + binding = 1; + descriptorType = input_attachment; + descriptorCount = 1; + stageFlags = fragment; + }, + { + binding = 2; + descriptorType = input_attachment; + descriptorCount = 1; + stageFlags = fragment; + }, + ); + }; + particle_set = { + bindings = ( + { + binding = 0; + descriptorType = storage_buffer; + descriptorCount = 1; + stageFlags = compute; + }, + { + binding = 1; + descriptorType = storage_buffer; + descriptorCount = 1; + stageFlags = compute; + }, + { + binding = 2; + descriptorType = storage_buffer; + descriptorCount = 1; + stageFlags = compute; + }, + ); + }; + particle_set = { + bindings = ( + { + binding = 0; + descriptorType = storage_buffer; + descriptorCount = 1; + stageFlags = compute; + }, + { + binding = 1; + descriptorType = storage_buffer; + descriptorCount = 1; + stageFlags = compute; + }, + { + binding = 2; + descriptorType = storage_buffer; + descriptorCount = 1; + stageFlags = compute; + }, + ); + }; + output_set = { + bindings = ( + { + binding = 0; + descriptorType = combined_image_sampler; + descriptorCount = 1; + stageFlags = fragment; + }, + ); + }; +}; +images = { + depth = { + @inherit = $image_base; + format = x8_d24_unorm_pack32; + usage = depth_stencil_attachment|input_attachment|transient_attachment; + }; + color = { + @inherit = $image_base; + usage = color_attachment|input_attachment|sampled; + format = $render_output.format; + }; + cube_depth = { + @inherit = $cube_image_base; + format = x8_d24_unorm_pack32; + usage = depth_stencil_attachment|input_attachment|transient_attachment; + }; + cube_color = { + @inherit = $cube_image_base; + flags = cube_compatible; + usage = color_attachment|input_attachment|sampled; + format = $render_output.format; + }; +}; +imageviews = { + depth = { + @inherit = $view_base; + image = depth; + subresourceRange = { + aspectMask = depth; + }; + }; + color = { + @inherit = $view_base; + image = color; + format = $images.color.format; + }; + cube_depth = { + @inherit = $cube_view_base; + image = cube_depth; + subresourceRange = { + aspectMask = depth; + }; + }; + cube_color = { + @inherit = $cube_view_base; + viewType = cube; + image = cube_color; + }; +}; +output = { + view = $output; + format = r16g16b16a16_sfloat; + finalLayout = shader_read_only_optimal; +}; +renderpasses = { + deferred = { + color = "[0, 1, 0, 1]"; + framebuffer = { + width = $render_output.extent.width; + height = $render_output.extent.height; + layers = 1; + attachments = { + depth = { + @inherit = $attachment_base; + format = $images.depth.format; + loadOp = clear; + finalLayout = depth_stencil_attachment_optimal; + clearValue = { depthStencil = { depth = 1; stencil = 0; }; }; + view = depth; + }; + color = { + @inherit = $attachment_base; + format = $images.color.format; + loadOp = clear; + storeOp = store; + finalLayout = $render_output.finalLayout; + view = color; + }; + }; + }; + subpasses = { + depth = { + color = "[ 0.5, 0.5, 0.5, 1]"; + attachments = { + depth = { + depth = depth_stencil_attachment_optimal; + }; + preserve = (color); + }; + + base_pipeline = { + @inherit = $pipeline_base; + depthStencil = $depth_test_and_write; + rasterization = $cw_cull_back; + }; + pipelines = { + bsp:depth = { + color = $color.bsp; + tasks = ( + { func = bsp_draw_queue; + params = (main, solid, 0); }, + { func = bsp_draw_queue; + params = (main, sky, 0); }, + ); + + stages = ( + $brush.shader.depth_vertex, + ); + 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; + }; + alias:depth = { + color = $color.alias; + tasks = ( + { func = alias_draw; + params = (0); }, + ); + + stages = ( + $alias.shader.depth_vertex, + ); + vertexInput = { + // depth pass doesn't use UVs + bindings = ( + "$alias.vertexInput.bindings[0]", + "$alias.vertexInput.bindings[1]", + ); + attributes = ( + "$alias.vertexInput.attributes[0]", + "$alias.vertexInput.attributes[1]", + "$alias.vertexInput.attributes[2]", + "$alias.vertexInput.attributes[3]", + ); + }; + inputAssembly = $alias.inputAssembly; + layout = $alias.layout; + }; + iqm:depth = { + color = $color.iqm; + tasks = ( + { func = iqm_draw; + params = (0); }, + ); + + stages = ( + $iqm.shader.depth_vertex, + ); + vertexInput = $iqm.vertexInput; + inputAssembly = $iqm.inputAssembly; + layout = $iqm.layout; + }; + sprite:depth = { + color = $color.sprite; + tasks = ( + { func = sprite_draw; }, + ); + + stages = ( + $sprite.shader.depth_vertex, + $sprite.shader.depth_fragment, + ); + vertexInput = $sprite.vertexInput; + inputAssembly = $sprite.inputAssembly; + layout = $sprite.layout; + }; + }; + }; + color = { + color = "[ 0.3, 0.7, 0.3, 1]"; + dependencies = { + depth = $depth_dependency; + }; + attachments = { + color = { + color = { + layout = color_attachment_optimal; + blend = $blend_disable; + }; + }; + depth = { + depth = depth_stencil_read_only_optimal; + }; + }; + base_pipeline = { + @inherit = $pipeline_base; + rasterization = $cw_cull_back; + }; + pipelines = { + bsp:color = { + color = $color.bsp; + tasks = ( + { func = bsp_draw_queue; + params = (main, solid, 1); }, + { func = bsp_draw_queue; + params = (main, sky, 1); }, + ); + + stages = ( + $brush.shader.gbuf_vertex, + $brush.shader.gbuf_geometry, + $brush.shader.gbuf_fragment, + ); + vertexInput = $brush.vertexInput; + inputAssembly = $brush.inputAssembly; + layout = $brush.layout; + }; + alias:color = { + color = $color.alias; + tasks = ( + { func = alias_draw; + params = (1); }, + ); + + stages = ( + $alias.shader.gbuf_vertex, + $alias.shader.gbuf_fragment, + ); + vertexInput = $alias.vertexInput; + inputAssembly = $alias.inputAssembly; + layout = $alias.layout; + }; + iqm:color = { + color = $color.iqm; + tasks = ( + { func = iqm_draw; + params = (1); }, + ); + + stages = ( + $iqm.shader.gbuf_vertex, + $iqm.shader.gbuf_fragment, + ); + vertexInput = $iqm.vertexInput; + inputAssembly = $iqm.inputAssembly; + layout = $iqm.layout; + }; + sprite:color = { + color = $color.sprite; + tasks = ( + { func = sprite_draw; }, + ); + + stages = ( + $sprite.shader.gbuf_vertex, + $sprite.shader.gbuf_fragment, + ); + vertexInput = $sprite.vertexInput; + inputAssembly = $sprite.inputAssembly; + layout = $sprite.layout; + }; + }; + }; + }; + output = color; + }; + deferred_cube = { + @inherit = $renderpasses.deferred; + @next = (VkRenderPassMultiviewCreateInfo, { + viewMasks = (0x3fu, 0x3fu); + }); + framebuffer = { + width = "min($render_output.extent.width,$render_output.extent.height)"; + height = "min($render_output.extent.width,$render_output.extent.height)"; + layers = 1; + attachments = { + depth = { + @inherit = $attachment_base; + format = $images.cube_depth.format; + loadOp = clear; + finalLayout = depth_stencil_attachment_optimal; + clearValue = { depthStencil = { depth = 1; stencil = 0; }; }; + view = cube_depth; + }; + color = { + @inherit = $attachment_base; + format = $images.cube_color.format; + loadOp = clear; + storeOp = store; + finalLayout = $render_output.finalLayout; + view = cube_color; + }; + }; + }; + output = cube_color; + }; + output = { + color = "[0, 1, 1, 1]"; + framebuffer = { + layers = 1; + attachments = { + output = $swapchain; + }; + }; + subpasses = { + compose = { + color = "[ 0, 0.5, 0.5, 1]"; + attachments = { + color = { + output = { + layout = color_attachment_optimal; + blend = $alpha_blend; + }; + }; + }; + pipelines = { + output = { + @inherit = $compose_base; + + color = $color.output; + tasks = ( + { func = output_draw_flat; }, + ); + + stages = ( + $fstriangle.shader.vertex, + $output.shader.fragment, + ); + layout = $output.layout; + }; + waterwarp = { + @inherit = $compose_base; + disabled = true; + + color = $color.output; + tasks = ( + { func = output_draw_waterwarp; }, + ); + + stages = ( + $fstriangle.shader.vertexst, + $waterwarp.shader.fragment, + ); + layout = $waterwarp.layout; + }; + fisheye = { + @inherit = $compose_base; + disabled = true; + + color = $color.output; + tasks = ( + { func = output_draw_fisheye; }, + ); + + stages = ( + $fstriangle.shader.vertexst, + $fisheye.shader.fragment, + ); + layout = $fisheye.layout; + }; + slice = { + @inherit = $compose_base; + + color = $color.slice; + tasks = ( + { func = slice_draw; }, + ); + + stages = ( + $slice.shader.vertex, + $slice.shader.fragment, + ); + vertexInput = $slice.vertexInput; + inputAssembly = $slice.inputAssembly; + layout = $slice.layout; + }; + lines = { + @inherit = $compose_base; + + color = $color.lines; + tasks = ( + { func = line_draw; }, + ); + + stages = ( + $lines.shader.vertex, + $lines.shader.fragment, + ); + vertexInput = $lines.vertexInput; + inputAssembly = $lines.inputAssembly; + layout = $lines.layout; + }; + }; + }; + }; + }; +}; +steps = { + wait_on_fence = { + process = { + tasks = ( + { func = wait_on_fence; }, + { func = capture_finalize; }, + { func = update_matrices; }, + { func = draw_scr_funcs; }, + ); + }; + }; + particles = { + dependencies = (wait_on_fence); + compute = { + pipelines = { + part:update = { + color = "[0.3, 0.8, 0.9]"; + tasks = ( + { func = update_particles; } + ); + stage = { + name = main; + module = $builtin/partupdate.comp; + }; + layout = $particle.layout.update; + }; + part:physics = { + color = "[0.6, 0.8, 0.9]"; + tasks = ( + { func = particle_physics; } + ); + stage = { + name = main; + module = $builtin/partphysics.comp; + }; + layout = $particle.layout.physics; + }; + }; + }; + }; + shadow = { + dependencies = (wait_on_fence); + //currently empty + }; + world = { + dependencies = (wait_on_fence); + process = { + tasks = ( + { func = bsp_visit_world; + params = (main); }, + { func = scene_draw_viewmodel; }, + //{ func = lighting_update_lights; }, + ); + }; + }; + setup_main = { + dependencies = (wait_on_fence); + process = { + tasks = ( + { func = output_select_renderpass; + params = ("\"main\""); }, + { func = update_framebuffer; + params = ("\"main\""); }, + { func = particle_wait_physics; }, + ); + }; + }; + main = { + dependencies = (setup_main, particles, shadow, world, translucent); + render = { + renderpasses = { + deferred = $renderpasses.deferred; + deferred_cube = $renderpasses.deferred_cube; + }; + }; + }; + preoutput = { + dependencies = (wait_on_fence); + process = { + tasks = ( + { func = acquire_output; + params = ("\"output\""); }, + { func = update_input; + params = ("\"main\""); }, + { func = output_select_pipeline; + params = ("\"output\""); }, + { func = flush_draw; }, + ); + }; + }; + output = { + dependencies = (main, preoutput); + render = { + renderpasses = { + output = $renderpasses.output; + }; + }; + }; + capture = { + dependencies = (output); + process = { + tasks = ( + { func = capture_initiate; }, + ); + }; + }; +}; diff --git a/libs/video/renderer/vulkan/vkparse.c b/libs/video/renderer/vulkan/vkparse.c index 223ba80fe..cac356fa8 100644 --- a/libs/video/renderer/vulkan/vkparse.c +++ b/libs/video/renderer/vulkan/vkparse.c @@ -1200,6 +1200,10 @@ static exprsym_t builtin_plist_syms[] = { .value = (void *) #include "libs/video/renderer/vulkan/rp_main_def.plc" }, + { .name = "main_fwd", + .value = (void *) +#include "libs/video/renderer/vulkan/rp_main_fwd.plc" + }, { .name = "smp_quake", .value = (void *) #include "libs/video/renderer/vulkan/smp_quake.plc"