diff options
author | cdalton <cdalton@nvidia.com> | 2016-03-07 13:58:26 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-07 13:58:26 -0800 |
commit | 28f45b949acc746849100fbe112ee5280f0594c9 (patch) | |
tree | b350d442680ef996ab6097433ab0cf960d3680b6 /src/gpu/vk | |
parent | b3b13b7edeabad4c8e53b0d309b0a44668d1e68f (diff) |
Add "sample locations" feature to GrProcessor
Adds a "sample locations" feature to GrProcessor. When enabled, this
allows a processor to know inside the shader where all the samples are
located. Also adds various infastructure to query, cache, and identify
multisample data.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1717393002
Review URL: https://codereview.chromium.org/1717393002
Diffstat (limited to 'src/gpu/vk')
-rw-r--r-- | src/gpu/vk/GrVkGpu.cpp | 7 | ||||
-rw-r--r-- | src/gpu/vk/GrVkGpu.h | 5 | ||||
-rw-r--r-- | src/gpu/vk/GrVkProgramDesc.cpp | 22 |
3 files changed, 28 insertions, 6 deletions
diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp index a0e6aa554d..1ce78fd192 100644 --- a/src/gpu/vk/GrVkGpu.cpp +++ b/src/gpu/vk/GrVkGpu.cpp @@ -1211,6 +1211,13 @@ bool GrVkGpu::onCopySurface(GrSurface* dst, return false; } +void GrVkGpu::onGetMultisampleSpecs(GrRenderTarget* rt, const GrStencilSettings&, + int* effectiveSampleCnt, SkAutoTDeleteArray<SkPoint>*) { + // TODO: stub. + SkASSERT(!this->caps()->sampleLocationsSupport()); + *effectiveSampleCnt = rt->desc().fSampleCnt; +} + bool GrVkGpu::onGetReadPixelsInfo(GrSurface* srcSurface, int width, int height, size_t rowBytes, GrPixelConfig readConfig, DrawPreference* drawPreference, ReadPixelTempDrawInfo* tempDrawInfo) { diff --git a/src/gpu/vk/GrVkGpu.h b/src/gpu/vk/GrVkGpu.h index 344f81c16c..723d714514 100644 --- a/src/gpu/vk/GrVkGpu.h +++ b/src/gpu/vk/GrVkGpu.h @@ -76,6 +76,11 @@ public: const SkIRect& srcRect, const SkIPoint& dstPoint) override; + void onGetMultisampleSpecs(GrRenderTarget* rt, + const GrStencilSettings&, + int* effectiveSampleCnt, + SkAutoTDeleteArray<SkPoint>*); + bool initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* desc) const override { SkDebugf("initCopySurfaceDstDesc not yet implemented for Vulkan\n"); return false; diff --git a/src/gpu/vk/GrVkProgramDesc.cpp b/src/gpu/vk/GrVkProgramDesc.cpp index 32357cdfcc..74e6bbb59d 100644 --- a/src/gpu/vk/GrVkProgramDesc.cpp +++ b/src/gpu/vk/GrVkProgramDesc.cpp @@ -9,6 +9,7 @@ //#include "GrVkProcessor.h" #include "GrProcessor.h" #include "GrPipeline.h" +#include "GrRenderTargetPriv.h" #include "GrVkGpu.h" #include "GrVkUtil.h" #include "SkChecksum.h" @@ -134,15 +135,24 @@ bool GrVkProgramDescBuilder::Build(GrProgramDesc* desc, // make sure any padding in the header is zeroed. memset(header, 0, kHeaderSize); - if (requiredFeatures & GrProcessor::kFragmentPosition_RequiredFeature) { - header->fFragPosKey = - GrGLSLFragmentShaderBuilder::KeyForFragmentPosition(pipeline.getRenderTarget()); + GrRenderTarget* rt = pipeline.getRenderTarget(); + + if (requiredFeatures & (GrProcessor::kFragmentPosition_RequiredFeature | + GrProcessor::kSampleLocations_RequiredFeature)) { + header->fSurfaceOriginKey = GrGLSLFragmentShaderBuilder::KeyForSurfaceOrigin(rt->origin()); + } else { + header->fSurfaceOriginKey = 0; + } + + if (requiredFeatures & GrProcessor::kSampleLocations_RequiredFeature) { + SkASSERT(pipeline.isHWAntialiasState()); + header->fSamplePatternKey = + rt->renderTargetPriv().getMultisampleSpecs(pipeline.getStencil()).fUniqueID; } else { - header->fFragPosKey = 0; + header->fSamplePatternKey = 0; } - header->fOutputSwizzle = - glslCaps.configOutputSwizzle(pipeline.getRenderTarget()->config()).asKey(); + header->fOutputSwizzle = glslCaps.configOutputSwizzle(rt->config()).asKey(); if (pipeline.ignoresCoverage()) { header->fIgnoresCoverage = 1; |