Commit c4ca12e3 by Mohan Maiya Committed by Commit Bot

Vulkan: Support the single-sampled targets

Add support for gl_SampleMask for single-sampled targets. When dealing with a single-sampled target, gl_SampleMask is always be set to 0xFFFFFFFF. And when the target is single-sampled, sample shading is disabled to enable Bresenham line rasterization. Bug: angleproject:3588 Tests: dEQP-GLES31.functional.shaders.sample_variables. sample_mask.discard_half_per_pixel.* sample_mask.discard_half_per_sample.* sample_pos.correctness.* sample_mask_in.bit*_per_two_samples.* sample_mask.discard_half_per_two_samples.* sample_mask.inverse_per_* Change-Id: Ibb471261b8451ff01fab3dc43f2e965ae2999610 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2477909Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Mohan Maiya <m.maiya@samsung.com>
parent 7784fce4
...@@ -941,9 +941,13 @@ bool TranslatorVulkan::translateImpl(TIntermBlock *root, ...@@ -941,9 +941,13 @@ bool TranslatorVulkan::translateImpl(TIntermBlock *root,
return false; return false;
} }
if (hasGLSampleMask && !RewriteSampleMask(this, root, &getSymbolTable())) if (hasGLSampleMask)
{ {
return false; TIntermBinary *numSamples = driverUniforms->getNumSamplesRef();
if (!RewriteSampleMask(this, root, &getSymbolTable(), numSamples))
{
return false;
}
} }
{ {
......
...@@ -24,6 +24,7 @@ namespace sh ...@@ -24,6 +24,7 @@ namespace sh
namespace namespace
{ {
constexpr int kMaxIndexForSampleMaskVar = 0; constexpr int kMaxIndexForSampleMaskVar = 0;
constexpr int kFullSampleMask = 0xFFFFFFFF;
// Traverse the tree and collect the redeclaration and replace all non constant index references of // Traverse the tree and collect the redeclaration and replace all non constant index references of
// gl_SampleMask or gl_SampleMaskIn with constant index references // gl_SampleMask or gl_SampleMaskIn with constant index references
...@@ -102,7 +103,8 @@ class GLSampleMaskRelatedReferenceTraverser : public TIntermTraverser ...@@ -102,7 +103,8 @@ class GLSampleMaskRelatedReferenceTraverser : public TIntermTraverser
ANGLE_NO_DISCARD bool RewriteSampleMask(TCompiler *compiler, ANGLE_NO_DISCARD bool RewriteSampleMask(TCompiler *compiler,
TIntermBlock *root, TIntermBlock *root,
TSymbolTable *symbolTable) TSymbolTable *symbolTable,
const TIntermTyped *numSamplesUniform)
{ {
const TIntermSymbol *redeclaredGLSampleMask = nullptr; const TIntermSymbol *redeclaredGLSampleMask = nullptr;
GLSampleMaskRelatedReferenceTraverser indexTraverser(&redeclaredGLSampleMask, GLSampleMaskRelatedReferenceTraverser indexTraverser(&redeclaredGLSampleMask,
...@@ -137,7 +139,28 @@ ANGLE_NO_DISCARD bool RewriteSampleMask(TCompiler *compiler, ...@@ -137,7 +139,28 @@ ANGLE_NO_DISCARD bool RewriteSampleMask(TCompiler *compiler,
const unsigned int arraySizeOfSampleMask = glSampleMaskVar->getType().getOutermostArraySize(); const unsigned int arraySizeOfSampleMask = glSampleMaskVar->getType().getOutermostArraySize();
ASSERT(arraySizeOfSampleMask == 1); ASSERT(arraySizeOfSampleMask == 1);
return true; TIntermSymbol *glSampleMaskSymbol = new TIntermSymbol(glSampleMaskVar);
// if (ANGLEUniforms.numSamples == 1)
// {
// gl_SampleMask[0] = int(0xFFFFFFFF);
// }
TIntermConstantUnion *singleSampleCount = CreateUIntNode(1);
TIntermBinary *equalTo =
new TIntermBinary(EOpEqual, numSamplesUniform->deepCopy(), singleSampleCount);
TIntermBlock *trueBlock = new TIntermBlock();
TIntermBinary *sampleMaskVar = new TIntermBinary(EOpIndexDirect, glSampleMaskSymbol->deepCopy(),
CreateIndexNode(kMaxIndexForSampleMaskVar));
TIntermConstantUnion *fullSampleMask = CreateIndexNode(kFullSampleMask);
TIntermBinary *assignment = new TIntermBinary(EOpAssign, sampleMaskVar, fullSampleMask);
trueBlock->appendStatement(assignment);
TIntermIfElse *multiSampleOrNot = new TIntermIfElse(equalTo, trueBlock, nullptr);
return RunAtTheEndOfShader(compiler, root, multiSampleOrNot, symbolTable);
} }
ANGLE_NO_DISCARD bool RewriteSampleMaskIn(TCompiler *compiler, ANGLE_NO_DISCARD bool RewriteSampleMaskIn(TCompiler *compiler,
......
...@@ -26,7 +26,8 @@ class TIntermTyped; ...@@ -26,7 +26,8 @@ class TIntermTyped;
// array problem. // array problem.
ANGLE_NO_DISCARD bool RewriteSampleMask(TCompiler *compiler, ANGLE_NO_DISCARD bool RewriteSampleMask(TCompiler *compiler,
TIntermBlock *root, TIntermBlock *root,
TSymbolTable *symbolTable); TSymbolTable *symbolTable,
const TIntermTyped *numSamplesUniform);
ANGLE_NO_DISCARD bool RewriteSampleMaskIn(TCompiler *compiler, ANGLE_NO_DISCARD bool RewriteSampleMaskIn(TCompiler *compiler,
TIntermBlock *root, TIntermBlock *root,
......
...@@ -2502,19 +2502,24 @@ void ContextVk::updateColorMasks(const gl::BlendStateExt &blendStateExt) ...@@ -2502,19 +2502,24 @@ void ContextVk::updateColorMasks(const gl::BlendStateExt &blendStateExt)
framebufferVk->getState().getEnabledDrawBuffers()); framebufferVk->getState().getEnabledDrawBuffers());
} }
void ContextVk::updateSampleMask(const gl::State &glState) void ContextVk::updateSampleMaskWithRasterizationSamples(const uint32_t rasterizationSamples)
{ {
// FramebufferVk::syncState could have been the origin for this call, at which point the
// draw FBO may have changed, retrieve the latest draw FBO.
FramebufferVk *drawFramebuffer = vk::GetImpl(mState.getDrawFramebuffer());
// If sample coverage is enabled, emulate it by generating and applying a mask on top of the // If sample coverage is enabled, emulate it by generating and applying a mask on top of the
// sample mask. // sample mask.
uint32_t coverageSampleCount = GetCoverageSampleCount(glState, mDrawFramebuffer); uint32_t coverageSampleCount = GetCoverageSampleCount(mState, drawFramebuffer);
static_assert(sizeof(uint32_t) == sizeof(GLbitfield), "Vulkan assumes 32-bit sample masks"); static_assert(sizeof(uint32_t) == sizeof(GLbitfield), "Vulkan assumes 32-bit sample masks");
for (uint32_t maskNumber = 0; maskNumber < glState.getMaxSampleMaskWords(); ++maskNumber) for (uint32_t maskNumber = 0; maskNumber < mState.getMaxSampleMaskWords(); ++maskNumber)
{ {
uint32_t mask = glState.isSampleMaskEnabled() ? glState.getSampleMaskWord(maskNumber) uint32_t mask = mState.isSampleMaskEnabled() && rasterizationSamples > 1
: std::numeric_limits<uint32_t>::max(); ? mState.getSampleMaskWord(maskNumber)
: std::numeric_limits<uint32_t>::max();
ApplySampleCoverage(glState, coverageSampleCount, maskNumber, &mask); ApplySampleCoverage(mState, coverageSampleCount, maskNumber, &mask);
mGraphicsPipelineDesc->updateSampleMask(&mGraphicsPipelineTransition, maskNumber, mask); mGraphicsPipelineDesc->updateSampleMask(&mGraphicsPipelineTransition, maskNumber, mask);
} }
...@@ -2615,6 +2620,27 @@ void ContextVk::updateScissor(const gl::State &glState) ...@@ -2615,6 +2620,27 @@ void ContextVk::updateScissor(const gl::State &glState)
} }
} }
// If the target is a single-sampled target, sampleShading should be disabled, to use Bresenham line
// raterization feature.
void ContextVk::updateSampleShadingWithRasterizationSamples(const uint32_t rasterizationSamples)
{
bool sampleShadingEnable =
(rasterizationSamples <= 1 ? false : mState.isSampleShadingEnabled());
mGraphicsPipelineDesc->updateSampleShading(&mGraphicsPipelineTransition, sampleShadingEnable,
mState.getMinSampleShading());
}
// If the target is switched between a single-sampled and multisample, the dependency related to the
// rasterization sample should be updated.
void ContextVk::updateRasterizationSamples(const uint32_t rasterizationSamples)
{
mGraphicsPipelineDesc->updateRasterizationSamples(&mGraphicsPipelineTransition,
rasterizationSamples);
updateSampleShadingWithRasterizationSamples(rasterizationSamples);
updateSampleMaskWithRasterizationSamples(rasterizationSamples);
}
void ContextVk::invalidateProgramBindingHelper(const gl::State &glState) void ContextVk::invalidateProgramBindingHelper(const gl::State &glState)
{ {
mProgram = nullptr; mProgram = nullptr;
...@@ -2736,16 +2762,16 @@ angle::Result ContextVk::syncState(const gl::Context *context, ...@@ -2736,16 +2762,16 @@ angle::Result ContextVk::syncState(const gl::Context *context,
iter.setLaterBit(gl::State::DIRTY_BIT_PROGRAM_EXECUTABLE); iter.setLaterBit(gl::State::DIRTY_BIT_PROGRAM_EXECUTABLE);
break; break;
case gl::State::DIRTY_BIT_SAMPLE_COVERAGE_ENABLED: case gl::State::DIRTY_BIT_SAMPLE_COVERAGE_ENABLED:
updateSampleMask(glState); updateSampleMaskWithRasterizationSamples(mDrawFramebuffer->getSamples());
break; break;
case gl::State::DIRTY_BIT_SAMPLE_COVERAGE: case gl::State::DIRTY_BIT_SAMPLE_COVERAGE:
updateSampleMask(glState); updateSampleMaskWithRasterizationSamples(mDrawFramebuffer->getSamples());
break; break;
case gl::State::DIRTY_BIT_SAMPLE_MASK_ENABLED: case gl::State::DIRTY_BIT_SAMPLE_MASK_ENABLED:
updateSampleMask(glState); updateSampleMaskWithRasterizationSamples(mDrawFramebuffer->getSamples());
break; break;
case gl::State::DIRTY_BIT_SAMPLE_MASK: case gl::State::DIRTY_BIT_SAMPLE_MASK:
updateSampleMask(glState); updateSampleMaskWithRasterizationSamples(mDrawFramebuffer->getSamples());
break; break;
case gl::State::DIRTY_BIT_DEPTH_TEST_ENABLED: case gl::State::DIRTY_BIT_DEPTH_TEST_ENABLED:
{ {
...@@ -2884,9 +2910,7 @@ angle::Result ContextVk::syncState(const gl::Context *context, ...@@ -2884,9 +2910,7 @@ angle::Result ContextVk::syncState(const gl::Context *context,
updateViewport(mDrawFramebuffer, glState.getViewport(), glState.getNearPlane(), updateViewport(mDrawFramebuffer, glState.getViewport(), glState.getNearPlane(),
glState.getFarPlane(), isViewportFlipEnabledForDrawFBO()); glState.getFarPlane(), isViewportFlipEnabledForDrawFBO());
updateColorMasks(glState.getBlendStateExt()); updateColorMasks(glState.getBlendStateExt());
updateSampleMask(glState); updateRasterizationSamples(mDrawFramebuffer->getSamples());
mGraphicsPipelineDesc->updateRasterizationSamples(&mGraphicsPipelineTransition,
mDrawFramebuffer->getSamples());
mGraphicsPipelineDesc->updateFrontFace(&mGraphicsPipelineTransition, mGraphicsPipelineDesc->updateFrontFace(&mGraphicsPipelineTransition,
glState.getRasterizerState(), glState.getRasterizerState(),
isViewportFlipEnabledForDrawFBO()); isViewportFlipEnabledForDrawFBO());
...@@ -2972,9 +2996,7 @@ angle::Result ContextVk::syncState(const gl::Context *context, ...@@ -2972,9 +2996,7 @@ angle::Result ContextVk::syncState(const gl::Context *context,
glState.isSampleAlphaToOneEnabled()); glState.isSampleAlphaToOneEnabled());
break; break;
case gl::State::DIRTY_BIT_SAMPLE_SHADING: case gl::State::DIRTY_BIT_SAMPLE_SHADING:
mGraphicsPipelineDesc->updateSampleShading(&mGraphicsPipelineTransition, updateSampleShadingWithRasterizationSamples(mDrawFramebuffer->getSamples());
glState.isSampleShadingEnabled(),
glState.getMinSampleShading());
break; break;
case gl::State::DIRTY_BIT_COVERAGE_MODULATION: case gl::State::DIRTY_BIT_COVERAGE_MODULATION:
break; break;
...@@ -3309,8 +3331,7 @@ void ContextVk::onFramebufferChange(FramebufferVk *framebufferVk) ...@@ -3309,8 +3331,7 @@ void ContextVk::onFramebufferChange(FramebufferVk *framebufferVk)
if (mGraphicsPipelineDesc->getRasterizationSamples() != if (mGraphicsPipelineDesc->getRasterizationSamples() !=
static_cast<uint32_t>(framebufferVk->getSamples())) static_cast<uint32_t>(framebufferVk->getSamples()))
{ {
mGraphicsPipelineDesc->updateRasterizationSamples(&mGraphicsPipelineTransition, updateRasterizationSamples(framebufferVk->getSamples());
framebufferVk->getSamples());
} }
// Update scissor. // Update scissor.
......
...@@ -338,7 +338,7 @@ class ContextVk : public ContextImpl, public vk::Context ...@@ -338,7 +338,7 @@ class ContextVk : public ContextImpl, public vk::Context
gl::TextureType type, gl::TextureType type,
gl::Texture **textureOut); gl::Texture **textureOut);
void updateColorMasks(const gl::BlendStateExt &blendStateExt); void updateColorMasks(const gl::BlendStateExt &blendStateExt);
void updateSampleMask(const gl::State &glState); void updateSampleMaskWithRasterizationSamples(const uint32_t rasterizationSamples);
void handleError(VkResult errorCode, void handleError(VkResult errorCode,
const char *file, const char *file,
...@@ -858,6 +858,9 @@ class ContextVk : public ContextImpl, public vk::Context ...@@ -858,6 +858,9 @@ class ContextVk : public ContextImpl, public vk::Context
void outputCumulativePerfCounters(); void outputCumulativePerfCounters();
void updateSampleShadingWithRasterizationSamples(const uint32_t rasterizationSamples);
void updateRasterizationSamples(const uint32_t rasterizationSamples);
std::array<DirtyBitHandler, DIRTY_BIT_MAX> mGraphicsDirtyBitHandlers; std::array<DirtyBitHandler, DIRTY_BIT_MAX> mGraphicsDirtyBitHandlers;
std::array<DirtyBitHandler, DIRTY_BIT_MAX> mComputeDirtyBitHandlers; std::array<DirtyBitHandler, DIRTY_BIT_MAX> mComputeDirtyBitHandlers;
......
...@@ -11,11 +11,3 @@ ...@@ -11,11 +11,3 @@
3589 VULKAN : dEQP-GLES31.functional.shaders.multisample_interpolation.interpolate_at_offset.centroid_qualifier.default_framebuffer = FAIL 3589 VULKAN : dEQP-GLES31.functional.shaders.multisample_interpolation.interpolate_at_offset.centroid_qualifier.default_framebuffer = FAIL
3589 VULKAN : dEQP-GLES31.functional.shaders.multisample_interpolation.interpolate_at_offset.sample_qualifier.default_framebuffer = FAIL 3589 VULKAN : dEQP-GLES31.functional.shaders.multisample_interpolation.interpolate_at_offset.sample_qualifier.default_framebuffer = FAIL
3589 VULKAN : dEQP-GLES31.functional.shaders.multisample_interpolation.interpolate_at_offset.array_element.default_framebuffer = FAIL 3589 VULKAN : dEQP-GLES31.functional.shaders.multisample_interpolation.interpolate_at_offset.array_element.default_framebuffer = FAIL
// Cannot ignore multisampling-related operations when the target is a single-sampled target:
3588 VULKAN : dEQP-GLES31.functional.shaders.sample_variables.sample_mask.discard_half_per_*.default_framebuffer = FAIL
3588 VULKAN : dEQP-GLES31.functional.shaders.sample_variables.sample_mask.inverse_per_*.default_framebuffer = FAIL
// Cannot ignore SampleShadingEnable when the target is a single-sampled target:
3588 VULKAN : dEQP-GLES31.functional.shaders.sample_variables.sample_mask_in.bit_count_per_two_samples.default_framebuffer = FAIL
3588 VULKAN : dEQP-GLES31.functional.shaders.sample_variables.sample_pos.correctness.default_framebuffer = FAIL
\ No newline at end of file
...@@ -186,26 +186,6 @@ ...@@ -186,26 +186,6 @@
// Cannot create 2D (array) view of 3D texture. // Cannot create 2D (array) view of 3D texture.
3886 VULKAN : dEQP-GLES31.functional.image_load_store.3d.*layer = FAIL 3886 VULKAN : dEQP-GLES31.functional.image_load_store.3d.*layer = FAIL
// Cannot ignore multisampling-related operations when the target is a single-sampled target:
3588 VULKAN : dEQP-GLES31.functional.shaders.sample_variables.sample_mask.discard_half_per_*.default_framebuffer = FAIL
3588 VULKAN : dEQP-GLES31.functional.shaders.sample_variables.sample_mask.discard_half_per_*.singlesample_texture = FAIL
3588 VULKAN : dEQP-GLES31.functional.shaders.sample_variables.sample_mask.discard_half_per_*.singlesample_rbo = FAIL
3588 VULKAN : dEQP-GLES31.functional.shaders.sample_variables.sample_mask.inverse_per_*.default_framebuffer = FAIL
3588 VULKAN : dEQP-GLES31.functional.shaders.sample_variables.sample_mask.inverse_per_*.singlesample_texture = FAIL
3588 VULKAN : dEQP-GLES31.functional.shaders.sample_variables.sample_mask.inverse_per_*.singlesample_rbo = FAIL
// Cannot ignore SampleShadingEnable when the target is a single-sampled target:
3588 VULKAN : dEQP-GLES31.functional.shaders.sample_variables.sample_mask_in.bit_count_per_two_samples.default_framebuffer = FAIL
3588 VULKAN : dEQP-GLES31.functional.shaders.sample_variables.sample_mask_in.bit_count_per_two_samples.singlesample_texture = FAIL
3588 VULKAN : dEQP-GLES31.functional.shaders.sample_variables.sample_mask_in.bit_count_per_two_samples.singlesample_rbo = FAIL
3588 VULKAN : dEQP-GLES31.functional.shaders.sample_variables.sample_mask_in.bits_unique_per_two_samples.singlesample_texture = FAIL
3588 VULKAN : dEQP-GLES31.functional.shaders.sample_variables.sample_mask.*_per_two_samples.default_framebuffer = FAIL
3588 VULKAN : dEQP-GLES31.functional.shaders.sample_variables.sample_mask.*_per_two_samples.singlesample_texture = FAIL
3588 VULKAN : dEQP-GLES31.functional.shaders.sample_variables.sample_mask.*_per_two_samples.singlesample_rbo = FAIL
3588 VULKAN : dEQP-GLES31.functional.shaders.sample_variables.sample_pos.correctness.default_framebuffer = FAIL
3588 VULKAN : dEQP-GLES31.functional.shaders.sample_variables.sample_pos.correctness.singlesample_texture = FAIL
3588 VULKAN : dEQP-GLES31.functional.shaders.sample_variables.sample_pos.correctness.singlesample_rbo = FAIL
//// ////
//// AMD Vulkan expectations //// AMD Vulkan expectations
//// ////
......
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