Commit 33bdab77 by Ian Elliott Committed by Commit Bot

Vulkan: Handle VK image being both a GL texture and GL image

Address a shader that uses the same texture as both a GL texture (e.g. using a sampler) AND as a GL image (e.g. using imageLoad or imageStore). The barrier and descriptor set created by ContextVk::handleDirtyTexturesImpl() are wrong (read-only). This is fixed by having ContextVk::handleDirtyTexturesImpl() look up if the image is also being used as an image texture, and if so, use the layout that should be used in that case. Bug: angleproject:4413 Change-Id: I75684e1cfc7ed74296802ab6e31468d81625d4a5 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2099311 Commit-Queue: Ian Elliott <ianelliott@google.com> Reviewed-by: 's avatarCody Northrop <cnorthrop@google.com>
parent 391f38c9
...@@ -135,6 +135,7 @@ class TextureState final : private angle::NonCopyable ...@@ -135,6 +135,7 @@ class TextureState final : private angle::NonCopyable
GLenum getUsage() const { return mUsage; } GLenum getUsage() const { return mUsage; }
GLenum getDepthStencilTextureMode() const { return mDepthStencilTextureMode; } GLenum getDepthStencilTextureMode() const { return mDepthStencilTextureMode; }
bool isStencilMode() const { return mDepthStencilTextureMode == GL_STENCIL_INDEX; } bool isStencilMode() const { return mDepthStencilTextureMode == GL_STENCIL_INDEX; }
bool isBoundAsImageTexture() const { return mBoundAsImageTexture; }
// Returns the desc of the base level. Only valid for cube-complete/mip-complete textures. // Returns the desc of the base level. Only valid for cube-complete/mip-complete textures.
const ImageDesc &getBaseLevelDesc() const; const ImageDesc &getBaseLevelDesc() const;
......
...@@ -1219,13 +1219,21 @@ ANGLE_INLINE angle::Result ContextVk::handleDirtyTexturesImpl( ...@@ -1219,13 +1219,21 @@ ANGLE_INLINE angle::Result ContextVk::handleDirtyTexturesImpl(
// lingering staged updates in its staging buffer for unused texture mip levels or // lingering staged updates in its staging buffer for unused texture mip levels or
// layers. Therefore we can't verify it has no staged updates right here. // layers. Therefore we can't verify it has no staged updates right here.
vk::ImageLayout textureLayout = vk::ImageLayout::AllGraphicsShadersReadOnly; // Select the appropriate vk::ImageLayout depending on whether the texture is also bound as
if (mProgram->getState().isCompute()) // a GL image, and whether the program is a compute or graphics shader.
vk::ImageLayout textureLayout;
if (textureVk->isBoundAsImageTexture())
{ {
textureLayout = vk::ImageLayout::ComputeShaderReadOnly; textureLayout = mProgram->getState().isCompute()
? vk::ImageLayout::ComputeShaderWrite
: vk::ImageLayout::AllGraphicsShadersWrite;
}
else
{
textureLayout = mProgram->getState().isCompute()
? vk::ImageLayout::ComputeShaderReadOnly
: vk::ImageLayout::AllGraphicsShadersReadOnly;
} }
// Ensure the image is in read-only layout
commandBufferHelper->imageRead(&mResourceUseList, image.getAspectFlags(), textureLayout, commandBufferHelper->imageRead(&mResourceUseList, image.getAspectFlags(), textureLayout,
&image); &image);
......
...@@ -226,6 +226,8 @@ class TextureVk : public TextureImpl ...@@ -226,6 +226,8 @@ class TextureVk : public TextureImpl
GLenum type, GLenum type,
void *pixels) override; void *pixels) override;
ANGLE_INLINE bool isBoundAsImageTexture() const { return mState.isBoundAsImageTexture(); }
private: private:
// Transform an image index from the frontend into one that can be used on the backing // Transform an image index from the frontend into one that can be used on the backing
// ImageHelper, taking into account mipmap or cube face offsets // ImageHelper, taking into account mipmap or cube face offsets
......
...@@ -61,7 +61,6 @@ ...@@ -61,7 +61,6 @@
// Image related failures // Image related failures
4413 VULKAN : KHR-GLES31.core.shader_image_load_store.advanced-sync-imageAccess = SKIP
4315 VULKAN : KHR-GLES31.core.shader_image_load_store.advanced-memory-order-vsfs = FAIL 4315 VULKAN : KHR-GLES31.core.shader_image_load_store.advanced-memory-order-vsfs = FAIL
// Unimplemented glValidateCreateShaderProgramv: // Unimplemented glValidateCreateShaderProgramv:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment