aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/vk/GrVkUniformHandler.cpp
diff options
context:
space:
mode:
authorGravatar egdaniel <egdaniel@google.com>2016-07-13 14:09:30 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-07-13 14:09:31 -0700
commit990dbc88796f656418bcc4c196df30ed9bef6345 (patch)
tree8ce14a655fd0e98363e5eb7a895ee79516012927 /src/gpu/vk/GrVkUniformHandler.cpp
parente5de130788c8637d2f7df9ddb0241b78e04d5882 (diff)
Add Texture2D and Sampler GrSLTypes
These two new types are in support of Vulkan and the ability to send separate texture and sampler uniforms to the shader. They don't really fit well in the current system, since the current system ties together to idea of intended use and how to emit shader code into the same GrSLType enum. In vulkan, I want the GrGLSLSampler object to be used as a Sampler2D, but when appending its declaration it will emit a Texture2D and sampler object. Our query for GrSLTypeIsSamplerType refers more to the combination of texture and sampler and not just the sampler part. The GrSLTypeIs2DTextureType query is for is a a SamplerType that uses Texture2Ds. My new types don't really fit into either these categories as they are just half of the whole. In some refactoring down the road (possibly connected with SkSL), I suggest we split apart the concept of how we intend to use a GrGLSLSampler (Sampler2D, SamplerBuffer, etc.), from how we actually add it to the code (sampler, texture2D, sampler2D, etc.). BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2143143002 Review-Url: https://codereview.chromium.org/2143143002
Diffstat (limited to 'src/gpu/vk/GrVkUniformHandler.cpp')
-rw-r--r--src/gpu/vk/GrVkUniformHandler.cpp36
1 files changed, 22 insertions, 14 deletions
diff --git a/src/gpu/vk/GrVkUniformHandler.cpp b/src/gpu/vk/GrVkUniformHandler.cpp
index ca61fc9a73..4a6e977a8c 100644
--- a/src/gpu/vk/GrVkUniformHandler.cpp
+++ b/src/gpu/vk/GrVkUniformHandler.cpp
@@ -32,6 +32,8 @@ uint32_t grsltype_to_alignment_mask(GrSLType type) {
0x0, // kBool_GrSLType
0x7, // kInt_GrSLType
0x7, // kUint_GrSLType
+ 0x0, // Texture2D_GrSLType, should never return this
+ 0x0, // Sampler_GrSLType, should never return this
};
GR_STATIC_ASSERT(0 == kVoid_GrSLType);
GR_STATIC_ASSERT(1 == kFloat_GrSLType);
@@ -41,13 +43,15 @@ uint32_t grsltype_to_alignment_mask(GrSLType type) {
GR_STATIC_ASSERT(5 == kMat22f_GrSLType);
GR_STATIC_ASSERT(6 == kMat33f_GrSLType);
GR_STATIC_ASSERT(7 == kMat44f_GrSLType);
- GR_STATIC_ASSERT(8 == kSampler2D_GrSLType);
- GR_STATIC_ASSERT(9 == kSamplerExternal_GrSLType);
- GR_STATIC_ASSERT(10 == kSampler2DRect_GrSLType);
- GR_STATIC_ASSERT(11 == kSamplerBuffer_GrSLType);
+ GR_STATIC_ASSERT(8 == kTexture2DSampler_GrSLType);
+ GR_STATIC_ASSERT(9 == kTextureExternalSampler_GrSLType);
+ GR_STATIC_ASSERT(10 == kTexture2DRectSampler_GrSLType);
+ GR_STATIC_ASSERT(11 == kTextureBufferSampler_GrSLType);
GR_STATIC_ASSERT(12 == kBool_GrSLType);
GR_STATIC_ASSERT(13 == kInt_GrSLType);
GR_STATIC_ASSERT(14 == kUint_GrSLType);
+ GR_STATIC_ASSERT(15 == kTexture2D_GrSLType);
+ GR_STATIC_ASSERT(16 == kSampler_GrSLType);
GR_STATIC_ASSERT(SK_ARRAY_COUNT(kAlignmentMask) == kGrSLTypeCount);
return kAlignmentMask[type];
}
@@ -66,13 +70,15 @@ static inline uint32_t grsltype_to_vk_size(GrSLType type) {
8 * sizeof(float), // kMat22f_GrSLType. TODO: this will be 4 * szof(float) on std430.
12 * sizeof(float), // kMat33f_GrSLType
16 * sizeof(float), // kMat44f_GrSLType
- 0, // kSampler2D_GrSLType
- 0, // kSamplerExternal_GrSLType
- 0, // kSampler2DRect_GrSLType
- 0, // kSamplerBuffer_GrSLType
+ 0, // kTexture2DSampler_GrSLType
+ 0, // kTextureExternalSampler_GrSLType
+ 0, // kTexture2DRectSampler_GrSLType
+ 0, // kTextureBufferSampler_GrSLType
1, // kBool_GrSLType
4, // kInt_GrSLType
- 4 // kUint_GrSLType
+ 4, // kUint_GrSLType
+ 0, // kTexture2D_GrSLType
+ 0, // kSampler_GrSLType
};
return kSizes[type];
@@ -84,13 +90,15 @@ static inline uint32_t grsltype_to_vk_size(GrSLType type) {
GR_STATIC_ASSERT(5 == kMat22f_GrSLType);
GR_STATIC_ASSERT(6 == kMat33f_GrSLType);
GR_STATIC_ASSERT(7 == kMat44f_GrSLType);
- GR_STATIC_ASSERT(8 == kSampler2D_GrSLType);
- GR_STATIC_ASSERT(9 == kSamplerExternal_GrSLType);
- GR_STATIC_ASSERT(10 == kSampler2DRect_GrSLType);
- GR_STATIC_ASSERT(11 == kSamplerBuffer_GrSLType);
+ GR_STATIC_ASSERT(8 == kTexture2DSampler_GrSLType);
+ GR_STATIC_ASSERT(9 == kTextureExternalSampler_GrSLType);
+ GR_STATIC_ASSERT(10 == kTexture2DRectSampler_GrSLType);
+ GR_STATIC_ASSERT(11 == kTextureBufferSampler_GrSLType);
GR_STATIC_ASSERT(12 == kBool_GrSLType);
GR_STATIC_ASSERT(13 == kInt_GrSLType);
GR_STATIC_ASSERT(14 == kUint_GrSLType);
+ GR_STATIC_ASSERT(15 == kTexture2D_GrSLType);
+ GR_STATIC_ASSERT(16 == kSampler_GrSLType);
GR_STATIC_ASSERT(SK_ARRAY_COUNT(kSizes) == kGrSLTypeCount);
}
@@ -192,7 +200,7 @@ void GrVkUniformHandler::appendUniformDecls(GrShaderFlags visibility, SkString*
for (int i = 0; i < fSamplers.count(); ++i) {
const GrVkGLSLSampler& sampler = fSamplers[i];
- SkASSERT(sampler.type() == kSampler2D_GrSLType);
+ SkASSERT(sampler.type() == kTexture2DSampler_GrSLType);
if (visibility == sampler.visibility()) {
sampler.fShaderVar.appendDecl(fProgramBuilder->glslCaps(), out);
out->append(";\n");