Skip to content

Commit

Permalink
UPBGE: Change previous commmit to fix #1827
Browse files Browse the repository at this point in the history
because i was not comfortable with what i did previously
  • Loading branch information
youle31 committed Jul 27, 2023
1 parent 2105aff commit daa5989
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
7 changes: 4 additions & 3 deletions source/gameengine/Ketsji/KX_Scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -886,15 +886,16 @@ void KX_Scene::RenderAfterCameraSetup(KX_Camera *cam,
RAS_FrameBuffer *input = rasty->GetFrameBuffer(rasty->NextFilterFrameBuffer(r));
RAS_FrameBuffer *output = rasty->GetFrameBuffer(rasty->NextRenderFrameBuffer(s));

GPUTexture *color = GPU_viewport_color_texture(m_currentGPUViewport, 0);

GPUAttachment config[] = {
GPU_ATTACHMENT_TEXTURE(GPU_viewport_depth_texture(m_currentGPUViewport)),
GPU_ATTACHMENT_TEXTURE(GPU_viewport_color_texture(m_currentGPUViewport, 0))};
GPU_ATTACHMENT_TEXTURE(color)};

GPU_framebuffer_config_array(
input->GetFrameBuffer(), config, sizeof(config) / sizeof(GPUAttachment));

GPU_framebuffer_config_array(
output->GetFrameBuffer(), config, sizeof(config) / sizeof(GPUAttachment));
output->UpdateSize(GPU_texture_width(color), GPU_texture_height(color));

RAS_FrameBuffer *f = is_overlay_pass ? input : Render2DFilters(rasty, canvas, input, output);

Expand Down
17 changes: 17 additions & 0 deletions source/gameengine/Rasterizer/RAS_FrameBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,23 @@ GPUTexture *RAS_FrameBuffer::GetDepthAttachment()
return m_depthAttachment;
}

void RAS_FrameBuffer::UpdateSize(int width, int height)
{
if (GPU_texture_width(m_colorAttachment) != width ||
GPU_texture_height(m_colorAttachment) != height) {
GPU_texture_free(m_colorAttachment);
GPU_texture_free(m_depthAttachment);
m_colorAttachment = GPU_texture_create_2d(
"color_tex", width, height, 1, GPU_RGBA16F, GPU_TEXTURE_USAGE_GENERAL, nullptr);
m_depthAttachment = GPU_texture_create_2d(
"depth_tex", width, height, 1, GPU_DEPTH24_STENCIL8, GPU_TEXTURE_USAGE_GENERAL, nullptr);
GPUAttachment config[] = {GPU_ATTACHMENT_TEXTURE(m_depthAttachment),
GPU_ATTACHMENT_TEXTURE(m_colorAttachment)};

GPU_framebuffer_config_array(m_frameBuffer, config, sizeof(config) / sizeof(GPUAttachment));
}
}

RAS_Rasterizer::FrameBufferType RAS_FrameBuffer::GetType() const
{
return m_frameBufferType;
Expand Down
2 changes: 2 additions & 0 deletions source/gameengine/Rasterizer/RAS_FrameBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,7 @@ class RAS_FrameBuffer {
GPUTexture *GetColorAttachment();
GPUTexture *GetDepthAttachment();

void UpdateSize(int width, int height);

RAS_Rasterizer::FrameBufferType GetType() const;
};

1 comment on commit daa5989

@lordloki
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix, youle.

Please sign in to comment.