Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Unified Diff: src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp

Issue 1717393002: Add "sample locations" feature to GrProcessor (Closed) Base URL: https://skia.googlesource.com/skia.git@upload_getmultisamp
Patch Set: addressed comments Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/glsl/GrGLSLFragmentShaderBuilder.h ('k') | tests/GLProgramsTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp
diff --git a/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp b/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp
index 44db57e68d840067e7cd6da474b026bb60e84366..a7d383532e3bf090aa44f425043bfa742156fc6e 100644
--- a/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp
+++ b/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp
@@ -170,6 +170,11 @@ const char* GrGLSLFragmentShaderBuilder::fragmentPosition() {
}
}
+void GrGLSLFragmentShaderBuilder::appendSampleOffset(const char* sampleIdx) {
+ SkASSERT(fProgramBuilder->pipeline().hasSampleLocations());
Chris Dalton 2016/02/23 01:51:01 I guess maskSampleCoverage() does a test/SkDEBUGFA
+ this->codeAppendf("sampleOffsets[%s]", sampleIdx);
+}
+
void GrGLSLFragmentShaderBuilder::maskSampleCoverage(const char* mask, bool invert) {
const GrGLSLCaps& glslCaps = *fProgramBuilder->glslCaps();
if (!glslCaps.sampleVariablesSupport()) {
@@ -306,6 +311,23 @@ void GrGLSLFragmentShaderBuilder::onFinalize() {
GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision,
*fProgramBuilder->glslCaps(),
&this->precisionQualifier());
+ if (fProgramBuilder->pipeline().hasSampleLocations()) {
+ const GrPipeline& pipeline = fProgramBuilder->pipeline();
+ int effectiveSampleCnt = pipeline.effectiveSampleCount();
+ const SkPoint* sampleLocations = pipeline.getSampleLocations();
+ this->definitions().append("const ");
+ if (fProgramBuilder->glslCaps()->usesPrecisionModifiers()) {
+ this->definitions().append("highp ");
+ }
+ this->definitions().appendf("vec2 sampleOffsets[] = vec2[](");
+ for (int i = 0; i < effectiveSampleCnt; ++i) {
+ this->definitions().appendf("vec2(%f, %f)%s",
+ sampleLocations[i].x() - 0.5f,
+ sampleLocations[i].y() - 0.5f,
+ i + 1 != effectiveSampleCnt ? ", " : ");\n");
+ }
+ SkASSERT(fProgramBuilder->header().fSamplePatternKey == pipeline.getSamplePatternID());
+ }
}
void GrGLSLFragmentShaderBuilder::onBeforeChildProcEmitCode() {
« no previous file with comments | « src/gpu/glsl/GrGLSLFragmentShaderBuilder.h ('k') | tests/GLProgramsTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698