Debug triangles rendering (r_showtris = 1).
This commit is contained in:
parent
0f1849da24
commit
30ad54bfbe
|
|
@ -1253,7 +1253,6 @@ typedef struct shaderCommands_s
|
||||||
|
|
||||||
// info extracted from current shader
|
// info extracted from current shader
|
||||||
int numPasses;
|
int numPasses;
|
||||||
void (*currentStageIteratorFunc)( void );
|
|
||||||
shaderStage_t **xstages;
|
shaderStage_t **xstages;
|
||||||
} shaderCommands_t;
|
} shaderCommands_t;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -114,6 +114,16 @@ static void DrawTris (shaderCommands_t *input) {
|
||||||
GLimp_LogComment( "glUnlockArraysEXT\n" );
|
GLimp_LogComment( "glUnlockArraysEXT\n" );
|
||||||
}
|
}
|
||||||
qglDepthRange( 0, 1 );
|
qglDepthRange( 0, 1 );
|
||||||
|
|
||||||
|
// VULKAN
|
||||||
|
if (vk.active) {
|
||||||
|
Com_Memset(tess.svars.colors, tr.identityLightByte, tess.numVertexes * 4 );
|
||||||
|
vk_bind_resources_shared_between_stages();
|
||||||
|
vk_bind_stage_specific_resources(vk.tris_debug_pipeline, false, Vk_Depth_Range::force_zero);
|
||||||
|
vkCmdDrawIndexed(vk.command_buffer, tess.numIndexes, 1, 0, 0, 0);
|
||||||
|
vk_resources.dirty_attachments = true;
|
||||||
|
vk.xyz_elements += tess.numVertexes;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -165,8 +175,6 @@ void RB_BeginSurface( shader_t *shader, int fogNum ) {
|
||||||
tess.xstages = state->stages;
|
tess.xstages = state->stages;
|
||||||
tess.numPasses = state->numUnfoggedPasses;
|
tess.numPasses = state->numUnfoggedPasses;
|
||||||
|
|
||||||
tess.currentStageIteratorFunc = state->isSky ? RB_StageIteratorSky : RB_StageIteratorGeneric;
|
|
||||||
|
|
||||||
tess.shaderTime = backEnd.refdef.floatTime - tess.shader->timeOffset;
|
tess.shaderTime = backEnd.refdef.floatTime - tess.shader->timeOffset;
|
||||||
if (tess.shader->clampTime && tess.shaderTime >= tess.shader->clampTime) {
|
if (tess.shader->clampTime && tess.shaderTime >= tess.shader->clampTime) {
|
||||||
tess.shaderTime = tess.shader->clampTime;
|
tess.shaderTime = tess.shader->clampTime;
|
||||||
|
|
@ -364,7 +372,7 @@ static void ProjectDlightTexture( void ) {
|
||||||
// VULKAN
|
// VULKAN
|
||||||
if (vk.active) {
|
if (vk.active) {
|
||||||
VkPipeline pipeline = vk.dlight_pipelines[dl->additive > 0 ? 1 : 0][tess.shader->cullType][tess.shader->polygonOffset];
|
VkPipeline pipeline = vk.dlight_pipelines[dl->additive > 0 ? 1 : 0][tess.shader->cullType][tess.shader->polygonOffset];
|
||||||
vk_bind_stage_specific_resources(pipeline, false, false);
|
vk_bind_stage_specific_resources(pipeline, false, Vk_Depth_Range::normal);
|
||||||
vkCmdDrawIndexed(vk.command_buffer, tess.numIndexes, 1, 0, 0, 0);
|
vkCmdDrawIndexed(vk.command_buffer, tess.numIndexes, 1, 0, 0, 0);
|
||||||
vk_resources.dirty_attachments = true;
|
vk_resources.dirty_attachments = true;
|
||||||
}
|
}
|
||||||
|
|
@ -411,7 +419,7 @@ static void RB_FogPass( void ) {
|
||||||
if (vk.active) {
|
if (vk.active) {
|
||||||
assert(tess.shader->fogPass > 0);
|
assert(tess.shader->fogPass > 0);
|
||||||
VkPipeline pipeline = vk.fog_pipelines[tess.shader->fogPass - 1][tess.shader->cullType][tess.shader->polygonOffset];
|
VkPipeline pipeline = vk.fog_pipelines[tess.shader->fogPass - 1][tess.shader->cullType][tess.shader->polygonOffset];
|
||||||
vk_bind_stage_specific_resources(pipeline, false, false);
|
vk_bind_stage_specific_resources(pipeline, false, Vk_Depth_Range::normal);
|
||||||
vkCmdDrawIndexed(vk.command_buffer, tess.numIndexes, 1, 0, 0, 0);
|
vkCmdDrawIndexed(vk.command_buffer, tess.numIndexes, 1, 0, 0, 0);
|
||||||
vk_resources.dirty_attachments = true;
|
vk_resources.dirty_attachments = true;
|
||||||
}
|
}
|
||||||
|
|
@ -774,7 +782,11 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input )
|
||||||
else if (backEnd.viewParms.isPortal)
|
else if (backEnd.viewParms.isPortal)
|
||||||
pipeline = pStage->vk_portal_pipeline;
|
pipeline = pStage->vk_portal_pipeline;
|
||||||
|
|
||||||
vk_bind_stage_specific_resources(pipeline, multitexture, input->shader->isSky == qtrue);
|
auto depth_range = Vk_Depth_Range::normal;
|
||||||
|
if (input->shader->isSky)
|
||||||
|
depth_range = r_showsky->integer ? Vk_Depth_Range::force_zero : Vk_Depth_Range::force_one;
|
||||||
|
|
||||||
|
vk_bind_stage_specific_resources(pipeline, multitexture, depth_range);
|
||||||
vkCmdDrawIndexed(vk.command_buffer, tess.numIndexes, 1, 0, 0, 0);
|
vkCmdDrawIndexed(vk.command_buffer, tess.numIndexes, 1, 0, 0, 0);
|
||||||
vk_resources.dirty_attachments = true;
|
vk_resources.dirty_attachments = true;
|
||||||
}
|
}
|
||||||
|
|
@ -944,7 +956,10 @@ void RB_EndSurface( void ) {
|
||||||
//
|
//
|
||||||
// call off to shader specific tess end function
|
// call off to shader specific tess end function
|
||||||
//
|
//
|
||||||
tess.currentStageIteratorFunc();
|
if (tess.shader->isSky)
|
||||||
|
RB_StageIteratorSky();
|
||||||
|
else
|
||||||
|
RB_StageIteratorGeneric();
|
||||||
|
|
||||||
//
|
//
|
||||||
// draw debugging stuff
|
// draw debugging stuff
|
||||||
|
|
|
||||||
|
|
@ -144,7 +144,7 @@ static void R_Vk_RenderShadowEdges(VkPipeline pipeline) {
|
||||||
}
|
}
|
||||||
|
|
||||||
vk_bind_resources_shared_between_stages();
|
vk_bind_resources_shared_between_stages();
|
||||||
vk_bind_stage_specific_resources(pipeline, false, false);
|
vk_bind_stage_specific_resources(pipeline, false, Vk_Depth_Range::normal);
|
||||||
vkCmdDrawIndexed(vk.command_buffer, tess.numIndexes, 1, 0, 0, 0);
|
vkCmdDrawIndexed(vk.command_buffer, tess.numIndexes, 1, 0, 0, 0);
|
||||||
vk_resources.dirty_attachments = true;
|
vk_resources.dirty_attachments = true;
|
||||||
vk.xyz_elements += tess.numVertexes;
|
vk.xyz_elements += tess.numVertexes;
|
||||||
|
|
@ -342,7 +342,7 @@ void RB_ShadowFinish( void ) {
|
||||||
|
|
||||||
Com_Memcpy(backEnd.or.modelMatrix, tmp, 64);
|
Com_Memcpy(backEnd.or.modelMatrix, tmp, 64);
|
||||||
|
|
||||||
vk_bind_stage_specific_resources(vk.shadow_finish_pipeline, false, false);
|
vk_bind_stage_specific_resources(vk.shadow_finish_pipeline, false, Vk_Depth_Range::normal);
|
||||||
vkCmdDrawIndexed(vk.command_buffer, tess.numIndexes, 1, 0, 0, 0);
|
vkCmdDrawIndexed(vk.command_buffer, tess.numIndexes, 1, 0, 0, 0);
|
||||||
vk_resources.dirty_attachments = true;
|
vk_resources.dirty_attachments = true;
|
||||||
vk.xyz_elements += tess.numVertexes;
|
vk.xyz_elements += tess.numVertexes;
|
||||||
|
|
|
||||||
|
|
@ -495,7 +495,7 @@ static void DrawSkyBox( shader_t *shader )
|
||||||
|
|
||||||
Com_Memset( tess.svars.colors, tr.identityLightByte, tess.numVertexes * 4 );
|
Com_Memset( tess.svars.colors, tr.identityLightByte, tess.numVertexes * 4 );
|
||||||
vk_bind_resources_shared_between_stages();
|
vk_bind_resources_shared_between_stages();
|
||||||
vk_bind_stage_specific_resources(vk.skybox_pipeline, false, true);
|
vk_bind_stage_specific_resources(vk.skybox_pipeline, false, r_showsky->integer ? Vk_Depth_Range::force_zero : Vk_Depth_Range::force_one);
|
||||||
vkCmdDrawIndexed(vk.command_buffer, tess.numIndexes, 1, 0, 0, 0);
|
vkCmdDrawIndexed(vk.command_buffer, tess.numIndexes, 1, 0, 0, 0);
|
||||||
vk_resources.dirty_attachments = true;
|
vk_resources.dirty_attachments = true;
|
||||||
vk.xyz_elements += tess.numVertexes;
|
vk.xyz_elements += tess.numVertexes;
|
||||||
|
|
|
||||||
|
|
@ -1163,6 +1163,18 @@ void vk_initialize() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// debug pipelines
|
||||||
|
{
|
||||||
|
Vk_Pipeline_Def def;
|
||||||
|
def.face_culling = CT_FRONT_SIDED;
|
||||||
|
def.polygon_offset = false;
|
||||||
|
def.state_bits = GLS_POLYMODE_LINE | GLS_DEPTHMASK_TRUE;
|
||||||
|
def.shader_type = Vk_Shader_Type::single_texture;
|
||||||
|
def.clipping_plane = false;
|
||||||
|
def.mirror = false;
|
||||||
|
vk.tris_debug_pipeline = create_pipeline(def);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
vk.active = true;
|
vk.active = true;
|
||||||
}
|
}
|
||||||
|
|
@ -1204,19 +1216,18 @@ void vk_shutdown() {
|
||||||
vkDestroyShaderModule(vk.device, vk.multi_texture_add_fs, nullptr);
|
vkDestroyShaderModule(vk.device, vk.multi_texture_add_fs, nullptr);
|
||||||
|
|
||||||
vkDestroyPipeline(vk.device, vk.skybox_pipeline, nullptr);
|
vkDestroyPipeline(vk.device, vk.skybox_pipeline, nullptr);
|
||||||
|
|
||||||
for (int i = 0; i < 2; i++)
|
for (int i = 0; i < 2; i++)
|
||||||
for (int j = 0; j < 2; j++) {
|
for (int j = 0; j < 2; j++) {
|
||||||
vkDestroyPipeline(vk.device, vk.shadow_volume_pipelines[i][j], nullptr);
|
vkDestroyPipeline(vk.device, vk.shadow_volume_pipelines[i][j], nullptr);
|
||||||
}
|
}
|
||||||
vkDestroyPipeline(vk.device, vk.shadow_finish_pipeline, nullptr);
|
vkDestroyPipeline(vk.device, vk.shadow_finish_pipeline, nullptr);
|
||||||
|
|
||||||
for (int i = 0; i < 2; i++)
|
for (int i = 0; i < 2; i++)
|
||||||
for (int j = 0; j < 3; j++)
|
for (int j = 0; j < 3; j++)
|
||||||
for (int k = 0; k < 2; k++) {
|
for (int k = 0; k < 2; k++) {
|
||||||
vkDestroyPipeline(vk.device, vk.fog_pipelines[i][j][k], nullptr);
|
vkDestroyPipeline(vk.device, vk.fog_pipelines[i][j][k], nullptr);
|
||||||
vkDestroyPipeline(vk.device, vk.dlight_pipelines[i][j][k], nullptr);
|
vkDestroyPipeline(vk.device, vk.dlight_pipelines[i][j][k], nullptr);
|
||||||
}
|
}
|
||||||
|
vkDestroyPipeline(vk.device, vk.tris_debug_pipeline, nullptr);
|
||||||
|
|
||||||
vkDestroySwapchainKHR(vk.device, vk.swapchain, nullptr);
|
vkDestroySwapchainKHR(vk.device, vk.swapchain, nullptr);
|
||||||
vkDestroyDevice(vk.device, nullptr);
|
vkDestroyDevice(vk.device, nullptr);
|
||||||
|
|
@ -1966,7 +1977,7 @@ static VkRect2D get_viewport_rect() {
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
static VkViewport get_viewport(bool sky_depth_range) {
|
static VkViewport get_viewport(Vk_Depth_Range depth_range) {
|
||||||
VkRect2D r = get_viewport_rect();
|
VkRect2D r = get_viewport_rect();
|
||||||
|
|
||||||
VkViewport viewport;
|
VkViewport viewport;
|
||||||
|
|
@ -1974,22 +1985,22 @@ static VkViewport get_viewport(bool sky_depth_range) {
|
||||||
viewport.y = (float)r.offset.y;
|
viewport.y = (float)r.offset.y;
|
||||||
viewport.width = (float)r.extent.width;
|
viewport.width = (float)r.extent.width;
|
||||||
viewport.height = (float)r.extent.height;
|
viewport.height = (float)r.extent.height;
|
||||||
|
|
||||||
|
if (depth_range == Vk_Depth_Range::force_zero) {
|
||||||
|
viewport.minDepth = 0.0f;
|
||||||
|
viewport.maxDepth = 0.0f;
|
||||||
|
} else if (depth_range == Vk_Depth_Range::force_one) {
|
||||||
|
viewport.minDepth = 1.0f;
|
||||||
|
viewport.maxDepth = 1.0f;
|
||||||
|
} else {
|
||||||
viewport.minDepth = 0.0f;
|
viewport.minDepth = 0.0f;
|
||||||
viewport.maxDepth = 1.0f;
|
viewport.maxDepth = 1.0f;
|
||||||
|
|
||||||
if (backEnd.currentEntity->e.renderfx & RF_DEPTHHACK) {
|
if (backEnd.currentEntity->e.renderfx & RF_DEPTHHACK) {
|
||||||
viewport.maxDepth = 0.3f;
|
viewport.maxDepth = 0.3f;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (sky_depth_range) {
|
|
||||||
if (r_showsky->integer) {
|
|
||||||
viewport.minDepth = 0.0f;
|
|
||||||
viewport.maxDepth = 0.0f;
|
|
||||||
} else {
|
|
||||||
viewport.minDepth = 1.0f;
|
|
||||||
viewport.maxDepth = 1.0f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return viewport;
|
return viewport;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2109,7 +2120,7 @@ void vk_bind_resources_shared_between_stages() {
|
||||||
vkCmdPushConstants(vk.command_buffer, vk.pipeline_layout, VK_SHADER_STAGE_VERTEX_BIT, 0, push_constants_size, push_constants);
|
vkCmdPushConstants(vk.command_buffer, vk.pipeline_layout, VK_SHADER_STAGE_VERTEX_BIT, 0, push_constants_size, push_constants);
|
||||||
}
|
}
|
||||||
|
|
||||||
void vk_bind_stage_specific_resources(VkPipeline pipeline, bool multitexture, bool sky_depth_range) {
|
void vk_bind_stage_specific_resources(VkPipeline pipeline, bool multitexture, Vk_Depth_Range depth_range) {
|
||||||
//
|
//
|
||||||
// Specify color/st for each draw call since they are regenerated for each Q3 shader's stage.
|
// Specify color/st for each draw call since they are regenerated for each Q3 shader's stage.
|
||||||
// xyz are specified only once for all stages.
|
// xyz are specified only once for all stages.
|
||||||
|
|
@ -2165,7 +2176,7 @@ void vk_bind_stage_specific_resources(VkPipeline pipeline, bool multitexture, bo
|
||||||
VkRect2D scissor_rect = vk_get_scissor_rect();
|
VkRect2D scissor_rect = vk_get_scissor_rect();
|
||||||
vkCmdSetScissor(vk.command_buffer, 0, 1, &scissor_rect);
|
vkCmdSetScissor(vk.command_buffer, 0, 1, &scissor_rect);
|
||||||
|
|
||||||
VkViewport viewport = get_viewport(sky_depth_range);
|
VkViewport viewport = get_viewport(depth_range);
|
||||||
vkCmdSetViewport(vk.command_buffer, 0, 1, &viewport);
|
vkCmdSetViewport(vk.command_buffer, 0, 1, &viewport);
|
||||||
|
|
||||||
if (tess.shader->polygonOffset) {
|
if (tess.shader->polygonOffset) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user