Skip to content

Commit dee676d

Browse files
cursoragenttimfox
andcommitted
Vulkan: cache main color extent for stable render-target queries
Store main FBO color attachment dimensions when attachments are built and have vk_get_render_target_width/height prefer them while FBO is active. Auxiliary passes that temporarily overwrite vk.renderWidth no longer skew Forward+, post params, temporal resets, or scissor clamping. Document the behavior in RENDERER_2026_ARCHITECTURE_PASS.md. Co-authored-by: Tim Fox <timfox@outlook.com>
1 parent 46188a6 commit dee676d

4 files changed

Lines changed: 14 additions & 0 deletions

File tree

docs/RENDERER_2026_ARCHITECTURE_PASS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ Treat temporal stability as a first-class renderer subsystem instead of a set of
100100
### Incremental (engine)
101101

102102
- **`VK_TEMPORAL_RESET_RENDER_SIZE_CHANGE`** in `vk_temporal.c` compares the **effective render target** size from **`vk_get_render_target_width()` / `vk_get_render_target_height()`** (FBO / `r_renderScale`), not `glConfig` alone, so internal resolution changes still clear motion, TAA, volumetric, exposure, and occlusion history consistently with the color pass.
103+
- When **`vk.fboActive`**, those helpers prefer **`vk.mainColorWidth` / `vk.mainColorHeight`** (set when the main scene color attachment is created in `vk_attachments.c`) so **Forward+**, **post params**, and **temporal** paths do not read transient **`vk.renderWidth`** overrides from shadow or atlas passes.
103104

104105
### Explicit non-goals
105106

src/renderers/vulkan/vk.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,6 +1271,9 @@ typedef struct {
12711271

12721272
uint32_t renderWidth;
12731273
uint32_t renderHeight;
1274+
/* Main scene color attachment (FBO) pixel size; stable while vk.renderWidth is temporarily overridden (shadow atlases, etc.). */
1275+
uint32_t mainColorWidth;
1276+
uint32_t mainColorHeight;
12741277

12751278
float renderScaleX;
12761279
float renderScaleY;

src/renderers/vulkan/vk_attachments.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,8 @@ void vk_create_attachments( void )
507507
// post-processing/msaa-resolve
508508
vk_create_fullres_color_attachment( vk.color_format,
509509
copyableColorUsage, &vk.color_image, &vk.color_image_view, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, qfalse );
510+
vk.mainColorWidth = fullWidth;
511+
vk.mainColorHeight = fullHeight;
510512
vk_create_fullres_color_attachment( vk.color_format,
511513
VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT,
512514
&vk.ui_overlay_image, &vk.ui_overlay_image_view, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, qfalse );
@@ -1866,6 +1868,8 @@ void vk_destroy_attachments( void )
18661868
vk.color_image_view = VK_NULL_HANDLE;
18671869
vk.post_fog_color_source = VK_NULL_HANDLE;
18681870
vk.scene_post_fog_color_source = VK_NULL_HANDLE;
1871+
vk.mainColorWidth = 0u;
1872+
vk.mainColorHeight = 0u;
18691873
}
18701874
if ( vk.ui_overlay_image ) {
18711875
qvkDestroyImage( vk.device, vk.ui_overlay_image, NULL );

src/renderers/vulkan/vk_view_state.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ static qboolean vk_curr_entity_model_valid[MAX_REFENTITIES];
2323

2424
uint32_t vk_get_render_target_width( void )
2525
{
26+
if ( vk.fboActive && vk.mainColorWidth > 0u ) {
27+
return vk.mainColorWidth;
28+
}
2629
if ( vk.renderWidth > 0 ) {
2730
return vk.renderWidth;
2831
}
@@ -34,6 +37,9 @@ uint32_t vk_get_render_target_width( void )
3437

3538
uint32_t vk_get_render_target_height( void )
3639
{
40+
if ( vk.fboActive && vk.mainColorHeight > 0u ) {
41+
return vk.mainColorHeight;
42+
}
3743
if ( vk.renderHeight > 0 ) {
3844
return vk.renderHeight;
3945
}

0 commit comments

Comments
 (0)