mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-04-19 06:47:02 -04:00
render/vk: Move render_setup into render_pass
Need to use imageless framebuffers, which every driver has implemented
This commit is contained in:
parent
5d4313eb82
commit
4ba290a7a9
4 changed files with 156 additions and 48 deletions
|
|
@ -101,7 +101,7 @@ static bool render_pass_submit(struct wlr_render_pass *wlr_pass) {
|
|||
};
|
||||
mat3_to_mat4(final_matrix, vert_pcr_data.mat4);
|
||||
|
||||
bind_pipeline(pass, render_buffer->render_setup->output_pipe);
|
||||
bind_pipeline(pass, pass->render_setup->output_pipe);
|
||||
vkCmdPushConstants(render_cb->vk, renderer->output_pipe_layout,
|
||||
VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(vert_pcr_data), &vert_pcr_data);
|
||||
vkCmdBindDescriptorSets(render_cb->vk,
|
||||
|
|
@ -476,7 +476,7 @@ static void render_pass_add_rect(struct wlr_render_pass *wlr_pass,
|
|||
wlr_matrix_multiply(matrix, pass->projection, matrix);
|
||||
|
||||
struct wlr_vk_pipeline *pipe = setup_get_or_create_pipeline(
|
||||
pass->render_buffer->render_setup,
|
||||
pass->render_setup,
|
||||
&(struct wlr_vk_pipeline_key) {
|
||||
.source = WLR_VK_SHADER_SOURCE_SINGLE_COLOR,
|
||||
.layout = { .ycbcr_format = NULL },
|
||||
|
|
@ -540,7 +540,6 @@ static void render_pass_add_texture(struct wlr_render_pass *wlr_pass,
|
|||
const struct wlr_render_texture_options *options) {
|
||||
struct wlr_vk_render_pass *pass = get_render_pass(wlr_pass);
|
||||
struct wlr_vk_renderer *renderer = pass->renderer;
|
||||
struct wlr_vk_render_buffer *render_buffer = pass->render_buffer;
|
||||
VkCommandBuffer cb = pass->command_buffer->vk;
|
||||
|
||||
struct wlr_vk_texture *texture = vulkan_get_texture(options->texture);
|
||||
|
|
@ -586,7 +585,7 @@ static void render_pass_add_texture(struct wlr_render_pass *wlr_pass,
|
|||
mat3_to_mat4(matrix, vert_pcr_data.mat4);
|
||||
|
||||
struct wlr_vk_pipeline *pipe = setup_get_or_create_pipeline(
|
||||
render_buffer->render_setup,
|
||||
pass->render_setup,
|
||||
&(struct wlr_vk_pipeline_key) {
|
||||
.source = WLR_VK_SHADER_SOURCE_TEXTURE,
|
||||
.layout = {
|
||||
|
|
@ -661,6 +660,21 @@ struct wlr_vk_render_pass *vulkan_begin_render_pass(struct wlr_vk_renderer *rend
|
|||
|
||||
rect_union_init(&pass->updated_region);
|
||||
|
||||
bool has_blending_buffer = buffer->blend_image != VK_NULL_HANDLE;
|
||||
struct wlr_vk_render_format_setup *render_setup = find_or_create_render_setup(
|
||||
renderer, buffer->fmt, has_blending_buffer);
|
||||
if (render_setup == NULL) {
|
||||
free(pass);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct wlr_vk_framebuffer *framebuffer = get_or_create_framebuffer(
|
||||
render_setup, buffer->wlr_buffer->width, buffer->wlr_buffer->height);
|
||||
if (framebuffer == NULL) {
|
||||
free(pass);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct wlr_vk_command_buffer *cb = vulkan_acquire_command_buffer(renderer);
|
||||
if (cb == NULL) {
|
||||
free(pass);
|
||||
|
|
@ -681,12 +695,25 @@ struct wlr_vk_render_pass *vulkan_begin_render_pass(struct wlr_vk_renderer *rend
|
|||
int width = buffer->wlr_buffer->width;
|
||||
int height = buffer->wlr_buffer->height;
|
||||
VkRect2D rect = { .extent = { width, height } };
|
||||
VkImageView attachments[2] = {0};
|
||||
uint32_t attachment_count = 0;
|
||||
|
||||
if (buffer->blend_image_view != VK_NULL_HANDLE) {
|
||||
attachments[attachment_count++] = buffer->blend_image_view;
|
||||
}
|
||||
attachments[attachment_count++] = buffer->image_view;
|
||||
|
||||
VkRenderPassAttachmentBeginInfo attachment_info = {
|
||||
.sType = VK_STRUCTURE_TYPE_RENDER_PASS_ATTACHMENT_BEGIN_INFO,
|
||||
.attachmentCount = attachment_count,
|
||||
.pAttachments = attachments,
|
||||
};
|
||||
VkRenderPassBeginInfo rp_info = {
|
||||
.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO,
|
||||
.pNext = &attachment_info,
|
||||
.renderArea = rect,
|
||||
.renderPass = buffer->render_setup->render_pass,
|
||||
.framebuffer = buffer->framebuffer,
|
||||
.renderPass = render_setup->render_pass,
|
||||
.framebuffer = framebuffer->vk,
|
||||
.clearValueCount = 0,
|
||||
};
|
||||
vkCmdBeginRenderPass(cb->vk, &rp_info, VK_SUBPASS_CONTENTS_INLINE);
|
||||
|
|
@ -703,6 +730,7 @@ struct wlr_vk_render_pass *vulkan_begin_render_pass(struct wlr_vk_renderer *rend
|
|||
|
||||
wlr_buffer_lock(buffer->wlr_buffer);
|
||||
pass->render_buffer = buffer;
|
||||
pass->render_setup = render_setup;
|
||||
pass->command_buffer = cb;
|
||||
return pass;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue