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

Unified Diff: src/gpu/vk/GrVkProgramDesc.cpp

Issue 1718693002: Add vulkan files into skia repo. (Closed) Base URL: https://skia.googlesource.com/skia.git@merge
Patch Set: fix path 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/vk/GrVkProgramDesc.h ('k') | src/gpu/vk/GrVkRenderPass.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/vk/GrVkProgramDesc.cpp
diff --git a/src/gpu/gl/GrGLProgramDesc.cpp b/src/gpu/vk/GrVkProgramDesc.cpp
similarity index 68%
copy from src/gpu/gl/GrGLProgramDesc.cpp
copy to src/gpu/vk/GrVkProgramDesc.cpp
index a2dea8739206cbcab2e356ca4e4c4e49da865502..346dbb6baaeaa15695f9255f6303e8f445854bd4 100644
--- a/src/gpu/gl/GrGLProgramDesc.cpp
+++ b/src/gpu/vk/GrVkProgramDesc.cpp
@@ -1,34 +1,22 @@
/*
- * Copyright 2013 Google Inc.
+ * Copyright 2015 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include "GrGLProgramDesc.h"
+#include "GrVkProgramDesc.h"
+//#include "GrVkProcessor.h"
#include "GrProcessor.h"
#include "GrPipeline.h"
+#include "GrVkGpu.h"
+#include "GrVkUtil.h"
#include "SkChecksum.h"
-#include "gl/GrGLDefines.h"
-#include "gl/GrGLTexture.h"
-#include "gl/GrGLTypes.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLCaps.h"
-static uint8_t texture_target_key(GrGLenum target) {
- switch (target) {
- case GR_GL_TEXTURE_2D:
- return 0;
- case GR_GL_TEXTURE_EXTERNAL:
- return 1;
- case GR_GL_TEXTURE_RECTANGLE:
- return 2;
- default:
- SkFAIL("Unexpected texture target.");
- return 0;
- }
-}
+#include "shaderc/shaderc.h"
static void add_texture_key(GrProcessorKeyBuilder* b, const GrProcessor& proc,
const GrGLSLCaps& caps) {
@@ -41,9 +29,8 @@ static void add_texture_key(GrProcessorKeyBuilder* b, const GrProcessor& proc,
uint16_t* k16 = SkTCast<uint16_t*>(b->add32n(word32Count));
for (int i = 0; i < numTextures; ++i) {
const GrTextureAccess& access = proc.textureAccess(i);
- GrGLTexture* texture = static_cast<GrGLTexture*>(access.getTexture());
- k16[i] = SkToU16(caps.configTextureSwizzle(texture->config()).asKey() |
- (texture_target_key(texture->target()) << 8));
+ GrTexture* texture = access.getTexture();
+ k16[i] = SkToU16(caps.configTextureSwizzle(texture->config()).asKey());
}
// zero the last 16 bits if the number of textures is odd.
if (numTextures & 0x1) {
@@ -52,14 +39,14 @@ static void add_texture_key(GrProcessorKeyBuilder* b, const GrProcessor& proc,
}
/**
- * A function which emits a meta key into the key builder. This is required because shader code may
- * be dependent on properties of the effect that the effect itself doesn't use
- * in its key (e.g. the pixel format of textures used). So we create a meta-key for
- * every effect using this function. It is also responsible for inserting the effect's class ID
- * which must be different for every GrProcessor subclass. It can fail if an effect uses too many
- * transforms, etc, for the space allotted in the meta-key. NOTE, both FPs and GPs share this
- * function because it is hairy, though FPs do not have attribs, and GPs do not have transforms
- */
+* A function which emits a meta key into the key builder. This is required because shader code may
+* be dependent on properties of the effect that the effect itself doesn't use
+* in its key (e.g. the pixel format of textures used). So we create a meta-key for
+* every effect using this function. It is also responsible for inserting the effect's class ID
+* which must be different for every GrProcessor subclass. It can fail if an effect uses too many
+* transforms, etc, for the space allotted in the meta-key. NOTE, both FPs and GPs share this
+* function because it is hairy, though FPs do not have attribs, and GPs do not have transforms
+*/
static bool gen_meta_key(const GrProcessor& proc,
const GrGLSLCaps& glslCaps,
uint32_t transformKey,
@@ -68,7 +55,7 @@ static bool gen_meta_key(const GrProcessor& proc,
uint32_t classID = proc.classID();
// Currently we allow 16 bits for the class id and the overall processor key size.
- static const uint32_t kMetaKeyInvalidMask = ~((uint32_t) SK_MaxU16);
+ static const uint32_t kMetaKeyInvalidMask = ~((uint32_t)SK_MaxU16);
if ((processorKeySize | classID) & kMetaKeyInvalidMask) {
return false;
}
@@ -94,10 +81,10 @@ static bool gen_frag_proc_and_meta_keys(const GrPrimitiveProcessor& primProc,
fp.getGLSLProcessorKey(glslCaps, b);
return gen_meta_key(fp, glslCaps, primProc.getTransformKey(fp.coordTransforms(),
- fp.numTransformsExclChildren()), b);
+ fp.numTransformsExclChildren()), b);
}
-bool GrGLProgramDescBuilder::Build(GrProgramDesc* desc,
+bool GrVkProgramDescBuilder::Build(GrProgramDesc* desc,
const GrPrimitiveProcessor& primProc,
const GrPipeline& pipeline,
const GrGLSLCaps& glslCaps) {
@@ -106,25 +93,25 @@ bool GrGLProgramDescBuilder::Build(GrProgramDesc* desc,
// bindings in use or other descriptor field settings) it should be set
// to a canonical value to avoid duplicate programs with different keys.
- GrGLProgramDesc* glDesc = (GrGLProgramDesc*) desc;
+ GrVkProgramDesc* vkDesc = (GrVkProgramDesc*)desc;
GR_STATIC_ASSERT(0 == kProcessorKeysOffset % sizeof(uint32_t));
// Make room for everything up to the effect keys.
- glDesc->key().reset();
- glDesc->key().push_back_n(kProcessorKeysOffset);
+ vkDesc->key().reset();
+ vkDesc->key().push_back_n(kProcessorKeysOffset);
- GrProcessorKeyBuilder b(&glDesc->key());
+ GrProcessorKeyBuilder b(&vkDesc->key());
primProc.getGLSLProcessorKey(glslCaps, &b);
if (!gen_meta_key(primProc, glslCaps, 0, &b)) {
- glDesc->key().reset();
+ vkDesc->key().reset();
return false;
}
for (int i = 0; i < pipeline.numFragmentProcessors(); ++i) {
const GrFragmentProcessor& fp = pipeline.getFragmentProcessor(i);
if (!gen_frag_proc_and_meta_keys(primProc, fp, glslCaps, &b)) {
- glDesc->key().reset();
+ vkDesc->key().reset();
return false;
}
}
@@ -132,21 +119,21 @@ bool GrGLProgramDescBuilder::Build(GrProgramDesc* desc,
const GrXferProcessor& xp = pipeline.getXferProcessor();
xp.getGLSLProcessorKey(glslCaps, &b);
if (!gen_meta_key(xp, glslCaps, 0, &b)) {
- glDesc->key().reset();
+ vkDesc->key().reset();
return false;
}
// --------DO NOT MOVE HEADER ABOVE THIS LINE--------------------------------------------------
// Because header is a pointer into the dynamic array, we can't push any new data into the key
// below here.
- KeyHeader* header = glDesc->atOffset<KeyHeader, kHeaderOffset>();
+ KeyHeader* header = vkDesc->atOffset<KeyHeader, kHeaderOffset>();
// make sure any padding in the header is zeroed.
memset(header, 0, kHeaderSize);
if (pipeline.readsFragPosition()) {
header->fFragPosKey =
- GrGLSLFragmentShaderBuilder::KeyForFragmentPosition(pipeline.getRenderTarget());
+ GrGLSLFragmentShaderBuilder::KeyForFragmentPosition(pipeline.getRenderTarget());
} else {
header->fFragPosKey = 0;
}
@@ -163,6 +150,6 @@ bool GrGLProgramDescBuilder::Build(GrProgramDesc* desc,
header->fSnapVerticesToPixelCenters = pipeline.snapVerticesToPixelCenters();
header->fColorEffectCnt = pipeline.numColorFragmentProcessors();
header->fCoverageEffectCnt = pipeline.numCoverageFragmentProcessors();
- glDesc->finalize();
+ vkDesc->finalize();
return true;
}
« no previous file with comments | « src/gpu/vk/GrVkProgramDesc.h ('k') | src/gpu/vk/GrVkRenderPass.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698