Skip to content

Commit 3d88476

Browse files
committed
Refactor CB contexts
1 parent c6b412d commit 3d88476

File tree

8 files changed

+256
-213
lines changed

8 files changed

+256
-213
lines changed

Quake/gl_rmain.c

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -789,8 +789,7 @@ R_DrawWorldTask
789789
*/
790790
static void R_DrawWorldTask (int index, void *use_tasks)
791791
{
792-
const int cbx_index = index + CBX_WORLD_0;
793-
cb_context_t *cbx = &vulkan_globals.secondary_cb_contexts[cbx_index];
792+
cb_context_t *cbx = &vulkan_globals.secondary_cb_contexts[SCBX_WORLD][index];
794793
R_SetupContext (cbx);
795794
Fog_EnableGFog (cbx);
796795
if (indirect)
@@ -806,10 +805,10 @@ R_DrawSkyAndWaterTask
806805
*/
807806
static void R_DrawSkyAndWaterTask (void *unused)
808807
{
809-
R_SetupContext (&vulkan_globals.secondary_cb_contexts[CBX_SKY_AND_WATER]);
810-
Fog_EnableGFog (&vulkan_globals.secondary_cb_contexts[CBX_SKY_AND_WATER]);
811-
Sky_DrawSky (&vulkan_globals.secondary_cb_contexts[CBX_SKY_AND_WATER]);
812-
R_DrawWorld_Water (&vulkan_globals.secondary_cb_contexts[CBX_SKY_AND_WATER]);
808+
R_SetupContext (&vulkan_globals.secondary_cb_contexts[SCBX_SKY_AND_WATER][0]);
809+
Fog_EnableGFog (&vulkan_globals.secondary_cb_contexts[SCBX_SKY_AND_WATER][0]);
810+
Sky_DrawSky (&vulkan_globals.secondary_cb_contexts[SCBX_SKY_AND_WATER][0]);
811+
R_DrawWorld_Water (&vulkan_globals.secondary_cb_contexts[SCBX_SKY_AND_WATER][0]);
813812
}
814813

815814
/*
@@ -819,10 +818,10 @@ R_DrawEntitiesTask
819818
*/
820819
static void R_DrawEntitiesTask (int index, void *use_tasks)
821820
{
822-
const int cbx_index = index + CBX_ENTITIES_0;
823-
R_SetupContext (&vulkan_globals.secondary_cb_contexts[cbx_index]);
824-
Fog_EnableGFog (&vulkan_globals.secondary_cb_contexts[cbx_index]); // johnfitz
825-
R_DrawEntitiesOnList (&vulkan_globals.secondary_cb_contexts[cbx_index], false, index + chain_model_0, use_tasks ? true : false);
821+
cb_context_t *cbx = &vulkan_globals.secondary_cb_contexts[SCBX_ENTITIES][index];
822+
R_SetupContext (cbx);
823+
Fog_EnableGFog (cbx); // johnfitz
824+
R_DrawEntitiesOnList (cbx, false, index + chain_model_0, use_tasks ? true : false);
826825
}
827826

828827
/*
@@ -832,11 +831,11 @@ R_DrawAlphaEntitiesTask
832831
*/
833832
static void R_DrawAlphaEntitiesTask (void *unused)
834833
{
835-
R_SetupContext (&vulkan_globals.secondary_cb_contexts[CBX_ALPHA_ENTITIES]);
836-
Fog_EnableGFog (&vulkan_globals.secondary_cb_contexts[CBX_ALPHA_ENTITIES]);
837-
R_DrawEntitiesOnList (
838-
&vulkan_globals.secondary_cb_contexts[CBX_ALPHA_ENTITIES], true, chain_alpha_model,
839-
false); // johnfitz -- true means this is the pass for alpha entities
834+
cb_context_t *cbx = &vulkan_globals.secondary_cb_contexts[SCBX_ALPHA_ENTITIES][0];
835+
R_SetupContext (cbx);
836+
Fog_EnableGFog (cbx);
837+
R_DrawEntitiesOnList (cbx, true, chain_alpha_model,
838+
false); // johnfitz -- true means this is the pass for alpha entities
840839
}
841840

842841
/*
@@ -846,11 +845,12 @@ R_DrawParticlesTask
846845
*/
847846
static void R_DrawParticlesTask (void *unused)
848847
{
849-
R_SetupContext (&vulkan_globals.secondary_cb_contexts[CBX_PARTICLES]);
850-
Fog_EnableGFog (&vulkan_globals.secondary_cb_contexts[CBX_PARTICLES]); // johnfitz
851-
R_DrawParticles (&vulkan_globals.secondary_cb_contexts[CBX_PARTICLES]);
848+
cb_context_t *cbx = &vulkan_globals.secondary_cb_contexts[SCBX_PARTICLES][0];
849+
R_SetupContext (cbx);
850+
Fog_EnableGFog (cbx); // johnfitz
851+
R_DrawParticles (cbx);
852852
#ifdef PSET_SCRIPT
853-
PScript_DrawParticles (&vulkan_globals.secondary_cb_contexts[CBX_PARTICLES]);
853+
PScript_DrawParticles (cbx);
854854
#endif
855855
}
856856

@@ -861,10 +861,11 @@ R_DrawViewModelTask
861861
*/
862862
static void R_DrawViewModelTask (void *unused)
863863
{
864-
R_SetupContext (&vulkan_globals.secondary_cb_contexts[CBX_VIEW_MODEL]);
865-
R_DrawViewModel (&vulkan_globals.secondary_cb_contexts[CBX_VIEW_MODEL]); // johnfitz -- moved here from R_RenderView
866-
R_ShowTris (&vulkan_globals.secondary_cb_contexts[CBX_VIEW_MODEL]); // johnfitz
867-
R_ShowBoundingBoxes (&vulkan_globals.secondary_cb_contexts[CBX_VIEW_MODEL]); // johnfitz
864+
cb_context_t *cbx = &vulkan_globals.secondary_cb_contexts[SCBX_VIEW_MODEL][0];
865+
R_SetupContext (cbx);
866+
R_DrawViewModel (cbx); // johnfitz -- moved here from R_RenderView
867+
R_ShowTris (cbx); // johnfitz
868+
R_ShowBoundingBoxes (cbx); // johnfitz
868869
}
869870

870871
/*
@@ -932,7 +933,6 @@ void R_RenderView (qboolean use_tasks, task_handle_t begin_rendering_task, task_
932933
else
933934
stats_ready = false;
934935

935-
cb_context_t *primary_cbx = &vulkan_globals.primary_cb_context;
936936
if (use_tasks)
937937
{
938938
task_handle_t before_mark = Task_AllocateAndAssignFunc (R_SetupViewBeforeMark, NULL, 0);
@@ -943,7 +943,7 @@ void R_RenderView (qboolean use_tasks, task_handle_t begin_rendering_task, task_
943943
task_handle_t chain_surfaces = INVALID_TASK_HANDLE;
944944
R_MarkSurfaces (use_tasks, before_mark, &store_efrags, &cull_surfaces, &chain_surfaces);
945945

946-
task_handle_t update_warp_textures = Task_AllocateAndAssignFunc ((task_func_t)R_UpdateWarpTextures, &primary_cbx, sizeof (cb_context_t *));
946+
task_handle_t update_warp_textures = Task_AllocateAndAssignFunc ((task_func_t)R_UpdateWarpTextures, NULL, 0);
947947
Task_AddDependency (cull_surfaces, update_warp_textures);
948948
Task_AddDependency (begin_rendering_task, update_warp_textures);
949949
Task_AddDependency (update_warp_textures, draw_done_task);
@@ -981,10 +981,10 @@ void R_RenderView (qboolean use_tasks, task_handle_t begin_rendering_task, task_
981981

982982
task_handle_t build_tlas_task = Task_AllocateAndAssignFunc (R_BuildTopLevelAccelerationStructure, NULL, 0);
983983
Task_AddDependency (begin_rendering_task, build_tlas_task);
984+
Task_AddDependency (build_tlas_task, draw_done_task);
984985

985986
task_handle_t update_lightmaps_task = Task_AllocateAndAssignFunc (R_UpdateLightmapsAndIndirect, NULL, 0);
986987
Task_AddDependency (cull_surfaces, update_lightmaps_task);
987-
Task_AddDependency (build_tlas_task, update_lightmaps_task);
988988
Task_AddDependency (draw_entities_task, update_lightmaps_task);
989989
Task_AddDependency (draw_alpha_entities_task, update_lightmaps_task);
990990
Task_AddDependency (update_lightmaps_task, draw_done_task);
@@ -1016,7 +1016,7 @@ void R_RenderView (qboolean use_tasks, task_handle_t begin_rendering_task, task_
10161016
{
10171017
R_SetupViewBeforeMark (NULL);
10181018
R_MarkSurfaces (use_tasks, INVALID_TASK_HANDLE, NULL, NULL, NULL); // johnfitz -- create texture chains from PVS
1019-
R_UpdateWarpTextures (&primary_cbx);
1019+
R_UpdateWarpTextures (NULL);
10201020
R_DrawWorldTask (0, NULL);
10211021
R_DrawSkyAndWaterTask (NULL);
10221022
R_DrawEntitiesTask (0, NULL);

Quake/gl_rmisc.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2330,7 +2330,7 @@ static void R_InitDefaultStates (pipeline_create_infos_t *infos)
23302330
infos->graphics_pipeline.pColorBlendState = &infos->color_blend_state;
23312331
infos->graphics_pipeline.pDynamicState = &infos->dynamic_state;
23322332
infos->graphics_pipeline.layout = vulkan_globals.basic_pipeline_layout.handle;
2333-
infos->graphics_pipeline.renderPass = vulkan_globals.secondary_cb_contexts[CBX_WORLD_0].render_pass;
2333+
infos->graphics_pipeline.renderPass = vulkan_globals.secondary_cb_contexts[SCBX_WORLD][0].render_pass;
23342334
}
23352335

23362336
/*
@@ -2345,8 +2345,8 @@ static void R_CreateBasicPipelines ()
23452345
pipeline_create_infos_t infos;
23462346
R_InitDefaultStates (&infos);
23472347

2348-
VkRenderPass main_render_pass = vulkan_globals.secondary_cb_contexts[CBX_WORLD_0].render_pass;
2349-
VkRenderPass ui_render_pass = vulkan_globals.secondary_cb_contexts[CBX_GUI].render_pass;
2348+
VkRenderPass main_render_pass = vulkan_globals.secondary_cb_contexts[SCBX_WORLD][0].render_pass;
2349+
VkRenderPass ui_render_pass = vulkan_globals.secondary_cb_contexts[SCBX_GUI][0].render_pass;
23502350

23512351
infos.shader_stages[1].module = basic_alphatest_frag_module;
23522352
for (render_pass = 0; render_pass < 2; ++render_pass)
@@ -2464,7 +2464,7 @@ static void R_CreateParticlesPipelines ()
24642464
infos.depth_stencil_state.depthTestEnable = VK_TRUE;
24652465
infos.depth_stencil_state.depthWriteEnable = VK_FALSE;
24662466

2467-
infos.graphics_pipeline.renderPass = vulkan_globals.secondary_cb_contexts[CBX_WORLD_0].render_pass;
2467+
infos.graphics_pipeline.renderPass = vulkan_globals.secondary_cb_contexts[SCBX_WORLD][0].render_pass;
24682468

24692469
infos.blend_attachment_state.blendEnable = VK_TRUE;
24702470

@@ -2567,7 +2567,7 @@ static void R_CreateFTEParticlesPipelines ()
25672567

25682568
infos.depth_stencil_state.depthTestEnable = VK_TRUE;
25692569
infos.depth_stencil_state.depthWriteEnable = VK_FALSE;
2570-
infos.graphics_pipeline.renderPass = vulkan_globals.secondary_cb_contexts[CBX_WORLD_0].render_pass;
2570+
infos.graphics_pipeline.renderPass = vulkan_globals.secondary_cb_contexts[SCBX_WORLD][0].render_pass;
25712571
infos.blend_attachment_state.blendEnable = VK_TRUE;
25722572

25732573
infos.multisample_state.sampleShadingEnable = VK_FALSE;
@@ -2655,7 +2655,7 @@ static void R_CreateSkyPipelines ()
26552655
infos.vertex_input_state.pVertexBindingDescriptions = &world_vertex_binding_description;
26562656
}
26572657

2658-
infos.graphics_pipeline.renderPass = vulkan_globals.secondary_cb_contexts[CBX_WORLD_0].render_pass;
2658+
infos.graphics_pipeline.renderPass = vulkan_globals.secondary_cb_contexts[SCBX_WORLD][0].render_pass;
26592659

26602660
infos.graphics_pipeline.stageCount = 1;
26612661
infos.shader_stages[1].module = VK_NULL_HANDLE;
@@ -3163,7 +3163,7 @@ static void R_CreatePostprocessPipelines ()
31633163

31643164
infos.shader_stages[0].module = postprocess_vert_module;
31653165
infos.shader_stages[1].module = postprocess_frag_module;
3166-
infos.graphics_pipeline.renderPass = vulkan_globals.secondary_cb_contexts[CBX_GUI].render_pass;
3166+
infos.graphics_pipeline.renderPass = vulkan_globals.secondary_cb_contexts[SCBX_GUI][0].render_pass;
31673167
infos.graphics_pipeline.layout = vulkan_globals.postprocess_pipeline.layout.handle;
31683168
infos.graphics_pipeline.subpass = 1;
31693169

Quake/gl_screen.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,7 @@ SCR_DrawGUI
10931093
*/
10941094
static void SCR_DrawGUI (void *unused)
10951095
{
1096-
cb_context_t *cbx = &vulkan_globals.secondary_cb_contexts[CBX_GUI];
1096+
cb_context_t *cbx = &vulkan_globals.secondary_cb_contexts[SCBX_GUI][0];
10971097

10981098
GL_SetCanvas (cbx, CANVAS_DEFAULT);
10991099
R_BindPipeline (cbx, VK_PIPELINE_BIND_POINT_GRAPHICS, vulkan_globals.basic_blend_pipeline[cbx->render_pass_index]);

0 commit comments

Comments
 (0)