WIP: Vulkan: Workbench #107886
|
@ -111,6 +111,15 @@ class VKFrameBuffer : public FrameBuffer {
|
|||
return vk_image_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Framebuffers that are owned by GHOST are immutable and don't have any attachments assigned. It
|
||||
* should be assumed that there is a single color texture in slot 0.
|
||||
*/
|
||||
bool is_immutable() const
|
||||
{
|
||||
return immutable_;
|
||||
}
|
||||
|
||||
private:
|
||||
void update_attachments();
|
||||
void render_pass_free();
|
||||
|
|
|
@ -22,8 +22,6 @@ VKPipelineStateManager::VKPipelineStateManager()
|
|||
depth_stencil_state = {};
|
||||
depth_stencil_state.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO;
|
||||
|
||||
/* TODO should be extracted from current framebuffer and should not be done here and now. */
|
||||
/* When the attachments differ the state should be forced. */
|
||||
color_blend_attachment_template = {};
|
||||
color_blend_attachment_template.colorWriteMask = VK_COLOR_COMPONENT_R_BIT |
|
||||
VK_COLOR_COMPONENT_G_BIT |
|
||||
|
@ -79,21 +77,35 @@ void VKPipelineStateManager::force_state(const GPUState &state,
|
|||
void VKPipelineStateManager::finalize_color_blend_state(const VKFrameBuffer &framebuffer)
|
||||
{
|
||||
color_blend_attachments.clear();
|
||||
if (framebuffer.is_immutable()) {
|
||||
/* Immutable framebuffers are owned by GHOST and don't have any attachments assigned. In this
|
||||
* case we assume that there is a single color texture assigned.
|
||||
*/
|
||||
color_blend_attachments.append(color_blend_attachment_template);
|
||||
}
|
||||
else {
|
||||
|
||||
for (int color_slot = 0; color_slot < GPU_FB_MAX_COLOR_ATTACHMENT; color_slot++) {
|
||||
VKTexture *texture = unwrap(unwrap(framebuffer.color_tex(color_slot)));
|
||||
if (texture) {
|
||||
eGPUTextureFormatFlag format_flag = texture->format_flag_get();
|
||||
if (format_flag & GPU_FORMAT_INTEGER) {
|
||||
color_blend_attachments.append(color_blend_attachment_int_template);
|
||||
bool is_sequential = true;
|
||||
for (int color_slot = 0; color_slot < GPU_FB_MAX_COLOR_ATTACHMENT; color_slot++) {
|
||||
VKTexture *texture = unwrap(unwrap(framebuffer.color_tex(color_slot)));
|
||||
if (texture) {
|
||||
BLI_assert(is_sequential);
|
||||
eGPUTextureFormatFlag format_flag = texture->format_flag_get();
|
||||
if (format_flag & GPU_FORMAT_INTEGER) {
|
||||
color_blend_attachments.append(color_blend_attachment_int_template);
|
||||
}
|
||||
else {
|
||||
color_blend_attachments.append(color_blend_attachment_template);
|
||||
}
|
||||
}
|
||||
else {
|
||||
color_blend_attachments.append(color_blend_attachment_template);
|
||||
/* Test to detect if all color textures are sequential attached from the first slot. We
|
||||
* assume at this moment that this is the case. Otherwise we need to rewire how attachments
|
||||
* and bindings work.*/
|
||||
is_sequential = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
color_blend_attachments.append(color_blend_attachment_template);
|
||||
}
|
||||
UNUSED_VARS_NDEBUG(is_sequential);
|
||||
}
|
||||
|
||||
pipeline_color_blend_state.attachmentCount = color_blend_attachments.size();
|
||||
|
|
Loading…
Reference in New Issue