When creating with data, always set vk GrBackendTexture layout to sampled.
We won't lose much by not going to color attachment layout since when the renderable GrBackendTexture gets wrapped in an SkSurface we still will put in a barrier to protect from write after write. The barrier will now just also include a layout change. Change-Id: I91cddd0a4de415760c3e7e4382c243946f788301 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/288136 Commit-Queue: Greg Daniel <egdaniel@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
This commit is contained in:
parent
76dcbc1eca
commit
dddf709101
@ -467,8 +467,7 @@ public:
|
||||
* client can assume the upload work has been submitted to the gpu. The finishedProc will always
|
||||
* get called even if we failed to create the GrBackendTexture.
|
||||
* For the Vulkan backend the layout of the created VkImage will be:
|
||||
* VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL if renderable is kNo
|
||||
* and VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL if renderable is kYes
|
||||
* VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
|
||||
*/
|
||||
GrBackendTexture createBackendTexture(int width, int height,
|
||||
const GrBackendFormat&,
|
||||
@ -488,8 +487,7 @@ public:
|
||||
* If successful, the created backend texture will be compatible with the provided
|
||||
* SkColorType.
|
||||
* For the Vulkan backend the layout of the created VkImage will be:
|
||||
* VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL if renderable is kNo
|
||||
* and VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL if renderable is kYes
|
||||
* VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
|
||||
*/
|
||||
GrBackendTexture createBackendTexture(int width, int height,
|
||||
SkColorType,
|
||||
@ -508,7 +506,8 @@ public:
|
||||
* the upload work has been submitted to the gpu. The finishedProc will always get called even
|
||||
* if we failed to create the GrBackendTexture.
|
||||
* For the Vulkan backend the layout of the created VkImage will be:
|
||||
* VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
|
||||
* VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL if texturaeble
|
||||
* VK_IMAGE_LAYOUT_UNDEFINED if not textureable
|
||||
*/
|
||||
GrBackendTexture createBackendTexture(const SkSurfaceCharacterization& characterization,
|
||||
const SkColor4f& color,
|
||||
@ -531,7 +530,6 @@ public:
|
||||
* Note: the pixmap's alphatypes and colorspaces are ignored.
|
||||
* For the Vulkan backend the layout of the created VkImage will be:
|
||||
* VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
|
||||
* regardless of the renderability setting
|
||||
*/
|
||||
GrBackendTexture createBackendTexture(const SkPixmap srcData[], int numLevels,
|
||||
GrRenderable, GrProtected,
|
||||
|
@ -1705,14 +1705,7 @@ bool GrVkGpu::createVkImageForBackendSurface(VkFormat vkFormat,
|
||||
regions.count(), regions.begin());
|
||||
}
|
||||
|
||||
if (data->type() == BackendTextureData::Type::kColor && renderable == GrRenderable::kYes) {
|
||||
// Change image layout to color-attachment-optimal since if we use this texture as a
|
||||
// borrowed texture within Ganesh we are probably going to render to it
|
||||
VkAccessFlags access = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT |
|
||||
VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
|
||||
image->setImageLayout(this, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, access,
|
||||
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, false);
|
||||
} else if (texturable == GrTexturable::kYes) {
|
||||
if (texturable == GrTexturable::kYes) {
|
||||
// Change image layout to shader read since if we use this texture as a borrowed
|
||||
// texture within Ganesh we require that its layout be set to that
|
||||
image->setImageLayout(this, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
|
||||
|
@ -483,7 +483,6 @@ static void test_pixmap_init(GrContext* context, skiatest::Reporter* reporter,
|
||||
enum class VkLayout {
|
||||
kUndefined,
|
||||
kReadOnlyOptimal,
|
||||
kColorAttachmentOptimal
|
||||
};
|
||||
|
||||
void check_vk_layout(const GrBackendTexture& backendTex, VkLayout layout) {
|
||||
@ -497,9 +496,6 @@ void check_vk_layout(const GrBackendTexture& backendTex, VkLayout layout) {
|
||||
case VkLayout::kReadOnlyOptimal:
|
||||
expected = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
|
||||
break;
|
||||
case VkLayout::kColorAttachmentOptimal:
|
||||
expected = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
||||
break;
|
||||
default:
|
||||
SkUNREACHABLE;
|
||||
}
|
||||
@ -582,7 +578,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(CharacterizationBackendAllocationTest, report
|
||||
SkColors::kRed,
|
||||
mark_signaled,
|
||||
&finished);
|
||||
check_vk_layout(backendTex, VkLayout::kColorAttachmentOptimal);
|
||||
check_vk_layout(backendTex, VkLayout::kReadOnlyOptimal);
|
||||
REPORTER_ASSERT(reporter, backendTex.isValid());
|
||||
REPORTER_ASSERT(reporter, c.isCompatible(backendTex));
|
||||
|
||||
@ -712,9 +708,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ColorTypeBackendAllocationTest, reporter, ctx
|
||||
GrProtected::kNo,
|
||||
mark_signaled,
|
||||
finishedPtr);
|
||||
check_vk_layout(result, GrRenderable::kYes == renderable
|
||||
? VkLayout::kColorAttachmentOptimal
|
||||
: VkLayout::kReadOnlyOptimal);
|
||||
check_vk_layout(result, VkLayout::kReadOnlyOptimal);
|
||||
|
||||
#ifdef SK_DEBUG
|
||||
{
|
||||
@ -1066,9 +1060,7 @@ DEF_GPUTEST_FOR_VULKAN_CONTEXT(VkBackendAllocationTest, reporter, ctxInfo) {
|
||||
GrProtected::kNo,
|
||||
mark_signaled,
|
||||
finishedPtr);
|
||||
check_vk_layout(beTex, GrRenderable::kYes == renderable
|
||||
? VkLayout::kColorAttachmentOptimal
|
||||
: VkLayout::kReadOnlyOptimal);
|
||||
check_vk_layout(beTex, VkLayout::kReadOnlyOptimal);
|
||||
return beTex;
|
||||
};
|
||||
test_color_init(context, reporter, createWithColorMtd,
|
||||
|
Loading…
Reference in New Issue
Block a user