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

Side by Side Diff: src/gpu/gl/GrGLGpu.cpp

Issue 1514033002: Initialize glGen* call id args to zero (Closed) Base URL: https://skia.googlesource.com/skia.git@run-debug-context
Patch Set: Created 5 years 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 unified diff | Download patch
« no previous file with comments | « no previous file | src/gpu/gl/debug/GrGLCreateDebugInterface.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 8
9 #include "GrGLGpu.h" 9 #include "GrGLGpu.h"
10 #include "GrGLGLSL.h" 10 #include "GrGLGLSL.h"
(...skipping 1059 matching lines...) Expand 10 before | Expand all | Expand 10 after
1070 const void* srcData, size_t rowBytes) { 1070 const void* srcData, size_t rowBytes) {
1071 // We fail if the MSAA was requested and is not available. 1071 // We fail if the MSAA was requested and is not available.
1072 if (GrGLCaps::kNone_MSFBOType == this->glCaps().msFBOType() && desc.fSampleC nt) { 1072 if (GrGLCaps::kNone_MSFBOType == this->glCaps().msFBOType() && desc.fSampleC nt) {
1073 //SkDebugf("MSAA RT requested but not supported on this platform."); 1073 //SkDebugf("MSAA RT requested but not supported on this platform.");
1074 return return_null_texture(); 1074 return return_null_texture();
1075 } 1075 }
1076 1076
1077 bool renderTarget = SkToBool(desc.fFlags & kRenderTarget_GrSurfaceFlag); 1077 bool renderTarget = SkToBool(desc.fFlags & kRenderTarget_GrSurfaceFlag);
1078 1078
1079 GrGLTexture::IDDesc idDesc; 1079 GrGLTexture::IDDesc idDesc;
1080 idDesc.fInfo.fID = 0;
1080 GL_CALL(GenTextures(1, &idDesc.fInfo.fID)); 1081 GL_CALL(GenTextures(1, &idDesc.fInfo.fID));
1081 idDesc.fLifeCycle = lifeCycle; 1082 idDesc.fLifeCycle = lifeCycle;
1082 // We only support GL_TEXTURE_2D at the moment. 1083 // We only support GL_TEXTURE_2D at the moment.
1083 idDesc.fInfo.fTarget = GR_GL_TEXTURE_2D; 1084 idDesc.fInfo.fTarget = GR_GL_TEXTURE_2D;
1084 1085
1085 if (!idDesc.fInfo.fID) { 1086 if (!idDesc.fInfo.fID) {
1086 return return_null_texture(); 1087 return return_null_texture();
1087 } 1088 }
1088 1089
1089 this->setScratchTextureUnit(); 1090 this->setScratchTextureUnit();
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1149 1150
1150 GrTexture* GrGLGpu::onCreateCompressedTexture(const GrSurfaceDesc& desc, 1151 GrTexture* GrGLGpu::onCreateCompressedTexture(const GrSurfaceDesc& desc,
1151 GrGpuResource::LifeCycle lifeCycle , 1152 GrGpuResource::LifeCycle lifeCycle ,
1152 const void* srcData) { 1153 const void* srcData) {
1153 // Make sure that we're not flipping Y. 1154 // Make sure that we're not flipping Y.
1154 if (kBottomLeft_GrSurfaceOrigin == desc.fOrigin) { 1155 if (kBottomLeft_GrSurfaceOrigin == desc.fOrigin) {
1155 return return_null_texture(); 1156 return return_null_texture();
1156 } 1157 }
1157 1158
1158 GrGLTexture::IDDesc idDesc; 1159 GrGLTexture::IDDesc idDesc;
1160 idDesc.fInfo.fID = 0;
1159 GL_CALL(GenTextures(1, &idDesc.fInfo.fID)); 1161 GL_CALL(GenTextures(1, &idDesc.fInfo.fID));
1160 idDesc.fLifeCycle = lifeCycle; 1162 idDesc.fLifeCycle = lifeCycle;
1161 // We only support GL_TEXTURE_2D at the moment. 1163 // We only support GL_TEXTURE_2D at the moment.
1162 idDesc.fInfo.fTarget = GR_GL_TEXTURE_2D; 1164 idDesc.fInfo.fTarget = GR_GL_TEXTURE_2D;
1163 1165
1164 if (!idDesc.fInfo.fID) { 1166 if (!idDesc.fInfo.fID) {
1165 return return_null_texture(); 1167 return return_null_texture();
1166 } 1168 }
1167 1169
1168 this->setScratchTextureUnit(); 1170 this->setScratchTextureUnit();
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1231 } 1233 }
1232 } 1234 }
1233 } 1235 }
1234 1236
1235 int GrGLGpu::getCompatibleStencilIndex(GrPixelConfig config) { 1237 int GrGLGpu::getCompatibleStencilIndex(GrPixelConfig config) {
1236 static const int kSize = 16; 1238 static const int kSize = 16;
1237 if (kUnknownStencilIndex == fPixelConfigToStencilIndex[config]) { 1239 if (kUnknownStencilIndex == fPixelConfigToStencilIndex[config]) {
1238 // Default to unsupported 1240 // Default to unsupported
1239 fPixelConfigToStencilIndex[config] = kUnsupportedStencilIndex; 1241 fPixelConfigToStencilIndex[config] = kUnsupportedStencilIndex;
1240 // Create color texture 1242 // Create color texture
1241 GrGLuint colorID; 1243 GrGLuint colorID = 0;
1242 GL_CALL(GenTextures(1, &colorID)); 1244 GL_CALL(GenTextures(1, &colorID));
1243 this->setScratchTextureUnit(); 1245 this->setScratchTextureUnit();
1244 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, colorID)); 1246 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, colorID));
1245 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, 1247 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D,
1246 GR_GL_TEXTURE_MAG_FILTER, 1248 GR_GL_TEXTURE_MAG_FILTER,
1247 GR_GL_NEAREST)); 1249 GR_GL_NEAREST));
1248 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, 1250 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D,
1249 GR_GL_TEXTURE_MIN_FILTER, 1251 GR_GL_TEXTURE_MIN_FILTER,
1250 GR_GL_NEAREST)); 1252 GR_GL_NEAREST));
1251 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, 1253 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1284 if (GR_GL_NO_ERROR != GR_GL_GET_ERROR(this->glInterface())) { 1286 if (GR_GL_NO_ERROR != GR_GL_GET_ERROR(this->glInterface())) {
1285 GL_CALL(DeleteTextures(1, &colorID)); 1287 GL_CALL(DeleteTextures(1, &colorID));
1286 fPixelConfigToStencilIndex[config] = kUnsupportedStencilIndex; 1288 fPixelConfigToStencilIndex[config] = kUnsupportedStencilIndex;
1287 return kUnsupportedStencilIndex; 1289 return kUnsupportedStencilIndex;
1288 } 1290 }
1289 1291
1290 // unbind the texture from the texture unit before binding it to the fra me buffer 1292 // unbind the texture from the texture unit before binding it to the fra me buffer
1291 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, 0)); 1293 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, 0));
1292 1294
1293 // Create Framebuffer 1295 // Create Framebuffer
1294 GrGLuint fb; 1296 GrGLuint fb = 0;
1295 GL_CALL(GenFramebuffers(1, &fb)); 1297 GL_CALL(GenFramebuffers(1, &fb));
1296 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, fb)); 1298 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, fb));
1297 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID; 1299 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID;
1298 GL_CALL(FramebufferTexture2D(GR_GL_FRAMEBUFFER, 1300 GL_CALL(FramebufferTexture2D(GR_GL_FRAMEBUFFER,
1299 GR_GL_COLOR_ATTACHMENT0, 1301 GR_GL_COLOR_ATTACHMENT0,
1300 GR_GL_TEXTURE_2D, 1302 GR_GL_TEXTURE_2D,
1301 colorID, 1303 colorID,
1302 0)); 1304 0));
1303 1305
1304 // look over formats till I find a compatible one 1306 // look over formats till I find a compatible one
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1418 GrVertexBuffer* GrGLGpu::onCreateVertexBuffer(size_t size, bool dynamic) { 1420 GrVertexBuffer* GrGLGpu::onCreateVertexBuffer(size_t size, bool dynamic) {
1419 GrGLVertexBuffer::Desc desc; 1421 GrGLVertexBuffer::Desc desc;
1420 desc.fUsage = dynamic ? GrGLBufferImpl::kDynamicDraw_Usage : GrGLBufferImpl: :kStaticDraw_Usage; 1422 desc.fUsage = dynamic ? GrGLBufferImpl::kDynamicDraw_Usage : GrGLBufferImpl: :kStaticDraw_Usage;
1421 desc.fSizeInBytes = size; 1423 desc.fSizeInBytes = size;
1422 1424
1423 if (this->glCaps().useNonVBOVertexAndIndexDynamicData() && dynamic) { 1425 if (this->glCaps().useNonVBOVertexAndIndexDynamicData() && dynamic) {
1424 desc.fID = 0; 1426 desc.fID = 0;
1425 GrGLVertexBuffer* vertexBuffer = new GrGLVertexBuffer(this, desc); 1427 GrGLVertexBuffer* vertexBuffer = new GrGLVertexBuffer(this, desc);
1426 return vertexBuffer; 1428 return vertexBuffer;
1427 } else { 1429 } else {
1430 desc.fID = 0;
1428 GL_CALL(GenBuffers(1, &desc.fID)); 1431 GL_CALL(GenBuffers(1, &desc.fID));
1429 if (desc.fID) { 1432 if (desc.fID) {
1430 fHWGeometryState.setVertexBufferID(this, desc.fID); 1433 fHWGeometryState.setVertexBufferID(this, desc.fID);
1431 CLEAR_ERROR_BEFORE_ALLOC(this->glInterface()); 1434 CLEAR_ERROR_BEFORE_ALLOC(this->glInterface());
1432 // make sure driver can allocate memory for this buffer 1435 // make sure driver can allocate memory for this buffer
1433 GL_ALLOC_CALL(this->glInterface(), 1436 GL_ALLOC_CALL(this->glInterface(),
1434 BufferData(GR_GL_ARRAY_BUFFER, 1437 BufferData(GR_GL_ARRAY_BUFFER,
1435 (GrGLsizeiptr) desc.fSizeInBytes, 1438 (GrGLsizeiptr) desc.fSizeInBytes,
1436 nullptr, // data ptr 1439 nullptr, // data ptr
1437 dynamic ? DYNAMIC_USAGE_PARAM : GR_GL_STATI C_DRAW)); 1440 dynamic ? DYNAMIC_USAGE_PARAM : GR_GL_STATI C_DRAW));
(...skipping 12 matching lines...) Expand all
1450 GrIndexBuffer* GrGLGpu::onCreateIndexBuffer(size_t size, bool dynamic) { 1453 GrIndexBuffer* GrGLGpu::onCreateIndexBuffer(size_t size, bool dynamic) {
1451 GrGLIndexBuffer::Desc desc; 1454 GrGLIndexBuffer::Desc desc;
1452 desc.fUsage = dynamic ? GrGLBufferImpl::kDynamicDraw_Usage : GrGLBufferImpl: :kStaticDraw_Usage; 1455 desc.fUsage = dynamic ? GrGLBufferImpl::kDynamicDraw_Usage : GrGLBufferImpl: :kStaticDraw_Usage;
1453 desc.fSizeInBytes = size; 1456 desc.fSizeInBytes = size;
1454 1457
1455 if (this->glCaps().useNonVBOVertexAndIndexDynamicData() && dynamic) { 1458 if (this->glCaps().useNonVBOVertexAndIndexDynamicData() && dynamic) {
1456 desc.fID = 0; 1459 desc.fID = 0;
1457 GrIndexBuffer* indexBuffer = new GrGLIndexBuffer(this, desc); 1460 GrIndexBuffer* indexBuffer = new GrGLIndexBuffer(this, desc);
1458 return indexBuffer; 1461 return indexBuffer;
1459 } else { 1462 } else {
1463 desc.fID = 0;
1460 GL_CALL(GenBuffers(1, &desc.fID)); 1464 GL_CALL(GenBuffers(1, &desc.fID));
1461 if (desc.fID) { 1465 if (desc.fID) {
1462 fHWGeometryState.setIndexBufferIDOnDefaultVertexArray(this, desc.fID ); 1466 fHWGeometryState.setIndexBufferIDOnDefaultVertexArray(this, desc.fID );
1463 CLEAR_ERROR_BEFORE_ALLOC(this->glInterface()); 1467 CLEAR_ERROR_BEFORE_ALLOC(this->glInterface());
1464 // make sure driver can allocate memory for this buffer 1468 // make sure driver can allocate memory for this buffer
1465 GL_ALLOC_CALL(this->glInterface(), 1469 GL_ALLOC_CALL(this->glInterface(),
1466 BufferData(GR_GL_ELEMENT_ARRAY_BUFFER, 1470 BufferData(GR_GL_ELEMENT_ARRAY_BUFFER,
1467 (GrGLsizeiptr) desc.fSizeInBytes, 1471 (GrGLsizeiptr) desc.fSizeInBytes,
1468 nullptr, // data ptr 1472 nullptr, // data ptr
1469 dynamic ? DYNAMIC_USAGE_PARAM : GR_GL_STATI C_DRAW)); 1473 dynamic ? DYNAMIC_USAGE_PARAM : GR_GL_STATI C_DRAW));
(...skipping 13 matching lines...) Expand all
1483 GrGLCaps::TransferBufferType xferBufferType = this->ctxInfo().caps()->transf erBufferType(); 1487 GrGLCaps::TransferBufferType xferBufferType = this->ctxInfo().caps()->transf erBufferType();
1484 if (GrGLCaps::kNone_TransferBufferType == xferBufferType) { 1488 if (GrGLCaps::kNone_TransferBufferType == xferBufferType) {
1485 return nullptr; 1489 return nullptr;
1486 } 1490 }
1487 1491
1488 GrGLTransferBuffer::Desc desc; 1492 GrGLTransferBuffer::Desc desc;
1489 bool toGpu = (kCpuToGpu_TransferType == xferType); 1493 bool toGpu = (kCpuToGpu_TransferType == xferType);
1490 desc.fUsage = toGpu ? GrGLBufferImpl::kStreamDraw_Usage : GrGLBufferImpl::kS treamRead_Usage; 1494 desc.fUsage = toGpu ? GrGLBufferImpl::kStreamDraw_Usage : GrGLBufferImpl::kS treamRead_Usage;
1491 1495
1492 desc.fSizeInBytes = size; 1496 desc.fSizeInBytes = size;
1493 1497 desc.fID = 0;
1494 GL_CALL(GenBuffers(1, &desc.fID)); 1498 GL_CALL(GenBuffers(1, &desc.fID));
1495 if (desc.fID) { 1499 if (desc.fID) {
1496 CLEAR_ERROR_BEFORE_ALLOC(this->glInterface()); 1500 CLEAR_ERROR_BEFORE_ALLOC(this->glInterface());
1497 // make sure driver can allocate memory for this bmapuffer 1501 // make sure driver can allocate memory for this bmapuffer
1498 GrGLenum type; 1502 GrGLenum type;
1499 if (GrGLCaps::kChromium_TransferBufferType == xferBufferType) { 1503 if (GrGLCaps::kChromium_TransferBufferType == xferBufferType) {
1500 type = toGpu ? GR_GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM 1504 type = toGpu ? GR_GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM
1501 : GR_GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM; 1505 : GR_GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM;
1502 } else { 1506 } else {
1503 SkASSERT(GrGLCaps::kPBO_TransferBufferType == xferBufferType); 1507 SkASSERT(GrGLCaps::kPBO_TransferBufferType == xferBufferType);
(...skipping 1636 matching lines...) Expand 10 before | Expand all | Expand 10 after
3140 GL_CALL_RET(fCopyPrograms[i].fPosXformUniform, 3144 GL_CALL_RET(fCopyPrograms[i].fPosXformUniform,
3141 GetUniformLocation(fCopyPrograms[i].fProgram, "u_posXform")) ; 3145 GetUniformLocation(fCopyPrograms[i].fProgram, "u_posXform")) ;
3142 GL_CALL_RET(fCopyPrograms[i].fTexCoordXformUniform, 3146 GL_CALL_RET(fCopyPrograms[i].fTexCoordXformUniform,
3143 GetUniformLocation(fCopyPrograms[i].fProgram, "u_texCoordXfo rm")); 3147 GetUniformLocation(fCopyPrograms[i].fProgram, "u_texCoordXfo rm"));
3144 3148
3145 GL_CALL(BindAttribLocation(fCopyPrograms[i].fProgram, 0, "a_vertex")); 3149 GL_CALL(BindAttribLocation(fCopyPrograms[i].fProgram, 0, "a_vertex"));
3146 3150
3147 GL_CALL(DeleteShader(vshader)); 3151 GL_CALL(DeleteShader(vshader));
3148 GL_CALL(DeleteShader(fshader)); 3152 GL_CALL(DeleteShader(fshader));
3149 } 3153 }
3150 3154 fCopyProgramArrayBuffer = 0;
3151 GL_CALL(GenBuffers(1, &fCopyProgramArrayBuffer)); 3155 GL_CALL(GenBuffers(1, &fCopyProgramArrayBuffer));
3152 fHWGeometryState.setVertexBufferID(this, fCopyProgramArrayBuffer); 3156 fHWGeometryState.setVertexBufferID(this, fCopyProgramArrayBuffer);
3153 static const GrGLfloat vdata[] = { 3157 static const GrGLfloat vdata[] = {
3154 0, 0, 3158 0, 0,
3155 0, 1, 3159 0, 1,
3156 1, 0, 3160 1, 0,
3157 1, 1 3161 1, 1
3158 }; 3162 };
3159 GL_ALLOC_CALL(this->glInterface(), 3163 GL_ALLOC_CALL(this->glInterface(),
3160 BufferData(GR_GL_ARRAY_BUFFER, 3164 BufferData(GR_GL_ARRAY_BUFFER,
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
3503 GL_CALL(BlendBarrier()); 3507 GL_CALL(BlendBarrier());
3504 return; 3508 return;
3505 default: break; // placate compiler warnings that kNone not handled 3509 default: break; // placate compiler warnings that kNone not handled
3506 } 3510 }
3507 } 3511 }
3508 3512
3509 GrBackendObject GrGLGpu::createTestingOnlyBackendTexture(void* pixels, int w, in t h, 3513 GrBackendObject GrGLGpu::createTestingOnlyBackendTexture(void* pixels, int w, in t h,
3510 GrPixelConfig config) c onst { 3514 GrPixelConfig config) c onst {
3511 GrGLTextureInfo* info = new GrGLTextureInfo; 3515 GrGLTextureInfo* info = new GrGLTextureInfo;
3512 info->fTarget = GR_GL_TEXTURE_2D; 3516 info->fTarget = GR_GL_TEXTURE_2D;
3517 info->fID = 0;
3513 GL_CALL(GenTextures(1, &info->fID)); 3518 GL_CALL(GenTextures(1, &info->fID));
3514 GL_CALL(ActiveTexture(GR_GL_TEXTURE0)); 3519 GL_CALL(ActiveTexture(GR_GL_TEXTURE0));
3515 GL_CALL(PixelStorei(GR_GL_UNPACK_ALIGNMENT, 1)); 3520 GL_CALL(PixelStorei(GR_GL_UNPACK_ALIGNMENT, 1));
3516 GL_CALL(BindTexture(info->fTarget, info->fID)); 3521 GL_CALL(BindTexture(info->fTarget, info->fID));
3517 GL_CALL(TexParameteri(info->fTarget, GR_GL_TEXTURE_MAG_FILTER, GR_GL_NEAREST )); 3522 GL_CALL(TexParameteri(info->fTarget, GR_GL_TEXTURE_MAG_FILTER, GR_GL_NEAREST ));
3518 GL_CALL(TexParameteri(info->fTarget, GR_GL_TEXTURE_MIN_FILTER, GR_GL_NEAREST )); 3523 GL_CALL(TexParameteri(info->fTarget, GR_GL_TEXTURE_MIN_FILTER, GR_GL_NEAREST ));
3519 GL_CALL(TexParameteri(info->fTarget, GR_GL_TEXTURE_WRAP_S, GR_GL_CLAMP_TO_ED GE)); 3524 GL_CALL(TexParameteri(info->fTarget, GR_GL_TEXTURE_WRAP_S, GR_GL_CLAMP_TO_ED GE));
3520 GL_CALL(TexParameteri(info->fTarget, GR_GL_TEXTURE_WRAP_T, GR_GL_CLAMP_TO_ED GE)); 3525 GL_CALL(TexParameteri(info->fTarget, GR_GL_TEXTURE_WRAP_T, GR_GL_CLAMP_TO_ED GE));
3521 3526
3522 GrGLenum internalFormat = 0x0; // suppress warning 3527 GrGLenum internalFormat = 0x0; // suppress warning
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
3622 this->setVertexArrayID(gpu, 0); 3627 this->setVertexArrayID(gpu, 0);
3623 } 3628 }
3624 int attrCount = gpu->glCaps().maxVertexAttributes(); 3629 int attrCount = gpu->glCaps().maxVertexAttributes();
3625 if (fDefaultVertexArrayAttribState.count() != attrCount) { 3630 if (fDefaultVertexArrayAttribState.count() != attrCount) {
3626 fDefaultVertexArrayAttribState.resize(attrCount); 3631 fDefaultVertexArrayAttribState.resize(attrCount);
3627 } 3632 }
3628 attribState = &fDefaultVertexArrayAttribState; 3633 attribState = &fDefaultVertexArrayAttribState;
3629 } 3634 }
3630 return attribState; 3635 return attribState;
3631 } 3636 }
OLDNEW
« no previous file with comments | « no previous file | src/gpu/gl/debug/GrGLCreateDebugInterface.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698