mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-12-22 18:09:49 +01:00
render/vulkan: Use image view swizzles instead of shader hack
Signed-off-by: Joshua Ashton <joshua@froggi.es>
This commit is contained in:
parent
e22a386319
commit
b62ce3c3c8
3 changed files with 13 additions and 23 deletions
|
@ -794,17 +794,6 @@ static bool vulkan_render_subtexture_with_matrix(struct wlr_renderer *wlr_render
|
|||
vert_pcr_data.uv_size[1] = -vert_pcr_data.uv_size[1];
|
||||
}
|
||||
|
||||
// When the texture itself does not have alpha information we want
|
||||
// to ignore the sampled value and just use the alpha passed here,
|
||||
// we pass a negative value to communicate that.
|
||||
// See the texture.frag shader for more details.
|
||||
const struct wlr_pixel_format_info *format_info = drm_get_pixel_format_info(
|
||||
texture->format->drm_format);
|
||||
assert(format_info);
|
||||
if (!format_info->has_alpha) {
|
||||
alpha *= -1;
|
||||
}
|
||||
|
||||
vkCmdPushConstants(cb, renderer->pipe_layout,
|
||||
VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(vert_pcr_data), &vert_pcr_data);
|
||||
vkCmdPushConstants(cb, renderer->pipe_layout,
|
||||
|
|
|
@ -11,15 +11,6 @@ layout(push_constant) uniform UBO {
|
|||
|
||||
void main() {
|
||||
out_color = textureLod(tex, uv, 0);
|
||||
|
||||
// We expect this shader to output pre-alpha-multiplied color values.
|
||||
// alpha < 0.0 means that this shader should ignore the texture's alpha
|
||||
// value.
|
||||
if (data.alpha < 0.0) {
|
||||
out_color.a = -data.alpha;
|
||||
out_color.rgb *= -data.alpha;
|
||||
} else {
|
||||
out_color *= data.alpha;
|
||||
}
|
||||
out_color *= data.alpha;
|
||||
}
|
||||
|
||||
|
|
|
@ -288,6 +288,9 @@ static struct wlr_texture *vulkan_texture_from_pixels(struct wlr_renderer *wlr_r
|
|||
goto error;
|
||||
}
|
||||
|
||||
const struct wlr_pixel_format_info *format_info = drm_get_pixel_format_info(drm_fmt);
|
||||
assert(format_info);
|
||||
|
||||
// view
|
||||
VkImageViewCreateInfo view_info = {0};
|
||||
view_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
|
||||
|
@ -296,7 +299,9 @@ static struct wlr_texture *vulkan_texture_from_pixels(struct wlr_renderer *wlr_r
|
|||
view_info.components.r = VK_COMPONENT_SWIZZLE_IDENTITY;
|
||||
view_info.components.g = VK_COMPONENT_SWIZZLE_IDENTITY;
|
||||
view_info.components.b = VK_COMPONENT_SWIZZLE_IDENTITY;
|
||||
view_info.components.a = VK_COMPONENT_SWIZZLE_IDENTITY;
|
||||
view_info.components.a = format_info->has_alpha
|
||||
? VK_COMPONENT_SWIZZLE_IDENTITY
|
||||
: VK_COMPONENT_SWIZZLE_ONE;
|
||||
|
||||
view_info.subresourceRange = (VkImageSubresourceRange) {
|
||||
VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1
|
||||
|
@ -613,6 +618,9 @@ static struct wlr_texture *vulkan_texture_from_dmabuf(struct wlr_renderer *wlr_r
|
|||
// return VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
const struct wlr_pixel_format_info *format_info = drm_get_pixel_format_info(attribs->format);
|
||||
assert(format_info);
|
||||
|
||||
// view
|
||||
VkImageViewCreateInfo view_info = {0};
|
||||
view_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
|
||||
|
@ -621,7 +629,9 @@ static struct wlr_texture *vulkan_texture_from_dmabuf(struct wlr_renderer *wlr_r
|
|||
view_info.components.r = VK_COMPONENT_SWIZZLE_IDENTITY;
|
||||
view_info.components.g = VK_COMPONENT_SWIZZLE_IDENTITY;
|
||||
view_info.components.b = VK_COMPONENT_SWIZZLE_IDENTITY;
|
||||
view_info.components.a = VK_COMPONENT_SWIZZLE_IDENTITY;
|
||||
view_info.components.a = format_info->has_alpha
|
||||
? VK_COMPONENT_SWIZZLE_IDENTITY
|
||||
: VK_COMPONENT_SWIZZLE_ONE;
|
||||
|
||||
view_info.subresourceRange = (VkImageSubresourceRange) {
|
||||
VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1
|
||||
|
|
Loading…
Reference in a new issue