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

Unified Diff: src/gpu/gl/GrGLProgram.cpp

Issue 1870893002: Implement texel buffers (Closed) Base URL: https://skia.googlesource.com/skia.git@upload_texelfetch
Patch Set: GrBuffer(Access) into include/gpu Created 4 years, 8 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/gl/GrGLProgram.h ('k') | src/gpu/gl/GrGLProgramDataManager.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/GrGLProgram.cpp
diff --git a/src/gpu/gl/GrGLProgram.cpp b/src/gpu/gl/GrGLProgram.cpp
index aa828a24c429ff2831df1fdf51510dd8f1aac910..6a433e17c5a5bbd4228402a179d4a3a9c3b51236 100644
--- a/src/gpu/gl/GrGLProgram.cpp
+++ b/src/gpu/gl/GrGLProgram.cpp
@@ -11,6 +11,7 @@
#include "GrProcessor.h"
#include "GrCoordTransform.h"
#include "GrGLGpu.h"
+#include "GrGLBuffer.h"
#include "GrGLPathRendering.h"
#include "GrPathProcessor.h"
#include "GrPipeline.h"
@@ -66,46 +67,34 @@ void GrGLProgram::abandon() {
///////////////////////////////////////////////////////////////////////////////
-static void append_texture_bindings(const GrProcessor& processor,
- SkTArray<const GrTextureAccess*>* textureBindings) {
- if (int numTextures = processor.numTextures()) {
- const GrTextureAccess** bindings = textureBindings->push_back_n(numTextures);
- int i = 0;
- do {
- bindings[i] = &processor.textureAccess(i);
- } while (++i < numTextures);
- }
-}
-
-void GrGLProgram::setData(const GrPrimitiveProcessor& primProc,
- const GrPipeline& pipeline,
- SkTArray<const GrTextureAccess*>* textureBindings) {
+void GrGLProgram::setData(const GrPrimitiveProcessor& primProc, const GrPipeline& pipeline) {
this->setRenderTargetState(primProc, pipeline);
// we set the textures, and uniforms for installed processors in a generic way, but subclasses
// of GLProgram determine how to set coord transforms
+ int nextSamplerIdx = 0;
fGeometryProcessor->setData(fProgramDataManager, primProc);
- append_texture_bindings(primProc, textureBindings);
+ this->bindTextures(primProc, pipeline.getAllowSRGBInputs(), &nextSamplerIdx);
- this->setFragmentData(primProc, pipeline, textureBindings);
+ this->setFragmentData(primProc, pipeline, &nextSamplerIdx);
if (primProc.getPixelLocalStorageState() !=
GrPixelLocalStorageState::kDraw_GrPixelLocalStorageState) {
const GrXferProcessor& xp = pipeline.getXferProcessor();
fXferProcessor->setData(fProgramDataManager, xp);
- append_texture_bindings(xp, textureBindings);
+ this->bindTextures(xp, pipeline.getAllowSRGBInputs(), &nextSamplerIdx);
}
}
void GrGLProgram::setFragmentData(const GrPrimitiveProcessor& primProc,
const GrPipeline& pipeline,
- SkTArray<const GrTextureAccess*>* textureBindings) {
+ int* nextSamplerIdx) {
int numProcessors = fFragmentProcessors.count();
for (int i = 0; i < numProcessors; ++i) {
const GrFragmentProcessor& processor = pipeline.getFragmentProcessor(i);
fFragmentProcessors[i]->setData(fProgramDataManager, processor);
this->setTransformData(primProc, processor, i);
- append_texture_bindings(processor, textureBindings);
+ this->bindTextures(processor, pipeline.getAllowSRGBInputs(), nextSamplerIdx);
}
}
void GrGLProgram::setTransformData(const GrPrimitiveProcessor& primProc,
@@ -145,3 +134,18 @@ void GrGLProgram::setRenderTargetState(const GrPrimitiveProcessor& primProc,
size, rt->origin());
}
}
+
+void GrGLProgram::bindTextures(const GrProcessor& processor,
+ bool allowSRGBInputs,
+ int* nextSamplerIdx) {
+ for (int i = 0; i < processor.numTextures(); ++i) {
+ const GrTextureAccess& access = processor.textureAccess(i);
+ fGpu->bindTexture((*nextSamplerIdx)++, access.getParams(),
+ allowSRGBInputs, static_cast<GrGLTexture*>(access.getTexture()));
+ }
+ for (int i = 0; i < processor.numBuffers(); ++i) {
+ const GrBufferAccess& access = processor.bufferAccess(i);
+ fGpu->bindTexelBuffer((*nextSamplerIdx)++, access.offsetInBytes(), access.texelConfig(),
+ static_cast<GrGLBuffer*>(access.buffer()));
+ }
+}
« no previous file with comments | « src/gpu/gl/GrGLProgram.h ('k') | src/gpu/gl/GrGLProgramDataManager.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698