0

Relax assertions around context loss and program initialization. Higher level code will take care of issuing repaints as necessary.

BUG=161571
TEST=GPUCrashTest.Kill in Debug mode on Windows


Review URL: https://chromiumcodereview.appspot.com/11415040

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@168464 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
kbr@chromium.org
2012-11-17 22:24:47 +00:00
parent 17018feca0
commit d01f0d4398
3 changed files with 26 additions and 23 deletions

@ -294,7 +294,7 @@ void GLRenderer::drawQuad(DrawingFrame& frame, const DrawQuad* quad)
void GLRenderer::drawCheckerboardQuad(const DrawingFrame& frame, const CheckerboardDrawQuad* quad)
{
const TileCheckerboardProgram* program = tileCheckerboardProgram();
DCHECK(program && program->initialized());
DCHECK(program && (program->initialized() || isContextLost()));
GLC(context(), context()->useProgram(program->program()));
SkColor color = quad->color();
@ -320,7 +320,7 @@ void GLRenderer::drawDebugBorderQuad(const DrawingFrame& frame, const DebugBorde
{
static float glMatrix[16];
const SolidColorProgram* program = solidColorProgram();
DCHECK(program && program->initialized());
DCHECK(program && (program->initialized() || isContextLost()));
GLC(context(), context()->useProgram(program->program()));
// Use the full quadRect for debug quads to not move the edges based on partial swaps.
@ -857,7 +857,7 @@ void GLRenderer::drawTileQuad(const DrawingFrame& frame, const TileDrawQuad* qua
void GLRenderer::drawYUVVideoQuad(const DrawingFrame& frame, const YUVVideoDrawQuad* quad)
{
const VideoYUVProgram* program = videoYUVProgram();
DCHECK(program && program->initialized());
DCHECK(program && (program->initialized() || isContextLost()));
const VideoLayerImpl::FramePlane& yPlane = quad->yPlane();
const VideoLayerImpl::FramePlane& uPlane = quad->uPlane();
@ -930,9 +930,10 @@ void GLRenderer::drawStreamVideoQuad(const DrawingFrame& frame, const StreamVide
}
struct TextureProgramBinding {
template<class Program> void set(Program* program)
template<class Program> void set(
Program* program, WebKit::WebGraphicsContext3D* context)
{
DCHECK(program && program->initialized());
DCHECK(program && (program->initialized() || context->isContextLost()));
programId = program->program();
samplerLocation = program->fragmentShader().samplerLocation();
matrixLocation = program->vertexShader().matrixLocation();
@ -945,9 +946,10 @@ struct TextureProgramBinding {
};
struct TexTransformTextureProgramBinding : TextureProgramBinding {
template<class Program> void set(Program* program)
template<class Program> void set(
Program* program, WebKit::WebGraphicsContext3D* context)
{
TextureProgramBinding::set(program);
TextureProgramBinding::set(program, context);
texTransformLocation = program->vertexShader().texTransformLocation();
}
int texTransformLocation;
@ -957,9 +959,9 @@ void GLRenderer::drawTextureQuad(const DrawingFrame& frame, const TextureDrawQua
{
TexTransformTextureProgramBinding binding;
if (quad->flipped())
binding.set(textureProgramFlip());
binding.set(textureProgramFlip(), context());
else
binding.set(textureProgram());
binding.set(textureProgram(), context());
GLC(context(), context()->useProgram(binding.programId));
GLC(context(), context()->uniform1i(binding.samplerLocation, 0));
const gfx::RectF& uvRect = quad->uvRect();
@ -990,7 +992,7 @@ void GLRenderer::drawTextureQuad(const DrawingFrame& frame, const TextureDrawQua
void GLRenderer::drawIOSurfaceQuad(const DrawingFrame& frame, const IOSurfaceDrawQuad* quad)
{
TexTransformTextureProgramBinding binding;
binding.set(textureIOSurfaceProgram());
binding.set(textureIOSurfaceProgram(), context());
GLC(context(), context()->useProgram(binding.programId));
GLC(context(), context()->uniform1i(binding.samplerLocation, 0));

@ -31,18 +31,12 @@ ProgramBindingBase::~ProgramBindingBase()
DCHECK(!m_initialized);
}
static bool contextLost(WebGraphicsContext3D* context)
{
return (context->getGraphicsResetStatusARB() != GL_NO_ERROR);
}
void ProgramBindingBase::init(WebGraphicsContext3D* context, const std::string& vertexShader, const std::string& fragmentShader)
{
TRACE_EVENT0("cc", "ProgramBindingBase::init");
m_vertexShaderId = loadShader(context, GL_VERTEX_SHADER, vertexShader);
if (!m_vertexShaderId) {
if (!contextLost(context))
if (!IsContextLost(context))
LOG(ERROR) << "Failed to create vertex shader";
return;
}
@ -51,13 +45,13 @@ void ProgramBindingBase::init(WebGraphicsContext3D* context, const std::string&
if (!m_fragmentShaderId) {
GLC(context, context->deleteShader(m_vertexShaderId));
m_vertexShaderId = 0;
if (!contextLost(context))
if (!IsContextLost(context))
LOG(ERROR) << "Failed to create fragment shader";
return;
}
m_program = createShaderProgram(context, m_vertexShaderId, m_fragmentShaderId);
DCHECK(m_program || contextLost(context));
DCHECK(m_program || IsContextLost(context));
}
void ProgramBindingBase::link(WebGraphicsContext3D* context)
@ -68,7 +62,7 @@ void ProgramBindingBase::link(WebGraphicsContext3D* context)
int linked = 0;
GLC(context, context->getProgramiv(m_program, GL_LINK_STATUS, &linked));
if (!linked) {
if (!contextLost(context))
if (!IsContextLost(context))
LOG(ERROR) << "Failed to link shader program";
GLC(context, context->deleteProgram(m_program));
}
@ -110,7 +104,7 @@ unsigned ProgramBindingBase::createShaderProgram(WebGraphicsContext3D* context,
{
unsigned programObject = context->createProgram();
if (!programObject) {
if (!contextLost(context))
if (!IsContextLost(context))
LOG(ERROR) << "Failed to create shader program";
return 0;
}
@ -137,4 +131,8 @@ void ProgramBindingBase::cleanupShaders(WebGraphicsContext3D* context)
}
}
bool ProgramBindingBase::IsContextLost(WebGraphicsContext3D* context) {
return (context->getGraphicsResetStatusARB() != GL_NO_ERROR);
}
} // namespace cc

@ -24,7 +24,7 @@ public:
void link(WebKit::WebGraphicsContext3D*);
void cleanup(WebKit::WebGraphicsContext3D*);
unsigned program() const { DCHECK(m_initialized); return m_program; }
unsigned program() const { return m_program; }
bool initialized() const { return m_initialized; }
protected:
@ -32,6 +32,7 @@ protected:
unsigned loadShader(WebKit::WebGraphicsContext3D*, unsigned type, const std::string& shaderSource);
unsigned createShaderProgram(WebKit::WebGraphicsContext3D*, unsigned vertexShader, unsigned fragmentShader);
void cleanupShaders(WebKit::WebGraphicsContext3D*);
bool IsContextLost(WebKit::WebGraphicsContext3D*);
unsigned m_program;
unsigned m_vertexShaderId;
@ -50,9 +51,11 @@ public:
void initialize(WebKit::WebGraphicsContext3D* context, bool usingBindUniform)
{
DCHECK(context);
DCHECK(m_program);
DCHECK(!m_initialized);
if (IsContextLost(context))
return;
// Need to bind uniforms before linking
if (!usingBindUniform)
link(context);