14ad1aa43a48567659193a298fad74f55e00b3dd9Ben Murdoch// Copyright 2014 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// This file is auto-generated from
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// gpu/command_buffer/build_gles2_cmd_buffer.py
7a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// It's formatted by clang-format using chromium coding style:
8a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)//    clang-format -i -style=chromium filename
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// DO NOT EDIT!
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// This file is included by gles2_implementation.cc to define the
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// GL api functions.
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_IMPL_AUTOGEN_H_
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_IMPL_AUTOGEN_H_
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void GLES2Implementation::AttachShader(GLuint program, GLuint shader) {
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
18a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glAttachShader(" << program << ", "
19a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << shader << ")");
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->AttachShader(program, shader);
212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void GLES2Implementation::BindBuffer(GLenum target, GLuint buffer) {
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
26a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glBindBuffer("
27a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringBufferTarget(target) << ", "
28a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << buffer << ")");
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (IsBufferReservedId(buffer)) {
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    SetGLError(GL_INVALID_OPERATION, "BindBuffer", "buffer reserved id");
315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  if (BindBufferHelper(target, buffer)) {
342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    helper_->BindBuffer(target, buffer);
352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void GLES2Implementation::BindFramebuffer(GLenum target, GLuint framebuffer) {
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
41a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glBindFramebuffer("
42a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringFrameBufferTarget(target) << ", "
43a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << framebuffer << ")");
445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (IsFramebufferReservedId(framebuffer)) {
455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    SetGLError(
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        GL_INVALID_OPERATION, "BindFramebuffer", "framebuffer reserved id");
475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  if (BindFramebufferHelper(target, framebuffer)) {
502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    helper_->BindFramebuffer(target, framebuffer);
512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
55a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void GLES2Implementation::BindRenderbuffer(GLenum target, GLuint renderbuffer) {
565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
57a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glBindRenderbuffer("
58a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringRenderBufferTarget(target) << ", "
59a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << renderbuffer << ")");
605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (IsRenderbufferReservedId(renderbuffer)) {
615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    SetGLError(
625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        GL_INVALID_OPERATION, "BindRenderbuffer", "renderbuffer reserved id");
635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  if (BindRenderbufferHelper(target, renderbuffer)) {
662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    helper_->BindRenderbuffer(target, renderbuffer);
672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void GLES2Implementation::BindTexture(GLenum target, GLuint texture) {
725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
73a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glBindTexture("
74a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringTextureBindTarget(target) << ", "
75a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << texture << ")");
765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (IsTextureReservedId(texture)) {
775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    SetGLError(GL_INVALID_OPERATION, "BindTexture", "texture reserved id");
785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  if (BindTextureHelper(target, texture)) {
812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    helper_->BindTexture(target, texture);
822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
86a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void GLES2Implementation::BlendColor(GLclampf red,
87a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                     GLclampf green,
88a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                     GLclampf blue,
89a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                     GLclampf alpha) {
905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
91a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glBlendColor(" << red << ", "
92a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << green << ", " << blue << ", " << alpha << ")");
935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->BlendColor(red, green, blue, alpha);
942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void GLES2Implementation::BlendEquation(GLenum mode) {
985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
99a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glBlendEquation("
100a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringEquation(mode) << ")");
1015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->BlendEquation(mode);
1022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
105a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void GLES2Implementation::BlendEquationSeparate(GLenum modeRGB,
106a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                                GLenum modeAlpha) {
1075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
108a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glBlendEquationSeparate("
109a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringEquation(modeRGB) << ", "
110a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringEquation(modeAlpha) << ")");
1115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->BlendEquationSeparate(modeRGB, modeAlpha);
1122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
1135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
1145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void GLES2Implementation::BlendFunc(GLenum sfactor, GLenum dfactor) {
1165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
117a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glBlendFunc("
118a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringSrcBlendFactor(sfactor) << ", "
119a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringDstBlendFactor(dfactor) << ")");
1205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->BlendFunc(sfactor, dfactor);
1212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
1225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
1235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
124a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void GLES2Implementation::BlendFuncSeparate(GLenum srcRGB,
125a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                            GLenum dstRGB,
126a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                            GLenum srcAlpha,
127a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                            GLenum dstAlpha) {
1285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
129a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glBlendFuncSeparate("
130a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringSrcBlendFactor(srcRGB) << ", "
131a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringDstBlendFactor(dstRGB) << ", "
132a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringSrcBlendFactor(srcAlpha) << ", "
133a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringDstBlendFactor(dstAlpha) << ")");
1345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->BlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
1352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
1365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
1375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)GLenum GLES2Implementation::CheckFramebufferStatus(GLenum target) {
1395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
1402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  TRACE_EVENT0("gpu", "GLES2Implementation::CheckFramebufferStatus");
141a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glCheckFramebufferStatus("
142a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringFrameBufferTarget(target) << ")");
1432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  typedef cmds::CheckFramebufferStatus::Result Result;
1445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  Result* result = GetResultAs<Result*>();
1455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (!result) {
1465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return GL_FRAMEBUFFER_UNSUPPORTED;
1475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
1485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  *result = 0;
1495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->CheckFramebufferStatus(
1505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      target, GetResultShmId(), GetResultShmOffset());
1515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  WaitForCmd();
1522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  GLenum result_value = *result;
1532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  GPU_CLIENT_LOG("returned " << result_value);
1542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
1552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  return result_value;
1562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
1572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void GLES2Implementation::Clear(GLbitfield mask) {
1592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
1602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glClear(" << mask << ")");
1612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  helper_->Clear(mask);
1622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
1635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
1645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
165a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void GLES2Implementation::ClearColor(GLclampf red,
166a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                     GLclampf green,
167a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                     GLclampf blue,
168a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                     GLclampf alpha) {
1695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
170a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glClearColor(" << red << ", "
171a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << green << ", " << blue << ", " << alpha << ")");
1725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->ClearColor(red, green, blue, alpha);
1732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
1745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
1755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void GLES2Implementation::ClearDepthf(GLclampf depth) {
1775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
1785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glClearDepthf(" << depth << ")");
1795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->ClearDepthf(depth);
1802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
1815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
1825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void GLES2Implementation::ClearStencil(GLint s) {
1845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
1855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glClearStencil(" << s << ")");
1865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->ClearStencil(s);
1872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
1885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
1895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
190a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void GLES2Implementation::ColorMask(GLboolean red,
191a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                    GLboolean green,
192a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                    GLboolean blue,
193a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                    GLboolean alpha) {
1945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
195a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glColorMask("
196a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringBool(red) << ", "
197a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringBool(green) << ", "
198a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringBool(blue) << ", "
199a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringBool(alpha) << ")");
2005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->ColorMask(red, green, blue, alpha);
2012a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
2025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
2035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void GLES2Implementation::CompileShader(GLuint shader) {
2055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
206a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glCompileShader(" << shader
207a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << ")");
2085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->CompileShader(shader);
2092a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
2105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
2115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
212a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void GLES2Implementation::CopyTexImage2D(GLenum target,
213a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                         GLint level,
214a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                         GLenum internalformat,
215a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                         GLint x,
216a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                         GLint y,
217a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                         GLsizei width,
218a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                         GLsizei height,
219a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                         GLint border) {
2205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
221a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG(
222a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      "[" << GetLogPrefix() << "] glCopyTexImage2D("
223a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)          << GLES2Util::GetStringTextureTarget(target) << ", " << level << ", "
224a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)          << GLES2Util::GetStringTextureInternalFormat(internalformat) << ", "
225a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)          << x << ", " << y << ", " << width << ", " << height << ", " << border
226a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)          << ")");
2275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (width < 0) {
2285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    SetGLError(GL_INVALID_VALUE, "glCopyTexImage2D", "width < 0");
2295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
2305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
2315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (height < 0) {
2325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    SetGLError(GL_INVALID_VALUE, "glCopyTexImage2D", "height < 0");
2335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
2345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
235cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  if (border != 0) {
236cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)    SetGLError(GL_INVALID_VALUE, "glCopyTexImage2D", "border GL_INVALID_VALUE");
237cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)    return;
238cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  }
239cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  helper_->CopyTexImage2D(target, level, internalformat, x, y, width, height);
2402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
2415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
2425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
243a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void GLES2Implementation::CopyTexSubImage2D(GLenum target,
244a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                            GLint level,
245a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                            GLint xoffset,
246a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                            GLint yoffset,
247a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                            GLint x,
248a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                            GLint y,
249a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                            GLsizei width,
250a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                            GLsizei height) {
2515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
252a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glCopyTexSubImage2D("
253a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringTextureTarget(target) << ", "
254a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << level << ", " << xoffset << ", " << yoffset << ", " << x
255a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << ", " << y << ", " << width << ", " << height << ")");
2565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (width < 0) {
2575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    SetGLError(GL_INVALID_VALUE, "glCopyTexSubImage2D", "width < 0");
2585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
2595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
2605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (height < 0) {
2615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    SetGLError(GL_INVALID_VALUE, "glCopyTexSubImage2D", "height < 0");
2625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
2635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
2645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->CopyTexSubImage2D(
2655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      target, level, xoffset, yoffset, x, y, width, height);
2662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
2675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
2685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)GLuint GLES2Implementation::CreateProgram() {
2705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
271a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glCreateProgram("
272a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << ")");
2735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GLuint client_id;
274a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GetIdHandler(id_namespaces::kProgramsAndShaders)
275a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      ->MakeIds(this, 0, 1, &client_id);
2765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->CreateProgram(client_id);
2775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_LOG("returned " << client_id);
2782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
2795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return client_id;
2805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
2815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)GLuint GLES2Implementation::CreateShader(GLenum type) {
2835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
284a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glCreateShader("
285a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringShaderType(type) << ")");
2865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GLuint client_id;
287a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GetIdHandler(id_namespaces::kProgramsAndShaders)
288a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      ->MakeIds(this, 0, 1, &client_id);
2895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->CreateShader(type, client_id);
2905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_LOG("returned " << client_id);
2912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
2925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return client_id;
2935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
2945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void GLES2Implementation::CullFace(GLenum mode) {
2965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
297a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glCullFace("
298a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringFaceType(mode) << ")");
2995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->CullFace(mode);
3002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
3015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
3025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void GLES2Implementation::DeleteBuffers(GLsizei n, const GLuint* buffers) {
3045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
305a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glDeleteBuffers(" << n << ", "
306a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << static_cast<const void*>(buffers) << ")");
3075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_LOG_CODE_BLOCK({
3085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    for (GLsizei i = 0; i < n; ++i) {
3095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      GPU_CLIENT_LOG("  " << i << ": " << buffers[i]);
3105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
3115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  });
3125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_DCHECK_CODE_BLOCK({
3135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    for (GLsizei i = 0; i < n; ++i) {
314f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)      DCHECK(buffers[i] != 0);
3155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
3165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  });
3175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (n < 0) {
3185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    SetGLError(GL_INVALID_VALUE, "glDeleteBuffers", "n < 0");
3195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
3205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
3215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  DeleteBuffersHelper(n, buffers);
3222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
3235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
3245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
325a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void GLES2Implementation::DeleteFramebuffers(GLsizei n,
326a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                             const GLuint* framebuffers) {
3275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
328a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glDeleteFramebuffers(" << n << ", "
329a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << static_cast<const void*>(framebuffers) << ")");
3305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_LOG_CODE_BLOCK({
3315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    for (GLsizei i = 0; i < n; ++i) {
3325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      GPU_CLIENT_LOG("  " << i << ": " << framebuffers[i]);
3335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
3345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  });
3355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_DCHECK_CODE_BLOCK({
3365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    for (GLsizei i = 0; i < n; ++i) {
337f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)      DCHECK(framebuffers[i] != 0);
3385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
3395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  });
3405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (n < 0) {
3415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    SetGLError(GL_INVALID_VALUE, "glDeleteFramebuffers", "n < 0");
3425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
3435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
3445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  DeleteFramebuffersHelper(n, framebuffers);
3452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
3465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
3475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void GLES2Implementation::DeleteProgram(GLuint program) {
3495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
350a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glDeleteProgram(" << program
351a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << ")");
3525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_DCHECK(program != 0);
3535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  DeleteProgramHelper(program);
3542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
3555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
3565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
357a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void GLES2Implementation::DeleteRenderbuffers(GLsizei n,
358a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                              const GLuint* renderbuffers) {
3595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
360a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glDeleteRenderbuffers(" << n
361a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << ", " << static_cast<const void*>(renderbuffers) << ")");
3625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_LOG_CODE_BLOCK({
3635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    for (GLsizei i = 0; i < n; ++i) {
3645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      GPU_CLIENT_LOG("  " << i << ": " << renderbuffers[i]);
3655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
3665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  });
3675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_DCHECK_CODE_BLOCK({
3685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    for (GLsizei i = 0; i < n; ++i) {
369f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)      DCHECK(renderbuffers[i] != 0);
3705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
3715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  });
3725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (n < 0) {
3735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    SetGLError(GL_INVALID_VALUE, "glDeleteRenderbuffers", "n < 0");
3745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
3755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
3765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  DeleteRenderbuffersHelper(n, renderbuffers);
3772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
3785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
3795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void GLES2Implementation::DeleteShader(GLuint shader) {
3815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
3825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glDeleteShader(" << shader << ")");
3835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_DCHECK(shader != 0);
3845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  DeleteShaderHelper(shader);
3852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
3865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
3875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void GLES2Implementation::DeleteTextures(GLsizei n, const GLuint* textures) {
3895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
390a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glDeleteTextures(" << n << ", "
391a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << static_cast<const void*>(textures) << ")");
3925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_LOG_CODE_BLOCK({
3935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    for (GLsizei i = 0; i < n; ++i) {
3945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      GPU_CLIENT_LOG("  " << i << ": " << textures[i]);
3955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
3965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  });
3975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_DCHECK_CODE_BLOCK({
3985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    for (GLsizei i = 0; i < n; ++i) {
399f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)      DCHECK(textures[i] != 0);
4005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
4015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  });
4025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (n < 0) {
4035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    SetGLError(GL_INVALID_VALUE, "glDeleteTextures", "n < 0");
4045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
4055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
4065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  DeleteTexturesHelper(n, textures);
4072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
4085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
4095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void GLES2Implementation::DepthFunc(GLenum func) {
4115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
412a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glDepthFunc("
413a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringCmpFunction(func) << ")");
4145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->DepthFunc(func);
4152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
4165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
4175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void GLES2Implementation::DepthMask(GLboolean flag) {
4195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
420a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glDepthMask("
421a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringBool(flag) << ")");
4225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->DepthMask(flag);
4232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
4245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
4255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void GLES2Implementation::DepthRangef(GLclampf zNear, GLclampf zFar) {
4275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
428a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glDepthRangef(" << zNear << ", "
429a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << zFar << ")");
4305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->DepthRangef(zNear, zFar);
4312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
4325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
4335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void GLES2Implementation::DetachShader(GLuint program, GLuint shader) {
4355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
436a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glDetachShader(" << program << ", "
437a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << shader << ")");
4385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->DetachShader(program, shader);
4392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
4405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
4415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
442a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void GLES2Implementation::FramebufferRenderbuffer(GLenum target,
443a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                                  GLenum attachment,
444a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                                  GLenum renderbuffertarget,
445a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                                  GLuint renderbuffer) {
4465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
447a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glFramebufferRenderbuffer("
448a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringFrameBufferTarget(target) << ", "
449a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringAttachment(attachment) << ", "
450a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringRenderBufferTarget(
451a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                            renderbuffertarget) << ", " << renderbuffer << ")");
4525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->FramebufferRenderbuffer(
4535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      target, attachment, renderbuffertarget, renderbuffer);
4542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
4555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
4565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
457a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void GLES2Implementation::FramebufferTexture2D(GLenum target,
458a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                               GLenum attachment,
459a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                               GLenum textarget,
460a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                               GLuint texture,
461a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                               GLint level) {
4625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
463a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glFramebufferTexture2D("
464a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringFrameBufferTarget(target) << ", "
465a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringAttachment(attachment) << ", "
466a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringTextureTarget(textarget) << ", "
467a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << texture << ", " << level << ")");
468cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  if (level != 0) {
469cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)    SetGLError(
470cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)        GL_INVALID_VALUE, "glFramebufferTexture2D", "level GL_INVALID_VALUE");
471cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)    return;
472cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  }
473cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  helper_->FramebufferTexture2D(target, attachment, textarget, texture);
4742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
4755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
4765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void GLES2Implementation::FrontFace(GLenum mode) {
4785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
479a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glFrontFace("
480a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringFaceMode(mode) << ")");
4815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->FrontFace(mode);
4822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
4835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
4845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void GLES2Implementation::GenBuffers(GLsizei n, GLuint* buffers) {
486a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGenBuffers(" << n << ", "
487a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << static_cast<const void*>(buffers) << ")");
4885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (n < 0) {
4895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    SetGLError(GL_INVALID_VALUE, "glGenBuffers", "n < 0");
4905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
4915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
4925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
493a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GetIdHandler(id_namespaces::kBuffers)->MakeIds(this, 0, n, buffers);
4942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  GenBuffersHelper(n, buffers);
4955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->GenBuffersImmediate(n, buffers);
496a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  if (share_group_->bind_generates_resource())
497a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    helper_->CommandBufferHelper::Flush();
4985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_LOG_CODE_BLOCK({
4995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    for (GLsizei i = 0; i < n; ++i) {
5005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      GPU_CLIENT_LOG("  " << i << ": " << buffers[i]);
5015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
5025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  });
5032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
5045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
5055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void GLES2Implementation::GenerateMipmap(GLenum target) {
5075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
508a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGenerateMipmap("
509a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringTextureBindTarget(target) << ")");
5105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->GenerateMipmap(target);
5112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
5125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
5135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void GLES2Implementation::GenFramebuffers(GLsizei n, GLuint* framebuffers) {
515a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGenFramebuffers(" << n << ", "
516a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << static_cast<const void*>(framebuffers) << ")");
5175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (n < 0) {
5185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    SetGLError(GL_INVALID_VALUE, "glGenFramebuffers", "n < 0");
5195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
5205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
5215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
522a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GetIdHandler(id_namespaces::kFramebuffers)->MakeIds(this, 0, n, framebuffers);
5232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  GenFramebuffersHelper(n, framebuffers);
5245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->GenFramebuffersImmediate(n, framebuffers);
525a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  if (share_group_->bind_generates_resource())
526a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    helper_->CommandBufferHelper::Flush();
5275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_LOG_CODE_BLOCK({
5285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    for (GLsizei i = 0; i < n; ++i) {
5295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      GPU_CLIENT_LOG("  " << i << ": " << framebuffers[i]);
5305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
5315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  });
5322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
5335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
5345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void GLES2Implementation::GenRenderbuffers(GLsizei n, GLuint* renderbuffers) {
536a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGenRenderbuffers(" << n << ", "
537a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << static_cast<const void*>(renderbuffers) << ")");
5385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (n < 0) {
5395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    SetGLError(GL_INVALID_VALUE, "glGenRenderbuffers", "n < 0");
5405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
5415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
5425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
543a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GetIdHandler(id_namespaces::kRenderbuffers)
544a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      ->MakeIds(this, 0, n, renderbuffers);
5452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  GenRenderbuffersHelper(n, renderbuffers);
5465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->GenRenderbuffersImmediate(n, renderbuffers);
547a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  if (share_group_->bind_generates_resource())
548a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    helper_->CommandBufferHelper::Flush();
5495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_LOG_CODE_BLOCK({
5505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    for (GLsizei i = 0; i < n; ++i) {
5515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      GPU_CLIENT_LOG("  " << i << ": " << renderbuffers[i]);
5525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
5535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  });
5542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
5555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
5565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void GLES2Implementation::GenTextures(GLsizei n, GLuint* textures) {
558a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGenTextures(" << n << ", "
559a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << static_cast<const void*>(textures) << ")");
5605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (n < 0) {
5615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    SetGLError(GL_INVALID_VALUE, "glGenTextures", "n < 0");
5625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
5635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
5645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
565a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GetIdHandler(id_namespaces::kTextures)->MakeIds(this, 0, n, textures);
5662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  GenTexturesHelper(n, textures);
5675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->GenTexturesImmediate(n, textures);
568a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  if (share_group_->bind_generates_resource())
569a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    helper_->CommandBufferHelper::Flush();
5705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_LOG_CODE_BLOCK({
5715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    for (GLsizei i = 0; i < n; ++i) {
5725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      GPU_CLIENT_LOG("  " << i << ": " << textures[i]);
5735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
5745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  });
5752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
5765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
5775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void GLES2Implementation::GetBooleanv(GLenum pname, GLboolean* params) {
5795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
5805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_VALIDATE_DESTINATION_INITALIZATION(GLboolean, params);
581a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetBooleanv("
582a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringGLState(pname) << ", "
583a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << static_cast<const void*>(params) << ")");
5842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  TRACE_EVENT0("gpu", "GLES2Implementation::GetBooleanv");
5855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (GetBooleanvHelper(pname, params)) {
5865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
5875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
5882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  typedef cmds::GetBooleanv::Result Result;
5895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  Result* result = GetResultAs<Result*>();
5905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (!result) {
5915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
5925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
5935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  result->SetNumResults(0);
594a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  helper_->GetBooleanv(pname, GetResultShmId(), GetResultShmOffset());
5955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  WaitForCmd();
5965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  result->CopyResult(params);
5975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_LOG_CODE_BLOCK({
598010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)    for (int32_t i = 0; i < result->GetNumResults(); ++i) {
5995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      GPU_CLIENT_LOG("  " << i << ": " << result->GetData()[i]);
6005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
6015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  });
6022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
6035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
604a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void GLES2Implementation::GetBufferParameteriv(GLenum target,
605a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                               GLenum pname,
606a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                               GLint* params) {
6075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
6085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_VALIDATE_DESTINATION_INITALIZATION(GLint, params);
609a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetBufferParameteriv("
610a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringBufferTarget(target) << ", "
611a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringBufferParameter(pname) << ", "
612a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << static_cast<const void*>(params) << ")");
6132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  TRACE_EVENT0("gpu", "GLES2Implementation::GetBufferParameteriv");
6145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (GetBufferParameterivHelper(target, pname, params)) {
6155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
6165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
6172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  typedef cmds::GetBufferParameteriv::Result Result;
6185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  Result* result = GetResultAs<Result*>();
6195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (!result) {
6205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
6215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
6225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  result->SetNumResults(0);
623a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  helper_->GetBufferParameteriv(
624a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      target, pname, GetResultShmId(), GetResultShmOffset());
6255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  WaitForCmd();
6265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  result->CopyResult(params);
6275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_LOG_CODE_BLOCK({
628010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)    for (int32_t i = 0; i < result->GetNumResults(); ++i) {
6295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      GPU_CLIENT_LOG("  " << i << ": " << result->GetData()[i]);
6305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
6315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  });
6322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
6335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
6345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void GLES2Implementation::GetFloatv(GLenum pname, GLfloat* params) {
6355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
636a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetFloatv("
637a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringGLState(pname) << ", "
638a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << static_cast<const void*>(params) << ")");
6392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  TRACE_EVENT0("gpu", "GLES2Implementation::GetFloatv");
6405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (GetFloatvHelper(pname, params)) {
6415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
6425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
6432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  typedef cmds::GetFloatv::Result Result;
6445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  Result* result = GetResultAs<Result*>();
6455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (!result) {
6465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
6475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
6485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  result->SetNumResults(0);
649a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  helper_->GetFloatv(pname, GetResultShmId(), GetResultShmOffset());
6505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  WaitForCmd();
6515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  result->CopyResult(params);
6525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_LOG_CODE_BLOCK({
653010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)    for (int32_t i = 0; i < result->GetNumResults(); ++i) {
6545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      GPU_CLIENT_LOG("  " << i << ": " << result->GetData()[i]);
6555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
6565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  });
6572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
6585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
659a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void GLES2Implementation::GetFramebufferAttachmentParameteriv(GLenum target,
660a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                                              GLenum attachment,
661a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                                              GLenum pname,
662a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                                              GLint* params) {
6635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
6645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_VALIDATE_DESTINATION_INITALIZATION(GLint, params);
665a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix()
666a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << "] glGetFramebufferAttachmentParameteriv("
667a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringFrameBufferTarget(target) << ", "
668a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringAttachment(attachment) << ", "
669a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringFrameBufferParameter(pname) << ", "
670a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << static_cast<const void*>(params) << ")");
671a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  TRACE_EVENT0("gpu",
672a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)               "GLES2Implementation::GetFramebufferAttachmentParameteriv");
6735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (GetFramebufferAttachmentParameterivHelper(
674a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)          target, attachment, pname, params)) {
6755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
6765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
6772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  typedef cmds::GetFramebufferAttachmentParameteriv::Result Result;
6785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  Result* result = GetResultAs<Result*>();
6795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (!result) {
6805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
6815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
6825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  result->SetNumResults(0);
683a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  helper_->GetFramebufferAttachmentParameteriv(
684a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      target, attachment, pname, GetResultShmId(), GetResultShmOffset());
6855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  WaitForCmd();
6865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  result->CopyResult(params);
6875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_LOG_CODE_BLOCK({
688010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)    for (int32_t i = 0; i < result->GetNumResults(); ++i) {
6895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      GPU_CLIENT_LOG("  " << i << ": " << result->GetData()[i]);
6905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
6915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  });
6922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
6935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
6945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void GLES2Implementation::GetIntegerv(GLenum pname, GLint* params) {
6955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
6965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_VALIDATE_DESTINATION_INITALIZATION(GLint, params);
697a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetIntegerv("
698a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringGLState(pname) << ", "
699a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << static_cast<const void*>(params) << ")");
7002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  TRACE_EVENT0("gpu", "GLES2Implementation::GetIntegerv");
7015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (GetIntegervHelper(pname, params)) {
7025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
7035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
7042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  typedef cmds::GetIntegerv::Result Result;
7055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  Result* result = GetResultAs<Result*>();
7065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (!result) {
7075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
7085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
7095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  result->SetNumResults(0);
710a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  helper_->GetIntegerv(pname, GetResultShmId(), GetResultShmOffset());
7115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  WaitForCmd();
7125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  result->CopyResult(params);
7135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_LOG_CODE_BLOCK({
714010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)    for (int32_t i = 0; i < result->GetNumResults(); ++i) {
7155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      GPU_CLIENT_LOG("  " << i << ": " << result->GetData()[i]);
7165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
7175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  });
7182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
7195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
720a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void GLES2Implementation::GetProgramiv(GLuint program,
721a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                       GLenum pname,
722a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                       GLint* params) {
7235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
7245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_VALIDATE_DESTINATION_INITALIZATION(GLint, params);
725a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetProgramiv(" << program << ", "
726a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringProgramParameter(pname) << ", "
727a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << static_cast<const void*>(params) << ")");
7282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  TRACE_EVENT0("gpu", "GLES2Implementation::GetProgramiv");
7295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (GetProgramivHelper(program, pname, params)) {
7305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
7315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
7322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  typedef cmds::GetProgramiv::Result Result;
7335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  Result* result = GetResultAs<Result*>();
7345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (!result) {
7355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
7365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
7375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  result->SetNumResults(0);
738a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  helper_->GetProgramiv(program, pname, GetResultShmId(), GetResultShmOffset());
7395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  WaitForCmd();
7405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  result->CopyResult(params);
7415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_LOG_CODE_BLOCK({
742010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)    for (int32_t i = 0; i < result->GetNumResults(); ++i) {
7435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      GPU_CLIENT_LOG("  " << i << ": " << result->GetData()[i]);
7445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
7455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  });
7462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
7475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
748a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void GLES2Implementation::GetProgramInfoLog(GLuint program,
749a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                            GLsizei bufsize,
750a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                            GLsizei* length,
751a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                            char* infolog) {
7525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
7535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_VALIDATE_DESTINATION_OPTIONAL_INITALIZATION(GLsizei, length);
754a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetProgramInfoLog"
755a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << "(" << program << ", " << bufsize << ", "
756a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << static_cast<void*>(length) << ", "
757a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << static_cast<void*>(infolog) << ")");
7585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->SetBucketSize(kResultBucketId, 0);
7595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->GetProgramInfoLog(program, kResultBucketId);
7605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  std::string str;
7615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GLsizei max_size = 0;
7625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (GetBucketAsString(kResultBucketId, &str)) {
7635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    if (bufsize > 0) {
764a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      max_size = std::min(static_cast<size_t>(bufsize) - 1, str.size());
7655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      memcpy(infolog, str.c_str(), max_size);
7665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      infolog[max_size] = '\0';
7675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      GPU_CLIENT_LOG("------\n" << infolog << "\n------");
7685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
7695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
7705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (length != NULL) {
7715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    *length = max_size;
7725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
7732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
7745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
775a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void GLES2Implementation::GetRenderbufferParameteriv(GLenum target,
776a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                                     GLenum pname,
777a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                                     GLint* params) {
7785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
7795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_VALIDATE_DESTINATION_INITALIZATION(GLint, params);
780a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetRenderbufferParameteriv("
781a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringRenderBufferTarget(target) << ", "
782a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringRenderBufferParameter(pname) << ", "
783a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << static_cast<const void*>(params) << ")");
7842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  TRACE_EVENT0("gpu", "GLES2Implementation::GetRenderbufferParameteriv");
7855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (GetRenderbufferParameterivHelper(target, pname, params)) {
7865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
7875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
7882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  typedef cmds::GetRenderbufferParameteriv::Result Result;
7895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  Result* result = GetResultAs<Result*>();
7905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (!result) {
7915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
7925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
7935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  result->SetNumResults(0);
794a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  helper_->GetRenderbufferParameteriv(
795a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      target, pname, GetResultShmId(), GetResultShmOffset());
7965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  WaitForCmd();
7975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  result->CopyResult(params);
7985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_LOG_CODE_BLOCK({
799010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)    for (int32_t i = 0; i < result->GetNumResults(); ++i) {
8005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      GPU_CLIENT_LOG("  " << i << ": " << result->GetData()[i]);
8015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
8025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  });
8032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
8045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
805a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void GLES2Implementation::GetShaderiv(GLuint shader,
806a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                      GLenum pname,
807a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                      GLint* params) {
8085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
8095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_VALIDATE_DESTINATION_INITALIZATION(GLint, params);
810a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetShaderiv(" << shader << ", "
811a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringShaderParameter(pname) << ", "
812a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << static_cast<const void*>(params) << ")");
8132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  TRACE_EVENT0("gpu", "GLES2Implementation::GetShaderiv");
8145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (GetShaderivHelper(shader, pname, params)) {
8155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
8165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
8172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  typedef cmds::GetShaderiv::Result Result;
8185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  Result* result = GetResultAs<Result*>();
8195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (!result) {
8205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
8215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
8225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  result->SetNumResults(0);
823a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  helper_->GetShaderiv(shader, pname, GetResultShmId(), GetResultShmOffset());
8245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  WaitForCmd();
8255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  result->CopyResult(params);
8265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_LOG_CODE_BLOCK({
827010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)    for (int32_t i = 0; i < result->GetNumResults(); ++i) {
8285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      GPU_CLIENT_LOG("  " << i << ": " << result->GetData()[i]);
8295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
8305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  });
8312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
8325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
833a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void GLES2Implementation::GetShaderInfoLog(GLuint shader,
834a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                           GLsizei bufsize,
835a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                           GLsizei* length,
836a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                           char* infolog) {
8375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
8385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_VALIDATE_DESTINATION_OPTIONAL_INITALIZATION(GLsizei, length);
839a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetShaderInfoLog"
840a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << "(" << shader << ", " << bufsize << ", "
841a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << static_cast<void*>(length) << ", "
842a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << static_cast<void*>(infolog) << ")");
8435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->SetBucketSize(kResultBucketId, 0);
8445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->GetShaderInfoLog(shader, kResultBucketId);
8455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  std::string str;
8465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GLsizei max_size = 0;
8475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (GetBucketAsString(kResultBucketId, &str)) {
8485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    if (bufsize > 0) {
849a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      max_size = std::min(static_cast<size_t>(bufsize) - 1, str.size());
8505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      memcpy(infolog, str.c_str(), max_size);
8515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      infolog[max_size] = '\0';
8525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      GPU_CLIENT_LOG("------\n" << infolog << "\n------");
8535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
8545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
8555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (length != NULL) {
8565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    *length = max_size;
8575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
8582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
8595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
860a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void GLES2Implementation::GetShaderSource(GLuint shader,
861a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                          GLsizei bufsize,
862a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                          GLsizei* length,
863a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                          char* source) {
8645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
8655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_VALIDATE_DESTINATION_OPTIONAL_INITALIZATION(GLsizei, length);
866a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetShaderSource"
867a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << "(" << shader << ", " << bufsize << ", "
868a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << static_cast<void*>(length) << ", "
869a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << static_cast<void*>(source) << ")");
8705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->SetBucketSize(kResultBucketId, 0);
8715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->GetShaderSource(shader, kResultBucketId);
8725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  std::string str;
8735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GLsizei max_size = 0;
8745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (GetBucketAsString(kResultBucketId, &str)) {
8755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    if (bufsize > 0) {
876a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      max_size = std::min(static_cast<size_t>(bufsize) - 1, str.size());
8775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      memcpy(source, str.c_str(), max_size);
8785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      source[max_size] = '\0';
8795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      GPU_CLIENT_LOG("------\n" << source << "\n------");
8805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
8815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
8825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (length != NULL) {
8835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    *length = max_size;
8845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
8852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
8865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
887a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void GLES2Implementation::GetTexParameterfv(GLenum target,
888a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                            GLenum pname,
889a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                            GLfloat* params) {
8905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
891a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetTexParameterfv("
892a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringGetTexParamTarget(target) << ", "
893a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringTextureParameter(pname) << ", "
894a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << static_cast<const void*>(params) << ")");
8952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  TRACE_EVENT0("gpu", "GLES2Implementation::GetTexParameterfv");
8965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (GetTexParameterfvHelper(target, pname, params)) {
8975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
8985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
8992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  typedef cmds::GetTexParameterfv::Result Result;
9005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  Result* result = GetResultAs<Result*>();
9015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (!result) {
9025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
9035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
9045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  result->SetNumResults(0);
905a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  helper_->GetTexParameterfv(
906a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      target, pname, GetResultShmId(), GetResultShmOffset());
9075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  WaitForCmd();
9085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  result->CopyResult(params);
9095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_LOG_CODE_BLOCK({
910010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)    for (int32_t i = 0; i < result->GetNumResults(); ++i) {
9115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      GPU_CLIENT_LOG("  " << i << ": " << result->GetData()[i]);
9125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
9135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  });
9142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
9155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
916a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void GLES2Implementation::GetTexParameteriv(GLenum target,
917a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                            GLenum pname,
918a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                            GLint* params) {
9195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
9205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_VALIDATE_DESTINATION_INITALIZATION(GLint, params);
921a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetTexParameteriv("
922a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringGetTexParamTarget(target) << ", "
923a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringTextureParameter(pname) << ", "
924a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << static_cast<const void*>(params) << ")");
9252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  TRACE_EVENT0("gpu", "GLES2Implementation::GetTexParameteriv");
9265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (GetTexParameterivHelper(target, pname, params)) {
9275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
9285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
9292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  typedef cmds::GetTexParameteriv::Result Result;
9305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  Result* result = GetResultAs<Result*>();
9315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (!result) {
9325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
9335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
9345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  result->SetNumResults(0);
935a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  helper_->GetTexParameteriv(
936a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      target, pname, GetResultShmId(), GetResultShmOffset());
9375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  WaitForCmd();
9385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  result->CopyResult(params);
9395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_LOG_CODE_BLOCK({
940010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)    for (int32_t i = 0; i < result->GetNumResults(); ++i) {
9415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      GPU_CLIENT_LOG("  " << i << ": " << result->GetData()[i]);
9425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
9435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  });
9442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
9455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
9465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void GLES2Implementation::Hint(GLenum target, GLenum mode) {
9475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
948a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glHint("
949a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringHintTarget(target) << ", "
950a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringHintMode(mode) << ")");
9515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->Hint(target, mode);
9522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
9535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
9545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
9555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)GLboolean GLES2Implementation::IsBuffer(GLuint buffer) {
9565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
9572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  TRACE_EVENT0("gpu", "GLES2Implementation::IsBuffer");
9585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glIsBuffer(" << buffer << ")");
9592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  typedef cmds::IsBuffer::Result Result;
9605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  Result* result = GetResultAs<Result*>();
9615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (!result) {
9625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return GL_FALSE;
9635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
9645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  *result = 0;
9655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->IsBuffer(buffer, GetResultShmId(), GetResultShmOffset());
9665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  WaitForCmd();
9672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  GLboolean result_value = *result;
9682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  GPU_CLIENT_LOG("returned " << result_value);
9692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
9702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  return result_value;
9715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
9725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
9735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)GLboolean GLES2Implementation::IsFramebuffer(GLuint framebuffer) {
9745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
9752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  TRACE_EVENT0("gpu", "GLES2Implementation::IsFramebuffer");
976a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glIsFramebuffer(" << framebuffer
977a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << ")");
9782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  typedef cmds::IsFramebuffer::Result Result;
9795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  Result* result = GetResultAs<Result*>();
9805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (!result) {
9815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return GL_FALSE;
9825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
9835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  *result = 0;
9845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->IsFramebuffer(framebuffer, GetResultShmId(), GetResultShmOffset());
9855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  WaitForCmd();
9862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  GLboolean result_value = *result;
9872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  GPU_CLIENT_LOG("returned " << result_value);
9882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
9892a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  return result_value;
9905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
9915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
9925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)GLboolean GLES2Implementation::IsProgram(GLuint program) {
9935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
9942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  TRACE_EVENT0("gpu", "GLES2Implementation::IsProgram");
9955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glIsProgram(" << program << ")");
9962a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  typedef cmds::IsProgram::Result Result;
9975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  Result* result = GetResultAs<Result*>();
9985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (!result) {
9995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return GL_FALSE;
10005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
10015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  *result = 0;
10025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->IsProgram(program, GetResultShmId(), GetResultShmOffset());
10035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  WaitForCmd();
10042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  GLboolean result_value = *result;
10052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  GPU_CLIENT_LOG("returned " << result_value);
10062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
10072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  return result_value;
10085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
10095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
10105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)GLboolean GLES2Implementation::IsRenderbuffer(GLuint renderbuffer) {
10115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
10122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  TRACE_EVENT0("gpu", "GLES2Implementation::IsRenderbuffer");
1013a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glIsRenderbuffer(" << renderbuffer
1014a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << ")");
10152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  typedef cmds::IsRenderbuffer::Result Result;
10165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  Result* result = GetResultAs<Result*>();
10175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (!result) {
10185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return GL_FALSE;
10195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
10205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  *result = 0;
1021a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  helper_->IsRenderbuffer(renderbuffer, GetResultShmId(), GetResultShmOffset());
10225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  WaitForCmd();
10232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  GLboolean result_value = *result;
10242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  GPU_CLIENT_LOG("returned " << result_value);
10252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
10262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  return result_value;
10275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
10285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
10295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)GLboolean GLES2Implementation::IsShader(GLuint shader) {
10305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
10312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  TRACE_EVENT0("gpu", "GLES2Implementation::IsShader");
10325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glIsShader(" << shader << ")");
10332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  typedef cmds::IsShader::Result Result;
10345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  Result* result = GetResultAs<Result*>();
10355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (!result) {
10365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return GL_FALSE;
10375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
10385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  *result = 0;
10395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->IsShader(shader, GetResultShmId(), GetResultShmOffset());
10405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  WaitForCmd();
10412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  GLboolean result_value = *result;
10422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  GPU_CLIENT_LOG("returned " << result_value);
10432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
10442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  return result_value;
10455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
10465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
10475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)GLboolean GLES2Implementation::IsTexture(GLuint texture) {
10485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
10492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  TRACE_EVENT0("gpu", "GLES2Implementation::IsTexture");
10505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glIsTexture(" << texture << ")");
10512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  typedef cmds::IsTexture::Result Result;
10525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  Result* result = GetResultAs<Result*>();
10535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (!result) {
10545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return GL_FALSE;
10555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
10565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  *result = 0;
10575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->IsTexture(texture, GetResultShmId(), GetResultShmOffset());
10585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  WaitForCmd();
10592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  GLboolean result_value = *result;
10602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  GPU_CLIENT_LOG("returned " << result_value);
10612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
10622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  return result_value;
10635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
10645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
10655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void GLES2Implementation::LineWidth(GLfloat width) {
10665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
10675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glLineWidth(" << width << ")");
10685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->LineWidth(width);
10692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
10705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
10715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
10725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void GLES2Implementation::PolygonOffset(GLfloat factor, GLfloat units) {
10735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
1074a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glPolygonOffset(" << factor << ", "
1075a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << units << ")");
10765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->PolygonOffset(factor, units);
10772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
10785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
10795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
10805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void GLES2Implementation::ReleaseShaderCompiler() {
10815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
1082a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glReleaseShaderCompiler("
1083a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << ")");
10845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->ReleaseShaderCompiler();
10852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
10865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
10875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1088a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void GLES2Implementation::RenderbufferStorage(GLenum target,
1089a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                              GLenum internalformat,
1090a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                              GLsizei width,
1091a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                              GLsizei height) {
10925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
1093a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glRenderbufferStorage("
1094a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringRenderBufferTarget(target) << ", "
1095a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringRenderBufferFormat(internalformat)
1096a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << ", " << width << ", " << height << ")");
10975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (width < 0) {
10985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    SetGLError(GL_INVALID_VALUE, "glRenderbufferStorage", "width < 0");
10995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
11005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
11015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (height < 0) {
11025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    SetGLError(GL_INVALID_VALUE, "glRenderbufferStorage", "height < 0");
11035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
11045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
11055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->RenderbufferStorage(target, internalformat, width, height);
11062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
11075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
11085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
11095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void GLES2Implementation::SampleCoverage(GLclampf value, GLboolean invert) {
11105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
1111a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glSampleCoverage(" << value << ", "
1112a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringBool(invert) << ")");
11135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->SampleCoverage(value, invert);
11142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
11155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
11165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1117a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void GLES2Implementation::Scissor(GLint x,
1118a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                  GLint y,
1119a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                  GLsizei width,
1120a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                  GLsizei height) {
11215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
1122a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glScissor(" << x << ", " << y
1123a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << ", " << width << ", " << height << ")");
11245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (width < 0) {
11255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    SetGLError(GL_INVALID_VALUE, "glScissor", "width < 0");
11265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
11275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
11285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (height < 0) {
11295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    SetGLError(GL_INVALID_VALUE, "glScissor", "height < 0");
11305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
11315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
11325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->Scissor(x, y, width, height);
11332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
11345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
11355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
11365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void GLES2Implementation::StencilFunc(GLenum func, GLint ref, GLuint mask) {
11375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
1138a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glStencilFunc("
1139a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringCmpFunction(func) << ", " << ref
1140a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << ", " << mask << ")");
11415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->StencilFunc(func, ref, mask);
11422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
11435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
11445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1145a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void GLES2Implementation::StencilFuncSeparate(GLenum face,
1146a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                              GLenum func,
1147a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                              GLint ref,
1148a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                              GLuint mask) {
11495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
1150a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glStencilFuncSeparate("
1151a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringFaceType(face) << ", "
1152a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringCmpFunction(func) << ", " << ref
1153a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << ", " << mask << ")");
11545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->StencilFuncSeparate(face, func, ref, mask);
11552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
11565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
11575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
11585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void GLES2Implementation::StencilMask(GLuint mask) {
11595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
11605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glStencilMask(" << mask << ")");
11615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->StencilMask(mask);
11622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
11635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
11645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
11655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void GLES2Implementation::StencilMaskSeparate(GLenum face, GLuint mask) {
11665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
1167a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glStencilMaskSeparate("
1168a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringFaceType(face) << ", " << mask
1169a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << ")");
11705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->StencilMaskSeparate(face, mask);
11712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
11725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
11735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
11745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void GLES2Implementation::StencilOp(GLenum fail, GLenum zfail, GLenum zpass) {
11755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
1176a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glStencilOp("
1177a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringStencilOp(fail) << ", "
1178a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringStencilOp(zfail) << ", "
1179a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringStencilOp(zpass) << ")");
11805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->StencilOp(fail, zfail, zpass);
11812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
11825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
11835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1184a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void GLES2Implementation::StencilOpSeparate(GLenum face,
1185a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                            GLenum fail,
1186a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                            GLenum zfail,
1187a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                            GLenum zpass) {
11885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
1189a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glStencilOpSeparate("
1190a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringFaceType(face) << ", "
1191a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringStencilOp(fail) << ", "
1192a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringStencilOp(zfail) << ", "
1193a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringStencilOp(zpass) << ")");
11945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->StencilOpSeparate(face, fail, zfail, zpass);
11952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
11965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
11975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1198a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void GLES2Implementation::TexParameterf(GLenum target,
1199a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                        GLenum pname,
1200a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                        GLfloat param) {
12015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
1202a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glTexParameterf("
1203a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringTextureBindTarget(target) << ", "
1204a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringTextureParameter(pname) << ", "
1205a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << param << ")");
12065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->TexParameterf(target, pname, param);
12072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
12085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
12095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1210a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void GLES2Implementation::TexParameterfv(GLenum target,
1211a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                         GLenum pname,
1212a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                         const GLfloat* params) {
12135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
1214a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glTexParameterfv("
1215a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringTextureBindTarget(target) << ", "
1216a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringTextureParameter(pname) << ", "
1217a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << static_cast<const void*>(params) << ")");
12185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_LOG("values: " << params[0]);
12195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->TexParameterfvImmediate(target, pname, params);
12202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
12215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
12225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1223a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void GLES2Implementation::TexParameteri(GLenum target,
1224a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                        GLenum pname,
1225a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                        GLint param) {
12265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
1227a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glTexParameteri("
1228a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringTextureBindTarget(target) << ", "
1229a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringTextureParameter(pname) << ", "
1230a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << param << ")");
12315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->TexParameteri(target, pname, param);
12322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
12335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
12345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1235a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void GLES2Implementation::TexParameteriv(GLenum target,
1236a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                         GLenum pname,
1237a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                         const GLint* params) {
12385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
1239a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glTexParameteriv("
1240a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringTextureBindTarget(target) << ", "
1241a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringTextureParameter(pname) << ", "
1242a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << static_cast<const void*>(params) << ")");
12435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_LOG("values: " << params[0]);
12445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->TexParameterivImmediate(target, pname, params);
12452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
12465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
12475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
12485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void GLES2Implementation::Uniform1f(GLint location, GLfloat x) {
12495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
1250a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glUniform1f(" << location << ", "
1251a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << x << ")");
12525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->Uniform1f(location, x);
12532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
12545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
12555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1256a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void GLES2Implementation::Uniform1fv(GLint location,
1257a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                     GLsizei count,
1258a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                     const GLfloat* v) {
12595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
1260a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glUniform1fv(" << location << ", "
1261a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << count << ", " << static_cast<const void*>(v) << ")");
12625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_LOG_CODE_BLOCK({
12635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    for (GLsizei i = 0; i < count; ++i) {
1264a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      GPU_CLIENT_LOG("  " << i << ": " << v[0 + i * 1]);
12655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
12665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  });
12675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (count < 0) {
12685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    SetGLError(GL_INVALID_VALUE, "glUniform1fv", "count < 0");
12695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
12705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
12715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->Uniform1fvImmediate(location, count, v);
12722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
12735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
12745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
12755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void GLES2Implementation::Uniform1i(GLint location, GLint x) {
12765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
1277a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glUniform1i(" << location << ", "
1278a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << x << ")");
12795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->Uniform1i(location, x);
12802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
12815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
12825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1283a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void GLES2Implementation::Uniform1iv(GLint location,
1284a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                     GLsizei count,
1285a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                     const GLint* v) {
12865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
1287a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glUniform1iv(" << location << ", "
1288a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << count << ", " << static_cast<const void*>(v) << ")");
12895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_LOG_CODE_BLOCK({
12905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    for (GLsizei i = 0; i < count; ++i) {
1291a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      GPU_CLIENT_LOG("  " << i << ": " << v[0 + i * 1]);
12925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
12935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  });
12945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (count < 0) {
12955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    SetGLError(GL_INVALID_VALUE, "glUniform1iv", "count < 0");
12965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
12975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
12985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->Uniform1ivImmediate(location, count, v);
12992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
13005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
13015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
13025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void GLES2Implementation::Uniform2f(GLint location, GLfloat x, GLfloat y) {
13035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
1304a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glUniform2f(" << location << ", "
1305a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << x << ", " << y << ")");
13065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->Uniform2f(location, x, y);
13072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
13085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
13095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1310a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void GLES2Implementation::Uniform2fv(GLint location,
1311a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                     GLsizei count,
1312a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                     const GLfloat* v) {
13135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
1314a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glUniform2fv(" << location << ", "
1315a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << count << ", " << static_cast<const void*>(v) << ")");
13165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_LOG_CODE_BLOCK({
13175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    for (GLsizei i = 0; i < count; ++i) {
1318a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      GPU_CLIENT_LOG("  " << i << ": " << v[0 + i * 2] << ", " << v[1 + i * 2]);
13195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
13205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  });
13215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (count < 0) {
13225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    SetGLError(GL_INVALID_VALUE, "glUniform2fv", "count < 0");
13235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
13245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
13255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->Uniform2fvImmediate(location, count, v);
13262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
13275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
13285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
13295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void GLES2Implementation::Uniform2i(GLint location, GLint x, GLint y) {
13305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
1331a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glUniform2i(" << location << ", "
1332a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << x << ", " << y << ")");
13335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->Uniform2i(location, x, y);
13342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
13355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
13365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1337a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void GLES2Implementation::Uniform2iv(GLint location,
1338a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                     GLsizei count,
1339a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                     const GLint* v) {
13405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
1341a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glUniform2iv(" << location << ", "
1342a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << count << ", " << static_cast<const void*>(v) << ")");
13435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_LOG_CODE_BLOCK({
13445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    for (GLsizei i = 0; i < count; ++i) {
1345a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      GPU_CLIENT_LOG("  " << i << ": " << v[0 + i * 2] << ", " << v[1 + i * 2]);
13465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
13475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  });
13485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (count < 0) {
13495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    SetGLError(GL_INVALID_VALUE, "glUniform2iv", "count < 0");
13505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
13515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
13525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->Uniform2ivImmediate(location, count, v);
13532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
13545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
13555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1356a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void GLES2Implementation::Uniform3f(GLint location,
1357a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                    GLfloat x,
1358a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                    GLfloat y,
1359a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                    GLfloat z) {
13605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
1361a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glUniform3f(" << location << ", "
1362a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << x << ", " << y << ", " << z << ")");
13635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->Uniform3f(location, x, y, z);
13642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
13655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
13665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1367a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void GLES2Implementation::Uniform3fv(GLint location,
1368a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                     GLsizei count,
1369a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                     const GLfloat* v) {
13705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
1371a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glUniform3fv(" << location << ", "
1372a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << count << ", " << static_cast<const void*>(v) << ")");
13735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_LOG_CODE_BLOCK({
13745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    for (GLsizei i = 0; i < count; ++i) {
1375a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      GPU_CLIENT_LOG("  " << i << ": " << v[0 + i * 3] << ", " << v[1 + i * 3]
1376a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                          << ", " << v[2 + i * 3]);
13775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
13785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  });
13795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (count < 0) {
13805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    SetGLError(GL_INVALID_VALUE, "glUniform3fv", "count < 0");
13815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
13825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
13835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->Uniform3fvImmediate(location, count, v);
13842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
13855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
13865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1387a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void GLES2Implementation::Uniform3i(GLint location, GLint x, GLint y, GLint z) {
13885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
1389a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glUniform3i(" << location << ", "
1390a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << x << ", " << y << ", " << z << ")");
13915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->Uniform3i(location, x, y, z);
13922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
13935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
13945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1395a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void GLES2Implementation::Uniform3iv(GLint location,
1396a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                     GLsizei count,
1397a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                     const GLint* v) {
13985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
1399a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glUniform3iv(" << location << ", "
1400a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << count << ", " << static_cast<const void*>(v) << ")");
14015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_LOG_CODE_BLOCK({
14025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    for (GLsizei i = 0; i < count; ++i) {
1403a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      GPU_CLIENT_LOG("  " << i << ": " << v[0 + i * 3] << ", " << v[1 + i * 3]
1404a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                          << ", " << v[2 + i * 3]);
14055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
14065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  });
14075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (count < 0) {
14085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    SetGLError(GL_INVALID_VALUE, "glUniform3iv", "count < 0");
14095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
14105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
14115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->Uniform3ivImmediate(location, count, v);
14122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
14135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
14145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1415a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void GLES2Implementation::Uniform4f(GLint location,
1416a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                    GLfloat x,
1417a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                    GLfloat y,
1418a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                    GLfloat z,
1419a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                    GLfloat w) {
14205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
1421a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glUniform4f(" << location << ", "
1422a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << x << ", " << y << ", " << z << ", " << w << ")");
14235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->Uniform4f(location, x, y, z, w);
14242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
14255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
14265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1427a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void GLES2Implementation::Uniform4fv(GLint location,
1428a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                     GLsizei count,
1429a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                     const GLfloat* v) {
14305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
1431a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glUniform4fv(" << location << ", "
1432a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << count << ", " << static_cast<const void*>(v) << ")");
14335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_LOG_CODE_BLOCK({
14345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    for (GLsizei i = 0; i < count; ++i) {
1435a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      GPU_CLIENT_LOG("  " << i << ": " << v[0 + i * 4] << ", " << v[1 + i * 4]
1436a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                          << ", " << v[2 + i * 4] << ", " << v[3 + i * 4]);
14375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
14385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  });
14395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (count < 0) {
14405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    SetGLError(GL_INVALID_VALUE, "glUniform4fv", "count < 0");
14415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
14425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
14435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->Uniform4fvImmediate(location, count, v);
14442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
14455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
14465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1447a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void GLES2Implementation::Uniform4i(GLint location,
1448a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                    GLint x,
1449a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                    GLint y,
1450a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                    GLint z,
1451a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                    GLint w) {
14525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
1453a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glUniform4i(" << location << ", "
1454a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << x << ", " << y << ", " << z << ", " << w << ")");
14555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->Uniform4i(location, x, y, z, w);
14562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
14575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
14585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1459a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void GLES2Implementation::Uniform4iv(GLint location,
1460a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                     GLsizei count,
1461a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                     const GLint* v) {
14625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
1463a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glUniform4iv(" << location << ", "
1464a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << count << ", " << static_cast<const void*>(v) << ")");
14655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_LOG_CODE_BLOCK({
14665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    for (GLsizei i = 0; i < count; ++i) {
1467a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      GPU_CLIENT_LOG("  " << i << ": " << v[0 + i * 4] << ", " << v[1 + i * 4]
1468a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                          << ", " << v[2 + i * 4] << ", " << v[3 + i * 4]);
14695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
14705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  });
14715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (count < 0) {
14725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    SetGLError(GL_INVALID_VALUE, "glUniform4iv", "count < 0");
14735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
14745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
14755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->Uniform4ivImmediate(location, count, v);
14762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
14775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
14785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1479a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void GLES2Implementation::UniformMatrix2fv(GLint location,
1480a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                           GLsizei count,
1481a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                           GLboolean transpose,
1482a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                           const GLfloat* value) {
14835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
1484a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glUniformMatrix2fv(" << location
1485a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << ", " << count << ", "
1486a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringBool(transpose) << ", "
1487a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << static_cast<const void*>(value) << ")");
14885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_LOG_CODE_BLOCK({
14895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    for (GLsizei i = 0; i < count; ++i) {
1490a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      GPU_CLIENT_LOG("  " << i << ": " << value[0 + i * 4] << ", "
1491a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                          << value[1 + i * 4] << ", " << value[2 + i * 4]
1492a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                          << ", " << value[3 + i * 4]);
14935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
14945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  });
14955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (count < 0) {
14965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    SetGLError(GL_INVALID_VALUE, "glUniformMatrix2fv", "count < 0");
14975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
14985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
1499cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  if (transpose != false) {
1500cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)    SetGLError(
1501cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)        GL_INVALID_VALUE, "glUniformMatrix2fv", "transpose GL_INVALID_VALUE");
1502cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)    return;
1503cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  }
1504cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  helper_->UniformMatrix2fvImmediate(location, count, value);
15052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
15065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
15075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1508a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void GLES2Implementation::UniformMatrix3fv(GLint location,
1509a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                           GLsizei count,
1510a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                           GLboolean transpose,
1511a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                           const GLfloat* value) {
15125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
1513a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glUniformMatrix3fv(" << location
1514a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << ", " << count << ", "
1515a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringBool(transpose) << ", "
1516a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << static_cast<const void*>(value) << ")");
15175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_LOG_CODE_BLOCK({
15185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    for (GLsizei i = 0; i < count; ++i) {
1519a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      GPU_CLIENT_LOG("  " << i << ": " << value[0 + i * 9] << ", "
1520a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                          << value[1 + i * 9] << ", " << value[2 + i * 9]
1521a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                          << ", " << value[3 + i * 9] << ", "
1522a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                          << value[4 + i * 9] << ", " << value[5 + i * 9]
1523a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                          << ", " << value[6 + i * 9] << ", "
1524a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                          << value[7 + i * 9] << ", " << value[8 + i * 9]);
15255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
15265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  });
15275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (count < 0) {
15285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    SetGLError(GL_INVALID_VALUE, "glUniformMatrix3fv", "count < 0");
15295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
15305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
1531cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  if (transpose != false) {
1532cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)    SetGLError(
1533cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)        GL_INVALID_VALUE, "glUniformMatrix3fv", "transpose GL_INVALID_VALUE");
1534cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)    return;
1535cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  }
1536cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  helper_->UniformMatrix3fvImmediate(location, count, value);
15372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
15385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
15395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1540a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void GLES2Implementation::UniformMatrix4fv(GLint location,
1541a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                           GLsizei count,
1542a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                           GLboolean transpose,
1543a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                           const GLfloat* value) {
15445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
1545a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glUniformMatrix4fv(" << location
1546a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << ", " << count << ", "
1547a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringBool(transpose) << ", "
1548a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << static_cast<const void*>(value) << ")");
15495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_LOG_CODE_BLOCK({
15505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    for (GLsizei i = 0; i < count; ++i) {
1551a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      GPU_CLIENT_LOG(
1552a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)          "  " << i << ": " << value[0 + i * 16] << ", " << value[1 + i * 16]
1553a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)               << ", " << value[2 + i * 16] << ", " << value[3 + i * 16] << ", "
1554a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)               << value[4 + i * 16] << ", " << value[5 + i * 16] << ", "
1555a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)               << value[6 + i * 16] << ", " << value[7 + i * 16] << ", "
1556a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)               << value[8 + i * 16] << ", " << value[9 + i * 16] << ", "
1557a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)               << value[10 + i * 16] << ", " << value[11 + i * 16] << ", "
1558a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)               << value[12 + i * 16] << ", " << value[13 + i * 16] << ", "
1559a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)               << value[14 + i * 16] << ", " << value[15 + i * 16]);
15605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
15615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  });
15625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (count < 0) {
15635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    SetGLError(GL_INVALID_VALUE, "glUniformMatrix4fv", "count < 0");
15645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
15655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
1566cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  if (transpose != false) {
1567cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)    SetGLError(
1568cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)        GL_INVALID_VALUE, "glUniformMatrix4fv", "transpose GL_INVALID_VALUE");
1569cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)    return;
1570cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  }
1571cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  helper_->UniformMatrix4fvImmediate(location, count, value);
15722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
15735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
15745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1575effb81e5f8246d0db0270817048dc992db66e9fbBen Murdochvoid GLES2Implementation::UseProgram(GLuint program) {
1576effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  GPU_CLIENT_SINGLE_THREAD_CHECK();
1577effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glUseProgram(" << program << ")");
1578effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  if (IsProgramReservedId(program)) {
1579effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch    SetGLError(GL_INVALID_OPERATION, "UseProgram", "program reserved id");
1580effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch    return;
1581effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  }
1582effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  if (UseProgramHelper(program)) {
1583effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch    helper_->UseProgram(program);
1584effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  }
1585effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  CheckGLError();
1586effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch}
1587effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch
15885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void GLES2Implementation::ValidateProgram(GLuint program) {
15895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
1590a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glValidateProgram(" << program
1591a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << ")");
15925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->ValidateProgram(program);
15932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
15945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
15955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
15965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void GLES2Implementation::VertexAttrib1f(GLuint indx, GLfloat x) {
15975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
1598a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glVertexAttrib1f(" << indx << ", "
1599a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << x << ")");
16005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->VertexAttrib1f(indx, x);
16012a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
16025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
16035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
16045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void GLES2Implementation::VertexAttrib1fv(GLuint indx, const GLfloat* values) {
16055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
1606a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glVertexAttrib1fv(" << indx << ", "
1607a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << static_cast<const void*>(values) << ")");
16085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_LOG("values: " << values[0]);
16095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->VertexAttrib1fvImmediate(indx, values);
16102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
16115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
16125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
16135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void GLES2Implementation::VertexAttrib2f(GLuint indx, GLfloat x, GLfloat y) {
16145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
1615a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glVertexAttrib2f(" << indx << ", "
1616a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << x << ", " << y << ")");
16175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->VertexAttrib2f(indx, x, y);
16182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
16195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
16205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
16215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void GLES2Implementation::VertexAttrib2fv(GLuint indx, const GLfloat* values) {
16225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
1623a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glVertexAttrib2fv(" << indx << ", "
1624a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << static_cast<const void*>(values) << ")");
16255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_LOG("values: " << values[0] << ", " << values[1]);
16265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->VertexAttrib2fvImmediate(indx, values);
16272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
16285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
16295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1630a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void GLES2Implementation::VertexAttrib3f(GLuint indx,
1631a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                         GLfloat x,
1632a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                         GLfloat y,
1633a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                         GLfloat z) {
16345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
1635a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glVertexAttrib3f(" << indx << ", "
1636a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << x << ", " << y << ", " << z << ")");
16375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->VertexAttrib3f(indx, x, y, z);
16382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
16395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
16405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
16415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void GLES2Implementation::VertexAttrib3fv(GLuint indx, const GLfloat* values) {
16425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
1643a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glVertexAttrib3fv(" << indx << ", "
1644a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << static_cast<const void*>(values) << ")");
1645a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("values: " << values[0] << ", " << values[1] << ", "
1646a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                            << values[2]);
16475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->VertexAttrib3fvImmediate(indx, values);
16482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
16495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
16505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1651a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void GLES2Implementation::VertexAttrib4f(GLuint indx,
1652a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                         GLfloat x,
1653a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                         GLfloat y,
1654a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                         GLfloat z,
1655a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                         GLfloat w) {
16565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
1657a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glVertexAttrib4f(" << indx << ", "
1658a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << x << ", " << y << ", " << z << ", " << w << ")");
16595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->VertexAttrib4f(indx, x, y, z, w);
16602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
16615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
16625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
16635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void GLES2Implementation::VertexAttrib4fv(GLuint indx, const GLfloat* values) {
16645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
1665a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glVertexAttrib4fv(" << indx << ", "
1666a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << static_cast<const void*>(values) << ")");
1667a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("values: " << values[0] << ", " << values[1] << ", "
1668a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                            << values[2] << ", " << values[3]);
16695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->VertexAttrib4fvImmediate(indx, values);
16702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
16715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
16725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1673a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void GLES2Implementation::Viewport(GLint x,
1674a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                   GLint y,
1675a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                   GLsizei width,
1676a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                   GLsizei height) {
16775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
1678a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glViewport(" << x << ", " << y
1679a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << ", " << width << ", " << height << ")");
16805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (width < 0) {
16815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    SetGLError(GL_INVALID_VALUE, "glViewport", "width < 0");
16825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
16835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
16845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (height < 0) {
16855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    SetGLError(GL_INVALID_VALUE, "glViewport", "height < 0");
16865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
16875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
16885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->Viewport(x, y, width, height);
16892a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
16905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
16915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1692a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void GLES2Implementation::BlitFramebufferCHROMIUM(GLint srcX0,
1693a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                                  GLint srcY0,
1694a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                                  GLint srcX1,
1695a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                                  GLint srcY1,
1696a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                                  GLint dstX0,
1697a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                                  GLint dstY0,
1698a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                                  GLint dstX1,
1699a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                                  GLint dstY1,
1700a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                                  GLbitfield mask,
1701a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                                  GLenum filter) {
17025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
1703a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glBlitFramebufferCHROMIUM("
1704a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << srcX0 << ", " << srcY0 << ", " << srcX1 << ", " << srcY1
1705a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << ", " << dstX0 << ", " << dstY0 << ", " << dstX1 << ", "
1706a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << dstY1 << ", " << mask << ", "
1707a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringBlitFilter(filter) << ")");
1708f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  helper_->BlitFramebufferCHROMIUM(
17095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
17102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
17115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
17125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1713f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)void GLES2Implementation::RenderbufferStorageMultisampleCHROMIUM(
1714a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    GLenum target,
1715a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    GLsizei samples,
1716a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    GLenum internalformat,
1717a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    GLsizei width,
1718f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)    GLsizei height) {
1719f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
1720a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG(
1721a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      "[" << GetLogPrefix() << "] glRenderbufferStorageMultisampleCHROMIUM("
1722a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)          << GLES2Util::GetStringRenderBufferTarget(target) << ", " << samples
1723a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)          << ", " << GLES2Util::GetStringRenderBufferFormat(internalformat)
1724a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)          << ", " << width << ", " << height << ")");
1725f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  if (samples < 0) {
1726a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    SetGLError(GL_INVALID_VALUE,
1727a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)               "glRenderbufferStorageMultisampleCHROMIUM",
1728a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)               "samples < 0");
1729f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)    return;
1730f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  }
1731f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  if (width < 0) {
1732a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    SetGLError(GL_INVALID_VALUE,
1733a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)               "glRenderbufferStorageMultisampleCHROMIUM",
1734a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)               "width < 0");
1735f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)    return;
1736f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  }
1737f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  if (height < 0) {
1738a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    SetGLError(GL_INVALID_VALUE,
1739a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)               "glRenderbufferStorageMultisampleCHROMIUM",
1740a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)               "height < 0");
1741f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)    return;
1742f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  }
1743f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  helper_->RenderbufferStorageMultisampleCHROMIUM(
1744f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)      target, samples, internalformat, width, height);
1745f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  CheckGLError();
1746f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)}
1747f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
17485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void GLES2Implementation::RenderbufferStorageMultisampleEXT(
1749a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    GLenum target,
1750a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    GLsizei samples,
1751a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    GLenum internalformat,
1752a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    GLsizei width,
17535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    GLsizei height) {
17545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
1755a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG(
1756a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      "[" << GetLogPrefix() << "] glRenderbufferStorageMultisampleEXT("
1757a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)          << GLES2Util::GetStringRenderBufferTarget(target) << ", " << samples
1758a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)          << ", " << GLES2Util::GetStringRenderBufferFormat(internalformat)
1759a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)          << ", " << width << ", " << height << ")");
17605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (samples < 0) {
17615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    SetGLError(
17625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        GL_INVALID_VALUE, "glRenderbufferStorageMultisampleEXT", "samples < 0");
17635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
17645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
17655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (width < 0) {
17665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    SetGLError(
17675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        GL_INVALID_VALUE, "glRenderbufferStorageMultisampleEXT", "width < 0");
17685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
17695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
17705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (height < 0) {
17715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    SetGLError(
17725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        GL_INVALID_VALUE, "glRenderbufferStorageMultisampleEXT", "height < 0");
17735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
17745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
17755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->RenderbufferStorageMultisampleEXT(
17765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      target, samples, internalformat, width, height);
17772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
17785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
17795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1780a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void GLES2Implementation::FramebufferTexture2DMultisampleEXT(GLenum target,
1781a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                                             GLenum attachment,
1782a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                                             GLenum textarget,
1783a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                                             GLuint texture,
1784a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                                             GLint level,
1785a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                                             GLsizei samples) {
17867dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  GPU_CLIENT_SINGLE_THREAD_CHECK();
1787a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix()
1788a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << "] glFramebufferTexture2DMultisampleEXT("
1789a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringFrameBufferTarget(target) << ", "
1790a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringAttachment(attachment) << ", "
1791a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringTextureTarget(textarget) << ", "
1792a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << texture << ", " << level << ", " << samples << ")");
1793cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  if (level != 0) {
1794cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)    SetGLError(GL_INVALID_VALUE,
1795cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)               "glFramebufferTexture2DMultisampleEXT",
1796cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)               "level GL_INVALID_VALUE");
1797cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)    return;
1798cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  }
17997dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  if (samples < 0) {
1800a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    SetGLError(GL_INVALID_VALUE,
1801a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)               "glFramebufferTexture2DMultisampleEXT",
1802a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)               "samples < 0");
18037dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch    return;
18047dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  }
18057dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  helper_->FramebufferTexture2DMultisampleEXT(
1806cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)      target, attachment, textarget, texture, samples);
18077dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  CheckGLError();
18087dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch}
18097dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch
1810a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void GLES2Implementation::TexStorage2DEXT(GLenum target,
1811a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                          GLsizei levels,
1812a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                          GLenum internalFormat,
1813a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                          GLsizei width,
1814a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                          GLsizei height) {
18155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
1816a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG(
1817a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      "[" << GetLogPrefix() << "] glTexStorage2DEXT("
1818a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)          << GLES2Util::GetStringTextureTarget(target) << ", " << levels << ", "
1819a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)          << GLES2Util::GetStringTextureInternalFormatStorage(internalFormat)
1820a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)          << ", " << width << ", " << height << ")");
18215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (levels < 0) {
18225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    SetGLError(GL_INVALID_VALUE, "glTexStorage2DEXT", "levels < 0");
18235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
18245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
18255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (width < 0) {
18265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    SetGLError(GL_INVALID_VALUE, "glTexStorage2DEXT", "width < 0");
18275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
18285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
18295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (height < 0) {
18305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    SetGLError(GL_INVALID_VALUE, "glTexStorage2DEXT", "height < 0");
18315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
18325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
18335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->TexStorage2DEXT(target, levels, internalFormat, width, height);
18342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
18355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
18365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
18375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void GLES2Implementation::GenQueriesEXT(GLsizei n, GLuint* queries) {
1838a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGenQueriesEXT(" << n << ", "
1839a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << static_cast<const void*>(queries) << ")");
18405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (n < 0) {
18415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    SetGLError(GL_INVALID_VALUE, "glGenQueriesEXT", "n < 0");
18425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
18435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
18445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
1845116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  IdAllocatorInterface* id_allocator = GetIdAllocator(id_namespaces::kQueries);
1846116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  for (GLsizei ii = 0; ii < n; ++ii)
1847116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch    queries[ii] = id_allocator->AllocateID();
18482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  GenQueriesEXTHelper(n, queries);
18495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->GenQueriesEXTImmediate(n, queries);
1850a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  if (share_group_->bind_generates_resource())
1851a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    helper_->CommandBufferHelper::Flush();
18525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_LOG_CODE_BLOCK({
18535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    for (GLsizei i = 0; i < n; ++i) {
18545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      GPU_CLIENT_LOG("  " << i << ": " << queries[i]);
18555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
18565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  });
18572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
18585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
18595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
18605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void GLES2Implementation::DeleteQueriesEXT(GLsizei n, const GLuint* queries) {
18615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
1862a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glDeleteQueriesEXT(" << n << ", "
1863a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << static_cast<const void*>(queries) << ")");
18645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_LOG_CODE_BLOCK({
18655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    for (GLsizei i = 0; i < n; ++i) {
18665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      GPU_CLIENT_LOG("  " << i << ": " << queries[i]);
18675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
18685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  });
18695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_DCHECK_CODE_BLOCK({
18705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    for (GLsizei i = 0; i < n; ++i) {
1871f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)      DCHECK(queries[i] != 0);
18725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
18735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  });
18745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (n < 0) {
18755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    SetGLError(GL_INVALID_VALUE, "glDeleteQueriesEXT", "n < 0");
18765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
18775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
18785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  DeleteQueriesEXTHelper(n, queries);
18792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
18805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
18815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
18825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void GLES2Implementation::GenVertexArraysOES(GLsizei n, GLuint* arrays) {
1883a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGenVertexArraysOES(" << n << ", "
1884a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << static_cast<const void*>(arrays) << ")");
18855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (n < 0) {
18865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    SetGLError(GL_INVALID_VALUE, "glGenVertexArraysOES", "n < 0");
18875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
18885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
18895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
1890a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GetIdHandler(id_namespaces::kVertexArrays)->MakeIds(this, 0, n, arrays);
18912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  GenVertexArraysOESHelper(n, arrays);
18925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->GenVertexArraysOESImmediate(n, arrays);
1893a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  if (share_group_->bind_generates_resource())
1894a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    helper_->CommandBufferHelper::Flush();
18955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_LOG_CODE_BLOCK({
18965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    for (GLsizei i = 0; i < n; ++i) {
18975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      GPU_CLIENT_LOG("  " << i << ": " << arrays[i]);
18985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
18995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  });
19002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
19015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
19025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1903a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void GLES2Implementation::DeleteVertexArraysOES(GLsizei n,
1904a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                                const GLuint* arrays) {
19055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
1906a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glDeleteVertexArraysOES(" << n
1907a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << ", " << static_cast<const void*>(arrays) << ")");
19085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_LOG_CODE_BLOCK({
19095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    for (GLsizei i = 0; i < n; ++i) {
19105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      GPU_CLIENT_LOG("  " << i << ": " << arrays[i]);
19115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
19125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  });
19135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_DCHECK_CODE_BLOCK({
19145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    for (GLsizei i = 0; i < n; ++i) {
1915f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)      DCHECK(arrays[i] != 0);
19165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
19175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  });
19185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (n < 0) {
19195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    SetGLError(GL_INVALID_VALUE, "glDeleteVertexArraysOES", "n < 0");
19205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
19215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
19225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  DeleteVertexArraysOESHelper(n, arrays);
19232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
19245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
19255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
19265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)GLboolean GLES2Implementation::IsVertexArrayOES(GLuint array) {
19275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
19282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  TRACE_EVENT0("gpu", "GLES2Implementation::IsVertexArrayOES");
1929a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glIsVertexArrayOES(" << array
1930a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << ")");
19312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  typedef cmds::IsVertexArrayOES::Result Result;
19325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  Result* result = GetResultAs<Result*>();
19335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (!result) {
19345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return GL_FALSE;
19355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
19365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  *result = 0;
19375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->IsVertexArrayOES(array, GetResultShmId(), GetResultShmOffset());
19385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  WaitForCmd();
19392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  GLboolean result_value = *result;
19402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  GPU_CLIENT_LOG("returned " << result_value);
19412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
19422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  return result_value;
19435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
19445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
19455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void GLES2Implementation::BindVertexArrayOES(GLuint array) {
19465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
1947a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glBindVertexArrayOES(" << array
1948a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << ")");
19495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (IsVertexArrayReservedId(array)) {
1950a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    SetGLError(GL_INVALID_OPERATION, "BindVertexArrayOES", "array reserved id");
19515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
19525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
1953effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  if (BindVertexArrayOESHelper(array)) {
19542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    helper_->BindVertexArrayOES(array);
19552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
19562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
19575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
19585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1959a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void GLES2Implementation::GetTranslatedShaderSourceANGLE(GLuint shader,
1960a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                                         GLsizei bufsize,
1961a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                                         GLsizei* length,
1962a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                                         char* source) {
19635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
19645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_VALIDATE_DESTINATION_OPTIONAL_INITALIZATION(GLsizei, length);
1965a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetTranslatedShaderSourceANGLE"
1966a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << "(" << shader << ", " << bufsize << ", "
1967a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << static_cast<void*>(length) << ", "
1968a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << static_cast<void*>(source) << ")");
19695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->SetBucketSize(kResultBucketId, 0);
19705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->GetTranslatedShaderSourceANGLE(shader, kResultBucketId);
19715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  std::string str;
19725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GLsizei max_size = 0;
19735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (GetBucketAsString(kResultBucketId, &str)) {
19745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    if (bufsize > 0) {
1975a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      max_size = std::min(static_cast<size_t>(bufsize) - 1, str.size());
19765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      memcpy(source, str.c_str(), max_size);
19775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      source[max_size] = '\0';
19785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      GPU_CLIENT_LOG("------\n" << source << "\n------");
19795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
19805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
19815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (length != NULL) {
19825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    *length = max_size;
19835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
19842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
19855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
1986a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void GLES2Implementation::TexImageIOSurface2DCHROMIUM(GLenum target,
1987a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                                      GLsizei width,
1988a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                                      GLsizei height,
1989a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                                      GLuint ioSurfaceId,
1990a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                                      GLuint plane) {
19915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
1992a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glTexImageIOSurface2DCHROMIUM("
1993a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringTextureBindTarget(target) << ", "
1994a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << width << ", " << height << ", " << ioSurfaceId << ", "
1995a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << plane << ")");
19965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (width < 0) {
19975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    SetGLError(GL_INVALID_VALUE, "glTexImageIOSurface2DCHROMIUM", "width < 0");
19985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
19995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
20005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (height < 0) {
2001a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    SetGLError(GL_INVALID_VALUE, "glTexImageIOSurface2DCHROMIUM", "height < 0");
20025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
20035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
20045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->TexImageIOSurface2DCHROMIUM(
20055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      target, width, height, ioSurfaceId, plane);
20062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
20075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
20085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2009a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void GLES2Implementation::CopyTextureCHROMIUM(GLenum target,
2010a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                              GLenum source_id,
2011a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                              GLenum dest_id,
2012a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                              GLint level,
2013a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                              GLint internalformat,
2014a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                              GLenum dest_type) {
20155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
2016a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glCopyTextureCHROMIUM("
2017a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringEnum(target) << ", "
2018a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringEnum(source_id) << ", "
2019a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringEnum(dest_id) << ", " << level
2020a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << ", " << internalformat << ", "
2021a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringPixelType(dest_type) << ")");
20225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->CopyTextureCHROMIUM(
2023c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)      target, source_id, dest_id, level, internalformat, dest_type);
20242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
20255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
20265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2027a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void GLES2Implementation::BindTexImage2DCHROMIUM(GLenum target, GLint imageId) {
20285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
2029a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glBindTexImage2DCHROMIUM("
2030a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringTextureBindTarget(target) << ", "
2031a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << imageId << ")");
20325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->BindTexImage2DCHROMIUM(target, imageId);
20332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
20345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
20355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2036a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void GLES2Implementation::ReleaseTexImage2DCHROMIUM(GLenum target,
2037a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                                    GLint imageId) {
20385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
2039a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glReleaseTexImage2DCHROMIUM("
2040a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringTextureBindTarget(target) << ", "
2041a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << imageId << ")");
20425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  helper_->ReleaseTexImage2DCHROMIUM(target, imageId);
20432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
20442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
20452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
2046a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void GLES2Implementation::DiscardFramebufferEXT(GLenum target,
2047a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                                GLsizei count,
2048a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                                const GLenum* attachments) {
20492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
2050a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glDiscardFramebufferEXT("
2051a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << GLES2Util::GetStringEnum(target) << ", " << count
2052a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << ", " << static_cast<const void*>(attachments) << ")");
20532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  GPU_CLIENT_LOG_CODE_BLOCK({
20542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    for (GLsizei i = 0; i < count; ++i) {
2055a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      GPU_CLIENT_LOG("  " << i << ": " << attachments[0 + i * 1]);
20562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    }
20572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  });
20582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  if (count < 0) {
20592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    SetGLError(GL_INVALID_VALUE, "glDiscardFramebufferEXT", "count < 0");
20602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    return;
20612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
20622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  helper_->DiscardFramebufferEXTImmediate(target, count, attachments);
20632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
20642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
20652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
20662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void GLES2Implementation::LoseContextCHROMIUM(GLenum current, GLenum other) {
20672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
2068a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glLoseContextCHROMIUM("
2069cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)                     << GLES2Util::GetStringResetStatus(current) << ", "
2070cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)                     << GLES2Util::GetStringResetStatus(other) << ")");
20712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  helper_->LoseContextCHROMIUM(current, other);
20722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
20732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
20742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
20752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void GLES2Implementation::WaitSyncPointCHROMIUM(GLuint sync_point) {
20762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
2077a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glWaitSyncPointCHROMIUM("
2078a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << sync_point << ")");
20792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  helper_->WaitSyncPointCHROMIUM(sync_point);
20802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
20812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
20822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
20832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void GLES2Implementation::DrawBuffersEXT(GLsizei count, const GLenum* bufs) {
20842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
2085a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glDrawBuffersEXT(" << count << ", "
2086a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << static_cast<const void*>(bufs) << ")");
20872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  GPU_CLIENT_LOG_CODE_BLOCK({
20882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    for (GLsizei i = 0; i < count; ++i) {
2089a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      GPU_CLIENT_LOG("  " << i << ": " << bufs[0 + i * 1]);
20902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    }
20912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  });
20922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  if (count < 0) {
20932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    SetGLError(GL_INVALID_VALUE, "glDrawBuffersEXT", "count < 0");
20942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    return;
20952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
20962a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  helper_->DrawBuffersEXTImmediate(count, bufs);
20972a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  CheckGLError();
20985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
20995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
21005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void GLES2Implementation::DiscardBackbufferCHROMIUM() {
21015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  GPU_CLIENT_SINGLE_THREAD_CHECK();
2102a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glDiscardBackbufferCHROMIUM("
2103a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                     << ")");
21045d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  helper_->DiscardBackbufferCHROMIUM();
21055d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  CheckGLError();
21065d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
21075d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
2108c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdochvoid GLES2Implementation::ScheduleOverlayPlaneCHROMIUM(
2109c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch    GLint plane_z_order,
2110c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch    GLenum plane_transform,
2111c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch    GLuint overlay_texture_id,
2112c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch    GLint bounds_x,
2113c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch    GLint bounds_y,
2114c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch    GLint bounds_width,
2115c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch    GLint bounds_height,
2116c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch    GLfloat uv_x,
2117c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch    GLfloat uv_y,
2118c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch    GLfloat uv_width,
2119c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch    GLfloat uv_height) {
2120c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch  GPU_CLIENT_SINGLE_THREAD_CHECK();
2121c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch  GPU_CLIENT_LOG(
2122c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch      "[" << GetLogPrefix() << "] glScheduleOverlayPlaneCHROMIUM("
2123c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch          << plane_z_order << ", " << GLES2Util::GetStringEnum(plane_transform)
2124c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch          << ", " << overlay_texture_id << ", " << bounds_x << ", " << bounds_y
2125c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch          << ", " << bounds_width << ", " << bounds_height << ", " << uv_x
2126c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch          << ", " << uv_y << ", " << uv_width << ", " << uv_height << ")");
2127c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch  helper_->ScheduleOverlayPlaneCHROMIUM(plane_z_order,
2128c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch                                        plane_transform,
2129c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch                                        overlay_texture_id,
2130c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch                                        bounds_x,
2131c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch                                        bounds_y,
2132c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch                                        bounds_width,
2133c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch                                        bounds_height,
2134c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch                                        uv_x,
2135c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch                                        uv_y,
2136c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch                                        uv_width,
2137c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch                                        uv_height);
2138c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch  CheckGLError();
2139c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch}
2140c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch
21411320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccivoid GLES2Implementation::MatrixLoadfCHROMIUM(GLenum matrixMode,
21421320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci                                              const GLfloat* m) {
21431320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  GPU_CLIENT_SINGLE_THREAD_CHECK();
21441320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glMatrixLoadfCHROMIUM("
21451320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci                     << GLES2Util::GetStringMatrixMode(matrixMode) << ", "
21461320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci                     << static_cast<const void*>(m) << ")");
21471320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  GPU_CLIENT_LOG("values: " << m[0] << ", " << m[1] << ", " << m[2] << ", "
21481320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci                            << m[3] << ", " << m[4] << ", " << m[5] << ", "
21491320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci                            << m[6] << ", " << m[7] << ", " << m[8] << ", "
21501320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci                            << m[9] << ", " << m[10] << ", " << m[11] << ", "
21511320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci                            << m[12] << ", " << m[13] << ", " << m[14] << ", "
21521320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci                            << m[15]);
21531320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  helper_->MatrixLoadfCHROMIUMImmediate(matrixMode, m);
21541320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  CheckGLError();
21551320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci}
21561320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
21571320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccivoid GLES2Implementation::MatrixLoadIdentityCHROMIUM(GLenum matrixMode) {
21581320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  GPU_CLIENT_SINGLE_THREAD_CHECK();
21591320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glMatrixLoadIdentityCHROMIUM("
21601320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci                     << GLES2Util::GetStringMatrixMode(matrixMode) << ")");
21611320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  helper_->MatrixLoadIdentityCHROMIUM(matrixMode);
21621320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  CheckGLError();
21631320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci}
21641320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
21655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif  // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_IMPL_AUTOGEN_H_
2166