Commit 4cc753e0 by Jamie Madill Committed by Commit Bot

Vulkan: Implement sampler arrays.

Bug: angleproject:2462 Change-Id: If9c9cb69624d6f9f0895f6883e1eed19a27e6cb4 Reviewed-on: https://chromium-review.googlesource.com/1089809 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarFrank Henigman <fjhenigman@chromium.org>
parent 8ed634c0
......@@ -179,21 +179,20 @@ gl::Error ContextVk::setupDraw(const gl::Context *context,
{
ASSERT(!samplerBinding.unreferenced);
// TODO(jmadill): Sampler arrays
ASSERT(samplerBinding.boundTextureUnits.size() == 1);
for (GLuint textureUnit : samplerBinding.boundTextureUnits)
{
gl::Texture *texture = completeTextures[textureUnit];
GLuint textureUnit = samplerBinding.boundTextureUnits[0];
gl::Texture *texture = completeTextures[textureUnit];
// Null textures represent incomplete textures.
if (texture == nullptr)
{
ANGLE_TRY(getIncompleteTexture(context, samplerBinding.textureType, &texture));
}
// Null textures represent incomplete textures.
if (texture == nullptr)
{
ANGLE_TRY(getIncompleteTexture(context, samplerBinding.textureType, &texture));
TextureVk *textureVk = vk::GetImpl(texture);
ANGLE_TRY(textureVk->ensureImageInitialized(mRenderer));
textureVk->addReadDependency(framebufferVk);
}
TextureVk *textureVk = vk::GetImpl(texture);
ANGLE_TRY(textureVk->ensureImageInitialized(mRenderer));
textureVk->addReadDependency(framebufferVk);
}
}
......
......@@ -287,13 +287,16 @@ gl::LinkResult ProgramVk::link(const gl::Context *glContext,
ANGLE_TRY(renderer->getDescriptorSetLayout(
uniformsSetDesc, &mDescriptorSetLayouts[kUniformsDescriptorSetIndex]));
const uint32_t maxTextures = renderer->getMaxActiveTextures();
vk::DescriptorSetLayoutDesc texturesSetDesc;
for (uint32_t textureIndex = 0; textureIndex < maxTextures; ++textureIndex)
for (uint32_t textureIndex = 0; textureIndex < mState.getSamplerBindings().size();
++textureIndex)
{
// TODO(jmadll): Sampler arrays. http://anglebug.com/2462
texturesSetDesc.update(textureIndex, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1);
const gl::SamplerBinding &samplerBinding = mState.getSamplerBindings()[textureIndex];
// The front-end always binds array sampler units sequentially.
const uint32_t count = static_cast<uint32_t>(samplerBinding.boundTextureUnits.size());
texturesSetDesc.update(textureIndex, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, count);
}
ANGLE_TRY(renderer->getDescriptorSetLayout(texturesSetDesc,
......@@ -897,57 +900,61 @@ gl::Error ProgramVk::updateTexturesDescriptorSet(const gl::Context *context)
// TODO(jmadill): Don't hard-code the texture limit.
ShaderTextureArray<VkDescriptorImageInfo> descriptorImageInfo;
ShaderTextureArray<VkWriteDescriptorSet> writeDescriptorInfo;
uint32_t imageCount = 0;
uint32_t writeCount = 0;
const gl::State &glState = contextVk->getGLState();
const auto &completeTextures = glState.getCompleteTextureCache();
for (const gl::SamplerBinding &samplerBinding : mState.getSamplerBindings())
for (uint32_t textureIndex = 0; textureIndex < mState.getSamplerBindings().size();
++textureIndex)
{
ASSERT(!samplerBinding.unreferenced);
const gl::SamplerBinding &samplerBinding = mState.getSamplerBindings()[textureIndex];
// TODO(jmadill): Sampler arrays
ASSERT(samplerBinding.boundTextureUnits.size() == 1);
GLuint textureUnit = samplerBinding.boundTextureUnits[0];
gl::Texture *texture = completeTextures[textureUnit];
ASSERT(!samplerBinding.unreferenced);
if (texture == nullptr)
for (uint32_t arrayElement = 0; arrayElement < samplerBinding.boundTextureUnits.size();
++arrayElement)
{
// If we have an incomplete texture, fetch it from our renderer.
ANGLE_TRY(
contextVk->getIncompleteTexture(context, samplerBinding.textureType, &texture));
}
GLuint textureUnit = samplerBinding.boundTextureUnits[arrayElement];
gl::Texture *texture = completeTextures[textureUnit];
if (texture == nullptr)
{
// If we have an incomplete texture, fetch it from our renderer.
ANGLE_TRY(
contextVk->getIncompleteTexture(context, samplerBinding.textureType, &texture));
}
TextureVk *textureVk = vk::GetImpl(texture);
const vk::ImageHelper &image = textureVk->getImage();
TextureVk *textureVk = vk::GetImpl(texture);
const vk::ImageHelper &image = textureVk->getImage();
VkDescriptorImageInfo &imageInfo = descriptorImageInfo[imageCount];
VkDescriptorImageInfo &imageInfo = descriptorImageInfo[writeCount];
imageInfo.sampler = textureVk->getSampler().getHandle();
imageInfo.imageView = textureVk->getImageView().getHandle();
imageInfo.imageLayout = image.getCurrentLayout();
imageInfo.sampler = textureVk->getSampler().getHandle();
imageInfo.imageView = textureVk->getImageView().getHandle();
imageInfo.imageLayout = image.getCurrentLayout();
auto &writeInfo = writeDescriptorInfo[imageCount];
VkWriteDescriptorSet &writeInfo = writeDescriptorInfo[writeCount];
writeInfo.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
writeInfo.pNext = nullptr;
writeInfo.dstSet = descriptorSet;
writeInfo.dstBinding = imageCount;
writeInfo.dstArrayElement = 0;
writeInfo.descriptorCount = 1;
writeInfo.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
writeInfo.pImageInfo = &imageInfo;
writeInfo.pBufferInfo = nullptr;
writeInfo.pTexelBufferView = nullptr;
writeInfo.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
writeInfo.pNext = nullptr;
writeInfo.dstSet = descriptorSet;
writeInfo.dstBinding = textureIndex;
writeInfo.dstArrayElement = arrayElement;
writeInfo.descriptorCount = 1;
writeInfo.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
writeInfo.pImageInfo = &imageInfo;
writeInfo.pBufferInfo = nullptr;
writeInfo.pTexelBufferView = nullptr;
imageCount++;
writeCount++;
}
}
VkDevice device = contextVk->getDevice();
ASSERT(imageCount > 0);
vkUpdateDescriptorSets(device, imageCount, writeDescriptorInfo.data(), 0, nullptr);
ASSERT(writeCount > 0);
vkUpdateDescriptorSets(device, writeCount, writeDescriptorInfo.data(), 0, nullptr);
mDirtyTextures = false;
return gl::NoError();
......
......@@ -292,6 +292,7 @@ Error DynamicDescriptorPool::init(const VkDevice &device,
{
ASSERT(!mCurrentDescriptorSetPool.valid() && mCurrentAllocatedDescriptorSetCount == 0);
// Note that this may allocate more sets than strictly necessary for a particular layout.
mUniformBufferDescriptorsPerSet = uniformBufferDescriptorsPerSet;
mCombinedImageSamplerDescriptorsPerSet = combinedImageSamplerDescriptorsPerSet;
......
......@@ -251,12 +251,10 @@
2161 VULKAN : dEQP-GLES2.functional.vertex_arrays.* = SKIP
2598 VULKAN : dEQP-GLES2.functional.rasterization.primitives.line* = SKIP
2599 VULKAN : dEQP-GLES2.functional.rasterization.limits.points = SKIP
2462 VULKAN : dEQP-GLES2.functional.uniform_api.info_query.basic_array.sampler2D_* = SKIP
2161 VULKAN : dEQP-GLES2.functional.uniform_api.info_query.basic_struct.sampler2D_* = SKIP
2161 VULKAN : dEQP-GLES2.functional.uniform_api.info_query.struct_in_array.sampler2D_* = SKIP
2161 VULKAN : dEQP-GLES2.functional.uniform_api.info_query.array_in_struct.sampler2D_* = SKIP
2161 VULKAN : dEQP-GLES2.functional.uniform_api.info_query.nested_structs_arrays.sampler2D_* = SKIP
2161 VULKAN : dEQP-GLES2.functional.uniform_api.info_query.multiple_basic_array.sampler2D_* = SKIP
2161 VULKAN : dEQP-GLES2.functional.uniform_api.info_query.multiple_nested_structs_arrays.sampler2D_* = SKIP
2161 VULKAN : dEQP-GLES2.functional.uniform_api.info_query.unused_uniforms.sampler2D_* = SKIP
2161 VULKAN : dEQP-GLES2.functional.uniform_api.value.initial.get_uniform.basic.sampler* = SKIP
......@@ -266,7 +264,6 @@
2161 VULKAN : dEQP-GLES2.functional.uniform_api.value.initial.get_uniform.array_in_struct.sampler2D_* = SKIP
2161 VULKAN : dEQP-GLES2.functional.uniform_api.value.initial.get_uniform.nested_structs_arrays.sampler2D_* = SKIP
2161 VULKAN : dEQP-GLES2.functional.uniform_api.value.initial.render.basic.samplerCube_* = SKIP
2161 VULKAN : dEQP-GLES2.functional.uniform_api.value.initial.render.basic_array.sampler2D_* = SKIP
2161 VULKAN : dEQP-GLES2.functional.uniform_api.value.assigned.by_pointer.get_uniform.basic.sampler* = SKIP
2161 VULKAN : dEQP-GLES2.functional.uniform_api.value.assigned.by_pointer.get_uniform.basic_array.sampler2D_* = SKIP
2161 VULKAN : dEQP-GLES2.functional.uniform_api.value.assigned.by_pointer.get_uniform.basic_struct.sampler2D_* = SKIP
......@@ -275,7 +272,6 @@
2161 VULKAN : dEQP-GLES2.functional.uniform_api.value.assigned.by_pointer.get_uniform.nested_structs_arrays.sampler2D_* = SKIP
2161 VULKAN : dEQP-GLES2.functional.uniform_api.value.assigned.by_pointer.get_uniform.basic_array_first_elem_without_brackets.sampler2D* = SKIP
2161 VULKAN : dEQP-GLES2.functional.uniform_api.value.assigned.by_pointer.render.basic.samplerCube* = SKIP
2161 VULKAN : dEQP-GLES2.functional.uniform_api.value.assigned.by_pointer.render.basic_array.sampler2D_* = SKIP
2161 VULKAN : dEQP-GLES2.functional.uniform_api.value.assigned.by_pointer.render.basic_struct.sampler2D_* = SKIP
2161 VULKAN : dEQP-GLES2.functional.uniform_api.value.assigned.by_pointer.render.struct_in_array.sampler2D_* = SKIP
2161 VULKAN : dEQP-GLES2.functional.uniform_api.value.assigned.by_pointer.render.array_in_struct.sampler2D_* = SKIP
......@@ -288,7 +284,6 @@
2161 VULKAN : dEQP-GLES2.functional.uniform_api.value.assigned.by_value.get_uniform.nested_structs_arrays.sampler2D_* = SKIP
2161 VULKAN : dEQP-GLES2.functional.uniform_api.value.assigned.by_value.get_uniform.basic_array_first_elem_without_brackets.sampler2D_* = SKIP
2161 VULKAN : dEQP-GLES2.functional.uniform_api.value.assigned.by_value.render.basic.samplerCube* = SKIP
2161 VULKAN : dEQP-GLES2.functional.uniform_api.value.assigned.by_value.render.basic_array.sampler2D_* = SKIP
2161 VULKAN : dEQP-GLES2.functional.uniform_api.value.assigned.by_value.render.basic_struct.sampler2D_* = SKIP
2161 VULKAN : dEQP-GLES2.functional.uniform_api.value.assigned.by_value.render.struct_in_array.sampler2D_* = SKIP
2161 VULKAN : dEQP-GLES2.functional.uniform_api.value.assigned.by_value.render.array_in_struct.sampler2D_* = SKIP
......
......@@ -1956,10 +1956,6 @@ TEST_P(GLSLTest_ES3, InitGlobalArrayWithArrayIndexing)
// Test that index-constant sampler array indexing is supported.
TEST_P(GLSLTest, IndexConstantSamplerArrayIndexing)
{
// TODO(lucferron): Samplers array support.
// http://anglebug.com/2462
ANGLE_SKIP_TEST_IF(IsVulkan());
ANGLE_SKIP_TEST_IF(IsD3D11_FL93());
const std::string fragmentShaderSource =
......@@ -3090,8 +3086,7 @@ TEST_P(GLSLTest, ArrayOfStructsWithSamplersAsFunctionArg)
// Shader failed to compile on Android. http://anglebug.com/2114
ANGLE_SKIP_TEST_IF(IsAndroid() && IsAdreno() && IsOpenGLES());
// TODO(lucferron): Sampler arrays support
// http://anglebug.com/2462
// TODO(jmadill): Samplers in structs. http://anglebug.com/2494
ANGLE_SKIP_TEST_IF(IsVulkan());
const std::string &fragmentShader =
......@@ -3145,8 +3140,7 @@ TEST_P(GLSLTest, StructWithSamplerArrayAsFunctionArg)
// Shader failed to compile on Android. http://anglebug.com/2114
ANGLE_SKIP_TEST_IF(IsAndroid() && IsAdreno() && IsOpenGLES());
// TODO(lucferron): Sampler arrays support
// http://anglebug.com/2462
// TODO(jmadill): Samplers in structs. http://anglebug.com/2494
ANGLE_SKIP_TEST_IF(IsVulkan());
const std::string &fragmentShader =
......
......@@ -1231,10 +1231,6 @@ TEST_P(Texture2DTest, QueryBinding)
TEST_P(Texture2DTest, ZeroSizedUploads)
{
// TODO(lucferron): Enable this test on Vulkan after Sampler Arrays are implemented.
// http://anglebug.com/2462
ANGLE_SKIP_TEST_IF(IsVulkan());
glBindTexture(GL_TEXTURE_2D, mTexture2D);
EXPECT_GL_ERROR(GL_NO_ERROR);
......
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