blob: c9f8548d96f2d4d2801aaa6978867f7e49075a52 [file] [log] [blame]
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This file is auto-generated from
// gpu/command_buffer/build_gles2_cmd_buffer.py
// It's formatted by clang-format using chromium coding style:
// clang-format -i -style=chromium filename
// DO NOT EDIT!
// It is included by gles2_cmd_decoder.cc
#ifndef GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_AUTOGEN_H_
#define GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_AUTOGEN_H_
error::Error GLES2DecoderImpl::HandleActiveTexture(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
const volatile gles2::cmds::ActiveTexture& c =
*static_cast<const volatile gles2::cmds::ActiveTexture*>(cmd_data);
GLenum texture = static_cast<GLenum>(c.texture);
DoActiveTexture(texture);
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleAttachShader(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
const volatile gles2::cmds::AttachShader& c =
*static_cast<const volatile gles2::cmds::AttachShader*>(cmd_data);
GLuint program = c.program;
GLuint shader = c.shader;
DoAttachShader(program, shader);
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleBindBuffer(uint32_t immediate_data_size,
const volatile void* cmd_data) {
const volatile gles2::cmds::BindBuffer& c =
*static_cast<const volatile gles2::cmds::BindBuffer*>(cmd_data);
GLenum target = static_cast<GLenum>(c.target);
GLuint buffer = c.buffer;
if (!validators_->buffer_target.IsValid(target)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glBindBuffer", target, "target");
return error::kNoError;
}
DoBindBuffer(target, buffer);
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleBindBufferBase(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
if (!feature_info_->IsWebGL2OrES3OrHigherContext())
return error::kUnknownCommand;
const volatile gles2::cmds::BindBufferBase& c =
*static_cast<const volatile gles2::cmds::BindBufferBase*>(cmd_data);
GLenum target = static_cast<GLenum>(c.target);
GLuint index = static_cast<GLuint>(c.index);
GLuint buffer = c.buffer;
if (!validators_->indexed_buffer_target.IsValid(target)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glBindBufferBase", target, "target");
return error::kNoError;
}
DoBindBufferBase(target, index, buffer);
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleBindBufferRange(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
if (!feature_info_->IsWebGL2OrES3OrHigherContext())
return error::kUnknownCommand;
const volatile gles2::cmds::BindBufferRange& c =
*static_cast<const volatile gles2::cmds::BindBufferRange*>(cmd_data);
GLenum target = static_cast<GLenum>(c.target);
GLuint index = static_cast<GLuint>(c.index);
GLuint buffer = c.buffer;
GLintptr offset = static_cast<GLintptr>(c.offset);
GLsizeiptr size = static_cast<GLsizeiptr>(c.size);
if (!validators_->indexed_buffer_target.IsValid(target)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glBindBufferRange", target, "target");
return error::kNoError;
}
if (size < 0) {
LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glBindBufferRange", "size < 0");
return error::kNoError;
}
DoBindBufferRange(target, index, buffer, offset, size);
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleBindFramebuffer(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
const volatile gles2::cmds::BindFramebuffer& c =
*static_cast<const volatile gles2::cmds::BindFramebuffer*>(cmd_data);
GLenum target = static_cast<GLenum>(c.target);
GLuint framebuffer = c.framebuffer;
if (!validators_->framebuffer_target.IsValid(target)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glBindFramebuffer", target, "target");
return error::kNoError;
}
DoBindFramebuffer(target, framebuffer);
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleBindRenderbuffer(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
const volatile gles2::cmds::BindRenderbuffer& c =
*static_cast<const volatile gles2::cmds::BindRenderbuffer*>(cmd_data);
GLenum target = static_cast<GLenum>(c.target);
GLuint renderbuffer = c.renderbuffer;
if (!validators_->render_buffer_target.IsValid(target)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glBindRenderbuffer", target, "target");
return error::kNoError;
}
DoBindRenderbuffer(target, renderbuffer);
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleBindSampler(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
if (!feature_info_->IsWebGL2OrES3OrHigherContext())
return error::kUnknownCommand;
const volatile gles2::cmds::BindSampler& c =
*static_cast<const volatile gles2::cmds::BindSampler*>(cmd_data);
GLuint unit = static_cast<GLuint>(c.unit);
GLuint sampler = c.sampler;
DoBindSampler(unit, sampler);
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleBindTexture(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
const volatile gles2::cmds::BindTexture& c =
*static_cast<const volatile gles2::cmds::BindTexture*>(cmd_data);
GLenum target = static_cast<GLenum>(c.target);
GLuint texture = c.texture;
if (!validators_->texture_bind_target.IsValid(target)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glBindTexture", target, "target");
return error::kNoError;
}
DoBindTexture(target, texture);
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleBindTransformFeedback(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
if (!feature_info_->IsWebGL2OrES3OrHigherContext())
return error::kUnknownCommand;
const volatile gles2::cmds::BindTransformFeedback& c =
*static_cast<const volatile gles2::cmds::BindTransformFeedback*>(
cmd_data);
GLenum target = static_cast<GLenum>(c.target);
GLuint transformfeedback = c.transformfeedback;
if (!validators_->transform_feedback_bind_target.IsValid(target)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glBindTransformFeedback", target,
"target");
return error::kNoError;
}
DoBindTransformFeedback(target, transformfeedback);
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleBlendColor(uint32_t immediate_data_size,
const volatile void* cmd_data) {
const volatile gles2::cmds::BlendColor& c =
*static_cast<const volatile gles2::cmds::BlendColor*>(cmd_data);
GLclampf red = static_cast<GLclampf>(c.red);
GLclampf green = static_cast<GLclampf>(c.green);
GLclampf blue = static_cast<GLclampf>(c.blue);
GLclampf alpha = static_cast<GLclampf>(c.alpha);
if (state_.blend_color_red != red || state_.blend_color_green != green ||
state_.blend_color_blue != blue || state_.blend_color_alpha != alpha) {
state_.blend_color_red = red;
state_.blend_color_green = green;
state_.blend_color_blue = blue;
state_.blend_color_alpha = alpha;
api()->glBlendColorFn(red, green, blue, alpha);
}
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleBlendEquation(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
const volatile gles2::cmds::BlendEquation& c =
*static_cast<const volatile gles2::cmds::BlendEquation*>(cmd_data);
GLenum mode = static_cast<GLenum>(c.mode);
if (!validators_->equation.IsValid(mode)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendEquation", mode, "mode");
return error::kNoError;
}
if (state_.blend_equation_rgb != mode ||
state_.blend_equation_alpha != mode) {
state_.blend_equation_rgb = mode;
state_.blend_equation_alpha = mode;
api()->glBlendEquationFn(mode);
}
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleBlendEquationSeparate(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
const volatile gles2::cmds::BlendEquationSeparate& c =
*static_cast<const volatile gles2::cmds::BlendEquationSeparate*>(
cmd_data);
GLenum modeRGB = static_cast<GLenum>(c.modeRGB);
GLenum modeAlpha = static_cast<GLenum>(c.modeAlpha);
if (!validators_->equation.IsValid(modeRGB)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendEquationSeparate", modeRGB,
"modeRGB");
return error::kNoError;
}
if (!validators_->equation.IsValid(modeAlpha)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendEquationSeparate", modeAlpha,
"modeAlpha");
return error::kNoError;
}
if (state_.blend_equation_rgb != modeRGB ||
state_.blend_equation_alpha != modeAlpha) {
state_.blend_equation_rgb = modeRGB;
state_.blend_equation_alpha = modeAlpha;
api()->glBlendEquationSeparateFn(modeRGB, modeAlpha);
}
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleBlendFunc(uint32_t immediate_data_size,
const volatile void* cmd_data) {
const volatile gles2::cmds::BlendFunc& c =
*static_cast<const volatile gles2::cmds::BlendFunc*>(cmd_data);
GLenum sfactor = static_cast<GLenum>(c.sfactor);
GLenum dfactor = static_cast<GLenum>(c.dfactor);
if (!validators_->src_blend_factor.IsValid(sfactor)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendFunc", sfactor, "sfactor");
return error::kNoError;
}
if (!validators_->dst_blend_factor.IsValid(dfactor)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendFunc", dfactor, "dfactor");
return error::kNoError;
}
if (state_.blend_source_rgb != sfactor || state_.blend_dest_rgb != dfactor ||
state_.blend_source_alpha != sfactor ||
state_.blend_dest_alpha != dfactor) {
state_.blend_source_rgb = sfactor;
state_.blend_dest_rgb = dfactor;
state_.blend_source_alpha = sfactor;
state_.blend_dest_alpha = dfactor;
api()->glBlendFuncFn(sfactor, dfactor);
}
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleBlendFuncSeparate(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
const volatile gles2::cmds::BlendFuncSeparate& c =
*static_cast<const volatile gles2::cmds::BlendFuncSeparate*>(cmd_data);
GLenum srcRGB = static_cast<GLenum>(c.srcRGB);
GLenum dstRGB = static_cast<GLenum>(c.dstRGB);
GLenum srcAlpha = static_cast<GLenum>(c.srcAlpha);
GLenum dstAlpha = static_cast<GLenum>(c.dstAlpha);
if (!validators_->src_blend_factor.IsValid(srcRGB)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendFuncSeparate", srcRGB, "srcRGB");
return error::kNoError;
}
if (!validators_->dst_blend_factor.IsValid(dstRGB)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendFuncSeparate", dstRGB, "dstRGB");
return error::kNoError;
}
if (!validators_->src_blend_factor.IsValid(srcAlpha)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendFuncSeparate", srcAlpha,
"srcAlpha");
return error::kNoError;
}
if (!validators_->dst_blend_factor.IsValid(dstAlpha)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendFuncSeparate", dstAlpha,
"dstAlpha");
return error::kNoError;
}
if (state_.blend_source_rgb != srcRGB || state_.blend_dest_rgb != dstRGB ||
state_.blend_source_alpha != srcAlpha ||
state_.blend_dest_alpha != dstAlpha) {
state_.blend_source_rgb = srcRGB;
state_.blend_dest_rgb = dstRGB;
state_.blend_source_alpha = srcAlpha;
state_.blend_dest_alpha = dstAlpha;
api()->glBlendFuncSeparateFn(srcRGB, dstRGB, srcAlpha, dstAlpha);
}
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleBufferSubData(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
const volatile gles2::cmds::BufferSubData& c =
*static_cast<const volatile gles2::cmds::BufferSubData*>(cmd_data);
GLenum target = static_cast<GLenum>(c.target);
GLintptr offset = static_cast<GLintptr>(c.offset);
GLsizeiptr size = static_cast<GLsizeiptr>(c.size);
uint32_t data_size = size;
const void* data = GetSharedMemoryAs<const void*>(
c.data_shm_id, c.data_shm_offset, data_size);
if (!validators_->buffer_target.IsValid(target)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glBufferSubData", target, "target");
return error::kNoError;
}
if (size < 0) {
LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glBufferSubData", "size < 0");
return error::kNoError;
}
if (data == nullptr) {
return error::kOutOfBounds;
}
DoBufferSubData(target, offset, size, data);
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleCheckFramebufferStatus(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
const volatile gles2::cmds::CheckFramebufferStatus& c =
*static_cast<const volatile gles2::cmds::CheckFramebufferStatus*>(
cmd_data);
GLenum target = static_cast<GLenum>(c.target);
typedef cmds::CheckFramebufferStatus::Result Result;
Result* result_dst = GetSharedMemoryAs<Result*>(
c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
if (!result_dst) {
return error::kOutOfBounds;
}
if (!validators_->framebuffer_target.IsValid(target)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glCheckFramebufferStatus", target,
"target");
return error::kNoError;
}
*result_dst = DoCheckFramebufferStatus(target);
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleClear(uint32_t immediate_data_size,
const volatile void* cmd_data) {
const volatile gles2::cmds::Clear& c =
*static_cast<const volatile gles2::cmds::Clear*>(cmd_data);
error::Error error;
error = WillAccessBoundFramebufferForDraw();
if (error != error::kNoError)
return error;
GLbitfield mask = static_cast<GLbitfield>(c.mask);
DoClear(mask);
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleClearBufferfi(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
if (!feature_info_->IsWebGL2OrES3OrHigherContext())
return error::kUnknownCommand;
const volatile gles2::cmds::ClearBufferfi& c =
*static_cast<const volatile gles2::cmds::ClearBufferfi*>(cmd_data);
GLenum buffer = static_cast<GLenum>(c.buffer);
GLint drawbuffers = static_cast<GLint>(c.drawbuffers);
GLfloat depth = static_cast<GLfloat>(c.depth);
GLint stencil = static_cast<GLint>(c.stencil);
if (!validators_->bufferfi.IsValid(buffer)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glClearBufferfi", buffer, "buffer");
return error::kNoError;
}
DoClearBufferfi(buffer, drawbuffers, depth, stencil);
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleClearBufferfvImmediate(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
if (!feature_info_->IsWebGL2OrES3OrHigherContext())
return error::kUnknownCommand;
const volatile gles2::cmds::ClearBufferfvImmediate& c =
*static_cast<const volatile gles2::cmds::ClearBufferfvImmediate*>(
cmd_data);
GLenum buffer = static_cast<GLenum>(c.buffer);
GLint drawbuffers = static_cast<GLint>(c.drawbuffers);
uint32_t value_size;
if (!GLES2Util::ComputeDataSize<GLfloat, 4>(1, &value_size)) {
return error::kOutOfBounds;
}
if (value_size > immediate_data_size) {
return error::kOutOfBounds;
}
volatile const GLfloat* value = GetImmediateDataAs<volatile const GLfloat*>(
c, value_size, immediate_data_size);
if (!validators_->bufferfv.IsValid(buffer)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glClearBufferfv", buffer, "buffer");
return error::kNoError;
}
if (value == nullptr) {
return error::kOutOfBounds;
}
DoClearBufferfv(buffer, drawbuffers, value);
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleClearBufferivImmediate(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
if (!feature_info_->IsWebGL2OrES3OrHigherContext())
return error::kUnknownCommand;
const volatile gles2::cmds::ClearBufferivImmediate& c =
*static_cast<const volatile gles2::cmds::ClearBufferivImmediate*>(
cmd_data);
GLenum buffer = static_cast<GLenum>(c.buffer);
GLint drawbuffers = static_cast<GLint>(c.drawbuffers);
uint32_t value_size;
if (!GLES2Util::ComputeDataSize<GLint, 4>(1, &value_size)) {
return error::kOutOfBounds;
}
if (value_size > immediate_data_size) {
return error::kOutOfBounds;
}
volatile const GLint* value = GetImmediateDataAs<volatile const GLint*>(
c, value_size, immediate_data_size);
if (!validators_->bufferiv.IsValid(buffer)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glClearBufferiv", buffer, "buffer");
return error::kNoError;
}
if (value == nullptr) {
return error::kOutOfBounds;
}
DoClearBufferiv(buffer, drawbuffers, value);
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleClearBufferuivImmediate(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
if (!feature_info_->IsWebGL2OrES3OrHigherContext())
return error::kUnknownCommand;
const volatile gles2::cmds::ClearBufferuivImmediate& c =
*static_cast<const volatile gles2::cmds::ClearBufferuivImmediate*>(
cmd_data);
GLenum buffer = static_cast<GLenum>(c.buffer);
GLint drawbuffers = static_cast<GLint>(c.drawbuffers);
uint32_t value_size;
if (!GLES2Util::ComputeDataSize<GLuint, 4>(1, &value_size)) {
return error::kOutOfBounds;
}
if (value_size > immediate_data_size) {
return error::kOutOfBounds;
}
volatile const GLuint* value = GetImmediateDataAs<volatile const GLuint*>(
c, value_size, immediate_data_size);
if (!validators_->bufferuiv.IsValid(buffer)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glClearBufferuiv", buffer, "buffer");
return error::kNoError;
}
if (value == nullptr) {
return error::kOutOfBounds;
}
DoClearBufferuiv(buffer, drawbuffers, value);
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleClearColor(uint32_t immediate_data_size,
const volatile void* cmd_data) {
const volatile gles2::cmds::ClearColor& c =
*static_cast<const volatile gles2::cmds::ClearColor*>(cmd_data);
GLclampf red = static_cast<GLclampf>(c.red);
GLclampf green = static_cast<GLclampf>(c.green);
GLclampf blue = static_cast<GLclampf>(c.blue);
GLclampf alpha = static_cast<GLclampf>(c.alpha);
if (state_.color_clear_red != red || state_.color_clear_green != green ||
state_.color_clear_blue != blue || state_.color_clear_alpha != alpha) {
state_.color_clear_red = red;
state_.color_clear_green = green;
state_.color_clear_blue = blue;
state_.color_clear_alpha = alpha;
api()->glClearColorFn(red, green, blue, alpha);
}
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleClearDepthf(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
const volatile gles2::cmds::ClearDepthf& c =
*static_cast<const volatile gles2::cmds::ClearDepthf*>(cmd_data);
GLclampf depth = static_cast<GLclampf>(c.depth);
if (state_.depth_clear != depth) {
state_.depth_clear = depth;
glClearDepth(depth);
}
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleClearStencil(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
const volatile gles2::cmds::ClearStencil& c =
*static_cast<const volatile gles2::cmds::ClearStencil*>(cmd_data);
GLint s = static_cast<GLint>(c.s);
if (state_.stencil_clear != s) {
state_.stencil_clear = s;
api()->glClearStencilFn(s);
}
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleColorMask(uint32_t immediate_data_size,
const volatile void* cmd_data) {
const volatile gles2::cmds::ColorMask& c =
*static_cast<const volatile gles2::cmds::ColorMask*>(cmd_data);
GLboolean red = static_cast<GLboolean>(c.red);
GLboolean green = static_cast<GLboolean>(c.green);
GLboolean blue = static_cast<GLboolean>(c.blue);
GLboolean alpha = static_cast<GLboolean>(c.alpha);
if (state_.color_mask_red != red || state_.color_mask_green != green ||
state_.color_mask_blue != blue || state_.color_mask_alpha != alpha) {
state_.color_mask_red = red;
state_.color_mask_green = green;
state_.color_mask_blue = blue;
state_.color_mask_alpha = alpha;
framebuffer_state_.clear_state_dirty = true;
}
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleCompileShader(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
const volatile gles2::cmds::CompileShader& c =
*static_cast<const volatile gles2::cmds::CompileShader*>(cmd_data);
GLuint shader = c.shader;
DoCompileShader(shader);
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleCopyBufferSubData(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
if (!feature_info_->IsWebGL2OrES3OrHigherContext())
return error::kUnknownCommand;
const volatile gles2::cmds::CopyBufferSubData& c =
*static_cast<const volatile gles2::cmds::CopyBufferSubData*>(cmd_data);
GLenum readtarget = static_cast<GLenum>(c.readtarget);
GLenum writetarget = static_cast<GLenum>(c.writetarget);
GLintptr readoffset = static_cast<GLintptr>(c.readoffset);
GLintptr writeoffset = static_cast<GLintptr>(c.writeoffset);
GLsizeiptr size = static_cast<GLsizeiptr>(c.size);
if (!validators_->buffer_target.IsValid(readtarget)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glCopyBufferSubData", readtarget,
"readtarget");
return error::kNoError;
}
if (!validators_->buffer_target.IsValid(writetarget)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glCopyBufferSubData", writetarget,
"writetarget");
return error::kNoError;
}
if (size < 0) {
LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopyBufferSubData", "size < 0");
return error::kNoError;
}
DoCopyBufferSubData(readtarget, writetarget, readoffset, writeoffset, size);
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleCopyTexImage2D(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
const volatile gles2::cmds::CopyTexImage2D& c =
*static_cast<const volatile gles2::cmds::CopyTexImage2D*>(cmd_data);
error::Error error;
error = WillAccessBoundFramebufferForRead();
if (error != error::kNoError)
return error;
GLenum target = static_cast<GLenum>(c.target);
GLint level = static_cast<GLint>(c.level);
GLenum internalformat = static_cast<GLenum>(c.internalformat);
GLint x = static_cast<GLint>(c.x);
GLint y = static_cast<GLint>(c.y);
GLsizei width = static_cast<GLsizei>(c.width);
GLsizei height = static_cast<GLsizei>(c.height);
GLint border = static_cast<GLint>(c.border);
if (!validators_->texture_target.IsValid(target)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glCopyTexImage2D", target, "target");
return error::kNoError;
}
if (!validators_->texture_internal_format.IsValid(internalformat)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glCopyTexImage2D", internalformat,
"internalformat");
return error::kNoError;
}
if (width < 0) {
LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopyTexImage2D", "width < 0");
return error::kNoError;
}
if (height < 0) {
LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopyTexImage2D", "height < 0");
return error::kNoError;
}
DoCopyTexImage2D(target, level, internalformat, x, y, width, height, border);
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleCopyTexSubImage2D(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
const volatile gles2::cmds::CopyTexSubImage2D& c =
*static_cast<const volatile gles2::cmds::CopyTexSubImage2D*>(cmd_data);
error::Error error;
error = WillAccessBoundFramebufferForRead();
if (error != error::kNoError)
return error;
GLenum target = static_cast<GLenum>(c.target);
GLint level = static_cast<GLint>(c.level);
GLint xoffset = static_cast<GLint>(c.xoffset);
GLint yoffset = static_cast<GLint>(c.yoffset);
GLint x = static_cast<GLint>(c.x);
GLint y = static_cast<GLint>(c.y);
GLsizei width = static_cast<GLsizei>(c.width);
GLsizei height = static_cast<GLsizei>(c.height);
if (!validators_->texture_target.IsValid(target)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glCopyTexSubImage2D", target, "target");
return error::kNoError;
}
if (width < 0) {
LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopyTexSubImage2D", "width < 0");
return error::kNoError;
}
if (height < 0) {
LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopyTexSubImage2D", "height < 0");
return error::kNoError;
}
DoCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleCopyTexSubImage3D(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
if (!feature_info_->IsWebGL2OrES3OrHigherContext())
return error::kUnknownCommand;
const volatile gles2::cmds::CopyTexSubImage3D& c =
*static_cast<const volatile gles2::cmds::CopyTexSubImage3D*>(cmd_data);
error::Error error;
error = WillAccessBoundFramebufferForRead();
if (error != error::kNoError)
return error;
GLenum target = static_cast<GLenum>(c.target);
GLint level = static_cast<GLint>(c.level);
GLint xoffset = static_cast<GLint>(c.xoffset);
GLint yoffset = static_cast<GLint>(c.yoffset);
GLint zoffset = static_cast<GLint>(c.zoffset);
GLint x = static_cast<GLint>(c.x);
GLint y = static_cast<GLint>(c.y);
GLsizei width = static_cast<GLsizei>(c.width);
GLsizei height = static_cast<GLsizei>(c.height);
if (!validators_->texture_3_d_target.IsValid(target)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glCopyTexSubImage3D", target, "target");
return error::kNoError;
}
if (width < 0) {
LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopyTexSubImage3D", "width < 0");
return error::kNoError;
}
if (height < 0) {
LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopyTexSubImage3D", "height < 0");
return error::kNoError;
}
DoCopyTexSubImage3D(target, level, xoffset, yoffset, zoffset, x, y, width,
height);
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleCreateProgram(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
const volatile gles2::cmds::CreateProgram& c =
*static_cast<const volatile gles2::cmds::CreateProgram*>(cmd_data);
uint32_t client_id = c.client_id;
if (GetProgram(client_id)) {
return error::kInvalidArguments;
}
GLuint service_id = api()->glCreateProgramFn();
if (service_id) {
CreateProgram(client_id, service_id);
}
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleCreateShader(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
const volatile gles2::cmds::CreateShader& c =
*static_cast<const volatile gles2::cmds::CreateShader*>(cmd_data);
GLenum type = static_cast<GLenum>(c.type);
if (!validators_->shader_type.IsValid(type)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glCreateShader", type, "type");
return error::kNoError;
}
uint32_t client_id = c.client_id;
if (GetShader(client_id)) {
return error::kInvalidArguments;
}
GLuint service_id = api()->glCreateShaderFn(type);
if (service_id) {
CreateShader(client_id, service_id, type);
}
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleCullFace(uint32_t immediate_data_size,
const volatile void* cmd_data) {
const volatile gles2::cmds::CullFace& c =
*static_cast<const volatile gles2::cmds::CullFace*>(cmd_data);
GLenum mode = static_cast<GLenum>(c.mode);
if (!validators_->face_type.IsValid(mode)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glCullFace", mode, "mode");
return error::kNoError;
}
if (state_.cull_mode != mode) {
state_.cull_mode = mode;
api()->glCullFaceFn(mode);
}
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleDeleteBuffersImmediate(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
const volatile gles2::cmds::DeleteBuffersImmediate& c =
*static_cast<const volatile gles2::cmds::DeleteBuffersImmediate*>(
cmd_data);
GLsizei n = static_cast<GLsizei>(c.n);
uint32_t buffers_size;
if (!SafeMultiplyUint32(n, sizeof(GLuint), &buffers_size)) {
return error::kOutOfBounds;
}
volatile const GLuint* buffers = GetImmediateDataAs<volatile const GLuint*>(
c, buffers_size, immediate_data_size);
if (buffers == nullptr) {
return error::kOutOfBounds;
}
DeleteBuffersHelper(n, buffers);
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleDeleteFramebuffersImmediate(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
const volatile gles2::cmds::DeleteFramebuffersImmediate& c =
*static_cast<const volatile gles2::cmds::DeleteFramebuffersImmediate*>(
cmd_data);
GLsizei n = static_cast<GLsizei>(c.n);
uint32_t framebuffers_size;
if (!SafeMultiplyUint32(n, sizeof(GLuint), &framebuffers_size)) {
return error::kOutOfBounds;
}
volatile const GLuint* framebuffers =
GetImmediateDataAs<volatile const GLuint*>(c, framebuffers_size,
immediate_data_size);
if (framebuffers == nullptr) {
return error::kOutOfBounds;
}
DeleteFramebuffersHelper(n, framebuffers);
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleDeleteRenderbuffersImmediate(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
const volatile gles2::cmds::DeleteRenderbuffersImmediate& c =
*static_cast<const volatile gles2::cmds::DeleteRenderbuffersImmediate*>(
cmd_data);
GLsizei n = static_cast<GLsizei>(c.n);
uint32_t renderbuffers_size;
if (!SafeMultiplyUint32(n, sizeof(GLuint), &renderbuffers_size)) {
return error::kOutOfBounds;
}
volatile const GLuint* renderbuffers =
GetImmediateDataAs<volatile const GLuint*>(c, renderbuffers_size,
immediate_data_size);
if (renderbuffers == nullptr) {
return error::kOutOfBounds;
}
DeleteRenderbuffersHelper(n, renderbuffers);
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleDeleteSamplersImmediate(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
if (!feature_info_->IsWebGL2OrES3OrHigherContext())
return error::kUnknownCommand;
const volatile gles2::cmds::DeleteSamplersImmediate& c =
*static_cast<const volatile gles2::cmds::DeleteSamplersImmediate*>(
cmd_data);
GLsizei n = static_cast<GLsizei>(c.n);
uint32_t samplers_size;
if (!SafeMultiplyUint32(n, sizeof(GLuint), &samplers_size)) {
return error::kOutOfBounds;
}
volatile const GLuint* samplers = GetImmediateDataAs<volatile const GLuint*>(
c, samplers_size, immediate_data_size);
if (samplers == nullptr) {
return error::kOutOfBounds;
}
DeleteSamplersHelper(n, samplers);
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleDeleteSync(uint32_t immediate_data_size,
const volatile void* cmd_data) {
if (!feature_info_->IsWebGL2OrES3OrHigherContext())
return error::kUnknownCommand;
const volatile gles2::cmds::DeleteSync& c =
*static_cast<const volatile gles2::cmds::DeleteSync*>(cmd_data);
GLuint sync = c.sync;
DeleteSyncHelper(sync);
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleDeleteTexturesImmediate(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
const volatile gles2::cmds::DeleteTexturesImmediate& c =
*static_cast<const volatile gles2::cmds::DeleteTexturesImmediate*>(
cmd_data);
GLsizei n = static_cast<GLsizei>(c.n);
uint32_t textures_size;
if (!SafeMultiplyUint32(n, sizeof(GLuint), &textures_size)) {
return error::kOutOfBounds;
}
volatile const GLuint* textures = GetImmediateDataAs<volatile const GLuint*>(
c, textures_size, immediate_data_size);
if (textures == nullptr) {
return error::kOutOfBounds;
}
DeleteTexturesHelper(n, textures);
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleDeleteTransformFeedbacksImmediate(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
if (!feature_info_->IsWebGL2OrES3OrHigherContext())
return error::kUnknownCommand;
const volatile gles2::cmds::DeleteTransformFeedbacksImmediate& c =
*static_cast<
const volatile gles2::cmds::DeleteTransformFeedbacksImmediate*>(
cmd_data);
GLsizei n = static_cast<GLsizei>(c.n);
uint32_t ids_size;
if (!SafeMultiplyUint32(n, sizeof(GLuint), &ids_size)) {
return error::kOutOfBounds;
}
volatile const GLuint* ids = GetImmediateDataAs<volatile const GLuint*>(
c, ids_size, immediate_data_size);
if (ids == nullptr) {
return error::kOutOfBounds;
}
DeleteTransformFeedbacksHelper(n, ids);
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleDepthFunc(uint32_t immediate_data_size,
const volatile void* cmd_data) {
const volatile gles2::cmds::DepthFunc& c =
*static_cast<const volatile gles2::cmds::DepthFunc*>(cmd_data);
GLenum func = static_cast<GLenum>(c.func);
if (!validators_->cmp_function.IsValid(func)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glDepthFunc", func, "func");
return error::kNoError;
}
if (state_.depth_func != func) {
state_.depth_func = func;
api()->glDepthFuncFn(func);
}
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleDepthMask(uint32_t immediate_data_size,
const volatile void* cmd_data) {
const volatile gles2::cmds::DepthMask& c =
*static_cast<const volatile gles2::cmds::DepthMask*>(cmd_data);
GLboolean flag = static_cast<GLboolean>(c.flag);
if (state_.depth_mask != flag) {
state_.depth_mask = flag;
framebuffer_state_.clear_state_dirty = true;
}
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleDepthRangef(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
const volatile gles2::cmds::DepthRangef& c =
*static_cast<const volatile gles2::cmds::DepthRangef*>(cmd_data);
GLclampf zNear = static_cast<GLclampf>(c.zNear);
GLclampf zFar = static_cast<GLclampf>(c.zFar);
DoDepthRangef(zNear, zFar);
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleDetachShader(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
const volatile gles2::cmds::DetachShader& c =
*static_cast<const volatile gles2::cmds::DetachShader*>(cmd_data);
GLuint program = c.program;
GLuint shader = c.shader;
DoDetachShader(program, shader);
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleDisable(uint32_t immediate_data_size,
const volatile void* cmd_data) {
const volatile gles2::cmds::Disable& c =
*static_cast<const volatile gles2::cmds::Disable*>(cmd_data);
GLenum cap = static_cast<GLenum>(c.cap);
if (!validators_->capability.IsValid(cap)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glDisable", cap, "cap");
return error::kNoError;
}
DoDisable(cap);
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleDisableVertexAttribArray(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
const volatile gles2::cmds::DisableVertexAttribArray& c =
*static_cast<const volatile gles2::cmds::DisableVertexAttribArray*>(
cmd_data);
GLuint index = static_cast<GLuint>(c.index);
DoDisableVertexAttribArray(index);
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleEnable(uint32_t immediate_data_size,
const volatile void* cmd_data) {
const volatile gles2::cmds::Enable& c =
*static_cast<const volatile gles2::cmds::Enable*>(cmd_data);
GLenum cap = static_cast<GLenum>(c.cap);
if (!validators_->capability.IsValid(cap)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glEnable", cap, "cap");
return error::kNoError;
}
DoEnable(cap);
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleEnableVertexAttribArray(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
const volatile gles2::cmds::EnableVertexAttribArray& c =
*static_cast<const volatile gles2::cmds::EnableVertexAttribArray*>(
cmd_data);
GLuint index = static_cast<GLuint>(c.index);
DoEnableVertexAttribArray(index);
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleFenceSync(uint32_t immediate_data_size,
const volatile void* cmd_data) {
if (!feature_info_->IsWebGL2OrES3OrHigherContext())
return error::kUnknownCommand;
const volatile gles2::cmds::FenceSync& c =
*static_cast<const volatile gles2::cmds::FenceSync*>(cmd_data);
GLenum condition = static_cast<GLenum>(c.condition);
GLbitfield flags = static_cast<GLbitfield>(c.flags);
uint32_t client_id = c.client_id;
GLsync service_id = 0;
if (group_->GetSyncServiceId(client_id, &service_id)) {
return error::kInvalidArguments;
}
service_id = DoFenceSync(condition, flags);
if (service_id) {
group_->AddSyncId(client_id, service_id);
}
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleFinish(uint32_t immediate_data_size,
const volatile void* cmd_data) {
error::Error error;
error = WillAccessBoundFramebufferForRead();
if (error != error::kNoError)
return error;
DoFinish();
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleFlush(uint32_t immediate_data_size,
const volatile void* cmd_data) {
DoFlush();
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleFramebufferRenderbuffer(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
const volatile gles2::cmds::FramebufferRenderbuffer& c =
*static_cast<const volatile gles2::cmds::FramebufferRenderbuffer*>(
cmd_data);
GLenum target = static_cast<GLenum>(c.target);
GLenum attachment = static_cast<GLenum>(c.attachment);
GLenum renderbuffertarget = static_cast<GLenum>(c.renderbuffertarget);
GLuint renderbuffer = c.renderbuffer;
if (!validators_->framebuffer_target.IsValid(target)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glFramebufferRenderbuffer", target,
"target");
return error::kNoError;
}
if (!validators_->attachment.IsValid(attachment)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glFramebufferRenderbuffer", attachment,
"attachment");
return error::kNoError;
}
if (!validators_->render_buffer_target.IsValid(renderbuffertarget)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glFramebufferRenderbuffer",
renderbuffertarget, "renderbuffertarget");
return error::kNoError;
}
DoFramebufferRenderbuffer(target, attachment, renderbuffertarget,
renderbuffer);
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleFramebufferTexture2D(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
const volatile gles2::cmds::FramebufferTexture2D& c =
*static_cast<const volatile gles2::cmds::FramebufferTexture2D*>(cmd_data);
GLenum target = static_cast<GLenum>(c.target);
GLenum attachment = static_cast<GLenum>(c.attachment);
GLenum textarget = static_cast<GLenum>(c.textarget);
GLuint texture = c.texture;
GLint level = static_cast<GLint>(c.level);
if (!validators_->framebuffer_target.IsValid(target)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glFramebufferTexture2D", target, "target");
return error::kNoError;
}
if (!validators_->attachment.IsValid(attachment)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glFramebufferTexture2D", attachment,
"attachment");
return error::kNoError;
}
if (!validators_->texture_target.IsValid(textarget)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glFramebufferTexture2D", textarget,
"textarget");
return error::kNoError;
}
DoFramebufferTexture2D(target, attachment, textarget, texture, level);
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleFramebufferTextureLayer(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
if (!feature_info_->IsWebGL2OrES3OrHigherContext())
return error::kUnknownCommand;
const volatile gles2::cmds::FramebufferTextureLayer& c =
*static_cast<const volatile gles2::cmds::FramebufferTextureLayer*>(
cmd_data);
GLenum target = static_cast<GLenum>(c.target);
GLenum attachment = static_cast<GLenum>(c.attachment);
GLuint texture = c.texture;
GLint level = static_cast<GLint>(c.level);
GLint layer = static_cast<GLint>(c.layer);
if (!validators_->framebuffer_target.IsValid(target)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glFramebufferTextureLayer", target,
"target");
return error::kNoError;
}
if (!validators_->attachment.IsValid(attachment)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glFramebufferTextureLayer", attachment,
"attachment");
return error::kNoError;
}
DoFramebufferTextureLayer(target, attachment, texture, level, layer);
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleFrontFace(uint32_t immediate_data_size,
const volatile void* cmd_data) {
const volatile gles2::cmds::FrontFace& c =
*static_cast<const volatile gles2::cmds::FrontFace*>(cmd_data);
GLenum mode = static_cast<GLenum>(c.mode);
if (!validators_->face_mode.IsValid(mode)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glFrontFace", mode, "mode");
return error::kNoError;
}
if (state_.front_face != mode) {
state_.front_face = mode;
api()->glFrontFaceFn(mode);
}
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleGenBuffersImmediate(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
const volatile gles2::cmds::GenBuffersImmediate& c =
*static_cast<const volatile gles2::cmds::GenBuffersImmediate*>(cmd_data);
GLsizei n = static_cast<GLsizei>(c.n);
uint32_t buffers_size;
if (!SafeMultiplyUint32(n, sizeof(GLuint), &buffers_size)) {
return error::kOutOfBounds;
}
volatile GLuint* buffers = GetImmediateDataAs<volatile GLuint*>(
c, buffers_size, immediate_data_size);
if (buffers == nullptr) {
return error::kOutOfBounds;
}
auto buffers_copy = std::make_unique<GLuint[]>(n);
GLuint* buffers_safe = buffers_copy.get();
std::copy(buffers, buffers + n, buffers_safe);
if (!CheckUniqueAndNonNullIds(n, buffers_safe) ||
!GenBuffersHelper(n, buffers_safe)) {
return error::kInvalidArguments;
}
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleGenerateMipmap(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
const volatile gles2::cmds::GenerateMipmap& c =
*static_cast<const volatile gles2::cmds::GenerateMipmap*>(cmd_data);
GLenum target = static_cast<GLenum>(c.target);
if (!validators_->texture_bind_target.IsValid(target)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glGenerateMipmap", target, "target");
return error::kNoError;
}
DoGenerateMipmap(target);
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleGenFramebuffersImmediate(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
const volatile gles2::cmds::GenFramebuffersImmediate& c =
*static_cast<const volatile gles2::cmds::GenFramebuffersImmediate*>(
cmd_data);
GLsizei n = static_cast<GLsizei>(c.n);
uint32_t framebuffers_size;
if (!SafeMultiplyUint32(n, sizeof(GLuint), &framebuffers_size)) {
return error::kOutOfBounds;
}
volatile GLuint* framebuffers = GetImmediateDataAs<volatile GLuint*>(
c, framebuffers_size, immediate_data_size);
if (framebuffers == nullptr) {
return error::kOutOfBounds;
}
auto framebuffers_copy = std::make_unique<GLuint[]>(n);
GLuint* framebuffers_safe = framebuffers_copy.get();
std::copy(framebuffers, framebuffers + n, framebuffers_safe);
if (!CheckUniqueAndNonNullIds(n, framebuffers_safe) ||
!GenFramebuffersHelper(n, framebuffers_safe)) {
return error::kInvalidArguments;
}
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleGenRenderbuffersImmediate(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
const volatile gles2::cmds::GenRenderbuffersImmediate& c =
*static_cast<const volatile gles2::cmds::GenRenderbuffersImmediate*>(
cmd_data);
GLsizei n = static_cast<GLsizei>(c.n);
uint32_t renderbuffers_size;
if (!SafeMultiplyUint32(n, sizeof(GLuint), &renderbuffers_size)) {
return error::kOutOfBounds;
}
volatile GLuint* renderbuffers = GetImmediateDataAs<volatile GLuint*>(
c, renderbuffers_size, immediate_data_size);
if (renderbuffers == nullptr) {
return error::kOutOfBounds;
}
auto renderbuffers_copy = std::make_unique<GLuint[]>(n);
GLuint* renderbuffers_safe = renderbuffers_copy.get();
std::copy(renderbuffers, renderbuffers + n, renderbuffers_safe);
if (!CheckUniqueAndNonNullIds(n, renderbuffers_safe) ||
!GenRenderbuffersHelper(n, renderbuffers_safe)) {
return error::kInvalidArguments;
}
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleGenSamplersImmediate(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
if (!feature_info_->IsWebGL2OrES3OrHigherContext())
return error::kUnknownCommand;
const volatile gles2::cmds::GenSamplersImmediate& c =
*static_cast<const volatile gles2::cmds::GenSamplersImmediate*>(cmd_data);
GLsizei n = static_cast<GLsizei>(c.n);
uint32_t samplers_size;
if (!SafeMultiplyUint32(n, sizeof(GLuint), &samplers_size)) {
return error::kOutOfBounds;
}
volatile GLuint* samplers = GetImmediateDataAs<volatile GLuint*>(
c, samplers_size, immediate_data_size);
if (samplers == nullptr) {
return error::kOutOfBounds;
}
auto samplers_copy = std::make_unique<GLuint[]>(n);
GLuint* samplers_safe = samplers_copy.get();
std::copy(samplers, samplers + n, samplers_safe);
if (!CheckUniqueAndNonNullIds(n, samplers_safe) ||
!GenSamplersHelper(n, samplers_safe)) {
return error::kInvalidArguments;
}
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleGenTexturesImmediate(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
const volatile gles2::cmds::GenTexturesImmediate& c =
*static_cast<const volatile gles2::cmds::GenTexturesImmediate*>(cmd_data);
GLsizei n = static_cast<GLsizei>(c.n);
uint32_t textures_size;
if (!SafeMultiplyUint32(n, sizeof(GLuint), &textures_size)) {
return error::kOutOfBounds;
}
volatile GLuint* textures = GetImmediateDataAs<volatile GLuint*>(
c, textures_size, immediate_data_size);
if (textures == nullptr) {
return error::kOutOfBounds;
}
auto textures_copy = std::make_unique<GLuint[]>(n);
GLuint* textures_safe = textures_copy.get();
std::copy(textures, textures + n, textures_safe);
if (!CheckUniqueAndNonNullIds(n, textures_safe) ||
!GenTexturesHelper(n, textures_safe)) {
return error::kInvalidArguments;
}
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleGenTransformFeedbacksImmediate(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
if (!feature_info_->IsWebGL2OrES3OrHigherContext())
return error::kUnknownCommand;
const volatile gles2::cmds::GenTransformFeedbacksImmediate& c =
*static_cast<const volatile gles2::cmds::GenTransformFeedbacksImmediate*>(
cmd_data);
GLsizei n = static_cast<GLsizei>(c.n);
uint32_t ids_size;
if (!SafeMultiplyUint32(n, sizeof(GLuint), &ids_size)) {
return error::kOutOfBounds;
}
volatile GLuint* ids =
GetImmediateDataAs<volatile GLuint*>(c, ids_size, immediate_data_size);
if (ids == nullptr) {
return error::kOutOfBounds;
}
auto ids_copy = std::make_unique<GLuint[]>(n);
GLuint* ids_safe = ids_copy.get();
std::copy(ids, ids + n, ids_safe);
if (!CheckUniqueAndNonNullIds(n, ids_safe) ||
!GenTransformFeedbacksHelper(n, ids_safe)) {
return error::kInvalidArguments;
}
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleGetBooleanv(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
const volatile gles2::cmds::GetBooleanv& c =
*static_cast<const volatile gles2::cmds::GetBooleanv*>(cmd_data);
GLenum pname = static_cast<GLenum>(c.pname);
typedef cmds::GetBooleanv::Result Result;
GLsizei num_values = 0;
if (!GetNumValuesReturnedForGLGet(pname, &num_values)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM(":GetBooleanv", pname, "pname");
return error::kNoError;
}
uint32_t checked_size = 0;
if (!Result::ComputeSize(num_values).AssignIfValid(&checked_size)) {
return error::kOutOfBounds;
}
Result* result = GetSharedMemoryAs<Result*>(
c.params_shm_id, c.params_shm_offset, checked_size);
GLboolean* params = result ? result->GetData() : nullptr;
if (!validators_->g_l_state.IsValid(pname)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetBooleanv", pname, "pname");
return error::kNoError;
}
if (params == nullptr) {
return error::kOutOfBounds;
}
LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetBooleanv");
// Check that the client initialized the result.
if (result->size != 0) {
return error::kInvalidArguments;
}
DoGetBooleanv(pname, params, num_values);
GLenum error = LOCAL_PEEK_GL_ERROR("GetBooleanv");
if (error == GL_NO_ERROR) {
result->SetNumResults(num_values);
}
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleGetBufferParameteri64v(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
if (!feature_info_->IsWebGL2OrES3OrHigherContext())
return error::kUnknownCommand;
const volatile gles2::cmds::GetBufferParameteri64v& c =
*static_cast<const volatile gles2::cmds::GetBufferParameteri64v*>(
cmd_data);
GLenum target = static_cast<GLenum>(c.target);
GLenum pname = static_cast<GLenum>(c.pname);
typedef cmds::GetBufferParameteri64v::Result Result;
GLsizei num_values = 0;
if (!GetNumValuesReturnedForGLGet(pname, &num_values)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM(":GetBufferParameteri64v", pname, "pname");
return error::kNoError;
}
uint32_t checked_size = 0;
if (!Result::ComputeSize(num_values).AssignIfValid(&checked_size)) {
return error::kOutOfBounds;
}
Result* result = GetSharedMemoryAs<Result*>(
c.params_shm_id, c.params_shm_offset, checked_size);
GLint64* params = result ? result->GetData() : nullptr;
if (!validators_->buffer_target.IsValid(target)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetBufferParameteri64v", target,
"target");
return error::kNoError;
}
if (!validators_->buffer_parameter_64.IsValid(pname)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetBufferParameteri64v", pname, "pname");
return error::kNoError;
}
if (params == nullptr) {
return error::kOutOfBounds;
}
// Check that the client initialized the result.
if (result->size != 0) {
return error::kInvalidArguments;
}
DoGetBufferParameteri64v(target, pname, params, num_values);
result->SetNumResults(num_values);
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleGetBufferParameteriv(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
const volatile gles2::cmds::GetBufferParameteriv& c =
*static_cast<const volatile gles2::cmds::GetBufferParameteriv*>(cmd_data);
GLenum target = static_cast<GLenum>(c.target);
GLenum pname = static_cast<GLenum>(c.pname);
typedef cmds::GetBufferParameteriv::Result Result;
GLsizei num_values = 0;
if (!GetNumValuesReturnedForGLGet(pname, &num_values)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM(":GetBufferParameteriv", pname, "pname");
return error::kNoError;
}
uint32_t checked_size = 0;
if (!Result::ComputeSize(num_values).AssignIfValid(&checked_size)) {
return error::kOutOfBounds;
}
Result* result = GetSharedMemoryAs<Result*>(
c.params_shm_id, c.params_shm_offset, checked_size);
GLint* params = result ? result->GetData() : nullptr;
if (!validators_->buffer_target.IsValid(target)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetBufferParameteriv", target, "target");
return error::kNoError;
}
if (!validators_->buffer_parameter.IsValid(pname)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetBufferParameteriv", pname, "pname");
return error::kNoError;
}
if (params == nullptr) {
return error::kOutOfBounds;
}
// Check that the client initialized the result.
if (result->size != 0) {
return error::kInvalidArguments;
}
DoGetBufferParameteriv(target, pname, params, num_values);
result->SetNumResults(num_values);
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleGetError(uint32_t immediate_data_size,
const volatile void* cmd_data) {
const volatile gles2::cmds::GetError& c =
*static_cast<const volatile gles2::cmds::GetError*>(cmd_data);
typedef cmds::GetError::Result Result;
Result* result_dst = GetSharedMemoryAs<Result*>(
c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
if (!result_dst) {
return error::kOutOfBounds;
}
*result_dst = GetErrorState()->GetGLError();
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleGetFloatv(uint32_t immediate_data_size,
const volatile void* cmd_data) {
const volatile gles2::cmds::GetFloatv& c =
*static_cast<const volatile gles2::cmds::GetFloatv*>(cmd_data);
GLenum pname = static_cast<GLenum>(c.pname);
typedef cmds::GetFloatv::Result Result;
GLsizei num_values = 0;
if (!GetNumValuesReturnedForGLGet(pname, &num_values)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM(":GetFloatv", pname, "pname");
return error::kNoError;
}
uint32_t checked_size = 0;
if (!Result::ComputeSize(num_values).AssignIfValid(&checked_size)) {
return error::kOutOfBounds;
}
Result* result = GetSharedMemoryAs<Result*>(
c.params_shm_id, c.params_shm_offset, checked_size);
GLfloat* params = result ? result->GetData() : nullptr;
if (!validators_->g_l_state.IsValid(pname)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetFloatv", pname, "pname");
return error::kNoError;
}
if (params == nullptr) {
return error::kOutOfBounds;
}
LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetFloatv");
// Check that the client initialized the result.
if (result->size != 0) {
return error::kInvalidArguments;
}
DoGetFloatv(pname, params, num_values);
GLenum error = LOCAL_PEEK_GL_ERROR("GetFloatv");
if (error == GL_NO_ERROR) {
result->SetNumResults(num_values);
}
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleGetFramebufferAttachmentParameteriv(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
const volatile gles2::cmds::GetFramebufferAttachmentParameteriv& c =
*static_cast<
const volatile gles2::cmds::GetFramebufferAttachmentParameteriv*>(
cmd_data);
GLenum target = static_cast<GLenum>(c.target);
GLenum attachment = static_cast<GLenum>(c.attachment);
GLenum pname = static_cast<GLenum>(c.pname);
typedef cmds::GetFramebufferAttachmentParameteriv::Result Result;
GLsizei num_values = 0;
if (!GetNumValuesReturnedForGLGet(pname, &num_values)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM(":GetFramebufferAttachmentParameteriv",
pname, "pname");
return error::kNoError;
}
uint32_t checked_size = 0;
if (!Result::ComputeSize(num_values).AssignIfValid(&checked_size)) {
return error::kOutOfBounds;
}
Result* result = GetSharedMemoryAs<Result*>(
c.params_shm_id, c.params_shm_offset, checked_size);
GLint* params = result ? result->GetData() : nullptr;
if (!validators_->framebuffer_target.IsValid(target)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetFramebufferAttachmentParameteriv",
target, "target");
return error::kNoError;
}
if (!validators_->attachment_query.IsValid(attachment)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetFramebufferAttachmentParameteriv",
attachment, "attachment");
return error::kNoError;
}
if (!validators_->framebuffer_attachment_parameter.IsValid(pname)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetFramebufferAttachmentParameteriv",
pname, "pname");
return error::kNoError;
}
if (params == nullptr) {
return error::kOutOfBounds;
}
LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetFramebufferAttachmentParameteriv");
// Check that the client initialized the result.
if (result->size != 0) {
return error::kInvalidArguments;
}
DoGetFramebufferAttachmentParameteriv(target, attachment, pname, params,
num_values);
GLenum error = LOCAL_PEEK_GL_ERROR("GetFramebufferAttachmentParameteriv");
if (error == GL_NO_ERROR) {
result->SetNumResults(num_values);
}
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleGetInteger64v(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
if (!feature_info_->IsWebGL2OrES3OrHigherContext())
return error::kUnknownCommand;
const volatile gles2::cmds::GetInteger64v& c =
*static_cast<const volatile gles2::cmds::GetInteger64v*>(cmd_data);
GLenum pname = static_cast<GLenum>(c.pname);
typedef cmds::GetInteger64v::Result Result;
GLsizei num_values = 0;
if (!GetNumValuesReturnedForGLGet(pname, &num_values)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM(":GetInteger64v", pname, "pname");
return error::kNoError;
}
uint32_t checked_size = 0;
if (!Result::ComputeSize(num_values).AssignIfValid(&checked_size)) {
return error::kOutOfBounds;
}
Result* result = GetSharedMemoryAs<Result*>(
c.params_shm_id, c.params_shm_offset, checked_size);
GLint64* params = result ? result->GetData() : nullptr;
if (!validators_->g_l_state.IsValid(pname)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetInteger64v", pname, "pname");
return error::kNoError;
}
if (params == nullptr) {
return error::kOutOfBounds;
}
LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetInteger64v");
// Check that the client initialized the result.
if (result->size != 0) {
return error::kInvalidArguments;
}
DoGetInteger64v(pname, params, num_values);
GLenum error = LOCAL_PEEK_GL_ERROR("GetInteger64v");
if (error == GL_NO_ERROR) {
result->SetNumResults(num_values);
}
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleGetIntegeri_v(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
if (!feature_info_->IsWebGL2OrES3OrHigherContext())
return error::kUnknownCommand;
const volatile gles2::cmds::GetIntegeri_v& c =
*static_cast<const volatile gles2::cmds::GetIntegeri_v*>(cmd_data);
GLenum pname = static_cast<GLenum>(c.pname);
GLuint index = static_cast<GLuint>(c.index);
typedef cmds::GetIntegeri_v::Result Result;
GLsizei num_values = 0;
if (!GetNumValuesReturnedForGLGet(pname, &num_values)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM(":GetIntegeri_v", pname, "pname");
return error::kNoError;
}
uint32_t checked_size = 0;
if (!Result::ComputeSize(num_values).AssignIfValid(&checked_size)) {
return error::kOutOfBounds;
}
Result* result = GetSharedMemoryAs<Result*>(c.data_shm_id, c.data_shm_offset,
checked_size);
GLint* data = result ? result->GetData() : nullptr;
if (!validators_->indexed_g_l_state.IsValid(pname)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetIntegeri_v", pname, "pname");
return error::kNoError;
}
if (data == nullptr) {
return error::kOutOfBounds;
}
// Check that the client initialized the result.
if (result->size != 0) {
return error::kInvalidArguments;
}
DoGetIntegeri_v(pname, index, data, num_values);
result->SetNumResults(num_values);
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleGetInteger64i_v(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
if (!feature_info_->IsWebGL2OrES3OrHigherContext())
return error::kUnknownCommand;
const volatile gles2::cmds::GetInteger64i_v& c =
*static_cast<const volatile gles2::cmds::GetInteger64i_v*>(cmd_data);
GLenum pname = static_cast<GLenum>(c.pname);
GLuint index = static_cast<GLuint>(c.index);
typedef cmds::GetInteger64i_v::Result Result;
GLsizei num_values = 0;
if (!GetNumValuesReturnedForGLGet(pname, &num_values)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM(":GetInteger64i_v", pname, "pname");
return error::kNoError;
}
uint32_t checked_size = 0;
if (!Result::ComputeSize(num_values).AssignIfValid(&checked_size)) {
return error::kOutOfBounds;
}
Result* result = GetSharedMemoryAs<Result*>(c.data_shm_id, c.data_shm_offset,
checked_size);
GLint64* data = result ? result->GetData() : nullptr;
if (!validators_->indexed_g_l_state.IsValid(pname)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetInteger64i_v", pname, "pname");
return error::kNoError;
}
if (data == nullptr) {
return error::kOutOfBounds;
}
// Check that the client initialized the result.
if (result->size != 0) {
return error::kInvalidArguments;
}
DoGetInteger64i_v(pname, index, data, num_values);
result->SetNumResults(num_values);
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleGetIntegerv(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
const volatile gles2::cmds::GetIntegerv& c =
*static_cast<const volatile gles2::cmds::GetIntegerv*>(cmd_data);
GLenum pname = static_cast<GLenum>(c.pname);
typedef cmds::GetIntegerv::Result Result;
GLsizei num_values = 0;
if (!GetNumValuesReturnedForGLGet(pname, &num_values)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM(":GetIntegerv", pname, "pname");
return error::kNoError;
}
uint32_t checked_size = 0;
if (!Result::ComputeSize(num_values).AssignIfValid(&checked_size)) {
return error::kOutOfBounds;
}
Result* result = GetSharedMemoryAs<Result*>(
c.params_shm_id, c.params_shm_offset, checked_size);
GLint* params = result ? result->GetData() : nullptr;
if (!validators_->g_l_state.IsValid(pname)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetIntegerv", pname, "pname");
return error::kNoError;
}
if (params == nullptr) {
return error::kOutOfBounds;
}
LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetIntegerv");
// Check that the client initialized the result.
if (result->size != 0) {
return error::kInvalidArguments;
}
DoGetIntegerv(pname, params, num_values);
GLenum error = LOCAL_PEEK_GL_ERROR("GetIntegerv");
if (error == GL_NO_ERROR) {
result->SetNumResults(num_values);
}
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleGetProgramiv(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
const volatile gles2::cmds::GetProgramiv& c =
*static_cast<const volatile gles2::cmds::GetProgramiv*>(cmd_data);
GLuint program = c.program;
GLenum pname = static_cast<GLenum>(c.pname);
typedef cmds::GetProgramiv::Result Result;
GLsizei num_values = 0;
if (!GetNumValuesReturnedForGLGet(pname, &num_values)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM(":GetProgramiv", pname, "pname");
return error::kNoError;
}
uint32_t checked_size = 0;
if (!Result::ComputeSize(num_values).AssignIfValid(&checked_size)) {
return error::kOutOfBounds;
}
Result* result = GetSharedMemoryAs<Result*>(
c.params_shm_id, c.params_shm_offset, checked_size);
GLint* params = result ? result->GetData() : nullptr;
if (!validators_->program_parameter.IsValid(pname)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetProgramiv", pname, "pname");
return error::kNoError;
}
if (params == nullptr) {
return error::kOutOfBounds;
}
LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetProgramiv");
// Check that the client initialized the result.
if (result->size != 0) {
return error::kInvalidArguments;
}
DoGetProgramiv(program, pname, params, num_values);
GLenum error = LOCAL_PEEK_GL_ERROR("GetProgramiv");
if (error == GL_NO_ERROR) {
result->SetNumResults(num_values);
}
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleGetRenderbufferParameteriv(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
const volatile gles2::cmds::GetRenderbufferParameteriv& c =
*static_cast<const volatile gles2::cmds::GetRenderbufferParameteriv*>(
cmd_data);
GLenum target = static_cast<GLenum>(c.target);
GLenum pname = static_cast<GLenum>(c.pname);
typedef cmds::GetRenderbufferParameteriv::Result Result;
GLsizei num_values = 0;
if (!GetNumValuesReturnedForGLGet(pname, &num_values)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM(":GetRenderbufferParameteriv", pname,
"pname");
return error::kNoError;
}
uint32_t checked_size = 0;
if (!Result::ComputeSize(num_values).AssignIfValid(&checked_size)) {
return error::kOutOfBounds;
}
Result* result = GetSharedMemoryAs<Result*>(
c.params_shm_id, c.params_shm_offset, checked_size);
GLint* params = result ? result->GetData() : nullptr;
if (!validators_->render_buffer_target.IsValid(target)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetRenderbufferParameteriv", target,
"target");
return error::kNoError;
}
if (!validators_->render_buffer_parameter.IsValid(pname)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetRenderbufferParameteriv", pname,
"pname");
return error::kNoError;
}
if (params == nullptr) {
return error::kOutOfBounds;
}
LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetRenderbufferParameteriv");
// Check that the client initialized the result.
if (result->size != 0) {
return error::kInvalidArguments;
}
DoGetRenderbufferParameteriv(target, pname, params, num_values);
GLenum error = LOCAL_PEEK_GL_ERROR("GetRenderbufferParameteriv");
if (error == GL_NO_ERROR) {
result->SetNumResults(num_values);
}
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleGetSamplerParameterfv(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
if (!feature_info_->IsWebGL2OrES3OrHigherContext())
return error::kUnknownCommand;
const volatile gles2::cmds::GetSamplerParameterfv& c =
*static_cast<const volatile gles2::cmds::GetSamplerParameterfv*>(
cmd_data);
GLuint sampler = c.sampler;
GLenum pname = static_cast<GLenum>(c.pname);
typedef cmds::GetSamplerParameterfv::Result Result;
GLsizei num_values = 0;
if (!GetNumValuesReturnedForGLGet(pname, &num_values)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM(":GetSamplerParameterfv", pname, "pname");
return error::kNoError;
}
uint32_t checked_size = 0;
if (!Result::ComputeSize(num_values).AssignIfValid(&checked_size)) {
return error::kOutOfBounds;
}
Result* result = GetSharedMemoryAs<Result*>(
c.params_shm_id, c.params_shm_offset, checked_size);
GLfloat* params = result ? result->GetData() : nullptr;
if (!validators_->sampler_parameter.IsValid(pname)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetSamplerParameterfv", pname, "pname");
return error::kNoError;
}
if (params == nullptr) {
return error::kOutOfBounds;
}
LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetSamplerParameterfv");
// Check that the client initialized the result.
if (result->size != 0) {
return error::kInvalidArguments;
}
DoGetSamplerParameterfv(sampler, pname, params, num_values);
GLenum error = LOCAL_PEEK_GL_ERROR("GetSamplerParameterfv");
if (error == GL_NO_ERROR) {
result->SetNumResults(num_values);
}
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleGetSamplerParameteriv(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
if (!feature_info_->IsWebGL2OrES3OrHigherContext())
return error::kUnknownCommand;
const volatile gles2::cmds::GetSamplerParameteriv& c =
*static_cast<const volatile gles2::cmds::GetSamplerParameteriv*>(
cmd_data);
GLuint sampler = c.sampler;
GLenum pname = static_cast<GLenum>(c.pname);
typedef cmds::GetSamplerParameteriv::Result Result;
GLsizei num_values = 0;
if (!GetNumValuesReturnedForGLGet(pname, &num_values)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM(":GetSamplerParameteriv", pname, "pname");
return error::kNoError;
}
uint32_t checked_size = 0;
if (!Result::ComputeSize(num_values).AssignIfValid(&checked_size)) {
return error::kOutOfBounds;
}
Result* result = GetSharedMemoryAs<Result*>(
c.params_shm_id, c.params_shm_offset, checked_size);
GLint* params = result ? result->GetData() : nullptr;
if (!validators_->sampler_parameter.IsValid(pname)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetSamplerParameteriv", pname, "pname");
return error::kNoError;
}
if (params == nullptr) {
return error::kOutOfBounds;
}
LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetSamplerParameteriv");
// Check that the client initialized the result.
if (result->size != 0) {
return error::kInvalidArguments;
}
DoGetSamplerParameteriv(sampler, pname, params, num_values);
GLenum error = LOCAL_PEEK_GL_ERROR("GetSamplerParameteriv");
if (error == GL_NO_ERROR) {
result->SetNumResults(num_values);
}
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleGetShaderiv(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
const volatile gles2::cmds::GetShaderiv& c =
*static_cast<const volatile gles2::cmds::GetShaderiv*>(cmd_data);
GLuint shader = c.shader;
GLenum pname = static_cast<GLenum>(c.pname);
typedef cmds::GetShaderiv::Result Result;
GLsizei num_values = 0;
if (!GetNumValuesReturnedForGLGet(pname, &num_values)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM(":GetShaderiv", pname, "pname");
return error::kNoError;
}
uint32_t checked_size = 0;
if (!Result::ComputeSize(num_values).AssignIfValid(&checked_size)) {
return error::kOutOfBounds;
}
Result* result = GetSharedMemoryAs<Result*>(
c.params_shm_id, c.params_shm_offset, checked_size);
GLint* params = result ? result->GetData() : nullptr;
if (!validators_->shader_parameter.IsValid(pname)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetShaderiv", pname, "pname");
return error::kNoError;
}
if (params == nullptr) {
return error::kOutOfBounds;
}
LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetShaderiv");
// Check that the client initialized the result.
if (result->size != 0) {
return error::kInvalidArguments;
}
DoGetShaderiv(shader, pname, params, num_values);
GLenum error = LOCAL_PEEK_GL_ERROR("GetShaderiv");
if (error == GL_NO_ERROR) {
result->SetNumResults(num_values);
}
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleGetSynciv(uint32_t immediate_data_size,
const volatile void* cmd_data) {
if (!feature_info_->IsWebGL2OrES3OrHigherContext())
return error::kUnknownCommand;
const volatile gles2::cmds::GetSynciv& c =
*static_cast<const volatile gles2::cmds::GetSynciv*>(cmd_data);
GLuint sync = static_cast<GLuint>(c.sync);
GLenum pname = static_cast<GLenum>(c.pname);
typedef cmds::GetSynciv::Result Result;
GLsizei num_values = 0;
if (!GetNumValuesReturnedForGLGet(pname, &num_values)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM(":GetSynciv", pname, "pname");
return error::kNoError;
}
uint32_t checked_size = 0;
if (!Result::ComputeSize(num_values).AssignIfValid(&checked_size)) {
return error::kOutOfBounds;
}
Result* result = GetSharedMemoryAs<Result*>(
c.values_shm_id, c.values_shm_offset, checked_size);
GLint* values = result ? result->GetData() : nullptr;
if (!validators_->sync_parameter.IsValid(pname)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetSynciv", pname, "pname");
return error::kNoError;
}
if (values == nullptr) {
return error::kOutOfBounds;
}
LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetSynciv");
// Check that the client initialized the result.
if (result->size != 0) {
return error::kInvalidArguments;
}
DoGetSynciv(sync, pname, num_values, nullptr, values);
GLenum error = LOCAL_PEEK_GL_ERROR("GetSynciv");
if (error == GL_NO_ERROR) {
result->SetNumResults(num_values);
}
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleGetTexParameterfv(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
const volatile gles2::cmds::GetTexParameterfv& c =
*static_cast<const volatile gles2::cmds::GetTexParameterfv*>(cmd_data);
GLenum target = static_cast<GLenum>(c.target);
GLenum pname = static_cast<GLenum>(c.pname);
typedef cmds::GetTexParameterfv::Result Result;
GLsizei num_values = 0;
if (!GetNumValuesReturnedForGLGet(pname, &num_values)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM(":GetTexParameterfv", pname, "pname");
return error::kNoError;
}
uint32_t checked_size = 0;
if (!Result::ComputeSize(num_values).AssignIfValid(&checked_size)) {
return error::kOutOfBounds;
}
Result* result = GetSharedMemoryAs<Result*>(
c.params_shm_id, c.params_shm_offset, checked_size);
GLfloat* params = result ? result->GetData() : nullptr;
if (!validators_->get_tex_param_target.IsValid(target)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetTexParameterfv", target, "target");
return error::kNoError;
}
if (!validators_->texture_parameter.IsValid(pname)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetTexParameterfv", pname, "pname");
return error::kNoError;
}
if (params == nullptr) {
return error::kOutOfBounds;
}
LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetTexParameterfv");
// Check that the client initialized the result.
if (result->size != 0) {
return error::kInvalidArguments;
}
DoGetTexParameterfv(target, pname, params, num_values);
GLenum error = LOCAL_PEEK_GL_ERROR("GetTexParameterfv");
if (error == GL_NO_ERROR) {
result->SetNumResults(num_values);
}
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleGetTexParameteriv(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
const volatile gles2::cmds::GetTexParameteriv& c =
*static_cast<const volatile gles2::cmds::GetTexParameteriv*>(cmd_data);
GLenum target = static_cast<GLenum>(c.target);
GLenum pname = static_cast<GLenum>(c.pname);
typedef cmds::GetTexParameteriv::Result Result;
GLsizei num_values = 0;
if (!GetNumValuesReturnedForGLGet(pname, &num_values)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM(":GetTexParameteriv", pname, "pname");
return error::kNoError;
}
uint32_t checked_size = 0;
if (!Result::ComputeSize(num_values).AssignIfValid(&checked_size)) {
return error::kOutOfBounds;
}
Result* result = GetSharedMemoryAs<Result*>(
c.params_shm_id, c.params_shm_offset, checked_size);
GLint* params = result ? result->GetData() : nullptr;
if (!validators_->get_tex_param_target.IsValid(target)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetTexParameteriv", target, "target");
return error::kNoError;
}
if (!validators_->texture_parameter.IsValid(pname)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetTexParameteriv", pname, "pname");
return error::kNoError;
}
if (params == nullptr) {
return error::kOutOfBounds;
}
LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetTexParameteriv");
// Check that the client initialized the result.
if (result->size != 0) {
return error::kInvalidArguments;
}
DoGetTexParameteriv(target, pname, params, num_values);
GLenum error = LOCAL_PEEK_GL_ERROR("GetTexParameteriv");
if (error == GL_NO_ERROR) {
result->SetNumResults(num_values);
}
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleGetVertexAttribfv(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
const volatile gles2::cmds::GetVertexAttribfv& c =
*static_cast<const volatile gles2::cmds::GetVertexAttribfv*>(cmd_data);
GLuint index = static_cast<GLuint>(c.index);
GLenum pname = static_cast<GLenum>(c.pname);
typedef cmds::GetVertexAttribfv::Result Result;
GLsizei num_values = 0;
if (!GetNumValuesReturnedForGLGet(pname, &num_values)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM(":GetVertexAttribfv", pname, "pname");
return error::kNoError;
}
uint32_t checked_size = 0;
if (!Result::ComputeSize(num_values).AssignIfValid(&checked_size)) {
return error::kOutOfBounds;
}
Result* result = GetSharedMemoryAs<Result*>(
c.params_shm_id, c.params_shm_offset, checked_size);
GLfloat* params = result ? result->GetData() : nullptr;
if (!validators_->vertex_attribute.IsValid(pname)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetVertexAttribfv", pname, "pname");
return error::kNoError;
}
if (params == nullptr) {
return error::kOutOfBounds;
}
LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetVertexAttribfv");
// Check that the client initialized the result.
if (result->size != 0) {
return error::kInvalidArguments;
}
DoGetVertexAttribfv(index, pname, params, num_values);
GLenum error = LOCAL_PEEK_GL_ERROR("GetVertexAttribfv");
if (error == GL_NO_ERROR) {
result->SetNumResults(num_values);
}
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleGetVertexAttribiv(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
const volatile gles2::cmds::GetVertexAttribiv& c =
*static_cast<const volatile gles2::cmds::GetVertexAttribiv*>(cmd_data);
GLuint index = static_cast<GLuint>(c.index);
GLenum pname = static_cast<GLenum>(c.pname);
typedef cmds::GetVertexAttribiv::Result Result;
GLsizei num_values = 0;
if (!GetNumValuesReturnedForGLGet(pname, &num_values)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM(":GetVertexAttribiv", pname, "pname");
return error::kNoError;
}
uint32_t checked_size = 0;
if (!Result::ComputeSize(num_values).AssignIfValid(&checked_size)) {
return error::kOutOfBounds;
}
Result* result = GetSharedMemoryAs<Result*>(
c.params_shm_id, c.params_shm_offset, checked_size);
GLint* params = result ? result->GetData() : nullptr;
if (!validators_->vertex_attribute.IsValid(pname)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetVertexAttribiv", pname, "pname");
return error::kNoError;
}
if (params == nullptr) {
return error::kOutOfBounds;
}
LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetVertexAttribiv");
// Check that the client initialized the result.
if (result->size != 0) {
return error::kInvalidArguments;
}
DoGetVertexAttribiv(index, pname, params, num_values);
GLenum error = LOCAL_PEEK_GL_ERROR("GetVertexAttribiv");
if (error == GL_NO_ERROR) {
result->SetNumResults(num_values);
}
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleGetVertexAttribIiv(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
if (!feature_info_->IsWebGL2OrES3OrHigherContext())
return error::kUnknownCommand;
const volatile gles2::cmds::GetVertexAttribIiv& c =
*static_cast<const volatile gles2::cmds::GetVertexAttribIiv*>(cmd_data);
GLuint index = static_cast<GLuint>(c.index);
GLenum pname = static_cast<GLenum>(c.pname);
typedef cmds::GetVertexAttribIiv::Result Result;
GLsizei num_values = 0;
if (!GetNumValuesReturnedForGLGet(pname, &num_values)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM(":GetVertexAttribIiv", pname, "pname");
return error::kNoError;
}
uint32_t checked_size = 0;
if (!Result::ComputeSize(num_values).AssignIfValid(&checked_size)) {
return error::kOutOfBounds;
}
Result* result = GetSharedMemoryAs<Result*>(
c.params_shm_id, c.params_shm_offset, checked_size);
GLint* params = result ? result->GetData() : nullptr;
if (!validators_->vertex_attribute.IsValid(pname)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetVertexAttribIiv", pname, "pname");
return error::kNoError;
}
if (params == nullptr) {
return error::kOutOfBounds;
}
LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetVertexAttribIiv");
// Check that the client initialized the result.
if (result->size != 0) {
return error::kInvalidArguments;
}
DoGetVertexAttribIiv(index, pname, params, num_values);
GLenum error = LOCAL_PEEK_GL_ERROR("GetVertexAttribIiv");
if (error == GL_NO_ERROR) {
result->SetNumResults(num_values);
}
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleGetVertexAttribIuiv(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
if (!feature_info_->IsWebGL2OrES3OrHigherContext())
return error::kUnknownCommand;
const volatile gles2::cmds::GetVertexAttribIuiv& c =
*static_cast<const volatile gles2::cmds::GetVertexAttribIuiv*>(cmd_data);
GLuint index = static_cast<GLuint>(c.index);
GLenum pname = static_cast<GLenum>(c.pname);
typedef cmds::GetVertexAttribIuiv::Result Result;
GLsizei num_values = 0;
if (!GetNumValuesReturnedForGLGet(pname, &num_values)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM(":GetVertexAttribIuiv", pname, "pname");
return error::kNoError;
}
uint32_t checked_size = 0;
if (!Result::ComputeSize(num_values).AssignIfValid(&checked_size)) {
return error::kOutOfBounds;
}
Result* result = GetSharedMemoryAs<Result*>(
c.params_shm_id, c.params_shm_offset, checked_size);
GLuint* params = result ? result->GetData() : nullptr;
if (!validators_->vertex_attribute.IsValid(pname)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetVertexAttribIuiv", pname, "pname");
return error::kNoError;
}
if (params == nullptr) {
return error::kOutOfBounds;
}
LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetVertexAttribIuiv");
// Check that the client initialized the result.
if (result->size != 0) {
return error::kInvalidArguments;
}
DoGetVertexAttribIuiv(index, pname, params, num_values);
GLenum error = LOCAL_PEEK_GL_ERROR("GetVertexAttribIuiv");
if (error == GL_NO_ERROR) {
result->SetNumResults(num_values);
}
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleHint(uint32_t immediate_data_size,
const volatile void* cmd_data) {
const volatile gles2::cmds::Hint& c =
*static_cast<const volatile gles2::cmds::Hint*>(cmd_data);
GLenum target = static_cast<GLenum>(c.target);
GLenum mode = static_cast<GLenum>(c.mode);
if (!validators_->hint_target.IsValid(target)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glHint", target, "target");
return error::kNoError;
}
if (!validators_->hint_mode.IsValid(mode)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glHint", mode, "mode");
return error::kNoError;
}
switch (target) {
case GL_GENERATE_MIPMAP_HINT:
if (state_.hint_generate_mipmap != mode) {
state_.hint_generate_mipmap = mode;
if (!feature_info_->gl_version_info().is_desktop_core_profile) {
api()->glHintFn(target, mode);
}
}
break;
case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES:
if (state_.hint_fragment_shader_derivative != mode) {
state_.hint_fragment_shader_derivative = mode;
if (feature_info_->feature_flags().oes_standard_derivatives) {
api()->glHintFn(target, mode);
}
}
break;
case GL_TEXTURE_FILTERING_HINT_CHROMIUM:
if (state_.hint_texture_filtering != mode) {
state_.hint_texture_filtering = mode;
if (feature_info_->feature_flags().chromium_texture_filtering_hint) {
api()->glHintFn(target, mode);
}
}
break;
default:
NOTREACHED();
}
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleInvalidateFramebufferImmediate(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
if (!feature_info_->IsWebGL2OrES3OrHigherContext())
return error::kUnknownCommand;
const volatile gles2::cmds::InvalidateFramebufferImmediate& c =
*static_cast<const volatile gles2::cmds::InvalidateFramebufferImmediate*>(
cmd_data);
GLenum target = static_cast<GLenum>(c.target);
GLsizei count = static_cast<GLsizei>(c.count);
uint32_t attachments_size = 0;
if (count >= 0 &&
!GLES2Util::ComputeDataSize<GLenum, 1>(count, &attachments_size)) {
return error::kOutOfBounds;
}
if (attachments_size > immediate_data_size) {
return error::kOutOfBounds;
}
volatile const GLenum* attachments =
GetImmediateDataAs<volatile const GLenum*>(c, attachments_size,
immediate_data_size);
if (!validators_->framebuffer_target.IsValid(target)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glInvalidateFramebuffer", target,
"target");
return error::kNoError;
}
if (count < 0) {
LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glInvalidateFramebuffer",
"count < 0");
return error::kNoError;
}
if (attachments == nullptr) {
return error::kOutOfBounds;
}
DoInvalidateFramebuffer(target, count, attachments);
return error::kNoError;
}
error::Error GLES2DecoderImpl::HandleInvalidateSubFramebufferImmediate(
uint32_t immediate_data_size,
const volatile void* cmd_data) {
if (!feature_info_->IsWebGL2OrES3OrHigherContext())
return error::kUnknownCommand;
const volatile gles2::cmds::InvalidateSubFramebufferImmediate& c =
*static_cast<
const volatile gles2::cmds::InvalidateSubFramebufferImmediate*>(
cmd_data);
GLenum target = static_cast<GLenum>(c.target);
GLsizei count = static_cast<GLsizei>(c.count);
uint32_t attachments_size = 0;
if (count >= 0 &&
!GLES2Util::ComputeDataSize<GLenum, 1>(count, &attachments_size)) {
return error::kOutOfBounds;
}
if (attachments_size > immediate_data_size) {
return error::kOutOfBounds;
}
volatile const GLenum* attachments =
GetImmediateDataAs<volatile const GLenum*>(c, attachments_size,
immediate_data_size);
GLint x = static_cast<GLint>(c.x);
GLint y = static_cast<GLint>(c.y);
GLsizei width = static_cast<GLsizei>(c.width);
GLsizei height = static_cast<GLsizei>(c.height);
if (!validators_->framebuffer_target.IsValid(target)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glInvalidateSubFramebuffer", target,
"target");
return error::kNoError;
}
if (count < 0