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

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

Issue 1785873003: Implement GL support for buffer textures (Closed) Base URL: https://skia.googlesource.com/skia.git@upload_glTexBuffer
Patch Set: rebase Created 4 years, 9 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/GrGLGpu.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/GrGLGpu.cpp
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 76cb1a068a2bc3dee7ae2df28bc167d1eda2aad9..21adb4abdad98816b94212d8c87653b33c5a8bbe 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -582,6 +582,26 @@ GrTexture* GrGLGpu::onWrapBackendTexture(const GrBackendTextureDesc& desc,
if (!this->glCaps().rectangleTextureSupport()) {
return nullptr;
}
+ } else if (GR_GL_TEXTURE_BUFFER == idDesc.fInfo.fTarget) {
+ if (!this->glCaps().glslCaps()->bufferTextureSupport()) {
+ SkDEBUGFAIL("Buffer textures are not supported.");
+ return nullptr;
+ }
+ if (renderTarget) {
+ SkDEBUGFAIL("Rendering to a buffer texture is not supported.");
+ return nullptr;
+ }
+ if (0 != desc.fHeight) {
+ // This texture is just a 1-dimensional window into a buffer object. It has no height
+ // and its GPU memory size is effectively zero, because the actual memory is attributed
+ // to the buffer object itself.
+ SkDEBUGFAIL("Buffer textures must have a height of 0.");
+ return nullptr;
+ }
+ if (0 != desc.fSampleCnt) {
+ SkDEBUGFAIL("Multisampled buffer textures are not supported.");
+ return nullptr;
+ }
} else if (GR_GL_TEXTURE_2D != idDesc.fInfo.fTarget) {
return nullptr;
}
@@ -2102,8 +2122,12 @@ bool GrGLGpu::flushGLState(const GrPipeline& pipeline, const GrPrimitiveProcesso
int numTextureAccesses = textureAccesses.count();
for (int i = 0; i < numTextureAccesses; i++) {
- this->bindTexture(i, textureAccesses[i]->getParams(),
- static_cast<GrGLTexture*>(textureAccesses[i]->getTexture()));
+ GrGLTexture* texture = static_cast<GrGLTexture*>(textureAccesses[i]->getTexture());
+ if (!texture->supportsTextureParams()) {
+ this->bindTexture(i, texture);
+ } else {
+ this->flushTexture(i, textureAccesses[i]->getParams(), texture);
+ }
}
GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(pipeline.getRenderTarget());
@@ -3271,6 +3295,24 @@ void GrGLGpu::flushBlend(const GrXferProcessor::BlendInfo& blendInfo, const GrSw
}
}
+void GrGLGpu::bindTexture(int unitIdx, GrGLTexture* texture) {
+ SkASSERT(texture);
+
+ // If we created a rt/tex and rendered to it without using a texture and now we're texturing
+ // from the rt it will still be the last bound texture, but it needs resolving. So keep this
+ // out of the "last != next" check.
+ GrGLRenderTarget* texRT = static_cast<GrGLRenderTarget*>(texture->asRenderTarget());
+ if (texRT) {
+ this->onResolveRenderTarget(texRT);
+ }
+
+ if (fHWBoundTextureUniqueIDs[unitIdx] != texture->getUniqueID()) {
+ this->setTextureUnit(unitIdx);
+ GL_CALL(BindTexture(texture->target(), texture->textureID()));
+ fHWBoundTextureUniqueIDs[unitIdx] = texture->getUniqueID();
+ }
+}
+
static inline GrGLenum tile_to_gl_wrap(SkShader::TileMode tm) {
static const GrGLenum gWrapModes[] = {
GR_GL_CLAMP_TO_EDGE,
@@ -3311,8 +3353,8 @@ static void get_tex_param_swizzle(GrPixelConfig config,
}
}
-void GrGLGpu::bindTexture(int unitIdx, const GrTextureParams& params, GrGLTexture* texture) {
- SkASSERT(texture);
+void GrGLGpu::flushTexture(int unitIdx, const GrTextureParams& params, GrGLTexture* texture) {
+ this->bindTexture(unitIdx, texture);
#ifdef SK_DEBUG
if (!this->caps()->npotTextureTileSupport()) {
@@ -3326,22 +3368,6 @@ void GrGLGpu::bindTexture(int unitIdx, const GrTextureParams& params, GrGLTextur
}
#endif
- // If we created a rt/tex and rendered to it without using a texture and now we're texturing
- // from the rt it will still be the last bound texture, but it needs resolving. So keep this
- // out of the "last != next" check.
- GrGLRenderTarget* texRT = static_cast<GrGLRenderTarget*>(texture->asRenderTarget());
- if (texRT) {
- this->onResolveRenderTarget(texRT);
- }
-
- uint32_t textureID = texture->getUniqueID();
- GrGLenum target = texture->target();
- if (fHWBoundTextureUniqueIDs[unitIdx] != textureID) {
- this->setTextureUnit(unitIdx);
- GL_CALL(BindTexture(target, texture->textureID()));
- fHWBoundTextureUniqueIDs[unitIdx] = textureID;
- }
-
ResetTimestamp timestamp;
const GrGLTexture::TexParams& oldTexParams = texture->getCachedTexParams(&timestamp);
bool setAll = timestamp < this->getResetTimestamp();
@@ -3357,7 +3383,9 @@ void GrGLGpu::bindTexture(int unitIdx, const GrTextureParams& params, GrGLTextur
GR_GL_LINEAR,
GR_GL_LINEAR
};
+
GrTextureParams::FilterMode filterMode = params.filterMode();
+ GrGLenum target = texture->target();
if (GrTextureParams::kMipMap_FilterMode == filterMode) {
if (!this->caps()->mipMapSupport() || GrPixelConfigIsCompressed(texture->config())) {
@@ -3798,7 +3826,7 @@ void GrGLGpu::createCopyPrograms() {
" %s = %s(u_texture, v_texCoord);"
"}",
fsOutName,
- GrGLSLTexture2DFunctionName(kVec2f_GrSLType, kSamplerTypes[i], this->glslGeneration())
+ GrGLSLTextureFunctionName(kVec2f_GrSLType, kSamplerTypes[i], this->glslGeneration())
);
GL_CALL_RET(fCopyPrograms[i].fProgram, CreateProgram());
@@ -4014,7 +4042,7 @@ void GrGLGpu::copySurfaceAsDraw(GrSurface* dst,
GrGLTexture* srcTex = static_cast<GrGLTexture*>(src->asTexture());
GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::kNone_FilterMode);
- this->bindTexture(0, params, srcTex);
+ this->flushTexture(0, params, srcTex);
GrGLIRect dstVP;
this->bindSurfaceFBOForCopy(dst, GR_GL_FRAMEBUFFER, &dstVP, kDst_TempFBOTarget);
« no previous file with comments | « src/gpu/gl/GrGLGpu.h ('k') | src/gpu/gl/GrGLProgramDataManager.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698