Vulkan: Clearing Framebuffer + Scissors #106044
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
No due date set.
Depends on
#105762 Vulkan: Texture Data Conversions
blender/blender
#105921 GPU: Renderdoc Frame Capturing
blender/blender
Reference: blender/blender#106044
Loading…
Reference in New Issue
No description provided.
Delete Branch "Jeroen-Bakker/blender:vulkan-framebuffer-clear"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This PR adds support for clearing framebuffers and scissor testing.
Tweaks had to be made to VKTexture to keep track of its layout
on the device. Based on the actual call the layout can switch
to a more optimum layout.
For example during upload of a texture the texture will be converted
to a transfer destination optimized layout. When reading from the
texture it will be converted to a transfer source optimized layout.
The order of the attachments in the framebuffer follows the next rules
be placed in the slot they are defined. This way it will match
the ShaderCreateInfo binding location.
right after the color attachments. When there isn't a color
attachment it will be the first attachment.
Depth attachment in Vulkan doesn't have a specific binding location
as there can only be one in the framebuffer.
To demonstrate what is possible. This is the image created by the
GPUVulkanTest.framebuffer_scissor_test
test case. Drawing withscissors!
Vulkan: Clearing Framebufferto WIP: Vulkan: Clearing FramebufferWIP: Vulkan: Clearing Framebufferto Vulkan: Clearing FramebufferVulkan: Clearing Framebufferto Vulkan: Clearing Framebuffer + Scissors@ -68,0 +82,4 @@
* \{ */
public:
/**
* Change the current layout setting, without actually changing the layout.
Update the current layout attribute, without actually changing the layout.
@ -0,0 +64,4 @@
float4 *read_data2 = static_cast<float4 *>(GPU_texture_read(texture2, GPU_DATA_FLOAT, 0));
for (float4 pixel_color : Span<float4>(read_data1, size.x * size.y)) {
EXPECT_EQ(pixel_color, clear_color);
}
This Check may result in an error.
Sometimes it clears correctly.
\blender\source\blender\gpu\tests\framebuffer_test.cc(66): error: Expected equality of these values:
pixel_color
Which is: (-1.9984e+18, -1.9984e+18, -1.9984e+18, -1.9984e+18)
clear_color
Which is: (0.1, 0.2, 0.5, 1)
A possible cause of this suspicious behavior is that the layout is only general.
@ -0,0 +80,4 @@
GPUTexture *texture1 = GPU_texture_create_2d(
__func__, UNPACK2(size), 1, GPU_RGBA32F, usage, nullptr);
GPUTexture *texture2 = GPU_texture_create_2d(
__func__, UNPACK2(size), 1, GPU_RGBA32F, usage, nullptr);
Would be best to test if clearing attachments with different formats work.
And also with integer format.
@ -62,0 +111,4 @@
VkClearAttachment clear_attachment = {};
clear_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
clear_attachment.colorAttachment = color_slot;
copy_v4_v4(clear_attachment.clearValue.color.float32, clear_colors[color_index]);
I believe that doesn't work if the attachement is a integer texture. If I remember correctly we expect the data to be converted to (U)INT. So would still suggest to cast the floats to int so that
1.0f > 1
.After looking up the usage, it seem to be only used for object IDs and thoses are cleared to 0.
EDIT: In GL, we reinterpret the data:
@ -0,0 +64,4 @@
uint4 *read_data2 = static_cast<uint4 *>(GPU_texture_read(texture2, GPU_DATA_UINT, 0));
uint4 clear_color_uint(1036831949, 1045220557, 1056964608, 1065353216);
for (uint4 pixel_color : Span<uint4>(read_data2, size.x * size.y)) {
EXPECT_EQ(pixel_color, clear_color_uint);
The issue was a read out of bounds. Can you recheck if it still fails for you.
The root cause was that
read_data1
was read, but was already freed. It should have checkedread_data2
.@ -62,0 +111,4 @@
VkClearAttachment clear_attachment = {};
clear_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
clear_attachment.colorAttachment = color_slot;
copy_v4_v4(clear_attachment.clearValue.color.float32, clear_colors[color_index]);
Yes you're right, I misread the specifications how they handled SINT/UINT texture formats. Althought
VkClearColorValue
is an union and would have the same effect as the OpenGL code. I cleaned the code up so this is more visible.I think we should change the API as the API uses a float parameter here, which is confusing when clearing other type of buffers. In that case I can move
to_vk_clear_color_value
tovk_common.cc
and use that one. Something to do outside this patch.@ -99,0 +330,4 @@
VkSubpassDescription subpass = {};
subpass.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
subpass.colorAttachmentCount = color_attachment_len;
subpass.pColorAttachments = attachment_references.begin();
In case of windows machine, this part does not pass.
attachment_references.data();
image_views.data();
No problem here.