aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrShaderVar.cpp
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2016-11-22 15:56:30 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-11-22 21:35:11 +0000
commitbe34882042048db096baca32ddf4a8b472529804 (patch)
tree2676dc4a9e6506f19728eddfe011ba4465f1c3ab /src/gpu/GrShaderVar.cpp
parent030cbd5f3cc60255b887fb88920fb655c8a2a9be (diff)
Initial OpenGL Image support.
This change along with recently landed changes is enough to make the new unit test work and not much else. imageLoad is support but not stores or any other image functions (atomics). Barriers in the shading language or the GL API are not yet hooked up. GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4182 Change-Id: I5958b7c89e40ae5ee05f7bbaca3b3738162fe5ce Reviewed-on: https://skia-review.googlesource.com/4182 Reviewed-by: Greg Daniel <egdaniel@google.com> Reviewed-by: Chris Dalton <csmartdalton@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu/GrShaderVar.cpp')
-rw-r--r--src/gpu/GrShaderVar.cpp35
1 files changed, 34 insertions, 1 deletions
diff --git a/src/gpu/GrShaderVar.cpp b/src/gpu/GrShaderVar.cpp
index ef305cbfc9..e1ea207e81 100644
--- a/src/gpu/GrShaderVar.cpp
+++ b/src/gpu/GrShaderVar.cpp
@@ -9,14 +9,47 @@
#include "GrShaderVar.h"
#include "glsl/GrGLSLCaps.h"
+static const char* type_modifier_string(GrShaderVar::TypeModifier t) {
+ switch (t) {
+ case GrShaderVar::kNone_TypeModifier: return "";
+ case GrShaderVar::kIn_TypeModifier: return "in";
+ case GrShaderVar::kInOut_TypeModifier: return "inout";
+ case GrShaderVar::kOut_TypeModifier: return "out";
+ case GrShaderVar::kUniform_TypeModifier: return "uniform";
+ }
+ SkFAIL("Unknown shader variable type modifier.");
+ return "";
+}
+
+void GrShaderVar::setImageStorageFormat(GrImageStorageFormat format) {
+ const char* formatStr = nullptr;
+ switch (format) {
+ case GrImageStorageFormat::kRGBA8:
+ formatStr = "rgba8";
+ break;
+ case GrImageStorageFormat::kRGBA8i:
+ formatStr = "rgba8i";
+ break;
+ case GrImageStorageFormat::kRGBA16f:
+ formatStr = "rgba16f";
+ break;
+ case GrImageStorageFormat::kRGBA32f:
+ formatStr = "rgba32f";
+ break;
+ }
+ this->addLayoutQualifier(formatStr);
+ SkASSERT(formatStr);
+}
+
void GrShaderVar::appendDecl(const GrGLSLCaps* glslCaps, SkString* out) const {
SkASSERT(kDefault_GrSLPrecision == fPrecision || GrSLTypeAcceptsPrecision(fType));
+ SkString layout = fLayoutQualifier;
if (!fLayoutQualifier.isEmpty()) {
out->appendf("layout(%s) ", fLayoutQualifier.c_str());
}
out->append(fExtraModifiers);
if (this->getTypeModifier() != kNone_TypeModifier) {
- out->append(TypeModifierString(this->getTypeModifier()));
+ out->append(type_modifier_string(this->getTypeModifier()));
out->append(" ");
}
GrSLType effectiveType = this->getType();