Commit 90968360 by Luc Ferron Committed by Commit Bot

Vulkan: Incomplete textures support

2D multisample is out of scope since its ES 3 only. Bug: angleproject:2499 Change-Id: Id5f81d713a2882ba2a91b7d3f281d71a3e9289f4 Reviewed-on: https://chromium-review.googlesource.com/1046786 Commit-Queue: Luc Ferron <lucferron@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 58662082
...@@ -69,9 +69,19 @@ ContextVk::~ContextVk() ...@@ -69,9 +69,19 @@ ContextVk::~ContextVk()
void ContextVk::onDestroy(const gl::Context *context) void ContextVk::onDestroy(const gl::Context *context)
{ {
mIncompleteTextures.onDestroy(context);
mDynamicDescriptorPool.destroy(mRenderer); mDynamicDescriptorPool.destroy(mRenderer);
} }
gl::Error ContextVk::getIncompleteTexture(const gl::Context *context,
gl::TextureType type,
gl::Texture **textureOut)
{
// At some point, we'll need to support multisample and we'll pass "this" instead of nullptr
// and implement the necessary interface.
return mIncompleteTextures.getIncompleteTexture(context, type, nullptr, textureOut);
}
gl::Error ContextVk::initialize() gl::Error ContextVk::initialize()
{ {
ANGLE_TRY(mDynamicDescriptorPool.init(this->getDevice(), ANGLE_TRY(mDynamicDescriptorPool.init(this->getDevice(),
...@@ -127,7 +137,8 @@ gl::Error ContextVk::initPipeline() ...@@ -127,7 +137,8 @@ gl::Error ContextVk::initPipeline()
return gl::NoError(); return gl::NoError();
} }
gl::Error ContextVk::setupDraw(const gl::DrawCallParams &drawCallParams, gl::Error ContextVk::setupDraw(const gl::Context *context,
const gl::DrawCallParams &drawCallParams,
vk::CommandGraphNode **drawNodeOut, vk::CommandGraphNode **drawNodeOut,
bool *newCommandBufferOut) bool *newCommandBufferOut)
{ {
...@@ -180,11 +191,14 @@ gl::Error ContextVk::setupDraw(const gl::DrawCallParams &drawCallParams, ...@@ -180,11 +191,14 @@ gl::Error ContextVk::setupDraw(const gl::DrawCallParams &drawCallParams,
// TODO(jmadill): Sampler arrays // TODO(jmadill): Sampler arrays
ASSERT(samplerBinding.boundTextureUnits.size() == 1); ASSERT(samplerBinding.boundTextureUnits.size() == 1);
GLuint textureUnit = samplerBinding.boundTextureUnits[0]; GLuint textureUnit = samplerBinding.boundTextureUnits[0];
const gl::Texture *texture = completeTextures[textureUnit]; gl::Texture *texture = completeTextures[textureUnit];
// TODO(jmadill): Incomplete textures handling. // Null textures represent incomplete textures.
ASSERT(texture); if (texture == nullptr)
{
ANGLE_TRY(getIncompleteTexture(context, samplerBinding.textureType, &texture));
}
TextureVk *textureVk = vk::GetImpl(texture); TextureVk *textureVk = vk::GetImpl(texture);
ANGLE_TRY(textureVk->ensureImageInitialized(mRenderer)); ANGLE_TRY(textureVk->ensureImageInitialized(mRenderer));
...@@ -200,7 +214,7 @@ gl::Error ContextVk::setupDraw(const gl::DrawCallParams &drawCallParams, ...@@ -200,7 +214,7 @@ gl::Error ContextVk::setupDraw(const gl::DrawCallParams &drawCallParams,
// TODO(jmadill): Can probably use more dirty bits here. // TODO(jmadill): Can probably use more dirty bits here.
ANGLE_TRY(programVk->updateUniforms(this)); ANGLE_TRY(programVk->updateUniforms(this));
ANGLE_TRY(programVk->updateTexturesDescriptorSet(this)); ANGLE_TRY(programVk->updateTexturesDescriptorSet(context));
// Bind the graphics descriptor sets. // Bind the graphics descriptor sets.
// TODO(jmadill): Handle multiple command buffers. // TODO(jmadill): Handle multiple command buffers.
...@@ -227,7 +241,7 @@ gl::Error ContextVk::drawArrays(const gl::Context *context, GLenum mode, GLint f ...@@ -227,7 +241,7 @@ gl::Error ContextVk::drawArrays(const gl::Context *context, GLenum mode, GLint f
vk::CommandGraphNode *drawNode = nullptr; vk::CommandGraphNode *drawNode = nullptr;
bool newCommands = false; bool newCommands = false;
ANGLE_TRY(setupDraw(drawCallParams, &drawNode, &newCommands)); ANGLE_TRY(setupDraw(context, drawCallParams, &drawNode, &newCommands));
const gl::VertexArray *vertexArray = context->getGLState().getVertexArray(); const gl::VertexArray *vertexArray = context->getGLState().getVertexArray();
VertexArrayVk *vertexArrayVk = vk::GetImpl(vertexArray); VertexArrayVk *vertexArrayVk = vk::GetImpl(vertexArray);
...@@ -256,7 +270,7 @@ gl::Error ContextVk::drawElements(const gl::Context *context, ...@@ -256,7 +270,7 @@ gl::Error ContextVk::drawElements(const gl::Context *context,
vk::CommandGraphNode *drawNode = nullptr; vk::CommandGraphNode *drawNode = nullptr;
bool newCommands = false; bool newCommands = false;
ANGLE_TRY(setupDraw(drawCallParams, &drawNode, &newCommands)); ANGLE_TRY(setupDraw(context, drawCallParams, &drawNode, &newCommands));
gl::VertexArray *vao = mState.getState().getVertexArray(); gl::VertexArray *vao = mState.getState().getVertexArray();
VertexArrayVk *vertexArrayVk = vk::GetImpl(vao); VertexArrayVk *vertexArrayVk = vk::GetImpl(vao);
......
...@@ -160,10 +160,14 @@ class ContextVk : public ContextImpl ...@@ -160,10 +160,14 @@ class ContextVk : public ContextImpl
const VkClearValue &getClearDepthStencilValue() const; const VkClearValue &getClearDepthStencilValue() const;
VkColorComponentFlags getClearColorMask() const; VkColorComponentFlags getClearColorMask() const;
const VkRect2D &getScissor() const { return mPipelineDesc->getScissor(); } const VkRect2D &getScissor() const { return mPipelineDesc->getScissor(); }
gl::Error getIncompleteTexture(const gl::Context *context,
gl::TextureType type,
gl::Texture **textureOut);
private: private:
gl::Error initPipeline(); gl::Error initPipeline();
gl::Error setupDraw(const gl::DrawCallParams &drawCallParams, gl::Error setupDraw(const gl::Context *context,
const gl::DrawCallParams &drawCallParams,
vk::CommandGraphNode **drawNodeOut, vk::CommandGraphNode **drawNodeOut,
bool *newCommandBufferOut); bool *newCommandBufferOut);
...@@ -189,6 +193,8 @@ class ContextVk : public ContextImpl ...@@ -189,6 +193,8 @@ class ContextVk : public ContextImpl
VkClearValue mClearColorValue; VkClearValue mClearColorValue;
VkClearValue mClearDepthStencilValue; VkClearValue mClearDepthStencilValue;
VkColorComponentFlags mClearColorMask; VkColorComponentFlags mClearColorMask;
IncompleteTextureSet mIncompleteTextures;
}; };
} // namespace rx } // namespace rx
......
...@@ -825,13 +825,14 @@ const gl::RangeUI &ProgramVk::getUsedDescriptorSetRange() const ...@@ -825,13 +825,14 @@ const gl::RangeUI &ProgramVk::getUsedDescriptorSetRange() const
return mUsedDescriptorSetRange; return mUsedDescriptorSetRange;
} }
vk::Error ProgramVk::updateTexturesDescriptorSet(ContextVk *contextVk) gl::Error ProgramVk::updateTexturesDescriptorSet(const gl::Context *context)
{ {
if (mState.getSamplerBindings().empty() || !mDirtyTextures) if (mState.getSamplerBindings().empty() || !mDirtyTextures)
{ {
return vk::NoError(); return gl::NoError();
} }
ContextVk *contextVk = GetImplAs<ContextVk>(context);
ANGLE_TRY(allocateDescriptorSet(contextVk, vk::TextureIndex)); ANGLE_TRY(allocateDescriptorSet(contextVk, vk::TextureIndex));
ASSERT(mUsedDescriptorSetRange.contains(1)); ASSERT(mUsedDescriptorSetRange.contains(1));
...@@ -852,11 +853,15 @@ vk::Error ProgramVk::updateTexturesDescriptorSet(ContextVk *contextVk) ...@@ -852,11 +853,15 @@ vk::Error ProgramVk::updateTexturesDescriptorSet(ContextVk *contextVk)
// TODO(jmadill): Sampler arrays // TODO(jmadill): Sampler arrays
ASSERT(samplerBinding.boundTextureUnits.size() == 1); ASSERT(samplerBinding.boundTextureUnits.size() == 1);
GLuint textureUnit = samplerBinding.boundTextureUnits[0]; GLuint textureUnit = samplerBinding.boundTextureUnits[0];
const gl::Texture *texture = completeTextures[textureUnit]; gl::Texture *texture = completeTextures[textureUnit];
// TODO(jmadill): Incomplete textures handling. if (texture == nullptr)
ASSERT(texture); {
// If we have an incomplete texture, fetch it from our renderer.
ANGLE_TRY(
contextVk->getIncompleteTexture(context, samplerBinding.textureType, &texture));
}
TextureVk *textureVk = vk::GetImpl(texture); TextureVk *textureVk = vk::GetImpl(texture);
const vk::ImageHelper &image = textureVk->getImage(); const vk::ImageHelper &image = textureVk->getImage();
...@@ -889,7 +894,7 @@ vk::Error ProgramVk::updateTexturesDescriptorSet(ContextVk *contextVk) ...@@ -889,7 +894,7 @@ vk::Error ProgramVk::updateTexturesDescriptorSet(ContextVk *contextVk)
vkUpdateDescriptorSets(device, imageCount, writeDescriptorInfo.data(), 0, nullptr); vkUpdateDescriptorSets(device, imageCount, writeDescriptorInfo.data(), 0, nullptr);
mDirtyTextures = false; mDirtyTextures = false;
return vk::NoError(); return gl::NoError();
} }
void ProgramVk::invalidateTextures() void ProgramVk::invalidateTextures()
......
...@@ -118,7 +118,7 @@ class ProgramVk : public ProgramImpl ...@@ -118,7 +118,7 @@ class ProgramVk : public ProgramImpl
// or Textures. // or Textures.
const gl::RangeUI &getUsedDescriptorSetRange() const; const gl::RangeUI &getUsedDescriptorSetRange() const;
vk::Error updateTexturesDescriptorSet(ContextVk *contextVk); gl::Error updateTexturesDescriptorSet(const gl::Context *context);
void invalidateTextures(); void invalidateTextures();
// For testing only. // For testing only.
......
...@@ -1029,4 +1029,5 @@ vk::ShaderLibrary *RendererVk::getShaderLibrary() ...@@ -1029,4 +1029,5 @@ vk::ShaderLibrary *RendererVk::getShaderLibrary()
{ {
return &mShaderLibrary; return &mShaderLibrary;
} }
} // namespace rx } // namespace rx
...@@ -238,9 +238,12 @@ gl::Error TextureVk::setImage(const gl::Context *context, ...@@ -238,9 +238,12 @@ gl::Error TextureVk::setImage(const gl::Context *context,
if (mImage.valid()) if (mImage.valid())
{ {
const gl::ImageDesc &desc = mState.getImageDesc(index);
const vk::Format &vkFormat = renderer->getFormat(formatInfo.sizedInternalFormat); const vk::Format &vkFormat = renderer->getFormat(formatInfo.sizedInternalFormat);
if (desc.size != size || mImage.getFormat() != vkFormat)
// Calculate the expected size for the index we are defining. If the size is different from
// the given size, or the format is different, we are redefining the image so we must
// release it.
if (mImage.getFormat() != vkFormat || size != mImage.getSize(index))
{ {
releaseImage(context, renderer); releaseImage(context, renderer);
} }
......
...@@ -209,6 +209,8 @@ Error DynamicBuffer::flush(VkDevice device) ...@@ -209,6 +209,8 @@ Error DynamicBuffer::flush(VkDevice device)
void DynamicBuffer::release(RendererVk *renderer) void DynamicBuffer::release(RendererVk *renderer)
{ {
releaseRetainedBuffers(renderer);
mAlignment = 0; mAlignment = 0;
Serial currentSerial = renderer->getCurrentQueueSerial(); Serial currentSerial = renderer->getCurrentQueueSerial();
renderer->releaseObject(currentSerial, &mBuffer); renderer->releaseObject(currentSerial, &mBuffer);
...@@ -796,6 +798,16 @@ void ImageHelper::clearDepthStencil(VkImageAspectFlags aspectFlags, ...@@ -796,6 +798,16 @@ void ImageHelper::clearDepthStencil(VkImageAspectFlags aspectFlags,
commandBuffer->clearDepthStencilImage(mImage, mCurrentLayout, depthStencil, 1, &clearRange); commandBuffer->clearDepthStencilImage(mImage, mCurrentLayout, depthStencil, 1, &clearRange);
} }
gl::Extents ImageHelper::getSize(const gl::ImageIndex &index) const
{
ASSERT(mExtents.depth == 1);
GLint mipLevel = index.getLevelIndex();
// Level 0 should be the size of the extents, after that every time you increase a level
// you shrink the extents by half.
return gl::Extents(std::max(1, mExtents.width >> mipLevel),
std::max(1, mExtents.height >> mipLevel), mExtents.depth);
}
// static // static
void ImageHelper::Copy(ImageHelper *srcImage, void ImageHelper::Copy(ImageHelper *srcImage,
ImageHelper *dstImage, ImageHelper *dstImage,
......
...@@ -221,6 +221,7 @@ class ImageHelper final : angle::NonCopyable ...@@ -221,6 +221,7 @@ class ImageHelper final : angle::NonCopyable
void clearDepthStencil(VkImageAspectFlags aspectFlags, void clearDepthStencil(VkImageAspectFlags aspectFlags,
const VkClearDepthStencilValue &depthStencil, const VkClearDepthStencilValue &depthStencil,
CommandBuffer *commandBuffer); CommandBuffer *commandBuffer);
gl::Extents getSize(const gl::ImageIndex &index) const;
static void Copy(ImageHelper *srcImage, static void Copy(ImageHelper *srcImage,
ImageHelper *dstImage, ImageHelper *dstImage,
......
...@@ -193,7 +193,6 @@ ...@@ -193,7 +193,6 @@
2161 VULKAN : dEQP-GLES2.functional.texture.mipmap.2d.generate.* = SKIP 2161 VULKAN : dEQP-GLES2.functional.texture.mipmap.2d.generate.* = SKIP
2161 VULKAN : dEQP-GLES2.functional.texture.mipmap.cube.generate.* = SKIP 2161 VULKAN : dEQP-GLES2.functional.texture.mipmap.cube.generate.* = SKIP
2161 VULKAN : dEQP-GLES2.functional.texture.specification.basic_copytex* = SKIP 2161 VULKAN : dEQP-GLES2.functional.texture.specification.basic_copytex* = SKIP
2161 VULKAN : dEQP-GLES2.functional.texture.completeness.* = SKIP
2161 VULKAN : dEQP-GLES2.functional.texture.vertex.* = SKIP 2161 VULKAN : dEQP-GLES2.functional.texture.vertex.* = SKIP
2161 VULKAN : dEQP-GLES2.functional.fragment_ops.random.* = SKIP 2161 VULKAN : dEQP-GLES2.functional.fragment_ops.random.* = SKIP
2161 VULKAN : dEQP-GLES2.functional.fragment_ops.interaction.* = SKIP 2161 VULKAN : dEQP-GLES2.functional.fragment_ops.interaction.* = SKIP
......
...@@ -206,6 +206,7 @@ ANGLE_INSTANTIATE_TEST(IncompleteTextureTest, ...@@ -206,6 +206,7 @@ ANGLE_INSTANTIATE_TEST(IncompleteTextureTest,
ES2_D3D9(), ES2_D3D9(),
ES2_D3D11(), ES2_D3D11(),
ES2_OPENGL(), ES2_OPENGL(),
ES2_OPENGLES()); ES2_OPENGLES(),
ES2_VULKAN());
ANGLE_INSTANTIATE_TEST(IncompleteTextureTestES31, ES31_D3D11(), ES31_OPENGL(), ES31_OPENGLES()); ANGLE_INSTANTIATE_TEST(IncompleteTextureTestES31, ES31_D3D11(), ES31_OPENGL(), ES31_OPENGLES());
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