[gtk+] Add an api to create intermediate textures
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Add an api to create intermediate textures
- Date: Thu, 28 Sep 2017 12:39:57 +0000 (UTC)
commit ff188f6bf075d2fe3f6a4faa401a4a83c80af483
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Sep 26 19:12:20 2017 -0400
Add an api to create intermediate textures
The new function creates a vulkan image that is suitable for
use as a framebuffer to render to and as a texture to read from.
gsk/gskvulkanimage.c | 29 ++++++++++++++++++++++++++---
gsk/gskvulkanimageprivate.h | 3 +++
2 files changed, 29 insertions(+), 3 deletions(-)
---
diff --git a/gsk/gskvulkanimage.c b/gsk/gskvulkanimage.c
index 1eb9c3a..f64a3ac 100644
--- a/gsk/gskvulkanimage.c
+++ b/gsk/gskvulkanimage.c
@@ -148,7 +148,7 @@ gsk_vulkan_uploader_upload (GskVulkanUploader *self)
command_buffer = gsk_vulkan_command_pool_get_buffer (self->command_pool);
vkCmdPipelineBarrier (command_buffer,
- VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
+ VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT |
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
VK_PIPELINE_STAGE_HOST_BIT | VK_PIPELINE_STAGE_TRANSFER_BIT,
0,
0, NULL,
@@ -604,6 +604,29 @@ gsk_vulkan_image_new_for_atlas (GdkVulkanContext *context,
return self;
}
+GskVulkanImage *
+gsk_vulkan_image_new_for_texture (GdkVulkanContext *context,
+ gsize width,
+ gsize height)
+{
+ GskVulkanImage *self;
+
+ self = gsk_vulkan_image_new (context,
+ width,
+ height,
+ VK_IMAGE_TILING_OPTIMAL,
+ VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT |
+ VK_IMAGE_USAGE_SAMPLED_BIT |
+ VK_IMAGE_USAGE_TRANSFER_SRC_BIT,
+ VK_IMAGE_LAYOUT_UNDEFINED,
+ 0,
+ VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
+
+ gsk_vulkan_image_ensure_view (self, VK_FORMAT_B8G8R8A8_UNORM);
+
+ return self;
+}
+
GskTexture *
gsk_vulkan_image_download (GskVulkanImage *self,
GskVulkanUploader *uploader)
@@ -615,14 +638,14 @@ gsk_vulkan_image_download (GskVulkanImage *self,
gsk_vulkan_uploader_add_image_barrier (uploader,
FALSE,
self,
- VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
+ VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
VK_ACCESS_TRANSFER_READ_BIT);
buffer = gsk_vulkan_buffer_new_download (self->vulkan, self->width * self->height * 4);
vkCmdCopyImageToBuffer (gsk_vulkan_uploader_get_copy_buffer (uploader),
self->vk_image,
- VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
+ VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
gsk_vulkan_buffer_get_buffer (buffer),
1,
(VkBufferImageCopy[1]) {
diff --git a/gsk/gskvulkanimageprivate.h b/gsk/gskvulkanimageprivate.h
index 8676062..f6223e9 100644
--- a/gsk/gskvulkanimageprivate.h
+++ b/gsk/gskvulkanimageprivate.h
@@ -51,6 +51,9 @@ GskVulkanImage * gsk_vulkan_image_new_for_framebuffer (GdkVulk
GskVulkanImage * gsk_vulkan_image_new_for_atlas (GdkVulkanContext *context,
gsize width,
gsize height);
+GskVulkanImage * gsk_vulkan_image_new_for_texture (GdkVulkanContext *context,
+ gsize width,
+ gsize height);
GskTexture * gsk_vulkan_image_download (GskVulkanImage *self,
GskVulkanUploader *uploader);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]