aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-02-07 15:57:36 +0000
committerGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-02-07 15:57:36 +0000
commit0439e569969d560e1c6d1716c8cb3d29b82305f9 (patch)
treebc874c40171eeb92c1424cb45f1aa0e9f7fe188a /src
parentaa6773557919fc9640e0873b7e87d4138aa2a6ad (diff)
revert 3144
git-svn-id: http://skia.googlecode.com/svn/trunk@3145 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r--src/gpu/GrGpuGL.cpp155
-rw-r--r--src/gpu/GrGpuGL.h40
2 files changed, 32 insertions, 163 deletions
diff --git a/src/gpu/GrGpuGL.cpp b/src/gpu/GrGpuGL.cpp
index 7d77a3f8b3..70d28d6785 100644
--- a/src/gpu/GrGpuGL.cpp
+++ b/src/gpu/GrGpuGL.cpp
@@ -34,78 +34,6 @@ static const int SPARE_TEX_UNIT = GrDrawState::kNumStages;
#define CHECK_ALLOC_ERROR(iface) GR_GL_NO_ERROR
#endif
-///////////////////////////////////////////////////////////////////////////////
-
-void GrGpuGL::GLCaps::markConfigAsValidColorAttachment(GrPixelConfig config) {
-#if !GR_GL_CHECK_FBO_STATUS_ONCE_PER_FORMAT
- return;
-#endif
- GrAssert(config < kGrPixelConfigCount);
- int u32Idx = config / 32;
- int bitIdx = config % 32;
- fVerifiedColorAttachmentConfigs[u32Idx] |= (1 << bitIdx);
-}
-
-bool GrGpuGL::GLCaps::isConfigVerifiedColorAttachment(
- GrPixelConfig config) const {
-#if !GR_GL_CHECK_FBO_STATUS_ONCE_PER_FORMAT
- return false;
-#endif
- GrAssert((unsigned)config < kGrPixelConfigCount);
- int u32Idx = config / 32;
- int bitIdx = config % 32;
- return SkToBool(fVerifiedColorAttachmentConfigs[u32Idx] & (1 << bitIdx));
-}
-
-void GrGpuGL::GLCaps::markColorConfigAndStencilFormatAsVerified(
- GrPixelConfig config,
- const GrGLStencilBuffer::Format& format) {
-#if !GR_GL_CHECK_FBO_STATUS_ONCE_PER_FORMAT
- return;
-#endif
- GrAssert((unsigned)config < kGrPixelConfigCount);
- int count = fStencilFormats.count();
- // we expect a really small number of possible formats so linear search
- // should be OK
- GrAssert(count < 16);
- for (int i = 0; i < count; ++i) {
- if (format.fInternalFormat ==
- fStencilFormats[i].fFormat.fInternalFormat) {
- int u32Idx = config / 32;
- int bitIdx = config % 32;
- fStencilFormats[i].fVerifiedColorConfigs[u32Idx] |= (1 << bitIdx);
- return;
- }
- }
- SkDEBUGFAIL("Why are we seeing a stencil format that GLCaps doesn't know about.");
-}
-
-bool GrGpuGL::GLCaps::isColorConfigAndStencilFormatVerified(
- GrPixelConfig config,
- const GrGLStencilBuffer::Format& format) const {
-#if !GR_GL_CHECK_FBO_STATUS_ONCE_PER_FORMAT
- return false;
-#endif
- GrAssert((unsigned)config < kGrPixelConfigCount);
- int count = fStencilFormats.count();
- // we expect a really small number of possible formats so linear search
- // should be OK
- GrAssert(count < 16);
- for (int i = 0; i < count; ++i) {
- if (format.fInternalFormat ==
- fStencilFormats[i].fFormat.fInternalFormat) {
- int u32Idx = config / 32;
- int bitIdx = config % 32;
- return SkToBool(fStencilFormats[i].fVerifiedColorConfigs[u32Idx] &
- (1 << bitIdx));
- }
- }
- SkDEBUGFAIL("Why are we seeing a stencil format that GLCaps doesn't know about.");
- return false;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
static const GrGLenum gXfermodeCoeff2Blend[] = {
GR_GL_ZERO,
GR_GL_ONE,
@@ -474,16 +402,14 @@ void GrGpuGL::initStencilFormats() {
// these consts are in order of most preferred to least preferred
// we don't bother with GL_STENCIL_INDEX1 or GL_DEPTH32F_STENCIL8
-
- // Omitting fVerifiedColorConfigs from initializer list should init to 0.
- static const GLCaps::StencilFormat
+ static const GrGLStencilBuffer::Format
// internal Format stencil bits total bits packed?
- gS8 = {{GR_GL_STENCIL_INDEX8, 8, 8, false}},
- gS16 = {{GR_GL_STENCIL_INDEX16, 16, 16, false}},
- gD24S8 = {{GR_GL_DEPTH24_STENCIL8, 8, 32, true }},
- gS4 = {{GR_GL_STENCIL_INDEX4, 4, 4, false}},
- gS = {{GR_GL_STENCIL_INDEX, kUnknownBitCount, kUnknownBitCount, false}},
- gDS = {{GR_GL_DEPTH_STENCIL, kUnknownBitCount, kUnknownBitCount, true }};
+ gS8 = {GR_GL_STENCIL_INDEX8, 8, 8, false},
+ gS16 = {GR_GL_STENCIL_INDEX16, 16, 16, false},
+ gD24S8 = {GR_GL_DEPTH24_STENCIL8, 8, 32, true },
+ gS4 = {GR_GL_STENCIL_INDEX4, 4, 4, false},
+ gS = {GR_GL_STENCIL_INDEX, kUnknownBitCount, kUnknownBitCount, false},
+ gDS = {GR_GL_DEPTH_STENCIL, kUnknownBitCount, kUnknownBitCount, true };
if (kDesktop_GrGLBinding == this->glBinding()) {
bool supportsPackedDS = fGLVersion >= GR_GL_VER(3,0) ||
@@ -516,17 +442,6 @@ void GrGpuGL::initStencilFormats() {
fGLCaps.fStencilFormats.push_back() = gS4;
}
}
-#if GR_DEBUG
- // ensure that initially all color / stencil format combos have unverified
- // fbo status.
- for (int i = 0; i < fGLCaps.fStencilFormats.count(); ++i) {
- int numU32 =
- GR_ARRAY_COUNT(fGLCaps.fStencilFormats[i].fVerifiedColorConfigs);
- for (int j = 0; j < numU32; ++j) {
- GrAssert(0 == fGLCaps.fStencilFormats[i].fVerifiedColorConfigs);
- }
- }
-#endif
}
GrPixelConfig GrGpuGL::preferredReadPixelsConfig(GrPixelConfig config) const {
@@ -995,12 +910,9 @@ bool GrGpuGL::createRenderTargetObjects(int width, int height,
GR_GL_COLOR_ATTACHMENT0,
GR_GL_RENDERBUFFER,
desc->fMSColorRenderbufferID));
- if (!fGLCaps.isConfigVerifiedColorAttachment(desc->fConfig)) {
- GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER));
- if (status != GR_GL_FRAMEBUFFER_COMPLETE) {
- goto FAILED;
- }
- fGLCaps.markConfigAsValidColorAttachment(desc->fConfig);
+ GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER));
+ if (status != GR_GL_FRAMEBUFFER_COMPLETE) {
+ goto FAILED;
}
}
GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, desc->fTexFBOID));
@@ -1009,12 +921,9 @@ bool GrGpuGL::createRenderTargetObjects(int width, int height,
GR_GL_COLOR_ATTACHMENT0,
GR_GL_TEXTURE_2D,
texID, 0));
- if (!fGLCaps.isConfigVerifiedColorAttachment(desc->fConfig)) {
- GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER));
- if (status != GR_GL_FRAMEBUFFER_COMPLETE) {
- goto FAILED;
- }
- fGLCaps.markConfigAsValidColorAttachment(desc->fConfig);
+ GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER));
+ if (status != GR_GL_FRAMEBUFFER_COMPLETE) {
+ goto FAILED;
}
return true;
@@ -1206,7 +1115,7 @@ bool GrGpuGL::createStencilBufferForRenderTarget(GrRenderTarget* rt,
// that we won't go through this loop more than once after the
// first (painful) stencil creation.
int sIdx = (i + fLastSuccessfulStencilFmtIdx) % stencilFmtCnt;
- const GLCaps::StencilFormat& sFmt = fGLCaps.fStencilFormats[sIdx];
+ const GrGLStencilBuffer::Format& sFmt = fGLCaps.fStencilFormats[sIdx];
CLEAR_ERROR_BEFORE_ALLOC(this->glInterface());
// we do this "if" so that we don't call the multisample
// version on a GL that doesn't have an MSAA extension.
@@ -1214,12 +1123,12 @@ bool GrGpuGL::createStencilBufferForRenderTarget(GrRenderTarget* rt,
GL_ALLOC_CALL(this->glInterface(),
RenderbufferStorageMultisample(GR_GL_RENDERBUFFER,
samples,
- sFmt.fFormat.fInternalFormat,
+ sFmt.fInternalFormat,
width, height));
} else {
GL_ALLOC_CALL(this->glInterface(),
RenderbufferStorage(GR_GL_RENDERBUFFER,
- sFmt.fFormat.fInternalFormat,
+ sFmt.fInternalFormat,
width, height));
}
@@ -1227,7 +1136,7 @@ bool GrGpuGL::createStencilBufferForRenderTarget(GrRenderTarget* rt,
if (err == GR_GL_NO_ERROR) {
// After sized formats we attempt an unsized format and take whatever
// sizes GL gives us. In that case we query for the size.
- GrGLStencilBuffer::Format format = sFmt.fFormat;
+ GrGLStencilBuffer::Format format = sFmt;
get_stencil_rb_sizes(this->glInterface(), sbID, &format);
sb = new GrGLStencilBuffer(this, sbID, width, height,
samples, format);
@@ -1286,26 +1195,20 @@ bool GrGpuGL::attachStencilBufferToRenderTarget(GrStencilBuffer* sb,
}
GrGLenum status;
- if (!fGLCaps.isColorConfigAndStencilFormatVerified(rt->config(),
- glsb->format())) {
- GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER));
- if (status != GR_GL_FRAMEBUFFER_COMPLETE) {
+ GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER));
+ if (status != GR_GL_FRAMEBUFFER_COMPLETE) {
+ GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
+ GR_GL_STENCIL_ATTACHMENT,
+ GR_GL_RENDERBUFFER, 0));
+ if (glsb->format().fPacked) {
GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
- GR_GL_STENCIL_ATTACHMENT,
+ GR_GL_DEPTH_ATTACHMENT,
GR_GL_RENDERBUFFER, 0));
- if (glsb->format().fPacked) {
- GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
- GR_GL_DEPTH_ATTACHMENT,
- GR_GL_RENDERBUFFER, 0));
- }
- return false;
- } else {
- fGLCaps.markColorConfigAndStencilFormatAsVerified(
- rt->config(),
- glsb->format());
}
+ return false;
+ } else {
+ return true;
}
- return true;
}
}
@@ -2527,8 +2430,8 @@ void GrGpuGL::GLCaps::print() const {
for (int i = 0; i < fStencilFormats.count(); ++i) {
GrPrintf("Stencil Format %d, stencil bits: %02d, total bits: %02d\n",
i,
- fStencilFormats[i].fFormat.fStencilBits,
- fStencilFormats[i].fFormat.fTotalBits);
+ fStencilFormats[i].fStencilBits,
+ fStencilFormats[i].fTotalBits);
}
GR_STATIC_ASSERT(0 == kNone_MSFBO);
diff --git a/src/gpu/GrGpuGL.h b/src/gpu/GrGpuGL.h
index e11143289f..6ac48090c1 100644
--- a/src/gpu/GrGpuGL.h
+++ b/src/gpu/GrGpuGL.h
@@ -61,41 +61,8 @@ protected:
, fPackFlipYSupport(false)
, fTextureUsageSupport(false)
, fTexStorageSupport(false) {
- memset(&fVerifiedColorAttachmentConfigs, 0,
- sizeof(fVerifiedColorAttachmentConfigs));
}
-
- // Call to note that a color config has been verified as a valid
- // color attachment. This may save future calls to
- // CheckFramebufferStatus
- void markConfigAsValidColorAttachment(GrPixelConfig config);
-
- // Call to check whether a config has been verified as a valid color
- // attachment.
- bool isConfigVerifiedColorAttachment(GrPixelConfig config) const;
-
- // Call to note that a color config / stencil format pair passed
- // FBO status check. We may skip calling CheckFramebufferStatus for
- // this combination in the future.
- void markColorConfigAndStencilFormatAsVerified(
- GrPixelConfig config,
- const GrGLStencilBuffer::Format& format);
-
- // Call to check whether color config / stencil format pair has already
- // passed FBO status check.
- bool isColorConfigAndStencilFormatVerified(
- GrPixelConfig config,
- const GrGLStencilBuffer::Format& format) const;
-
- void print() const;
-
- struct StencilFormat {
- GrGLStencilBuffer::Format fFormat;
- uint32_t fVerifiedColorConfigs[(kGrPixelConfigCount + 31) / 32];
- };
-
- SkTArray<StencilFormat, true> fStencilFormats;
-
+ SkTArray<GrGLStencilBuffer::Format, true> fStencilFormats;
enum {
/**
@@ -151,10 +118,9 @@ protected:
// Is there support for glTexStorage
bool fTexStorageSupport;
- private:
- uint32_t fVerifiedColorAttachmentConfigs[(kGrPixelConfigCount + 31) / 32];
+ void print() const;
} fGLCaps;
-
+
struct {
size_t fVertexOffset;
GrVertexLayout fVertexLayout;