mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-10 07:12:07 +00:00
Merge pull request #643 from 0lvin/ref_vk
Enable depthWriteEnable for particles
This commit is contained in:
commit
8a54e49f61
5 changed files with 43 additions and 36 deletions
|
@ -229,9 +229,9 @@ extern VkDescriptorSetLayout vk_samplerDescSetLayout;
|
|||
|
||||
// *** pipelines ***
|
||||
extern qvkpipeline_t vk_drawTexQuadPipeline;
|
||||
extern qvkpipeline_t vk_drawColorQuadPipeline[2];
|
||||
extern qvkpipeline_t vk_drawModelPipelineStrip[2];
|
||||
extern qvkpipeline_t vk_drawModelPipelineFan[2];
|
||||
extern qvkpipeline_t vk_drawColorQuadPipeline[RP_COUNT];
|
||||
extern qvkpipeline_t vk_drawModelPipelineStrip[RP_COUNT];
|
||||
extern qvkpipeline_t vk_drawModelPipelineFan[RP_COUNT];
|
||||
extern qvkpipeline_t vk_drawNoDepthModelPipelineStrip;
|
||||
extern qvkpipeline_t vk_drawNoDepthModelPipelineFan;
|
||||
extern qvkpipeline_t vk_drawLefthandModelPipelineStrip;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// 8.13.3559
|
||||
// 8.13.3743
|
||||
#pragma once
|
||||
const uint32_t particle_vert_spv[] = {
|
||||
0x07230203,0x00010000,0x00080008,0x0000002d,0x00000000,0x00020011,0x00000001,0x0006000b,
|
||||
|
@ -34,7 +34,7 @@ const uint32_t particle_vert_spv[] = {
|
|||
0x00000001,0x0004003b,0x0000001e,0x00000026,0x00000003,0x00040020,0x00000027,0x00000001,
|
||||
0x00000007,0x0004003b,0x00000027,0x00000028,0x00000001,0x00040020,0x0000002a,0x00000003,
|
||||
0x00000006,0x0004003b,0x0000002a,0x0000002b,0x00000003,0x0004002b,0x00000006,0x0000002c,
|
||||
0x00000000,0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,
|
||||
0x3f000000,0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,
|
||||
0x00050041,0x00000011,0x00000012,0x00000010,0x0000000c,0x0004003d,0x0000000d,0x00000013,
|
||||
0x00000012,0x0004003d,0x00000014,0x00000017,0x00000016,0x00050051,0x00000006,0x00000019,
|
||||
0x00000017,0x00000000,0x00050051,0x00000006,0x0000001a,0x00000017,0x00000001,0x00050051,
|
||||
|
|
|
@ -124,9 +124,12 @@ qboolean vk_frameStarted = false;
|
|||
|
||||
// render pipelines
|
||||
qvkpipeline_t vk_drawTexQuadPipeline = QVKPIPELINE_INIT;
|
||||
qvkpipeline_t vk_drawColorQuadPipeline[2] = { QVKPIPELINE_INIT, QVKPIPELINE_INIT };
|
||||
qvkpipeline_t vk_drawModelPipelineStrip[2] = { QVKPIPELINE_INIT, QVKPIPELINE_INIT };
|
||||
qvkpipeline_t vk_drawModelPipelineFan[2] = { QVKPIPELINE_INIT, QVKPIPELINE_INIT };
|
||||
qvkpipeline_t vk_drawColorQuadPipeline[RP_COUNT] = {
|
||||
QVKPIPELINE_INIT, QVKPIPELINE_INIT, QVKPIPELINE_INIT };
|
||||
qvkpipeline_t vk_drawModelPipelineStrip[RP_COUNT] = {
|
||||
QVKPIPELINE_INIT, QVKPIPELINE_INIT, QVKPIPELINE_INIT };
|
||||
qvkpipeline_t vk_drawModelPipelineFan[RP_COUNT] = {
|
||||
QVKPIPELINE_INIT, QVKPIPELINE_INIT, QVKPIPELINE_INIT };
|
||||
qvkpipeline_t vk_drawNoDepthModelPipelineStrip = QVKPIPELINE_INIT;
|
||||
qvkpipeline_t vk_drawNoDepthModelPipelineFan = QVKPIPELINE_INIT;
|
||||
qvkpipeline_t vk_drawLefthandModelPipelineStrip = QVKPIPELINE_INIT;
|
||||
|
@ -248,6 +251,12 @@ VkDescriptorSetLayout vk_uboDescSetLayout;
|
|||
VkDescriptorSetLayout vk_samplerDescSetLayout;
|
||||
VkDescriptorSetLayout vk_samplerLightmapDescSetLayout;
|
||||
|
||||
static const char *renderpassObjectNames[] = {
|
||||
"RP_WORLD",
|
||||
"RP_UI",
|
||||
"RP_WORLD_WARP"
|
||||
};
|
||||
|
||||
VkFormat QVk_FindDepthFormat()
|
||||
{
|
||||
VkFormat depthFormats[] = {
|
||||
|
@ -348,7 +357,7 @@ static VkResult CreateFramebuffers()
|
|||
vk_framebuffers[i] = (VkFramebuffer *)malloc(vk_swapchain.imageCount * sizeof(VkFramebuffer));
|
||||
|
||||
VkFramebufferCreateInfo fbCreateInfos[] = {
|
||||
// main world view framebuffer
|
||||
// RP_WORLD: main world view framebuffer
|
||||
{
|
||||
.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO,
|
||||
.pNext = NULL,
|
||||
|
@ -359,7 +368,7 @@ static VkResult CreateFramebuffers()
|
|||
.height = vk_swapchain.extent.height,
|
||||
.layers = 1
|
||||
},
|
||||
// UI framebuffer
|
||||
// RP_UI: UI framebuffer
|
||||
{
|
||||
.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO,
|
||||
.pNext = NULL,
|
||||
|
@ -370,7 +379,7 @@ static VkResult CreateFramebuffers()
|
|||
.height = vk_swapchain.extent.height,
|
||||
.layers = 1
|
||||
},
|
||||
// warped main world view (postprocessing) framebuffer
|
||||
// RP_WORLD_WARP: warped main world view (postprocessing) framebuffer
|
||||
{
|
||||
.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO,
|
||||
.pNext = NULL,
|
||||
|
@ -399,7 +408,7 @@ static VkResult CreateFramebuffers()
|
|||
VkResult res = vkCreateFramebuffer(vk_device.logical, &fbCreateInfos[j], NULL, &vk_framebuffers[j][i]);
|
||||
QVk_DebugSetObjectName((uint64_t)vk_framebuffers[j][i],
|
||||
VK_OBJECT_TYPE_FRAMEBUFFER, va("Framebuffer #" YQ2_COM_PRIdS "for Render Pass %s",
|
||||
i, j == RP_WORLD ? "RP_WORLD" : j == RP_UI ? "RP_UI" : "RP_WORLD_WARP"));
|
||||
i, renderpassObjectNames[j]));
|
||||
|
||||
if (res != VK_SUCCESS)
|
||||
{
|
||||
|
@ -686,12 +695,10 @@ static VkResult CreateRenderpasses()
|
|||
R_Printf(PRINT_ALL, "%s(): renderpass #%d create error: %s\n", __func__, i, QVk_GetError(res));
|
||||
return res;
|
||||
}
|
||||
QVk_DebugSetObjectName((uint64_t)vk_renderpasses[i].rp, VK_OBJECT_TYPE_RENDER_PASS,
|
||||
va("Render Pass: %s", renderpassObjectNames[i]));
|
||||
}
|
||||
|
||||
QVk_DebugSetObjectName((uint64_t)vk_renderpasses[RP_WORLD].rp, VK_OBJECT_TYPE_RENDER_PASS, "Render Pass: World");
|
||||
QVk_DebugSetObjectName((uint64_t)vk_renderpasses[RP_WORLD_WARP].rp, VK_OBJECT_TYPE_RENDER_PASS, "Render Pass: UI");
|
||||
QVk_DebugSetObjectName((uint64_t)vk_renderpasses[RP_UI].rp, VK_OBJECT_TYPE_RENDER_PASS, "Render Pass: Warp Postprocess");
|
||||
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -1240,7 +1247,7 @@ static void CreatePipelines()
|
|||
|
||||
// draw particles pipeline (using a texture)
|
||||
VK_LOAD_VERTFRAG_SHADERS(shaders, particle, basic);
|
||||
vk_drawParticlesPipeline.depthWriteEnable = VK_FALSE;
|
||||
vk_drawParticlesPipeline.depthWriteEnable = VK_TRUE;
|
||||
vk_drawParticlesPipeline.blendOpts.blendEnable = VK_TRUE;
|
||||
QVk_CreatePipeline(&vk_samplerDescSetLayout, 1, &vertInfoRGB_RGBA_RG, &vk_drawParticlesPipeline, &vk_renderpasses[RP_WORLD], shaders, 2);
|
||||
QVk_DebugSetObjectName((uint64_t)vk_drawParticlesPipeline.layout, VK_OBJECT_TYPE_PIPELINE_LAYOUT, "Pipeline Layout: textured particles");
|
||||
|
@ -1249,7 +1256,7 @@ static void CreatePipelines()
|
|||
// draw particles pipeline (using point list)
|
||||
VK_LOAD_VERTFRAG_SHADERS(shaders, point_particle, point_particle);
|
||||
vk_drawPointParticlesPipeline.topology = VK_PRIMITIVE_TOPOLOGY_POINT_LIST;
|
||||
vk_drawPointParticlesPipeline.depthWriteEnable = VK_FALSE;
|
||||
vk_drawPointParticlesPipeline.depthWriteEnable = VK_TRUE;
|
||||
vk_drawPointParticlesPipeline.blendOpts.blendEnable = VK_TRUE;
|
||||
QVk_CreatePipeline(&vk_uboDescSetLayout, 1, &vertInfoRGB_RGBA, &vk_drawPointParticlesPipeline, &vk_renderpasses[RP_WORLD], shaders, 2);
|
||||
QVk_DebugSetObjectName((uint64_t)vk_drawPointParticlesPipeline.layout, VK_OBJECT_TYPE_PIPELINE_LAYOUT, "Pipeline Layout: point particles");
|
||||
|
@ -1257,16 +1264,16 @@ static void CreatePipelines()
|
|||
|
||||
// colored quad pipeline
|
||||
VK_LOAD_VERTFRAG_SHADERS(shaders, basic_color_quad, basic_color_quad);
|
||||
for (int i = 0; i < 2; ++i)
|
||||
for (int i = 0; i < RP_COUNT; ++i)
|
||||
{
|
||||
vk_drawColorQuadPipeline[i].depthTestEnable = VK_FALSE;
|
||||
vk_drawColorQuadPipeline[i].blendOpts.blendEnable = VK_TRUE;
|
||||
QVk_CreatePipeline(&vk_uboDescSetLayout, 1, &vertInfoRG, &vk_drawColorQuadPipeline[i], &vk_renderpasses[i], shaders, 2);
|
||||
QVk_DebugSetObjectName((uint64_t)vk_drawColorQuadPipeline[i].layout, VK_OBJECT_TYPE_PIPELINE_LAYOUT,
|
||||
va("Pipeline Layout: colored quad (%s)", renderpassObjectNames[i]));
|
||||
QVk_DebugSetObjectName((uint64_t)vk_drawColorQuadPipeline[i].pl, VK_OBJECT_TYPE_PIPELINE,
|
||||
va("Pipeline: colored quad (%s)", renderpassObjectNames[i]));
|
||||
}
|
||||
QVk_DebugSetObjectName((uint64_t)vk_drawColorQuadPipeline[0].layout, VK_OBJECT_TYPE_PIPELINE_LAYOUT, "Pipeline Layout: colored quad (RP_WORLD)");
|
||||
QVk_DebugSetObjectName((uint64_t)vk_drawColorQuadPipeline[0].pl, VK_OBJECT_TYPE_PIPELINE, "Pipeline: colored quad (RP_WORLD)");
|
||||
QVk_DebugSetObjectName((uint64_t)vk_drawColorQuadPipeline[1].layout, VK_OBJECT_TYPE_PIPELINE_LAYOUT, "Pipeline Layout: colored quad (RP_UI)");
|
||||
QVk_DebugSetObjectName((uint64_t)vk_drawColorQuadPipeline[1].pl, VK_OBJECT_TYPE_PIPELINE, "Pipeline: colored quad (RP_UI)");
|
||||
|
||||
// untextured null model
|
||||
VK_LOAD_VERTFRAG_SHADERS(shaders, nullmodel, basic_color_quad);
|
||||
|
@ -1278,24 +1285,24 @@ static void CreatePipelines()
|
|||
|
||||
// textured model
|
||||
VK_LOAD_VERTFRAG_SHADERS(shaders, model, model);
|
||||
for (int i = 0; i < 2; ++i)
|
||||
for (int i = 0; i < RP_COUNT; ++i)
|
||||
{
|
||||
vk_drawModelPipelineStrip[i].topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP;
|
||||
vk_drawModelPipelineStrip[i].blendOpts.blendEnable = VK_TRUE;
|
||||
QVk_CreatePipeline(samplerUboDsLayouts, 2, &vertInfoRGB_RGBA_RG, &vk_drawModelPipelineStrip[i], &vk_renderpasses[i], shaders, 2);
|
||||
QVk_DebugSetObjectName((uint64_t)vk_drawModelPipelineStrip[i].layout, VK_OBJECT_TYPE_PIPELINE_LAYOUT,
|
||||
va("Pipeline Layout: draw model: strip (%s)", renderpassObjectNames[i]));
|
||||
QVk_DebugSetObjectName((uint64_t)vk_drawModelPipelineStrip[i].pl, VK_OBJECT_TYPE_PIPELINE,
|
||||
va("Pipeline: draw model: strip (%s)", renderpassObjectNames[i]));
|
||||
|
||||
vk_drawModelPipelineFan[i].topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
|
||||
vk_drawModelPipelineFan[i].blendOpts.blendEnable = VK_TRUE;
|
||||
QVk_CreatePipeline(samplerUboDsLayouts, 2, &vertInfoRGB_RGBA_RG, &vk_drawModelPipelineFan[i], &vk_renderpasses[i], shaders, 2);
|
||||
QVk_DebugSetObjectName((uint64_t)vk_drawModelPipelineFan[i].layout, VK_OBJECT_TYPE_PIPELINE_LAYOUT,
|
||||
va("Pipeline Layout: draw model: fan (%s)", renderpassObjectNames[i]));
|
||||
QVk_DebugSetObjectName((uint64_t)vk_drawModelPipelineFan[i].pl, VK_OBJECT_TYPE_PIPELINE,
|
||||
va("Pipeline: draw model: fan (%s)", renderpassObjectNames[i]));
|
||||
}
|
||||
QVk_DebugSetObjectName((uint64_t)vk_drawModelPipelineStrip[0].layout, VK_OBJECT_TYPE_PIPELINE_LAYOUT, "Pipeline Layout: draw model: strip (RP_WORLD)");
|
||||
QVk_DebugSetObjectName((uint64_t)vk_drawModelPipelineStrip[0].pl, VK_OBJECT_TYPE_PIPELINE, "Pipeline: draw model: strip (RP_WORLD)");
|
||||
QVk_DebugSetObjectName((uint64_t)vk_drawModelPipelineStrip[1].layout, VK_OBJECT_TYPE_PIPELINE_LAYOUT, "Pipeline Layout: draw model: strip (RP_UI)");
|
||||
QVk_DebugSetObjectName((uint64_t)vk_drawModelPipelineStrip[1].pl, VK_OBJECT_TYPE_PIPELINE, "Pipeline: draw model: strip (RP_UI)");
|
||||
QVk_DebugSetObjectName((uint64_t)vk_drawModelPipelineFan[0].layout, VK_OBJECT_TYPE_PIPELINE_LAYOUT, "Pipeline Layout: draw model: fan (RP_WORLD)");
|
||||
QVk_DebugSetObjectName((uint64_t)vk_drawModelPipelineFan[0].pl, VK_OBJECT_TYPE_PIPELINE, "Pipeline: draw model: fan (RP_WORLD)");
|
||||
QVk_DebugSetObjectName((uint64_t)vk_drawModelPipelineFan[1].layout, VK_OBJECT_TYPE_PIPELINE_LAYOUT, "Pipeline Layout: draw model: fan (RP_UI)");
|
||||
QVk_DebugSetObjectName((uint64_t)vk_drawModelPipelineFan[1].pl, VK_OBJECT_TYPE_PIPELINE, "Pipeline: draw model: fan (RP_UI)");
|
||||
|
||||
// dedicated model pipelines for translucent objects with depth write disabled
|
||||
vk_drawNoDepthModelPipelineStrip.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP;
|
||||
|
@ -1459,7 +1466,7 @@ void QVk_Shutdown( void )
|
|||
{
|
||||
R_Printf(PRINT_ALL, "Shutting down Vulkan\n");
|
||||
|
||||
for (int i = 0; i < 2; ++i)
|
||||
for (int i = 0; i < RP_COUNT; ++i)
|
||||
{
|
||||
QVk_DestroyPipeline(&vk_drawColorQuadPipeline[i]);
|
||||
QVk_DestroyPipeline(&vk_drawModelPipelineStrip[i]);
|
||||
|
@ -2236,7 +2243,7 @@ static uint8_t *QVk_GetIndexBuffer(VkDeviceSize size, VkDeviceSize *dstOffset)
|
|||
uint8_t *QVk_GetUniformBuffer(VkDeviceSize size, uint32_t *dstOffset, VkDescriptorSet *dstUboDescriptorSet)
|
||||
{
|
||||
// 0x100 alignment is required by Vulkan spec
|
||||
const uint32_t aligned_size = ROUNDUP(size, 256);
|
||||
const uint32_t aligned_size = ROUNDUP(size, 0x100);
|
||||
|
||||
if (vk_dynUniformBuffers[vk_activeDynBufferIdx].currentOffset + UNIFORM_ALLOC_SIZE > vk_config.uniform_buffer_size)
|
||||
{
|
||||
|
|
|
@ -911,7 +911,7 @@ R_SetupVulkan (void)
|
|||
vkCmdPushConstants(vk_activeCmdbuffer, vk_drawTexQuadPipeline.layout, VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(r_viewproj_matrix), r_viewproj_matrix);
|
||||
}
|
||||
|
||||
void R_Flash( void )
|
||||
static void R_Flash( void )
|
||||
{
|
||||
R_PolyBlend ();
|
||||
}
|
||||
|
|
|
@ -22,5 +22,5 @@ void main() {
|
|||
gl_Position = pc.mvpMatrix * vec4(inVertex, 1.0);
|
||||
texCoord = inTexCoord;
|
||||
color = inColor;
|
||||
aTreshold = 0.0;
|
||||
aTreshold = 0.5;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue