WIP: Vulkan: Workbench #107886
|
@ -111,6 +111,15 @@ class VKFrameBuffer : public FrameBuffer {
|
||||||
return vk_image_;
|
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:
|
private:
|
||||||
void update_attachments();
|
void update_attachments();
|
||||||
void render_pass_free();
|
void render_pass_free();
|
||||||
|
|
|
@ -22,8 +22,6 @@ VKPipelineStateManager::VKPipelineStateManager()
|
||||||
depth_stencil_state = {};
|
depth_stencil_state = {};
|
||||||
depth_stencil_state.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO;
|
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 = {};
|
||||||
color_blend_attachment_template.colorWriteMask = VK_COLOR_COMPONENT_R_BIT |
|
color_blend_attachment_template.colorWriteMask = VK_COLOR_COMPONENT_R_BIT |
|
||||||
VK_COLOR_COMPONENT_G_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)
|
void VKPipelineStateManager::finalize_color_blend_state(const VKFrameBuffer &framebuffer)
|
||||||
{
|
{
|
||||||
color_blend_attachments.clear();
|
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++) {
|
bool is_sequential = true;
|
||||||
VKTexture *texture = unwrap(unwrap(framebuffer.color_tex(color_slot)));
|
for (int color_slot = 0; color_slot < GPU_FB_MAX_COLOR_ATTACHMENT; color_slot++) {
|
||||||
if (texture) {
|
VKTexture *texture = unwrap(unwrap(framebuffer.color_tex(color_slot)));
|
||||||
eGPUTextureFormatFlag format_flag = texture->format_flag_get();
|
if (texture) {
|
||||||
if (format_flag & GPU_FORMAT_INTEGER) {
|
BLI_assert(is_sequential);
|
||||||
color_blend_attachments.append(color_blend_attachment_int_template);
|
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 {
|
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 {
|
UNUSED_VARS_NDEBUG(is_sequential);
|
||||||
color_blend_attachments.append(color_blend_attachment_template);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pipeline_color_blend_state.attachmentCount = color_blend_attachments.size();
|
pipeline_color_blend_state.attachmentCount = color_blend_attachments.size();
|
||||||
|
|
Loading…
Reference in New Issue