1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // This file is auto-generated from
6 // gpu/command_buffer/build_gles2_cmd_buffer.py
7 // It's formatted by clang-format using chromium coding style:
8 // clang-format -i -style=chromium filename
11 // It is included by gles2_cmd_decoder.cc
12 #ifndef GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_AUTOGEN_H_
13 #define GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_AUTOGEN_H_
15 error::Error
GLES2DecoderImpl::HandleActiveTexture(uint32_t immediate_data_size
,
16 const void* cmd_data
) {
17 const gles2::cmds::ActiveTexture
& c
=
18 *static_cast<const gles2::cmds::ActiveTexture
*>(cmd_data
);
20 GLenum texture
= static_cast<GLenum
>(c
.texture
);
21 DoActiveTexture(texture
);
22 return error::kNoError
;
25 error::Error
GLES2DecoderImpl::HandleAttachShader(uint32_t immediate_data_size
,
26 const void* cmd_data
) {
27 const gles2::cmds::AttachShader
& c
=
28 *static_cast<const gles2::cmds::AttachShader
*>(cmd_data
);
30 GLuint program
= c
.program
;
31 GLuint shader
= c
.shader
;
32 DoAttachShader(program
, shader
);
33 return error::kNoError
;
36 error::Error
GLES2DecoderImpl::HandleBindBuffer(uint32_t immediate_data_size
,
37 const void* cmd_data
) {
38 const gles2::cmds::BindBuffer
& c
=
39 *static_cast<const gles2::cmds::BindBuffer
*>(cmd_data
);
41 GLenum target
= static_cast<GLenum
>(c
.target
);
42 GLuint buffer
= c
.buffer
;
43 if (!validators_
->buffer_target
.IsValid(target
)) {
44 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBindBuffer", target
, "target");
45 return error::kNoError
;
47 DoBindBuffer(target
, buffer
);
48 return error::kNoError
;
51 error::Error
GLES2DecoderImpl::HandleBindBufferBase(
52 uint32_t immediate_data_size
,
53 const void* cmd_data
) {
54 if (!unsafe_es3_apis_enabled())
55 return error::kUnknownCommand
;
56 const gles2::cmds::BindBufferBase
& c
=
57 *static_cast<const gles2::cmds::BindBufferBase
*>(cmd_data
);
59 GLenum target
= static_cast<GLenum
>(c
.target
);
60 GLuint index
= static_cast<GLuint
>(c
.index
);
61 GLuint buffer
= c
.buffer
;
62 if (!group_
->GetBufferServiceId(buffer
, &buffer
)) {
63 if (!group_
->bind_generates_resource()) {
64 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION
, "glBindBufferBase",
66 return error::kNoError
;
68 GLuint client_id
= buffer
;
69 glGenBuffersARB(1, &buffer
);
70 CreateBuffer(client_id
, buffer
);
72 glBindBufferBase(target
, index
, buffer
);
73 return error::kNoError
;
76 error::Error
GLES2DecoderImpl::HandleBindBufferRange(
77 uint32_t immediate_data_size
,
78 const void* cmd_data
) {
79 if (!unsafe_es3_apis_enabled())
80 return error::kUnknownCommand
;
81 const gles2::cmds::BindBufferRange
& c
=
82 *static_cast<const gles2::cmds::BindBufferRange
*>(cmd_data
);
84 GLenum target
= static_cast<GLenum
>(c
.target
);
85 GLuint index
= static_cast<GLuint
>(c
.index
);
86 GLuint buffer
= c
.buffer
;
87 GLintptr offset
= static_cast<GLintptr
>(c
.offset
);
88 GLsizeiptr size
= static_cast<GLsizeiptr
>(c
.size
);
89 if (!group_
->GetBufferServiceId(buffer
, &buffer
)) {
90 if (!group_
->bind_generates_resource()) {
91 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION
, "glBindBufferRange",
93 return error::kNoError
;
95 GLuint client_id
= buffer
;
96 glGenBuffersARB(1, &buffer
);
97 CreateBuffer(client_id
, buffer
);
99 glBindBufferRange(target
, index
, buffer
, offset
, size
);
100 return error::kNoError
;
103 error::Error
GLES2DecoderImpl::HandleBindFramebuffer(
104 uint32_t immediate_data_size
,
105 const void* cmd_data
) {
106 const gles2::cmds::BindFramebuffer
& c
=
107 *static_cast<const gles2::cmds::BindFramebuffer
*>(cmd_data
);
109 GLenum target
= static_cast<GLenum
>(c
.target
);
110 GLuint framebuffer
= c
.framebuffer
;
111 if (!validators_
->frame_buffer_target
.IsValid(target
)) {
112 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBindFramebuffer", target
, "target");
113 return error::kNoError
;
115 DoBindFramebuffer(target
, framebuffer
);
116 return error::kNoError
;
119 error::Error
GLES2DecoderImpl::HandleBindRenderbuffer(
120 uint32_t immediate_data_size
,
121 const void* cmd_data
) {
122 const gles2::cmds::BindRenderbuffer
& c
=
123 *static_cast<const gles2::cmds::BindRenderbuffer
*>(cmd_data
);
125 GLenum target
= static_cast<GLenum
>(c
.target
);
126 GLuint renderbuffer
= c
.renderbuffer
;
127 if (!validators_
->render_buffer_target
.IsValid(target
)) {
128 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBindRenderbuffer", target
, "target");
129 return error::kNoError
;
131 DoBindRenderbuffer(target
, renderbuffer
);
132 return error::kNoError
;
135 error::Error
GLES2DecoderImpl::HandleBindSampler(uint32_t immediate_data_size
,
136 const void* cmd_data
) {
137 if (!unsafe_es3_apis_enabled())
138 return error::kUnknownCommand
;
139 const gles2::cmds::BindSampler
& c
=
140 *static_cast<const gles2::cmds::BindSampler
*>(cmd_data
);
142 GLuint unit
= static_cast<GLuint
>(c
.unit
);
143 GLuint sampler
= c
.sampler
;
144 if (!group_
->GetSamplerServiceId(sampler
, &sampler
)) {
145 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION
, "glBindSampler",
146 "invalid sampler id");
147 return error::kNoError
;
149 glBindSampler(unit
, sampler
);
150 return error::kNoError
;
153 error::Error
GLES2DecoderImpl::HandleBindTexture(uint32_t immediate_data_size
,
154 const void* cmd_data
) {
155 const gles2::cmds::BindTexture
& c
=
156 *static_cast<const gles2::cmds::BindTexture
*>(cmd_data
);
158 GLenum target
= static_cast<GLenum
>(c
.target
);
159 GLuint texture
= c
.texture
;
160 if (!validators_
->texture_bind_target
.IsValid(target
)) {
161 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBindTexture", target
, "target");
162 return error::kNoError
;
164 DoBindTexture(target
, texture
);
165 return error::kNoError
;
168 error::Error
GLES2DecoderImpl::HandleBindTransformFeedback(
169 uint32_t immediate_data_size
,
170 const void* cmd_data
) {
171 if (!unsafe_es3_apis_enabled())
172 return error::kUnknownCommand
;
173 const gles2::cmds::BindTransformFeedback
& c
=
174 *static_cast<const gles2::cmds::BindTransformFeedback
*>(cmd_data
);
176 GLenum target
= static_cast<GLenum
>(c
.target
);
177 GLuint transformfeedback
= c
.transformfeedback
;
178 if (!group_
->GetTransformFeedbackServiceId(transformfeedback
,
179 &transformfeedback
)) {
180 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION
, "glBindTransformFeedback",
181 "invalid transformfeedback id");
182 return error::kNoError
;
184 glBindTransformFeedback(target
, transformfeedback
);
185 return error::kNoError
;
188 error::Error
GLES2DecoderImpl::HandleBlendColor(uint32_t immediate_data_size
,
189 const void* cmd_data
) {
190 const gles2::cmds::BlendColor
& c
=
191 *static_cast<const gles2::cmds::BlendColor
*>(cmd_data
);
193 GLclampf red
= static_cast<GLclampf
>(c
.red
);
194 GLclampf green
= static_cast<GLclampf
>(c
.green
);
195 GLclampf blue
= static_cast<GLclampf
>(c
.blue
);
196 GLclampf alpha
= static_cast<GLclampf
>(c
.alpha
);
197 if (state_
.blend_color_red
!= red
|| state_
.blend_color_green
!= green
||
198 state_
.blend_color_blue
!= blue
|| state_
.blend_color_alpha
!= alpha
) {
199 state_
.blend_color_red
= red
;
200 state_
.blend_color_green
= green
;
201 state_
.blend_color_blue
= blue
;
202 state_
.blend_color_alpha
= alpha
;
203 glBlendColor(red
, green
, blue
, alpha
);
205 return error::kNoError
;
208 error::Error
GLES2DecoderImpl::HandleBlendEquation(uint32_t immediate_data_size
,
209 const void* cmd_data
) {
210 const gles2::cmds::BlendEquation
& c
=
211 *static_cast<const gles2::cmds::BlendEquation
*>(cmd_data
);
213 GLenum mode
= static_cast<GLenum
>(c
.mode
);
214 if (!validators_
->equation
.IsValid(mode
)) {
215 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendEquation", mode
, "mode");
216 return error::kNoError
;
218 if (state_
.blend_equation_rgb
!= mode
||
219 state_
.blend_equation_alpha
!= mode
) {
220 state_
.blend_equation_rgb
= mode
;
221 state_
.blend_equation_alpha
= mode
;
222 glBlendEquation(mode
);
224 return error::kNoError
;
227 error::Error
GLES2DecoderImpl::HandleBlendEquationSeparate(
228 uint32_t immediate_data_size
,
229 const void* cmd_data
) {
230 const gles2::cmds::BlendEquationSeparate
& c
=
231 *static_cast<const gles2::cmds::BlendEquationSeparate
*>(cmd_data
);
233 GLenum modeRGB
= static_cast<GLenum
>(c
.modeRGB
);
234 GLenum modeAlpha
= static_cast<GLenum
>(c
.modeAlpha
);
235 if (!validators_
->equation
.IsValid(modeRGB
)) {
236 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendEquationSeparate", modeRGB
,
238 return error::kNoError
;
240 if (!validators_
->equation
.IsValid(modeAlpha
)) {
241 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendEquationSeparate", modeAlpha
,
243 return error::kNoError
;
245 if (state_
.blend_equation_rgb
!= modeRGB
||
246 state_
.blend_equation_alpha
!= modeAlpha
) {
247 state_
.blend_equation_rgb
= modeRGB
;
248 state_
.blend_equation_alpha
= modeAlpha
;
249 glBlendEquationSeparate(modeRGB
, modeAlpha
);
251 return error::kNoError
;
254 error::Error
GLES2DecoderImpl::HandleBlendFunc(uint32_t immediate_data_size
,
255 const void* cmd_data
) {
256 const gles2::cmds::BlendFunc
& c
=
257 *static_cast<const gles2::cmds::BlendFunc
*>(cmd_data
);
259 GLenum sfactor
= static_cast<GLenum
>(c
.sfactor
);
260 GLenum dfactor
= static_cast<GLenum
>(c
.dfactor
);
261 if (!validators_
->src_blend_factor
.IsValid(sfactor
)) {
262 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendFunc", sfactor
, "sfactor");
263 return error::kNoError
;
265 if (!validators_
->dst_blend_factor
.IsValid(dfactor
)) {
266 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendFunc", dfactor
, "dfactor");
267 return error::kNoError
;
269 if (state_
.blend_source_rgb
!= sfactor
|| state_
.blend_dest_rgb
!= dfactor
||
270 state_
.blend_source_alpha
!= sfactor
||
271 state_
.blend_dest_alpha
!= dfactor
) {
272 state_
.blend_source_rgb
= sfactor
;
273 state_
.blend_dest_rgb
= dfactor
;
274 state_
.blend_source_alpha
= sfactor
;
275 state_
.blend_dest_alpha
= dfactor
;
276 glBlendFunc(sfactor
, dfactor
);
278 return error::kNoError
;
281 error::Error
GLES2DecoderImpl::HandleBlendFuncSeparate(
282 uint32_t immediate_data_size
,
283 const void* cmd_data
) {
284 const gles2::cmds::BlendFuncSeparate
& c
=
285 *static_cast<const gles2::cmds::BlendFuncSeparate
*>(cmd_data
);
287 GLenum srcRGB
= static_cast<GLenum
>(c
.srcRGB
);
288 GLenum dstRGB
= static_cast<GLenum
>(c
.dstRGB
);
289 GLenum srcAlpha
= static_cast<GLenum
>(c
.srcAlpha
);
290 GLenum dstAlpha
= static_cast<GLenum
>(c
.dstAlpha
);
291 if (!validators_
->src_blend_factor
.IsValid(srcRGB
)) {
292 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendFuncSeparate", srcRGB
, "srcRGB");
293 return error::kNoError
;
295 if (!validators_
->dst_blend_factor
.IsValid(dstRGB
)) {
296 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendFuncSeparate", dstRGB
, "dstRGB");
297 return error::kNoError
;
299 if (!validators_
->src_blend_factor
.IsValid(srcAlpha
)) {
300 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendFuncSeparate", srcAlpha
,
302 return error::kNoError
;
304 if (!validators_
->dst_blend_factor
.IsValid(dstAlpha
)) {
305 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlendFuncSeparate", dstAlpha
,
307 return error::kNoError
;
309 if (state_
.blend_source_rgb
!= srcRGB
|| state_
.blend_dest_rgb
!= dstRGB
||
310 state_
.blend_source_alpha
!= srcAlpha
||
311 state_
.blend_dest_alpha
!= dstAlpha
) {
312 state_
.blend_source_rgb
= srcRGB
;
313 state_
.blend_dest_rgb
= dstRGB
;
314 state_
.blend_source_alpha
= srcAlpha
;
315 state_
.blend_dest_alpha
= dstAlpha
;
316 glBlendFuncSeparate(srcRGB
, dstRGB
, srcAlpha
, dstAlpha
);
318 return error::kNoError
;
321 error::Error
GLES2DecoderImpl::HandleBufferSubData(uint32_t immediate_data_size
,
322 const void* cmd_data
) {
323 const gles2::cmds::BufferSubData
& c
=
324 *static_cast<const gles2::cmds::BufferSubData
*>(cmd_data
);
326 GLenum target
= static_cast<GLenum
>(c
.target
);
327 GLintptr offset
= static_cast<GLintptr
>(c
.offset
);
328 GLsizeiptr size
= static_cast<GLsizeiptr
>(c
.size
);
329 uint32_t data_size
= size
;
330 const void* data
= GetSharedMemoryAs
<const void*>(
331 c
.data_shm_id
, c
.data_shm_offset
, data_size
);
332 if (!validators_
->buffer_target
.IsValid(target
)) {
333 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBufferSubData", target
, "target");
334 return error::kNoError
;
337 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE
, "glBufferSubData", "size < 0");
338 return error::kNoError
;
341 return error::kOutOfBounds
;
343 DoBufferSubData(target
, offset
, size
, data
);
344 return error::kNoError
;
347 error::Error
GLES2DecoderImpl::HandleCheckFramebufferStatus(
348 uint32_t immediate_data_size
,
349 const void* cmd_data
) {
350 const gles2::cmds::CheckFramebufferStatus
& c
=
351 *static_cast<const gles2::cmds::CheckFramebufferStatus
*>(cmd_data
);
353 GLenum target
= static_cast<GLenum
>(c
.target
);
354 typedef cmds::CheckFramebufferStatus::Result Result
;
355 Result
* result_dst
= GetSharedMemoryAs
<Result
*>(
356 c
.result_shm_id
, c
.result_shm_offset
, sizeof(*result_dst
));
358 return error::kOutOfBounds
;
360 if (!validators_
->frame_buffer_target
.IsValid(target
)) {
361 LOCAL_SET_GL_ERROR_INVALID_ENUM("glCheckFramebufferStatus", target
,
363 return error::kNoError
;
365 *result_dst
= DoCheckFramebufferStatus(target
);
366 return error::kNoError
;
369 error::Error
GLES2DecoderImpl::HandleClear(uint32_t immediate_data_size
,
370 const void* cmd_data
) {
371 const gles2::cmds::Clear
& c
=
372 *static_cast<const gles2::cmds::Clear
*>(cmd_data
);
375 error
= WillAccessBoundFramebufferForDraw();
376 if (error
!= error::kNoError
)
378 GLbitfield mask
= static_cast<GLbitfield
>(c
.mask
);
380 return error::kNoError
;
383 error::Error
GLES2DecoderImpl::HandleClearBufferfi(uint32_t immediate_data_size
,
384 const void* cmd_data
) {
385 if (!unsafe_es3_apis_enabled())
386 return error::kUnknownCommand
;
387 const gles2::cmds::ClearBufferfi
& c
=
388 *static_cast<const gles2::cmds::ClearBufferfi
*>(cmd_data
);
390 GLenum buffer
= static_cast<GLenum
>(c
.buffer
);
391 GLint drawbuffers
= static_cast<GLint
>(c
.drawbuffers
);
392 GLfloat depth
= static_cast<GLfloat
>(c
.depth
);
393 GLint stencil
= static_cast<GLint
>(c
.stencil
);
394 glClearBufferfi(buffer
, drawbuffers
, depth
, stencil
);
395 return error::kNoError
;
398 error::Error
GLES2DecoderImpl::HandleClearBufferfvImmediate(
399 uint32_t immediate_data_size
,
400 const void* cmd_data
) {
401 if (!unsafe_es3_apis_enabled())
402 return error::kUnknownCommand
;
403 const gles2::cmds::ClearBufferfvImmediate
& c
=
404 *static_cast<const gles2::cmds::ClearBufferfvImmediate
*>(cmd_data
);
406 GLenum buffer
= static_cast<GLenum
>(c
.buffer
);
407 GLint drawbuffers
= static_cast<GLint
>(c
.drawbuffers
);
409 if (!ComputeDataSize(1, sizeof(GLfloat
), 4, &data_size
)) {
410 return error::kOutOfBounds
;
412 if (data_size
> immediate_data_size
) {
413 return error::kOutOfBounds
;
415 const GLfloat
* value
=
416 GetImmediateDataAs
<const GLfloat
*>(c
, data_size
, immediate_data_size
);
418 return error::kOutOfBounds
;
420 glClearBufferfv(buffer
, drawbuffers
, value
);
421 return error::kNoError
;
424 error::Error
GLES2DecoderImpl::HandleClearBufferivImmediate(
425 uint32_t immediate_data_size
,
426 const void* cmd_data
) {
427 if (!unsafe_es3_apis_enabled())
428 return error::kUnknownCommand
;
429 const gles2::cmds::ClearBufferivImmediate
& c
=
430 *static_cast<const gles2::cmds::ClearBufferivImmediate
*>(cmd_data
);
432 GLenum buffer
= static_cast<GLenum
>(c
.buffer
);
433 GLint drawbuffers
= static_cast<GLint
>(c
.drawbuffers
);
435 if (!ComputeDataSize(1, sizeof(GLint
), 4, &data_size
)) {
436 return error::kOutOfBounds
;
438 if (data_size
> immediate_data_size
) {
439 return error::kOutOfBounds
;
442 GetImmediateDataAs
<const GLint
*>(c
, data_size
, immediate_data_size
);
444 return error::kOutOfBounds
;
446 glClearBufferiv(buffer
, drawbuffers
, value
);
447 return error::kNoError
;
450 error::Error
GLES2DecoderImpl::HandleClearBufferuivImmediate(
451 uint32_t immediate_data_size
,
452 const void* cmd_data
) {
453 if (!unsafe_es3_apis_enabled())
454 return error::kUnknownCommand
;
455 const gles2::cmds::ClearBufferuivImmediate
& c
=
456 *static_cast<const gles2::cmds::ClearBufferuivImmediate
*>(cmd_data
);
458 GLenum buffer
= static_cast<GLenum
>(c
.buffer
);
459 GLint drawbuffers
= static_cast<GLint
>(c
.drawbuffers
);
461 if (!ComputeDataSize(1, sizeof(GLuint
), 4, &data_size
)) {
462 return error::kOutOfBounds
;
464 if (data_size
> immediate_data_size
) {
465 return error::kOutOfBounds
;
467 const GLuint
* value
=
468 GetImmediateDataAs
<const GLuint
*>(c
, data_size
, immediate_data_size
);
470 return error::kOutOfBounds
;
472 glClearBufferuiv(buffer
, drawbuffers
, value
);
473 return error::kNoError
;
476 error::Error
GLES2DecoderImpl::HandleClearColor(uint32_t immediate_data_size
,
477 const void* cmd_data
) {
478 const gles2::cmds::ClearColor
& c
=
479 *static_cast<const gles2::cmds::ClearColor
*>(cmd_data
);
481 GLclampf red
= static_cast<GLclampf
>(c
.red
);
482 GLclampf green
= static_cast<GLclampf
>(c
.green
);
483 GLclampf blue
= static_cast<GLclampf
>(c
.blue
);
484 GLclampf alpha
= static_cast<GLclampf
>(c
.alpha
);
485 if (state_
.color_clear_red
!= red
|| state_
.color_clear_green
!= green
||
486 state_
.color_clear_blue
!= blue
|| state_
.color_clear_alpha
!= alpha
) {
487 state_
.color_clear_red
= red
;
488 state_
.color_clear_green
= green
;
489 state_
.color_clear_blue
= blue
;
490 state_
.color_clear_alpha
= alpha
;
491 glClearColor(red
, green
, blue
, alpha
);
493 return error::kNoError
;
496 error::Error
GLES2DecoderImpl::HandleClearDepthf(uint32_t immediate_data_size
,
497 const void* cmd_data
) {
498 const gles2::cmds::ClearDepthf
& c
=
499 *static_cast<const gles2::cmds::ClearDepthf
*>(cmd_data
);
501 GLclampf depth
= static_cast<GLclampf
>(c
.depth
);
502 if (state_
.depth_clear
!= depth
) {
503 state_
.depth_clear
= depth
;
506 return error::kNoError
;
509 error::Error
GLES2DecoderImpl::HandleClearStencil(uint32_t immediate_data_size
,
510 const void* cmd_data
) {
511 const gles2::cmds::ClearStencil
& c
=
512 *static_cast<const gles2::cmds::ClearStencil
*>(cmd_data
);
514 GLint s
= static_cast<GLint
>(c
.s
);
515 if (state_
.stencil_clear
!= s
) {
516 state_
.stencil_clear
= s
;
519 return error::kNoError
;
522 error::Error
GLES2DecoderImpl::HandleColorMask(uint32_t immediate_data_size
,
523 const void* cmd_data
) {
524 const gles2::cmds::ColorMask
& c
=
525 *static_cast<const gles2::cmds::ColorMask
*>(cmd_data
);
527 GLboolean red
= static_cast<GLboolean
>(c
.red
);
528 GLboolean green
= static_cast<GLboolean
>(c
.green
);
529 GLboolean blue
= static_cast<GLboolean
>(c
.blue
);
530 GLboolean alpha
= static_cast<GLboolean
>(c
.alpha
);
531 if (state_
.color_mask_red
!= red
|| state_
.color_mask_green
!= green
||
532 state_
.color_mask_blue
!= blue
|| state_
.color_mask_alpha
!= alpha
) {
533 state_
.color_mask_red
= red
;
534 state_
.color_mask_green
= green
;
535 state_
.color_mask_blue
= blue
;
536 state_
.color_mask_alpha
= alpha
;
537 framebuffer_state_
.clear_state_dirty
= true;
539 return error::kNoError
;
542 error::Error
GLES2DecoderImpl::HandleCompileShader(uint32_t immediate_data_size
,
543 const void* cmd_data
) {
544 const gles2::cmds::CompileShader
& c
=
545 *static_cast<const gles2::cmds::CompileShader
*>(cmd_data
);
547 GLuint shader
= c
.shader
;
548 DoCompileShader(shader
);
549 return error::kNoError
;
552 error::Error
GLES2DecoderImpl::HandleCompressedTexSubImage2D(
553 uint32_t immediate_data_size
,
554 const void* cmd_data
) {
555 const gles2::cmds::CompressedTexSubImage2D
& c
=
556 *static_cast<const gles2::cmds::CompressedTexSubImage2D
*>(cmd_data
);
558 GLenum target
= static_cast<GLenum
>(c
.target
);
559 GLint level
= static_cast<GLint
>(c
.level
);
560 GLint xoffset
= static_cast<GLint
>(c
.xoffset
);
561 GLint yoffset
= static_cast<GLint
>(c
.yoffset
);
562 GLsizei width
= static_cast<GLsizei
>(c
.width
);
563 GLsizei height
= static_cast<GLsizei
>(c
.height
);
564 GLenum format
= static_cast<GLenum
>(c
.format
);
565 GLsizei imageSize
= static_cast<GLsizei
>(c
.imageSize
);
566 uint32_t data_size
= imageSize
;
567 const void* data
= GetSharedMemoryAs
<const void*>(
568 c
.data_shm_id
, c
.data_shm_offset
, data_size
);
569 if (!validators_
->texture_target
.IsValid(target
)) {
570 LOCAL_SET_GL_ERROR_INVALID_ENUM("glCompressedTexSubImage2D", target
,
572 return error::kNoError
;
575 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE
, "glCompressedTexSubImage2D",
577 return error::kNoError
;
580 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE
, "glCompressedTexSubImage2D",
582 return error::kNoError
;
584 if (!validators_
->compressed_texture_format
.IsValid(format
)) {
585 LOCAL_SET_GL_ERROR_INVALID_ENUM("glCompressedTexSubImage2D", format
,
587 return error::kNoError
;
590 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE
, "glCompressedTexSubImage2D",
592 return error::kNoError
;
595 return error::kOutOfBounds
;
597 DoCompressedTexSubImage2D(target
, level
, xoffset
, yoffset
, width
, height
,
598 format
, imageSize
, data
);
599 return error::kNoError
;
602 error::Error
GLES2DecoderImpl::HandleCompressedTexSubImage3D(
603 uint32_t immediate_data_size
,
604 const void* cmd_data
) {
605 if (!unsafe_es3_apis_enabled())
606 return error::kUnknownCommand
;
607 const gles2::cmds::CompressedTexSubImage3D
& c
=
608 *static_cast<const gles2::cmds::CompressedTexSubImage3D
*>(cmd_data
);
610 GLenum target
= static_cast<GLenum
>(c
.target
);
611 GLint level
= static_cast<GLint
>(c
.level
);
612 GLint xoffset
= static_cast<GLint
>(c
.xoffset
);
613 GLint yoffset
= static_cast<GLint
>(c
.yoffset
);
614 GLint zoffset
= static_cast<GLint
>(c
.zoffset
);
615 GLsizei width
= static_cast<GLsizei
>(c
.width
);
616 GLsizei height
= static_cast<GLsizei
>(c
.height
);
617 GLsizei depth
= static_cast<GLsizei
>(c
.depth
);
618 GLenum format
= static_cast<GLenum
>(c
.format
);
619 GLsizei imageSize
= static_cast<GLsizei
>(c
.imageSize
);
620 uint32_t data_size
= imageSize
;
621 const void* data
= GetSharedMemoryAs
<const void*>(
622 c
.data_shm_id
, c
.data_shm_offset
, data_size
);
624 return error::kOutOfBounds
;
626 DoCompressedTexSubImage3D(target
, level
, xoffset
, yoffset
, zoffset
, width
,
627 height
, depth
, format
, imageSize
, data
);
628 return error::kNoError
;
631 error::Error
GLES2DecoderImpl::HandleCopyBufferSubData(
632 uint32_t immediate_data_size
,
633 const void* cmd_data
) {
634 if (!unsafe_es3_apis_enabled())
635 return error::kUnknownCommand
;
636 const gles2::cmds::CopyBufferSubData
& c
=
637 *static_cast<const gles2::cmds::CopyBufferSubData
*>(cmd_data
);
639 GLenum readtarget
= static_cast<GLenum
>(c
.readtarget
);
640 GLenum writetarget
= static_cast<GLenum
>(c
.writetarget
);
641 GLintptr readoffset
= static_cast<GLintptr
>(c
.readoffset
);
642 GLintptr writeoffset
= static_cast<GLintptr
>(c
.writeoffset
);
643 GLsizeiptr size
= static_cast<GLsizeiptr
>(c
.size
);
644 glCopyBufferSubData(readtarget
, writetarget
, readoffset
, writeoffset
, size
);
645 return error::kNoError
;
648 error::Error
GLES2DecoderImpl::HandleCopyTexImage2D(
649 uint32_t immediate_data_size
,
650 const void* cmd_data
) {
651 const gles2::cmds::CopyTexImage2D
& c
=
652 *static_cast<const gles2::cmds::CopyTexImage2D
*>(cmd_data
);
655 error
= WillAccessBoundFramebufferForRead();
656 if (error
!= error::kNoError
)
658 GLenum target
= static_cast<GLenum
>(c
.target
);
659 GLint level
= static_cast<GLint
>(c
.level
);
660 GLenum internalformat
= static_cast<GLenum
>(c
.internalformat
);
661 GLint x
= static_cast<GLint
>(c
.x
);
662 GLint y
= static_cast<GLint
>(c
.y
);
663 GLsizei width
= static_cast<GLsizei
>(c
.width
);
664 GLsizei height
= static_cast<GLsizei
>(c
.height
);
665 GLint border
= static_cast<GLint
>(c
.border
);
666 if (!validators_
->texture_target
.IsValid(target
)) {
667 LOCAL_SET_GL_ERROR_INVALID_ENUM("glCopyTexImage2D", target
, "target");
668 return error::kNoError
;
670 if (!validators_
->texture_internal_format
.IsValid(internalformat
)) {
671 LOCAL_SET_GL_ERROR_INVALID_ENUM("glCopyTexImage2D", internalformat
,
673 return error::kNoError
;
676 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE
, "glCopyTexImage2D", "width < 0");
677 return error::kNoError
;
680 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE
, "glCopyTexImage2D", "height < 0");
681 return error::kNoError
;
683 DoCopyTexImage2D(target
, level
, internalformat
, x
, y
, width
, height
, border
);
684 return error::kNoError
;
687 error::Error
GLES2DecoderImpl::HandleCopyTexSubImage2D(
688 uint32_t immediate_data_size
,
689 const void* cmd_data
) {
690 const gles2::cmds::CopyTexSubImage2D
& c
=
691 *static_cast<const gles2::cmds::CopyTexSubImage2D
*>(cmd_data
);
694 error
= WillAccessBoundFramebufferForRead();
695 if (error
!= error::kNoError
)
697 GLenum target
= static_cast<GLenum
>(c
.target
);
698 GLint level
= static_cast<GLint
>(c
.level
);
699 GLint xoffset
= static_cast<GLint
>(c
.xoffset
);
700 GLint yoffset
= static_cast<GLint
>(c
.yoffset
);
701 GLint x
= static_cast<GLint
>(c
.x
);
702 GLint y
= static_cast<GLint
>(c
.y
);
703 GLsizei width
= static_cast<GLsizei
>(c
.width
);
704 GLsizei height
= static_cast<GLsizei
>(c
.height
);
705 if (!validators_
->texture_target
.IsValid(target
)) {
706 LOCAL_SET_GL_ERROR_INVALID_ENUM("glCopyTexSubImage2D", target
, "target");
707 return error::kNoError
;
710 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE
, "glCopyTexSubImage2D", "width < 0");
711 return error::kNoError
;
714 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE
, "glCopyTexSubImage2D", "height < 0");
715 return error::kNoError
;
717 DoCopyTexSubImage2D(target
, level
, xoffset
, yoffset
, x
, y
, width
, height
);
718 return error::kNoError
;
721 error::Error
GLES2DecoderImpl::HandleCopyTexSubImage3D(
722 uint32_t immediate_data_size
,
723 const void* cmd_data
) {
724 if (!unsafe_es3_apis_enabled())
725 return error::kUnknownCommand
;
726 const gles2::cmds::CopyTexSubImage3D
& c
=
727 *static_cast<const gles2::cmds::CopyTexSubImage3D
*>(cmd_data
);
730 error
= WillAccessBoundFramebufferForRead();
731 if (error
!= error::kNoError
)
733 GLenum target
= static_cast<GLenum
>(c
.target
);
734 GLint level
= static_cast<GLint
>(c
.level
);
735 GLint xoffset
= static_cast<GLint
>(c
.xoffset
);
736 GLint yoffset
= static_cast<GLint
>(c
.yoffset
);
737 GLint zoffset
= static_cast<GLint
>(c
.zoffset
);
738 GLint x
= static_cast<GLint
>(c
.x
);
739 GLint y
= static_cast<GLint
>(c
.y
);
740 GLsizei width
= static_cast<GLsizei
>(c
.width
);
741 GLsizei height
= static_cast<GLsizei
>(c
.height
);
742 glCopyTexSubImage3D(target
, level
, xoffset
, yoffset
, zoffset
, x
, y
, width
,
744 return error::kNoError
;
747 error::Error
GLES2DecoderImpl::HandleCreateProgram(uint32_t immediate_data_size
,
748 const void* cmd_data
) {
749 const gles2::cmds::CreateProgram
& c
=
750 *static_cast<const gles2::cmds::CreateProgram
*>(cmd_data
);
752 uint32_t client_id
= c
.client_id
;
753 if (GetProgram(client_id
)) {
754 return error::kInvalidArguments
;
756 GLuint service_id
= glCreateProgram();
758 CreateProgram(client_id
, service_id
);
760 return error::kNoError
;
763 error::Error
GLES2DecoderImpl::HandleCreateShader(uint32_t immediate_data_size
,
764 const void* cmd_data
) {
765 const gles2::cmds::CreateShader
& c
=
766 *static_cast<const gles2::cmds::CreateShader
*>(cmd_data
);
768 GLenum type
= static_cast<GLenum
>(c
.type
);
769 if (!validators_
->shader_type
.IsValid(type
)) {
770 LOCAL_SET_GL_ERROR_INVALID_ENUM("glCreateShader", type
, "type");
771 return error::kNoError
;
773 uint32_t client_id
= c
.client_id
;
774 if (GetShader(client_id
)) {
775 return error::kInvalidArguments
;
777 GLuint service_id
= glCreateShader(type
);
779 CreateShader(client_id
, service_id
, type
);
781 return error::kNoError
;
784 error::Error
GLES2DecoderImpl::HandleCullFace(uint32_t immediate_data_size
,
785 const void* cmd_data
) {
786 const gles2::cmds::CullFace
& c
=
787 *static_cast<const gles2::cmds::CullFace
*>(cmd_data
);
789 GLenum mode
= static_cast<GLenum
>(c
.mode
);
790 if (!validators_
->face_type
.IsValid(mode
)) {
791 LOCAL_SET_GL_ERROR_INVALID_ENUM("glCullFace", mode
, "mode");
792 return error::kNoError
;
794 if (state_
.cull_mode
!= mode
) {
795 state_
.cull_mode
= mode
;
798 return error::kNoError
;
801 error::Error
GLES2DecoderImpl::HandleDeleteBuffersImmediate(
802 uint32_t immediate_data_size
,
803 const void* cmd_data
) {
804 const gles2::cmds::DeleteBuffersImmediate
& c
=
805 *static_cast<const gles2::cmds::DeleteBuffersImmediate
*>(cmd_data
);
807 GLsizei n
= static_cast<GLsizei
>(c
.n
);
809 if (!SafeMultiplyUint32(n
, sizeof(GLuint
), &data_size
)) {
810 return error::kOutOfBounds
;
812 const GLuint
* buffers
=
813 GetImmediateDataAs
<const GLuint
*>(c
, data_size
, immediate_data_size
);
814 if (buffers
== NULL
) {
815 return error::kOutOfBounds
;
817 DeleteBuffersHelper(n
, buffers
);
818 return error::kNoError
;
821 error::Error
GLES2DecoderImpl::HandleDeleteFramebuffersImmediate(
822 uint32_t immediate_data_size
,
823 const void* cmd_data
) {
824 const gles2::cmds::DeleteFramebuffersImmediate
& c
=
825 *static_cast<const gles2::cmds::DeleteFramebuffersImmediate
*>(cmd_data
);
827 GLsizei n
= static_cast<GLsizei
>(c
.n
);
829 if (!SafeMultiplyUint32(n
, sizeof(GLuint
), &data_size
)) {
830 return error::kOutOfBounds
;
832 const GLuint
* framebuffers
=
833 GetImmediateDataAs
<const GLuint
*>(c
, data_size
, immediate_data_size
);
834 if (framebuffers
== NULL
) {
835 return error::kOutOfBounds
;
837 DeleteFramebuffersHelper(n
, framebuffers
);
838 return error::kNoError
;
841 error::Error
GLES2DecoderImpl::HandleDeleteRenderbuffersImmediate(
842 uint32_t immediate_data_size
,
843 const void* cmd_data
) {
844 const gles2::cmds::DeleteRenderbuffersImmediate
& c
=
845 *static_cast<const gles2::cmds::DeleteRenderbuffersImmediate
*>(cmd_data
);
847 GLsizei n
= static_cast<GLsizei
>(c
.n
);
849 if (!SafeMultiplyUint32(n
, sizeof(GLuint
), &data_size
)) {
850 return error::kOutOfBounds
;
852 const GLuint
* renderbuffers
=
853 GetImmediateDataAs
<const GLuint
*>(c
, data_size
, immediate_data_size
);
854 if (renderbuffers
== NULL
) {
855 return error::kOutOfBounds
;
857 DeleteRenderbuffersHelper(n
, renderbuffers
);
858 return error::kNoError
;
861 error::Error
GLES2DecoderImpl::HandleDeleteSamplersImmediate(
862 uint32_t immediate_data_size
,
863 const void* cmd_data
) {
864 if (!unsafe_es3_apis_enabled())
865 return error::kUnknownCommand
;
866 const gles2::cmds::DeleteSamplersImmediate
& c
=
867 *static_cast<const gles2::cmds::DeleteSamplersImmediate
*>(cmd_data
);
869 GLsizei n
= static_cast<GLsizei
>(c
.n
);
871 if (!SafeMultiplyUint32(n
, sizeof(GLuint
), &data_size
)) {
872 return error::kOutOfBounds
;
874 const GLuint
* samplers
=
875 GetImmediateDataAs
<const GLuint
*>(c
, data_size
, immediate_data_size
);
876 if (samplers
== NULL
) {
877 return error::kOutOfBounds
;
879 for (GLsizei ii
= 0; ii
< n
; ++ii
) {
880 GLuint service_id
= 0;
881 if (group_
->GetSamplerServiceId(samplers
[ii
], &service_id
)) {
882 glDeleteSamplers(1, &service_id
);
883 group_
->RemoveSamplerId(samplers
[ii
]);
886 return error::kNoError
;
889 error::Error
GLES2DecoderImpl::HandleDeleteSync(uint32_t immediate_data_size
,
890 const void* cmd_data
) {
891 if (!unsafe_es3_apis_enabled())
892 return error::kUnknownCommand
;
893 const gles2::cmds::DeleteSync
& c
=
894 *static_cast<const gles2::cmds::DeleteSync
*>(cmd_data
);
896 GLuint sync
= c
.sync
;
897 GLsync service_id
= 0;
898 if (group_
->GetSyncServiceId(sync
, &service_id
)) {
899 glDeleteSync(service_id
);
900 group_
->RemoveSyncId(sync
);
902 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE
, "glDeleteSync", "unknown sync");
904 return error::kNoError
;
907 error::Error
GLES2DecoderImpl::HandleDeleteTexturesImmediate(
908 uint32_t immediate_data_size
,
909 const void* cmd_data
) {
910 const gles2::cmds::DeleteTexturesImmediate
& c
=
911 *static_cast<const gles2::cmds::DeleteTexturesImmediate
*>(cmd_data
);
913 GLsizei n
= static_cast<GLsizei
>(c
.n
);
915 if (!SafeMultiplyUint32(n
, sizeof(GLuint
), &data_size
)) {
916 return error::kOutOfBounds
;
918 const GLuint
* textures
=
919 GetImmediateDataAs
<const GLuint
*>(c
, data_size
, immediate_data_size
);
920 if (textures
== NULL
) {
921 return error::kOutOfBounds
;
923 DeleteTexturesHelper(n
, textures
);
924 return error::kNoError
;
927 error::Error
GLES2DecoderImpl::HandleDeleteTransformFeedbacksImmediate(
928 uint32_t immediate_data_size
,
929 const void* cmd_data
) {
930 if (!unsafe_es3_apis_enabled())
931 return error::kUnknownCommand
;
932 const gles2::cmds::DeleteTransformFeedbacksImmediate
& c
=
933 *static_cast<const gles2::cmds::DeleteTransformFeedbacksImmediate
*>(
936 GLsizei n
= static_cast<GLsizei
>(c
.n
);
938 if (!SafeMultiplyUint32(n
, sizeof(GLuint
), &data_size
)) {
939 return error::kOutOfBounds
;
942 GetImmediateDataAs
<const GLuint
*>(c
, data_size
, immediate_data_size
);
944 return error::kOutOfBounds
;
946 for (GLsizei ii
= 0; ii
< n
; ++ii
) {
947 GLuint service_id
= 0;
948 if (group_
->GetTransformFeedbackServiceId(ids
[ii
], &service_id
)) {
949 glDeleteTransformFeedbacks(1, &service_id
);
950 group_
->RemoveTransformFeedbackId(ids
[ii
]);
953 return error::kNoError
;
956 error::Error
GLES2DecoderImpl::HandleDepthFunc(uint32_t immediate_data_size
,
957 const void* cmd_data
) {
958 const gles2::cmds::DepthFunc
& c
=
959 *static_cast<const gles2::cmds::DepthFunc
*>(cmd_data
);
961 GLenum func
= static_cast<GLenum
>(c
.func
);
962 if (!validators_
->cmp_function
.IsValid(func
)) {
963 LOCAL_SET_GL_ERROR_INVALID_ENUM("glDepthFunc", func
, "func");
964 return error::kNoError
;
966 if (state_
.depth_func
!= func
) {
967 state_
.depth_func
= func
;
970 return error::kNoError
;
973 error::Error
GLES2DecoderImpl::HandleDepthMask(uint32_t immediate_data_size
,
974 const void* cmd_data
) {
975 const gles2::cmds::DepthMask
& c
=
976 *static_cast<const gles2::cmds::DepthMask
*>(cmd_data
);
978 GLboolean flag
= static_cast<GLboolean
>(c
.flag
);
979 if (state_
.depth_mask
!= flag
) {
980 state_
.depth_mask
= flag
;
981 framebuffer_state_
.clear_state_dirty
= true;
983 return error::kNoError
;
986 error::Error
GLES2DecoderImpl::HandleDepthRangef(uint32_t immediate_data_size
,
987 const void* cmd_data
) {
988 const gles2::cmds::DepthRangef
& c
=
989 *static_cast<const gles2::cmds::DepthRangef
*>(cmd_data
);
991 GLclampf zNear
= static_cast<GLclampf
>(c
.zNear
);
992 GLclampf zFar
= static_cast<GLclampf
>(c
.zFar
);
993 DoDepthRangef(zNear
, zFar
);
994 return error::kNoError
;
997 error::Error
GLES2DecoderImpl::HandleDetachShader(uint32_t immediate_data_size
,
998 const void* cmd_data
) {
999 const gles2::cmds::DetachShader
& c
=
1000 *static_cast<const gles2::cmds::DetachShader
*>(cmd_data
);
1002 GLuint program
= c
.program
;
1003 GLuint shader
= c
.shader
;
1004 DoDetachShader(program
, shader
);
1005 return error::kNoError
;
1008 error::Error
GLES2DecoderImpl::HandleDisable(uint32_t immediate_data_size
,
1009 const void* cmd_data
) {
1010 const gles2::cmds::Disable
& c
=
1011 *static_cast<const gles2::cmds::Disable
*>(cmd_data
);
1013 GLenum cap
= static_cast<GLenum
>(c
.cap
);
1014 if (!validators_
->capability
.IsValid(cap
)) {
1015 LOCAL_SET_GL_ERROR_INVALID_ENUM("glDisable", cap
, "cap");
1016 return error::kNoError
;
1019 return error::kNoError
;
1022 error::Error
GLES2DecoderImpl::HandleDisableVertexAttribArray(
1023 uint32_t immediate_data_size
,
1024 const void* cmd_data
) {
1025 const gles2::cmds::DisableVertexAttribArray
& c
=
1026 *static_cast<const gles2::cmds::DisableVertexAttribArray
*>(cmd_data
);
1028 GLuint index
= static_cast<GLuint
>(c
.index
);
1029 DoDisableVertexAttribArray(index
);
1030 return error::kNoError
;
1033 error::Error
GLES2DecoderImpl::HandleEnable(uint32_t immediate_data_size
,
1034 const void* cmd_data
) {
1035 const gles2::cmds::Enable
& c
=
1036 *static_cast<const gles2::cmds::Enable
*>(cmd_data
);
1038 GLenum cap
= static_cast<GLenum
>(c
.cap
);
1039 if (!validators_
->capability
.IsValid(cap
)) {
1040 LOCAL_SET_GL_ERROR_INVALID_ENUM("glEnable", cap
, "cap");
1041 return error::kNoError
;
1044 return error::kNoError
;
1047 error::Error
GLES2DecoderImpl::HandleEnableVertexAttribArray(
1048 uint32_t immediate_data_size
,
1049 const void* cmd_data
) {
1050 const gles2::cmds::EnableVertexAttribArray
& c
=
1051 *static_cast<const gles2::cmds::EnableVertexAttribArray
*>(cmd_data
);
1053 GLuint index
= static_cast<GLuint
>(c
.index
);
1054 DoEnableVertexAttribArray(index
);
1055 return error::kNoError
;
1058 error::Error
GLES2DecoderImpl::HandleFenceSync(uint32_t immediate_data_size
,
1059 const void* cmd_data
) {
1060 if (!unsafe_es3_apis_enabled())
1061 return error::kUnknownCommand
;
1062 const gles2::cmds::FenceSync
& c
=
1063 *static_cast<const gles2::cmds::FenceSync
*>(cmd_data
);
1065 GLenum condition
= static_cast<GLenum
>(c
.condition
);
1066 GLbitfield flags
= static_cast<GLbitfield
>(c
.flags
);
1067 uint32_t client_id
= c
.client_id
;
1068 GLsync service_id
= 0;
1069 if (group_
->GetSyncServiceId(client_id
, &service_id
)) {
1070 return error::kInvalidArguments
;
1072 service_id
= glFenceSync(condition
, flags
);
1074 group_
->AddSyncId(client_id
, service_id
);
1076 return error::kNoError
;
1079 error::Error
GLES2DecoderImpl::HandleFinish(uint32_t immediate_data_size
,
1080 const void* cmd_data
) {
1081 const gles2::cmds::Finish
& c
=
1082 *static_cast<const gles2::cmds::Finish
*>(cmd_data
);
1085 error
= WillAccessBoundFramebufferForRead();
1086 if (error
!= error::kNoError
)
1089 return error::kNoError
;
1092 error::Error
GLES2DecoderImpl::HandleFlush(uint32_t immediate_data_size
,
1093 const void* cmd_data
) {
1094 const gles2::cmds::Flush
& c
=
1095 *static_cast<const gles2::cmds::Flush
*>(cmd_data
);
1098 return error::kNoError
;
1101 error::Error
GLES2DecoderImpl::HandleFramebufferRenderbuffer(
1102 uint32_t immediate_data_size
,
1103 const void* cmd_data
) {
1104 const gles2::cmds::FramebufferRenderbuffer
& c
=
1105 *static_cast<const gles2::cmds::FramebufferRenderbuffer
*>(cmd_data
);
1107 GLenum target
= static_cast<GLenum
>(c
.target
);
1108 GLenum attachment
= static_cast<GLenum
>(c
.attachment
);
1109 GLenum renderbuffertarget
= static_cast<GLenum
>(c
.renderbuffertarget
);
1110 GLuint renderbuffer
= c
.renderbuffer
;
1111 if (!validators_
->frame_buffer_target
.IsValid(target
)) {
1112 LOCAL_SET_GL_ERROR_INVALID_ENUM("glFramebufferRenderbuffer", target
,
1114 return error::kNoError
;
1116 if (!validators_
->attachment
.IsValid(attachment
)) {
1117 LOCAL_SET_GL_ERROR_INVALID_ENUM("glFramebufferRenderbuffer", attachment
,
1119 return error::kNoError
;
1121 if (!validators_
->render_buffer_target
.IsValid(renderbuffertarget
)) {
1122 LOCAL_SET_GL_ERROR_INVALID_ENUM("glFramebufferRenderbuffer",
1123 renderbuffertarget
, "renderbuffertarget");
1124 return error::kNoError
;
1126 DoFramebufferRenderbuffer(target
, attachment
, renderbuffertarget
,
1128 return error::kNoError
;
1131 error::Error
GLES2DecoderImpl::HandleFramebufferTexture2D(
1132 uint32_t immediate_data_size
,
1133 const void* cmd_data
) {
1134 const gles2::cmds::FramebufferTexture2D
& c
=
1135 *static_cast<const gles2::cmds::FramebufferTexture2D
*>(cmd_data
);
1137 GLenum target
= static_cast<GLenum
>(c
.target
);
1138 GLenum attachment
= static_cast<GLenum
>(c
.attachment
);
1139 GLenum textarget
= static_cast<GLenum
>(c
.textarget
);
1140 GLuint texture
= c
.texture
;
1141 GLint level
= static_cast<GLint
>(c
.level
);
1142 if (!validators_
->frame_buffer_target
.IsValid(target
)) {
1143 LOCAL_SET_GL_ERROR_INVALID_ENUM("glFramebufferTexture2D", target
, "target");
1144 return error::kNoError
;
1146 if (!validators_
->attachment
.IsValid(attachment
)) {
1147 LOCAL_SET_GL_ERROR_INVALID_ENUM("glFramebufferTexture2D", attachment
,
1149 return error::kNoError
;
1151 if (!validators_
->texture_target
.IsValid(textarget
)) {
1152 LOCAL_SET_GL_ERROR_INVALID_ENUM("glFramebufferTexture2D", textarget
,
1154 return error::kNoError
;
1156 DoFramebufferTexture2D(target
, attachment
, textarget
, texture
, level
);
1157 return error::kNoError
;
1160 error::Error
GLES2DecoderImpl::HandleFramebufferTextureLayer(
1161 uint32_t immediate_data_size
,
1162 const void* cmd_data
) {
1163 if (!unsafe_es3_apis_enabled())
1164 return error::kUnknownCommand
;
1165 const gles2::cmds::FramebufferTextureLayer
& c
=
1166 *static_cast<const gles2::cmds::FramebufferTextureLayer
*>(cmd_data
);
1168 GLenum target
= static_cast<GLenum
>(c
.target
);
1169 GLenum attachment
= static_cast<GLenum
>(c
.attachment
);
1170 GLuint texture
= c
.texture
;
1171 GLint level
= static_cast<GLint
>(c
.level
);
1172 GLint layer
= static_cast<GLint
>(c
.layer
);
1173 DoFramebufferTextureLayer(target
, attachment
, texture
, level
, layer
);
1174 return error::kNoError
;
1177 error::Error
GLES2DecoderImpl::HandleFrontFace(uint32_t immediate_data_size
,
1178 const void* cmd_data
) {
1179 const gles2::cmds::FrontFace
& c
=
1180 *static_cast<const gles2::cmds::FrontFace
*>(cmd_data
);
1182 GLenum mode
= static_cast<GLenum
>(c
.mode
);
1183 if (!validators_
->face_mode
.IsValid(mode
)) {
1184 LOCAL_SET_GL_ERROR_INVALID_ENUM("glFrontFace", mode
, "mode");
1185 return error::kNoError
;
1187 if (state_
.front_face
!= mode
) {
1188 state_
.front_face
= mode
;
1191 return error::kNoError
;
1194 error::Error
GLES2DecoderImpl::HandleGenBuffersImmediate(
1195 uint32_t immediate_data_size
,
1196 const void* cmd_data
) {
1197 const gles2::cmds::GenBuffersImmediate
& c
=
1198 *static_cast<const gles2::cmds::GenBuffersImmediate
*>(cmd_data
);
1200 GLsizei n
= static_cast<GLsizei
>(c
.n
);
1202 if (!SafeMultiplyUint32(n
, sizeof(GLuint
), &data_size
)) {
1203 return error::kOutOfBounds
;
1206 GetImmediateDataAs
<GLuint
*>(c
, data_size
, immediate_data_size
);
1207 if (buffers
== NULL
) {
1208 return error::kOutOfBounds
;
1210 if (!GenBuffersHelper(n
, buffers
)) {
1211 return error::kInvalidArguments
;
1213 return error::kNoError
;
1216 error::Error
GLES2DecoderImpl::HandleGenerateMipmap(
1217 uint32_t immediate_data_size
,
1218 const void* cmd_data
) {
1219 const gles2::cmds::GenerateMipmap
& c
=
1220 *static_cast<const gles2::cmds::GenerateMipmap
*>(cmd_data
);
1222 GLenum target
= static_cast<GLenum
>(c
.target
);
1223 if (!validators_
->texture_bind_target
.IsValid(target
)) {
1224 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGenerateMipmap", target
, "target");
1225 return error::kNoError
;
1227 DoGenerateMipmap(target
);
1228 return error::kNoError
;
1231 error::Error
GLES2DecoderImpl::HandleGenFramebuffersImmediate(
1232 uint32_t immediate_data_size
,
1233 const void* cmd_data
) {
1234 const gles2::cmds::GenFramebuffersImmediate
& c
=
1235 *static_cast<const gles2::cmds::GenFramebuffersImmediate
*>(cmd_data
);
1237 GLsizei n
= static_cast<GLsizei
>(c
.n
);
1239 if (!SafeMultiplyUint32(n
, sizeof(GLuint
), &data_size
)) {
1240 return error::kOutOfBounds
;
1242 GLuint
* framebuffers
=
1243 GetImmediateDataAs
<GLuint
*>(c
, data_size
, immediate_data_size
);
1244 if (framebuffers
== NULL
) {
1245 return error::kOutOfBounds
;
1247 if (!GenFramebuffersHelper(n
, framebuffers
)) {
1248 return error::kInvalidArguments
;
1250 return error::kNoError
;
1253 error::Error
GLES2DecoderImpl::HandleGenRenderbuffersImmediate(
1254 uint32_t immediate_data_size
,
1255 const void* cmd_data
) {
1256 const gles2::cmds::GenRenderbuffersImmediate
& c
=
1257 *static_cast<const gles2::cmds::GenRenderbuffersImmediate
*>(cmd_data
);
1259 GLsizei n
= static_cast<GLsizei
>(c
.n
);
1261 if (!SafeMultiplyUint32(n
, sizeof(GLuint
), &data_size
)) {
1262 return error::kOutOfBounds
;
1264 GLuint
* renderbuffers
=
1265 GetImmediateDataAs
<GLuint
*>(c
, data_size
, immediate_data_size
);
1266 if (renderbuffers
== NULL
) {
1267 return error::kOutOfBounds
;
1269 if (!GenRenderbuffersHelper(n
, renderbuffers
)) {
1270 return error::kInvalidArguments
;
1272 return error::kNoError
;
1275 error::Error
GLES2DecoderImpl::HandleGenSamplersImmediate(
1276 uint32_t immediate_data_size
,
1277 const void* cmd_data
) {
1278 if (!unsafe_es3_apis_enabled())
1279 return error::kUnknownCommand
;
1280 const gles2::cmds::GenSamplersImmediate
& c
=
1281 *static_cast<const gles2::cmds::GenSamplersImmediate
*>(cmd_data
);
1283 GLsizei n
= static_cast<GLsizei
>(c
.n
);
1285 if (!SafeMultiplyUint32(n
, sizeof(GLuint
), &data_size
)) {
1286 return error::kOutOfBounds
;
1289 GetImmediateDataAs
<GLuint
*>(c
, data_size
, immediate_data_size
);
1290 if (samplers
== NULL
) {
1291 return error::kOutOfBounds
;
1293 for (GLsizei ii
= 0; ii
< n
; ++ii
) {
1294 if (group_
->GetSamplerServiceId(samplers
[ii
], NULL
)) {
1295 return error::kInvalidArguments
;
1298 scoped_ptr
<GLuint
[]> service_ids(new GLuint
[n
]);
1299 glGenSamplers(n
, service_ids
.get());
1300 for (GLsizei ii
= 0; ii
< n
; ++ii
) {
1301 group_
->AddSamplerId(samplers
[ii
], service_ids
[ii
]);
1303 return error::kNoError
;
1306 error::Error
GLES2DecoderImpl::HandleGenTexturesImmediate(
1307 uint32_t immediate_data_size
,
1308 const void* cmd_data
) {
1309 const gles2::cmds::GenTexturesImmediate
& c
=
1310 *static_cast<const gles2::cmds::GenTexturesImmediate
*>(cmd_data
);
1312 GLsizei n
= static_cast<GLsizei
>(c
.n
);
1314 if (!SafeMultiplyUint32(n
, sizeof(GLuint
), &data_size
)) {
1315 return error::kOutOfBounds
;
1318 GetImmediateDataAs
<GLuint
*>(c
, data_size
, immediate_data_size
);
1319 if (textures
== NULL
) {
1320 return error::kOutOfBounds
;
1322 if (!GenTexturesHelper(n
, textures
)) {
1323 return error::kInvalidArguments
;
1325 return error::kNoError
;
1328 error::Error
GLES2DecoderImpl::HandleGenTransformFeedbacksImmediate(
1329 uint32_t immediate_data_size
,
1330 const void* cmd_data
) {
1331 if (!unsafe_es3_apis_enabled())
1332 return error::kUnknownCommand
;
1333 const gles2::cmds::GenTransformFeedbacksImmediate
& c
=
1334 *static_cast<const gles2::cmds::GenTransformFeedbacksImmediate
*>(
1337 GLsizei n
= static_cast<GLsizei
>(c
.n
);
1339 if (!SafeMultiplyUint32(n
, sizeof(GLuint
), &data_size
)) {
1340 return error::kOutOfBounds
;
1342 GLuint
* ids
= GetImmediateDataAs
<GLuint
*>(c
, data_size
, immediate_data_size
);
1344 return error::kOutOfBounds
;
1346 for (GLsizei ii
= 0; ii
< n
; ++ii
) {
1347 if (group_
->GetTransformFeedbackServiceId(ids
[ii
], NULL
)) {
1348 return error::kInvalidArguments
;
1351 scoped_ptr
<GLuint
[]> service_ids(new GLuint
[n
]);
1352 glGenTransformFeedbacks(n
, service_ids
.get());
1353 for (GLsizei ii
= 0; ii
< n
; ++ii
) {
1354 group_
->AddTransformFeedbackId(ids
[ii
], service_ids
[ii
]);
1356 return error::kNoError
;
1359 error::Error
GLES2DecoderImpl::HandleGetBooleanv(uint32_t immediate_data_size
,
1360 const void* cmd_data
) {
1361 const gles2::cmds::GetBooleanv
& c
=
1362 *static_cast<const gles2::cmds::GetBooleanv
*>(cmd_data
);
1364 GLenum pname
= static_cast<GLenum
>(c
.pname
);
1365 typedef cmds::GetBooleanv::Result Result
;
1366 GLsizei num_values
= 0;
1367 GetNumValuesReturnedForGLGet(pname
, &num_values
);
1368 Result
* result
= GetSharedMemoryAs
<Result
*>(
1369 c
.params_shm_id
, c
.params_shm_offset
, Result::ComputeSize(num_values
));
1370 GLboolean
* params
= result
? result
->GetData() : NULL
;
1371 if (!validators_
->g_l_state
.IsValid(pname
)) {
1372 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetBooleanv", pname
, "pname");
1373 return error::kNoError
;
1375 if (params
== NULL
) {
1376 return error::kOutOfBounds
;
1378 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetBooleanv");
1379 // Check that the client initialized the result.
1380 if (result
->size
!= 0) {
1381 return error::kInvalidArguments
;
1383 DoGetBooleanv(pname
, params
);
1384 GLenum error
= LOCAL_PEEK_GL_ERROR("GetBooleanv");
1385 if (error
== GL_NO_ERROR
) {
1386 result
->SetNumResults(num_values
);
1388 return error::kNoError
;
1391 error::Error
GLES2DecoderImpl::HandleGetBufferParameteri64v(
1392 uint32_t immediate_data_size
,
1393 const void* cmd_data
) {
1394 if (!unsafe_es3_apis_enabled())
1395 return error::kUnknownCommand
;
1396 const gles2::cmds::GetBufferParameteri64v
& c
=
1397 *static_cast<const gles2::cmds::GetBufferParameteri64v
*>(cmd_data
);
1399 GLenum target
= static_cast<GLenum
>(c
.target
);
1400 GLenum pname
= static_cast<GLenum
>(c
.pname
);
1401 typedef cmds::GetBufferParameteri64v::Result Result
;
1402 GLsizei num_values
= 0;
1403 GetNumValuesReturnedForGLGet(pname
, &num_values
);
1404 Result
* result
= GetSharedMemoryAs
<Result
*>(
1405 c
.params_shm_id
, c
.params_shm_offset
, Result::ComputeSize(num_values
));
1406 GLint64
* params
= result
? result
->GetData() : NULL
;
1407 if (params
== NULL
) {
1408 return error::kOutOfBounds
;
1410 // Check that the client initialized the result.
1411 if (result
->size
!= 0) {
1412 return error::kInvalidArguments
;
1414 DoGetBufferParameteri64v(target
, pname
, params
);
1415 result
->SetNumResults(num_values
);
1416 return error::kNoError
;
1418 error::Error
GLES2DecoderImpl::HandleGetBufferParameteriv(
1419 uint32_t immediate_data_size
,
1420 const void* cmd_data
) {
1421 const gles2::cmds::GetBufferParameteriv
& c
=
1422 *static_cast<const gles2::cmds::GetBufferParameteriv
*>(cmd_data
);
1424 GLenum target
= static_cast<GLenum
>(c
.target
);
1425 GLenum pname
= static_cast<GLenum
>(c
.pname
);
1426 typedef cmds::GetBufferParameteriv::Result Result
;
1427 GLsizei num_values
= 0;
1428 GetNumValuesReturnedForGLGet(pname
, &num_values
);
1429 Result
* result
= GetSharedMemoryAs
<Result
*>(
1430 c
.params_shm_id
, c
.params_shm_offset
, Result::ComputeSize(num_values
));
1431 GLint
* params
= result
? result
->GetData() : NULL
;
1432 if (!validators_
->buffer_target
.IsValid(target
)) {
1433 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetBufferParameteriv", target
, "target");
1434 return error::kNoError
;
1436 if (!validators_
->buffer_parameter
.IsValid(pname
)) {
1437 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetBufferParameteriv", pname
, "pname");
1438 return error::kNoError
;
1440 if (params
== NULL
) {
1441 return error::kOutOfBounds
;
1443 // Check that the client initialized the result.
1444 if (result
->size
!= 0) {
1445 return error::kInvalidArguments
;
1447 DoGetBufferParameteriv(target
, pname
, params
);
1448 result
->SetNumResults(num_values
);
1449 return error::kNoError
;
1451 error::Error
GLES2DecoderImpl::HandleGetError(uint32_t immediate_data_size
,
1452 const void* cmd_data
) {
1453 const gles2::cmds::GetError
& c
=
1454 *static_cast<const gles2::cmds::GetError
*>(cmd_data
);
1456 typedef cmds::GetError::Result Result
;
1457 Result
* result_dst
= GetSharedMemoryAs
<Result
*>(
1458 c
.result_shm_id
, c
.result_shm_offset
, sizeof(*result_dst
));
1460 return error::kOutOfBounds
;
1462 *result_dst
= GetErrorState()->GetGLError();
1463 return error::kNoError
;
1466 error::Error
GLES2DecoderImpl::HandleGetFloatv(uint32_t immediate_data_size
,
1467 const void* cmd_data
) {
1468 const gles2::cmds::GetFloatv
& c
=
1469 *static_cast<const gles2::cmds::GetFloatv
*>(cmd_data
);
1471 GLenum pname
= static_cast<GLenum
>(c
.pname
);
1472 typedef cmds::GetFloatv::Result Result
;
1473 GLsizei num_values
= 0;
1474 GetNumValuesReturnedForGLGet(pname
, &num_values
);
1475 Result
* result
= GetSharedMemoryAs
<Result
*>(
1476 c
.params_shm_id
, c
.params_shm_offset
, Result::ComputeSize(num_values
));
1477 GLfloat
* params
= result
? result
->GetData() : NULL
;
1478 if (!validators_
->g_l_state
.IsValid(pname
)) {
1479 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetFloatv", pname
, "pname");
1480 return error::kNoError
;
1482 if (params
== NULL
) {
1483 return error::kOutOfBounds
;
1485 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetFloatv");
1486 // Check that the client initialized the result.
1487 if (result
->size
!= 0) {
1488 return error::kInvalidArguments
;
1490 DoGetFloatv(pname
, params
);
1491 GLenum error
= LOCAL_PEEK_GL_ERROR("GetFloatv");
1492 if (error
== GL_NO_ERROR
) {
1493 result
->SetNumResults(num_values
);
1495 return error::kNoError
;
1498 error::Error
GLES2DecoderImpl::HandleGetFramebufferAttachmentParameteriv(
1499 uint32_t immediate_data_size
,
1500 const void* cmd_data
) {
1501 const gles2::cmds::GetFramebufferAttachmentParameteriv
& c
=
1502 *static_cast<const gles2::cmds::GetFramebufferAttachmentParameteriv
*>(
1505 GLenum target
= static_cast<GLenum
>(c
.target
);
1506 GLenum attachment
= static_cast<GLenum
>(c
.attachment
);
1507 GLenum pname
= static_cast<GLenum
>(c
.pname
);
1508 typedef cmds::GetFramebufferAttachmentParameteriv::Result Result
;
1509 GLsizei num_values
= 0;
1510 GetNumValuesReturnedForGLGet(pname
, &num_values
);
1511 Result
* result
= GetSharedMemoryAs
<Result
*>(
1512 c
.params_shm_id
, c
.params_shm_offset
, Result::ComputeSize(num_values
));
1513 GLint
* params
= result
? result
->GetData() : NULL
;
1514 if (!validators_
->frame_buffer_target
.IsValid(target
)) {
1515 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetFramebufferAttachmentParameteriv",
1517 return error::kNoError
;
1519 if (!validators_
->attachment
.IsValid(attachment
)) {
1520 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetFramebufferAttachmentParameteriv",
1521 attachment
, "attachment");
1522 return error::kNoError
;
1524 if (!validators_
->frame_buffer_parameter
.IsValid(pname
)) {
1525 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetFramebufferAttachmentParameteriv",
1527 return error::kNoError
;
1529 if (params
== NULL
) {
1530 return error::kOutOfBounds
;
1532 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetFramebufferAttachmentParameteriv");
1533 // Check that the client initialized the result.
1534 if (result
->size
!= 0) {
1535 return error::kInvalidArguments
;
1537 DoGetFramebufferAttachmentParameteriv(target
, attachment
, pname
, params
);
1538 GLenum error
= LOCAL_PEEK_GL_ERROR("GetFramebufferAttachmentParameteriv");
1539 if (error
== GL_NO_ERROR
) {
1540 result
->SetNumResults(num_values
);
1542 return error::kNoError
;
1545 error::Error
GLES2DecoderImpl::HandleGetInteger64v(uint32_t immediate_data_size
,
1546 const void* cmd_data
) {
1547 if (!unsafe_es3_apis_enabled())
1548 return error::kUnknownCommand
;
1549 const gles2::cmds::GetInteger64v
& c
=
1550 *static_cast<const gles2::cmds::GetInteger64v
*>(cmd_data
);
1552 GLenum pname
= static_cast<GLenum
>(c
.pname
);
1553 typedef cmds::GetInteger64v::Result Result
;
1554 GLsizei num_values
= 0;
1555 GetNumValuesReturnedForGLGet(pname
, &num_values
);
1556 Result
* result
= GetSharedMemoryAs
<Result
*>(
1557 c
.params_shm_id
, c
.params_shm_offset
, Result::ComputeSize(num_values
));
1558 GLint64
* params
= result
? result
->GetData() : NULL
;
1559 if (params
== NULL
) {
1560 return error::kOutOfBounds
;
1562 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetInteger64v");
1563 // Check that the client initialized the result.
1564 if (result
->size
!= 0) {
1565 return error::kInvalidArguments
;
1567 DoGetInteger64v(pname
, params
);
1568 GLenum error
= LOCAL_PEEK_GL_ERROR("GetInteger64v");
1569 if (error
== GL_NO_ERROR
) {
1570 result
->SetNumResults(num_values
);
1572 return error::kNoError
;
1575 error::Error
GLES2DecoderImpl::HandleGetIntegeri_v(uint32_t immediate_data_size
,
1576 const void* cmd_data
) {
1577 if (!unsafe_es3_apis_enabled())
1578 return error::kUnknownCommand
;
1579 const gles2::cmds::GetIntegeri_v
& c
=
1580 *static_cast<const gles2::cmds::GetIntegeri_v
*>(cmd_data
);
1582 GLenum pname
= static_cast<GLenum
>(c
.pname
);
1583 GLuint index
= static_cast<GLuint
>(c
.index
);
1584 typedef cmds::GetIntegeri_v::Result Result
;
1585 GLsizei num_values
= 0;
1586 GetNumValuesReturnedForGLGet(pname
, &num_values
);
1587 Result
* result
= GetSharedMemoryAs
<Result
*>(c
.data_shm_id
, c
.data_shm_offset
,
1588 Result::ComputeSize(num_values
));
1589 GLint
* data
= result
? result
->GetData() : NULL
;
1591 return error::kOutOfBounds
;
1593 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetIntegeri_v");
1594 // Check that the client initialized the result.
1595 if (result
->size
!= 0) {
1596 return error::kInvalidArguments
;
1598 glGetIntegeri_v(pname
, index
, data
);
1599 GLenum error
= LOCAL_PEEK_GL_ERROR("GetIntegeri_v");
1600 if (error
== GL_NO_ERROR
) {
1601 result
->SetNumResults(num_values
);
1603 return error::kNoError
;
1606 error::Error
GLES2DecoderImpl::HandleGetInteger64i_v(
1607 uint32_t immediate_data_size
,
1608 const void* cmd_data
) {
1609 if (!unsafe_es3_apis_enabled())
1610 return error::kUnknownCommand
;
1611 const gles2::cmds::GetInteger64i_v
& c
=
1612 *static_cast<const gles2::cmds::GetInteger64i_v
*>(cmd_data
);
1614 GLenum pname
= static_cast<GLenum
>(c
.pname
);
1615 GLuint index
= static_cast<GLuint
>(c
.index
);
1616 typedef cmds::GetInteger64i_v::Result Result
;
1617 GLsizei num_values
= 0;
1618 GetNumValuesReturnedForGLGet(pname
, &num_values
);
1619 Result
* result
= GetSharedMemoryAs
<Result
*>(c
.data_shm_id
, c
.data_shm_offset
,
1620 Result::ComputeSize(num_values
));
1621 GLint64
* data
= result
? result
->GetData() : NULL
;
1623 return error::kOutOfBounds
;
1625 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetInteger64i_v");
1626 // Check that the client initialized the result.
1627 if (result
->size
!= 0) {
1628 return error::kInvalidArguments
;
1630 glGetInteger64i_v(pname
, index
, data
);
1631 GLenum error
= LOCAL_PEEK_GL_ERROR("GetInteger64i_v");
1632 if (error
== GL_NO_ERROR
) {
1633 result
->SetNumResults(num_values
);
1635 return error::kNoError
;
1638 error::Error
GLES2DecoderImpl::HandleGetIntegerv(uint32_t immediate_data_size
,
1639 const void* cmd_data
) {
1640 const gles2::cmds::GetIntegerv
& c
=
1641 *static_cast<const gles2::cmds::GetIntegerv
*>(cmd_data
);
1643 GLenum pname
= static_cast<GLenum
>(c
.pname
);
1644 typedef cmds::GetIntegerv::Result Result
;
1645 GLsizei num_values
= 0;
1646 GetNumValuesReturnedForGLGet(pname
, &num_values
);
1647 Result
* result
= GetSharedMemoryAs
<Result
*>(
1648 c
.params_shm_id
, c
.params_shm_offset
, Result::ComputeSize(num_values
));
1649 GLint
* params
= result
? result
->GetData() : NULL
;
1650 if (!validators_
->g_l_state
.IsValid(pname
)) {
1651 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetIntegerv", pname
, "pname");
1652 return error::kNoError
;
1654 if (params
== NULL
) {
1655 return error::kOutOfBounds
;
1657 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetIntegerv");
1658 // Check that the client initialized the result.
1659 if (result
->size
!= 0) {
1660 return error::kInvalidArguments
;
1662 DoGetIntegerv(pname
, params
);
1663 GLenum error
= LOCAL_PEEK_GL_ERROR("GetIntegerv");
1664 if (error
== GL_NO_ERROR
) {
1665 result
->SetNumResults(num_values
);
1667 return error::kNoError
;
1670 error::Error
GLES2DecoderImpl::HandleGetProgramiv(uint32_t immediate_data_size
,
1671 const void* cmd_data
) {
1672 const gles2::cmds::GetProgramiv
& c
=
1673 *static_cast<const gles2::cmds::GetProgramiv
*>(cmd_data
);
1675 GLuint program
= c
.program
;
1676 GLenum pname
= static_cast<GLenum
>(c
.pname
);
1677 typedef cmds::GetProgramiv::Result Result
;
1678 GLsizei num_values
= 0;
1679 GetNumValuesReturnedForGLGet(pname
, &num_values
);
1680 Result
* result
= GetSharedMemoryAs
<Result
*>(
1681 c
.params_shm_id
, c
.params_shm_offset
, Result::ComputeSize(num_values
));
1682 GLint
* params
= result
? result
->GetData() : NULL
;
1683 if (!validators_
->program_parameter
.IsValid(pname
)) {
1684 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetProgramiv", pname
, "pname");
1685 return error::kNoError
;
1687 if (params
== NULL
) {
1688 return error::kOutOfBounds
;
1690 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetProgramiv");
1691 // Check that the client initialized the result.
1692 if (result
->size
!= 0) {
1693 return error::kInvalidArguments
;
1695 DoGetProgramiv(program
, pname
, params
);
1696 GLenum error
= LOCAL_PEEK_GL_ERROR("GetProgramiv");
1697 if (error
== GL_NO_ERROR
) {
1698 result
->SetNumResults(num_values
);
1700 return error::kNoError
;
1703 error::Error
GLES2DecoderImpl::HandleGetRenderbufferParameteriv(
1704 uint32_t immediate_data_size
,
1705 const void* cmd_data
) {
1706 const gles2::cmds::GetRenderbufferParameteriv
& c
=
1707 *static_cast<const gles2::cmds::GetRenderbufferParameteriv
*>(cmd_data
);
1709 GLenum target
= static_cast<GLenum
>(c
.target
);
1710 GLenum pname
= static_cast<GLenum
>(c
.pname
);
1711 typedef cmds::GetRenderbufferParameteriv::Result Result
;
1712 GLsizei num_values
= 0;
1713 GetNumValuesReturnedForGLGet(pname
, &num_values
);
1714 Result
* result
= GetSharedMemoryAs
<Result
*>(
1715 c
.params_shm_id
, c
.params_shm_offset
, Result::ComputeSize(num_values
));
1716 GLint
* params
= result
? result
->GetData() : NULL
;
1717 if (!validators_
->render_buffer_target
.IsValid(target
)) {
1718 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetRenderbufferParameteriv", target
,
1720 return error::kNoError
;
1722 if (!validators_
->render_buffer_parameter
.IsValid(pname
)) {
1723 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetRenderbufferParameteriv", pname
,
1725 return error::kNoError
;
1727 if (params
== NULL
) {
1728 return error::kOutOfBounds
;
1730 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetRenderbufferParameteriv");
1731 // Check that the client initialized the result.
1732 if (result
->size
!= 0) {
1733 return error::kInvalidArguments
;
1735 DoGetRenderbufferParameteriv(target
, pname
, params
);
1736 GLenum error
= LOCAL_PEEK_GL_ERROR("GetRenderbufferParameteriv");
1737 if (error
== GL_NO_ERROR
) {
1738 result
->SetNumResults(num_values
);
1740 return error::kNoError
;
1743 error::Error
GLES2DecoderImpl::HandleGetSamplerParameterfv(
1744 uint32_t immediate_data_size
,
1745 const void* cmd_data
) {
1746 if (!unsafe_es3_apis_enabled())
1747 return error::kUnknownCommand
;
1748 const gles2::cmds::GetSamplerParameterfv
& c
=
1749 *static_cast<const gles2::cmds::GetSamplerParameterfv
*>(cmd_data
);
1751 GLuint sampler
= c
.sampler
;
1752 GLenum pname
= static_cast<GLenum
>(c
.pname
);
1753 typedef cmds::GetSamplerParameterfv::Result Result
;
1754 GLsizei num_values
= 0;
1755 GetNumValuesReturnedForGLGet(pname
, &num_values
);
1756 Result
* result
= GetSharedMemoryAs
<Result
*>(
1757 c
.params_shm_id
, c
.params_shm_offset
, Result::ComputeSize(num_values
));
1758 GLfloat
* params
= result
? result
->GetData() : NULL
;
1759 if (params
== NULL
) {
1760 return error::kOutOfBounds
;
1762 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetSamplerParameterfv");
1763 // Check that the client initialized the result.
1764 if (result
->size
!= 0) {
1765 return error::kInvalidArguments
;
1767 if (!group_
->GetSamplerServiceId(sampler
, &sampler
)) {
1768 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION
, "glGetSamplerParameterfv",
1769 "invalid sampler id");
1770 return error::kNoError
;
1772 glGetSamplerParameterfv(sampler
, pname
, params
);
1773 GLenum error
= LOCAL_PEEK_GL_ERROR("GetSamplerParameterfv");
1774 if (error
== GL_NO_ERROR
) {
1775 result
->SetNumResults(num_values
);
1777 return error::kNoError
;
1780 error::Error
GLES2DecoderImpl::HandleGetSamplerParameteriv(
1781 uint32_t immediate_data_size
,
1782 const void* cmd_data
) {
1783 if (!unsafe_es3_apis_enabled())
1784 return error::kUnknownCommand
;
1785 const gles2::cmds::GetSamplerParameteriv
& c
=
1786 *static_cast<const gles2::cmds::GetSamplerParameteriv
*>(cmd_data
);
1788 GLuint sampler
= c
.sampler
;
1789 GLenum pname
= static_cast<GLenum
>(c
.pname
);
1790 typedef cmds::GetSamplerParameteriv::Result Result
;
1791 GLsizei num_values
= 0;
1792 GetNumValuesReturnedForGLGet(pname
, &num_values
);
1793 Result
* result
= GetSharedMemoryAs
<Result
*>(
1794 c
.params_shm_id
, c
.params_shm_offset
, Result::ComputeSize(num_values
));
1795 GLint
* params
= result
? result
->GetData() : NULL
;
1796 if (params
== NULL
) {
1797 return error::kOutOfBounds
;
1799 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetSamplerParameteriv");
1800 // Check that the client initialized the result.
1801 if (result
->size
!= 0) {
1802 return error::kInvalidArguments
;
1804 if (!group_
->GetSamplerServiceId(sampler
, &sampler
)) {
1805 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION
, "glGetSamplerParameteriv",
1806 "invalid sampler id");
1807 return error::kNoError
;
1809 glGetSamplerParameteriv(sampler
, pname
, params
);
1810 GLenum error
= LOCAL_PEEK_GL_ERROR("GetSamplerParameteriv");
1811 if (error
== GL_NO_ERROR
) {
1812 result
->SetNumResults(num_values
);
1814 return error::kNoError
;
1817 error::Error
GLES2DecoderImpl::HandleGetShaderiv(uint32_t immediate_data_size
,
1818 const void* cmd_data
) {
1819 const gles2::cmds::GetShaderiv
& c
=
1820 *static_cast<const gles2::cmds::GetShaderiv
*>(cmd_data
);
1822 GLuint shader
= c
.shader
;
1823 GLenum pname
= static_cast<GLenum
>(c
.pname
);
1824 typedef cmds::GetShaderiv::Result Result
;
1825 GLsizei num_values
= 0;
1826 GetNumValuesReturnedForGLGet(pname
, &num_values
);
1827 Result
* result
= GetSharedMemoryAs
<Result
*>(
1828 c
.params_shm_id
, c
.params_shm_offset
, Result::ComputeSize(num_values
));
1829 GLint
* params
= result
? result
->GetData() : NULL
;
1830 if (!validators_
->shader_parameter
.IsValid(pname
)) {
1831 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetShaderiv", pname
, "pname");
1832 return error::kNoError
;
1834 if (params
== NULL
) {
1835 return error::kOutOfBounds
;
1837 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetShaderiv");
1838 // Check that the client initialized the result.
1839 if (result
->size
!= 0) {
1840 return error::kInvalidArguments
;
1842 DoGetShaderiv(shader
, pname
, params
);
1843 GLenum error
= LOCAL_PEEK_GL_ERROR("GetShaderiv");
1844 if (error
== GL_NO_ERROR
) {
1845 result
->SetNumResults(num_values
);
1847 return error::kNoError
;
1850 error::Error
GLES2DecoderImpl::HandleGetSynciv(uint32_t immediate_data_size
,
1851 const void* cmd_data
) {
1852 if (!unsafe_es3_apis_enabled())
1853 return error::kUnknownCommand
;
1854 const gles2::cmds::GetSynciv
& c
=
1855 *static_cast<const gles2::cmds::GetSynciv
*>(cmd_data
);
1857 GLuint sync
= static_cast<GLuint
>(c
.sync
);
1858 GLenum pname
= static_cast<GLenum
>(c
.pname
);
1859 typedef cmds::GetSynciv::Result Result
;
1860 GLsizei num_values
= 0;
1861 GetNumValuesReturnedForGLGet(pname
, &num_values
);
1862 Result
* result
= GetSharedMemoryAs
<Result
*>(
1863 c
.values_shm_id
, c
.values_shm_offset
, Result::ComputeSize(num_values
));
1864 GLint
* values
= result
? result
->GetData() : NULL
;
1865 if (values
== NULL
) {
1866 return error::kOutOfBounds
;
1868 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetSynciv");
1869 // Check that the client initialized the result.
1870 if (result
->size
!= 0) {
1871 return error::kInvalidArguments
;
1873 GLsync service_sync
= 0;
1874 if (!group_
->GetSyncServiceId(sync
, &service_sync
)) {
1875 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION
, "glGetSynciv", "invalid sync id");
1876 return error::kNoError
;
1878 glGetSynciv(service_sync
, pname
, num_values
, nullptr, values
);
1879 GLenum error
= LOCAL_PEEK_GL_ERROR("GetSynciv");
1880 if (error
== GL_NO_ERROR
) {
1881 result
->SetNumResults(num_values
);
1883 return error::kNoError
;
1886 error::Error
GLES2DecoderImpl::HandleGetTexParameterfv(
1887 uint32_t immediate_data_size
,
1888 const void* cmd_data
) {
1889 const gles2::cmds::GetTexParameterfv
& c
=
1890 *static_cast<const gles2::cmds::GetTexParameterfv
*>(cmd_data
);
1892 GLenum target
= static_cast<GLenum
>(c
.target
);
1893 GLenum pname
= static_cast<GLenum
>(c
.pname
);
1894 typedef cmds::GetTexParameterfv::Result Result
;
1895 GLsizei num_values
= 0;
1896 GetNumValuesReturnedForGLGet(pname
, &num_values
);
1897 Result
* result
= GetSharedMemoryAs
<Result
*>(
1898 c
.params_shm_id
, c
.params_shm_offset
, Result::ComputeSize(num_values
));
1899 GLfloat
* params
= result
? result
->GetData() : NULL
;
1900 if (!validators_
->get_tex_param_target
.IsValid(target
)) {
1901 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetTexParameterfv", target
, "target");
1902 return error::kNoError
;
1904 if (!validators_
->texture_parameter
.IsValid(pname
)) {
1905 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetTexParameterfv", pname
, "pname");
1906 return error::kNoError
;
1908 if (params
== NULL
) {
1909 return error::kOutOfBounds
;
1911 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetTexParameterfv");
1912 // Check that the client initialized the result.
1913 if (result
->size
!= 0) {
1914 return error::kInvalidArguments
;
1916 DoGetTexParameterfv(target
, pname
, params
);
1917 GLenum error
= LOCAL_PEEK_GL_ERROR("GetTexParameterfv");
1918 if (error
== GL_NO_ERROR
) {
1919 result
->SetNumResults(num_values
);
1921 return error::kNoError
;
1924 error::Error
GLES2DecoderImpl::HandleGetTexParameteriv(
1925 uint32_t immediate_data_size
,
1926 const void* cmd_data
) {
1927 const gles2::cmds::GetTexParameteriv
& c
=
1928 *static_cast<const gles2::cmds::GetTexParameteriv
*>(cmd_data
);
1930 GLenum target
= static_cast<GLenum
>(c
.target
);
1931 GLenum pname
= static_cast<GLenum
>(c
.pname
);
1932 typedef cmds::GetTexParameteriv::Result Result
;
1933 GLsizei num_values
= 0;
1934 GetNumValuesReturnedForGLGet(pname
, &num_values
);
1935 Result
* result
= GetSharedMemoryAs
<Result
*>(
1936 c
.params_shm_id
, c
.params_shm_offset
, Result::ComputeSize(num_values
));
1937 GLint
* params
= result
? result
->GetData() : NULL
;
1938 if (!validators_
->get_tex_param_target
.IsValid(target
)) {
1939 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetTexParameteriv", target
, "target");
1940 return error::kNoError
;
1942 if (!validators_
->texture_parameter
.IsValid(pname
)) {
1943 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetTexParameteriv", pname
, "pname");
1944 return error::kNoError
;
1946 if (params
== NULL
) {
1947 return error::kOutOfBounds
;
1949 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetTexParameteriv");
1950 // Check that the client initialized the result.
1951 if (result
->size
!= 0) {
1952 return error::kInvalidArguments
;
1954 DoGetTexParameteriv(target
, pname
, params
);
1955 GLenum error
= LOCAL_PEEK_GL_ERROR("GetTexParameteriv");
1956 if (error
== GL_NO_ERROR
) {
1957 result
->SetNumResults(num_values
);
1959 return error::kNoError
;
1962 error::Error
GLES2DecoderImpl::HandleGetVertexAttribfv(
1963 uint32_t immediate_data_size
,
1964 const void* cmd_data
) {
1965 const gles2::cmds::GetVertexAttribfv
& c
=
1966 *static_cast<const gles2::cmds::GetVertexAttribfv
*>(cmd_data
);
1968 GLuint index
= static_cast<GLuint
>(c
.index
);
1969 GLenum pname
= static_cast<GLenum
>(c
.pname
);
1970 typedef cmds::GetVertexAttribfv::Result Result
;
1971 GLsizei num_values
= 0;
1972 GetNumValuesReturnedForGLGet(pname
, &num_values
);
1973 Result
* result
= GetSharedMemoryAs
<Result
*>(
1974 c
.params_shm_id
, c
.params_shm_offset
, Result::ComputeSize(num_values
));
1975 GLfloat
* params
= result
? result
->GetData() : NULL
;
1976 if (!validators_
->vertex_attribute
.IsValid(pname
)) {
1977 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetVertexAttribfv", pname
, "pname");
1978 return error::kNoError
;
1980 if (params
== NULL
) {
1981 return error::kOutOfBounds
;
1983 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetVertexAttribfv");
1984 // Check that the client initialized the result.
1985 if (result
->size
!= 0) {
1986 return error::kInvalidArguments
;
1988 DoGetVertexAttribfv(index
, pname
, params
);
1989 GLenum error
= LOCAL_PEEK_GL_ERROR("GetVertexAttribfv");
1990 if (error
== GL_NO_ERROR
) {
1991 result
->SetNumResults(num_values
);
1993 return error::kNoError
;
1996 error::Error
GLES2DecoderImpl::HandleGetVertexAttribiv(
1997 uint32_t immediate_data_size
,
1998 const void* cmd_data
) {
1999 const gles2::cmds::GetVertexAttribiv
& c
=
2000 *static_cast<const gles2::cmds::GetVertexAttribiv
*>(cmd_data
);
2002 GLuint index
= static_cast<GLuint
>(c
.index
);
2003 GLenum pname
= static_cast<GLenum
>(c
.pname
);
2004 typedef cmds::GetVertexAttribiv::Result Result
;
2005 GLsizei num_values
= 0;
2006 GetNumValuesReturnedForGLGet(pname
, &num_values
);
2007 Result
* result
= GetSharedMemoryAs
<Result
*>(
2008 c
.params_shm_id
, c
.params_shm_offset
, Result::ComputeSize(num_values
));
2009 GLint
* params
= result
? result
->GetData() : NULL
;
2010 if (!validators_
->vertex_attribute
.IsValid(pname
)) {
2011 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetVertexAttribiv", pname
, "pname");
2012 return error::kNoError
;
2014 if (params
== NULL
) {
2015 return error::kOutOfBounds
;
2017 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetVertexAttribiv");
2018 // Check that the client initialized the result.
2019 if (result
->size
!= 0) {
2020 return error::kInvalidArguments
;
2022 DoGetVertexAttribiv(index
, pname
, params
);
2023 GLenum error
= LOCAL_PEEK_GL_ERROR("GetVertexAttribiv");
2024 if (error
== GL_NO_ERROR
) {
2025 result
->SetNumResults(num_values
);
2027 return error::kNoError
;
2030 error::Error
GLES2DecoderImpl::HandleGetVertexAttribIiv(
2031 uint32_t immediate_data_size
,
2032 const void* cmd_data
) {
2033 if (!unsafe_es3_apis_enabled())
2034 return error::kUnknownCommand
;
2035 const gles2::cmds::GetVertexAttribIiv
& c
=
2036 *static_cast<const gles2::cmds::GetVertexAttribIiv
*>(cmd_data
);
2038 GLuint index
= static_cast<GLuint
>(c
.index
);
2039 GLenum pname
= static_cast<GLenum
>(c
.pname
);
2040 typedef cmds::GetVertexAttribIiv::Result Result
;
2041 GLsizei num_values
= 0;
2042 GetNumValuesReturnedForGLGet(pname
, &num_values
);
2043 Result
* result
= GetSharedMemoryAs
<Result
*>(
2044 c
.params_shm_id
, c
.params_shm_offset
, Result::ComputeSize(num_values
));
2045 GLint
* params
= result
? result
->GetData() : NULL
;
2046 if (params
== NULL
) {
2047 return error::kOutOfBounds
;
2049 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetVertexAttribIiv");
2050 // Check that the client initialized the result.
2051 if (result
->size
!= 0) {
2052 return error::kInvalidArguments
;
2054 DoGetVertexAttribIiv(index
, pname
, params
);
2055 GLenum error
= LOCAL_PEEK_GL_ERROR("GetVertexAttribIiv");
2056 if (error
== GL_NO_ERROR
) {
2057 result
->SetNumResults(num_values
);
2059 return error::kNoError
;
2062 error::Error
GLES2DecoderImpl::HandleGetVertexAttribIuiv(
2063 uint32_t immediate_data_size
,
2064 const void* cmd_data
) {
2065 if (!unsafe_es3_apis_enabled())
2066 return error::kUnknownCommand
;
2067 const gles2::cmds::GetVertexAttribIuiv
& c
=
2068 *static_cast<const gles2::cmds::GetVertexAttribIuiv
*>(cmd_data
);
2070 GLuint index
= static_cast<GLuint
>(c
.index
);
2071 GLenum pname
= static_cast<GLenum
>(c
.pname
);
2072 typedef cmds::GetVertexAttribIuiv::Result Result
;
2073 GLsizei num_values
= 0;
2074 GetNumValuesReturnedForGLGet(pname
, &num_values
);
2075 Result
* result
= GetSharedMemoryAs
<Result
*>(
2076 c
.params_shm_id
, c
.params_shm_offset
, Result::ComputeSize(num_values
));
2077 GLuint
* params
= result
? result
->GetData() : NULL
;
2078 if (params
== NULL
) {
2079 return error::kOutOfBounds
;
2081 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("GetVertexAttribIuiv");
2082 // Check that the client initialized the result.
2083 if (result
->size
!= 0) {
2084 return error::kInvalidArguments
;
2086 DoGetVertexAttribIuiv(index
, pname
, params
);
2087 GLenum error
= LOCAL_PEEK_GL_ERROR("GetVertexAttribIuiv");
2088 if (error
== GL_NO_ERROR
) {
2089 result
->SetNumResults(num_values
);
2091 return error::kNoError
;
2094 error::Error
GLES2DecoderImpl::HandleHint(uint32_t immediate_data_size
,
2095 const void* cmd_data
) {
2096 const gles2::cmds::Hint
& c
= *static_cast<const gles2::cmds::Hint
*>(cmd_data
);
2098 GLenum target
= static_cast<GLenum
>(c
.target
);
2099 GLenum mode
= static_cast<GLenum
>(c
.mode
);
2100 if (!validators_
->hint_target
.IsValid(target
)) {
2101 LOCAL_SET_GL_ERROR_INVALID_ENUM("glHint", target
, "target");
2102 return error::kNoError
;
2104 if (!validators_
->hint_mode
.IsValid(mode
)) {
2105 LOCAL_SET_GL_ERROR_INVALID_ENUM("glHint", mode
, "mode");
2106 return error::kNoError
;
2109 case GL_GENERATE_MIPMAP_HINT
:
2110 if (state_
.hint_generate_mipmap
!= mode
) {
2111 state_
.hint_generate_mipmap
= mode
;
2112 glHint(target
, mode
);
2115 case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES
:
2116 if (state_
.hint_fragment_shader_derivative
!= mode
) {
2117 state_
.hint_fragment_shader_derivative
= mode
;
2118 glHint(target
, mode
);
2124 return error::kNoError
;
2127 error::Error
GLES2DecoderImpl::HandleInvalidateFramebufferImmediate(
2128 uint32_t immediate_data_size
,
2129 const void* cmd_data
) {
2130 if (!unsafe_es3_apis_enabled())
2131 return error::kUnknownCommand
;
2132 const gles2::cmds::InvalidateFramebufferImmediate
& c
=
2133 *static_cast<const gles2::cmds::InvalidateFramebufferImmediate
*>(
2136 GLenum target
= static_cast<GLenum
>(c
.target
);
2137 GLsizei count
= static_cast<GLsizei
>(c
.count
);
2139 if (!ComputeDataSize(count
, sizeof(GLenum
), 1, &data_size
)) {
2140 return error::kOutOfBounds
;
2142 if (data_size
> immediate_data_size
) {
2143 return error::kOutOfBounds
;
2145 const GLenum
* attachments
=
2146 GetImmediateDataAs
<const GLenum
*>(c
, data_size
, immediate_data_size
);
2147 if (attachments
== NULL
) {
2148 return error::kOutOfBounds
;
2150 glInvalidateFramebuffer(target
, count
, attachments
);
2151 return error::kNoError
;
2154 error::Error
GLES2DecoderImpl::HandleInvalidateSubFramebufferImmediate(
2155 uint32_t immediate_data_size
,
2156 const void* cmd_data
) {
2157 if (!unsafe_es3_apis_enabled())
2158 return error::kUnknownCommand
;
2159 const gles2::cmds::InvalidateSubFramebufferImmediate
& c
=
2160 *static_cast<const gles2::cmds::InvalidateSubFramebufferImmediate
*>(
2163 GLenum target
= static_cast<GLenum
>(c
.target
);
2164 GLsizei count
= static_cast<GLsizei
>(c
.count
);
2166 if (!ComputeDataSize(count
, sizeof(GLenum
), 1, &data_size
)) {
2167 return error::kOutOfBounds
;
2169 if (data_size
> immediate_data_size
) {
2170 return error::kOutOfBounds
;
2172 const GLenum
* attachments
=
2173 GetImmediateDataAs
<const GLenum
*>(c
, data_size
, immediate_data_size
);
2174 GLint x
= static_cast<GLint
>(c
.x
);
2175 GLint y
= static_cast<GLint
>(c
.y
);
2176 GLsizei width
= static_cast<GLsizei
>(c
.width
);
2177 GLsizei height
= static_cast<GLsizei
>(c
.height
);
2178 if (attachments
== NULL
) {
2179 return error::kOutOfBounds
;
2181 glInvalidateSubFramebuffer(target
, count
, attachments
, x
, y
, width
, height
);
2182 return error::kNoError
;
2185 error::Error
GLES2DecoderImpl::HandleIsBuffer(uint32_t immediate_data_size
,
2186 const void* cmd_data
) {
2187 const gles2::cmds::IsBuffer
& c
=
2188 *static_cast<const gles2::cmds::IsBuffer
*>(cmd_data
);
2190 GLuint buffer
= c
.buffer
;
2191 typedef cmds::IsBuffer::Result Result
;
2192 Result
* result_dst
= GetSharedMemoryAs
<Result
*>(
2193 c
.result_shm_id
, c
.result_shm_offset
, sizeof(*result_dst
));
2195 return error::kOutOfBounds
;
2197 *result_dst
= DoIsBuffer(buffer
);
2198 return error::kNoError
;
2201 error::Error
GLES2DecoderImpl::HandleIsEnabled(uint32_t immediate_data_size
,
2202 const void* cmd_data
) {
2203 const gles2::cmds::IsEnabled
& c
=
2204 *static_cast<const gles2::cmds::IsEnabled
*>(cmd_data
);
2206 GLenum cap
= static_cast<GLenum
>(c
.cap
);
2207 typedef cmds::IsEnabled::Result Result
;
2208 Result
* result_dst
= GetSharedMemoryAs
<Result
*>(
2209 c
.result_shm_id
, c
.result_shm_offset
, sizeof(*result_dst
));
2211 return error::kOutOfBounds
;
2213 if (!validators_
->capability
.IsValid(cap
)) {
2214 LOCAL_SET_GL_ERROR_INVALID_ENUM("glIsEnabled", cap
, "cap");
2215 return error::kNoError
;
2217 *result_dst
= DoIsEnabled(cap
);
2218 return error::kNoError
;
2221 error::Error
GLES2DecoderImpl::HandleIsFramebuffer(uint32_t immediate_data_size
,
2222 const void* cmd_data
) {
2223 const gles2::cmds::IsFramebuffer
& c
=
2224 *static_cast<const gles2::cmds::IsFramebuffer
*>(cmd_data
);
2226 GLuint framebuffer
= c
.framebuffer
;
2227 typedef cmds::IsFramebuffer::Result Result
;
2228 Result
* result_dst
= GetSharedMemoryAs
<Result
*>(
2229 c
.result_shm_id
, c
.result_shm_offset
, sizeof(*result_dst
));
2231 return error::kOutOfBounds
;
2233 *result_dst
= DoIsFramebuffer(framebuffer
);
2234 return error::kNoError
;
2237 error::Error
GLES2DecoderImpl::HandleIsProgram(uint32_t immediate_data_size
,
2238 const void* cmd_data
) {
2239 const gles2::cmds::IsProgram
& c
=
2240 *static_cast<const gles2::cmds::IsProgram
*>(cmd_data
);
2242 GLuint program
= c
.program
;
2243 typedef cmds::IsProgram::Result Result
;
2244 Result
* result_dst
= GetSharedMemoryAs
<Result
*>(
2245 c
.result_shm_id
, c
.result_shm_offset
, sizeof(*result_dst
));
2247 return error::kOutOfBounds
;
2249 *result_dst
= DoIsProgram(program
);
2250 return error::kNoError
;
2253 error::Error
GLES2DecoderImpl::HandleIsRenderbuffer(
2254 uint32_t immediate_data_size
,
2255 const void* cmd_data
) {
2256 const gles2::cmds::IsRenderbuffer
& c
=
2257 *static_cast<const gles2::cmds::IsRenderbuffer
*>(cmd_data
);
2259 GLuint renderbuffer
= c
.renderbuffer
;
2260 typedef cmds::IsRenderbuffer::Result Result
;
2261 Result
* result_dst
= GetSharedMemoryAs
<Result
*>(
2262 c
.result_shm_id
, c
.result_shm_offset
, sizeof(*result_dst
));
2264 return error::kOutOfBounds
;
2266 *result_dst
= DoIsRenderbuffer(renderbuffer
);
2267 return error::kNoError
;
2270 error::Error
GLES2DecoderImpl::HandleIsSampler(uint32_t immediate_data_size
,
2271 const void* cmd_data
) {
2272 if (!unsafe_es3_apis_enabled())
2273 return error::kUnknownCommand
;
2274 const gles2::cmds::IsSampler
& c
=
2275 *static_cast<const gles2::cmds::IsSampler
*>(cmd_data
);
2277 GLuint sampler
= c
.sampler
;
2278 typedef cmds::IsSampler::Result Result
;
2279 Result
* result_dst
= GetSharedMemoryAs
<Result
*>(
2280 c
.result_shm_id
, c
.result_shm_offset
, sizeof(*result_dst
));
2282 return error::kOutOfBounds
;
2284 GLuint service_sampler
= 0;
2285 *result_dst
= group_
->GetSamplerServiceId(sampler
, &service_sampler
);
2286 return error::kNoError
;
2289 error::Error
GLES2DecoderImpl::HandleIsShader(uint32_t immediate_data_size
,
2290 const void* cmd_data
) {
2291 const gles2::cmds::IsShader
& c
=
2292 *static_cast<const gles2::cmds::IsShader
*>(cmd_data
);
2294 GLuint shader
= c
.shader
;
2295 typedef cmds::IsShader::Result Result
;
2296 Result
* result_dst
= GetSharedMemoryAs
<Result
*>(
2297 c
.result_shm_id
, c
.result_shm_offset
, sizeof(*result_dst
));
2299 return error::kOutOfBounds
;
2301 *result_dst
= DoIsShader(shader
);
2302 return error::kNoError
;
2305 error::Error
GLES2DecoderImpl::HandleIsSync(uint32_t immediate_data_size
,
2306 const void* cmd_data
) {
2307 if (!unsafe_es3_apis_enabled())
2308 return error::kUnknownCommand
;
2309 const gles2::cmds::IsSync
& c
=
2310 *static_cast<const gles2::cmds::IsSync
*>(cmd_data
);
2312 GLuint sync
= c
.sync
;
2313 typedef cmds::IsSync::Result Result
;
2314 Result
* result_dst
= GetSharedMemoryAs
<Result
*>(
2315 c
.result_shm_id
, c
.result_shm_offset
, sizeof(*result_dst
));
2317 return error::kOutOfBounds
;
2319 GLsync service_sync
= 0;
2320 *result_dst
= group_
->GetSyncServiceId(sync
, &service_sync
);
2321 return error::kNoError
;
2324 error::Error
GLES2DecoderImpl::HandleIsTexture(uint32_t immediate_data_size
,
2325 const void* cmd_data
) {
2326 const gles2::cmds::IsTexture
& c
=
2327 *static_cast<const gles2::cmds::IsTexture
*>(cmd_data
);
2329 GLuint texture
= c
.texture
;
2330 typedef cmds::IsTexture::Result Result
;
2331 Result
* result_dst
= GetSharedMemoryAs
<Result
*>(
2332 c
.result_shm_id
, c
.result_shm_offset
, sizeof(*result_dst
));
2334 return error::kOutOfBounds
;
2336 *result_dst
= DoIsTexture(texture
);
2337 return error::kNoError
;
2340 error::Error
GLES2DecoderImpl::HandleIsTransformFeedback(
2341 uint32_t immediate_data_size
,
2342 const void* cmd_data
) {
2343 if (!unsafe_es3_apis_enabled())
2344 return error::kUnknownCommand
;
2345 const gles2::cmds::IsTransformFeedback
& c
=
2346 *static_cast<const gles2::cmds::IsTransformFeedback
*>(cmd_data
);
2348 GLuint transformfeedback
= c
.transformfeedback
;
2349 typedef cmds::IsTransformFeedback::Result Result
;
2350 Result
* result_dst
= GetSharedMemoryAs
<Result
*>(
2351 c
.result_shm_id
, c
.result_shm_offset
, sizeof(*result_dst
));
2353 return error::kOutOfBounds
;
2355 GLuint service_transformfeedback
= 0;
2356 *result_dst
= group_
->GetTransformFeedbackServiceId(
2357 transformfeedback
, &service_transformfeedback
);
2358 return error::kNoError
;
2361 error::Error
GLES2DecoderImpl::HandleLineWidth(uint32_t immediate_data_size
,
2362 const void* cmd_data
) {
2363 const gles2::cmds::LineWidth
& c
=
2364 *static_cast<const gles2::cmds::LineWidth
*>(cmd_data
);
2366 GLfloat width
= static_cast<GLfloat
>(c
.width
);
2367 if (width
<= 0.0f
|| std::isnan(width
)) {
2368 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE
, "LineWidth", "width out of range");
2369 return error::kNoError
;
2371 if (state_
.line_width
!= width
) {
2372 state_
.line_width
= width
;
2375 return error::kNoError
;
2378 error::Error
GLES2DecoderImpl::HandleLinkProgram(uint32_t immediate_data_size
,
2379 const void* cmd_data
) {
2380 const gles2::cmds::LinkProgram
& c
=
2381 *static_cast<const gles2::cmds::LinkProgram
*>(cmd_data
);
2383 GLuint program
= c
.program
;
2384 DoLinkProgram(program
);
2385 return error::kNoError
;
2388 error::Error
GLES2DecoderImpl::HandlePauseTransformFeedback(
2389 uint32_t immediate_data_size
,
2390 const void* cmd_data
) {
2391 if (!unsafe_es3_apis_enabled())
2392 return error::kUnknownCommand
;
2393 const gles2::cmds::PauseTransformFeedback
& c
=
2394 *static_cast<const gles2::cmds::PauseTransformFeedback
*>(cmd_data
);
2396 glPauseTransformFeedback();
2397 return error::kNoError
;
2400 error::Error
GLES2DecoderImpl::HandlePolygonOffset(uint32_t immediate_data_size
,
2401 const void* cmd_data
) {
2402 const gles2::cmds::PolygonOffset
& c
=
2403 *static_cast<const gles2::cmds::PolygonOffset
*>(cmd_data
);
2405 GLfloat factor
= static_cast<GLfloat
>(c
.factor
);
2406 GLfloat units
= static_cast<GLfloat
>(c
.units
);
2407 if (state_
.polygon_offset_factor
!= factor
||
2408 state_
.polygon_offset_units
!= units
) {
2409 state_
.polygon_offset_factor
= factor
;
2410 state_
.polygon_offset_units
= units
;
2411 glPolygonOffset(factor
, units
);
2413 return error::kNoError
;
2416 error::Error
GLES2DecoderImpl::HandleReadBuffer(uint32_t immediate_data_size
,
2417 const void* cmd_data
) {
2418 if (!unsafe_es3_apis_enabled())
2419 return error::kUnknownCommand
;
2420 const gles2::cmds::ReadBuffer
& c
=
2421 *static_cast<const gles2::cmds::ReadBuffer
*>(cmd_data
);
2423 GLenum src
= static_cast<GLenum
>(c
.src
);
2425 return error::kNoError
;
2428 error::Error
GLES2DecoderImpl::HandleReleaseShaderCompiler(
2429 uint32_t immediate_data_size
,
2430 const void* cmd_data
) {
2431 const gles2::cmds::ReleaseShaderCompiler
& c
=
2432 *static_cast<const gles2::cmds::ReleaseShaderCompiler
*>(cmd_data
);
2434 DoReleaseShaderCompiler();
2435 return error::kNoError
;
2438 error::Error
GLES2DecoderImpl::HandleRenderbufferStorage(
2439 uint32_t immediate_data_size
,
2440 const void* cmd_data
) {
2441 const gles2::cmds::RenderbufferStorage
& c
=
2442 *static_cast<const gles2::cmds::RenderbufferStorage
*>(cmd_data
);
2444 GLenum target
= static_cast<GLenum
>(c
.target
);
2445 GLenum internalformat
= static_cast<GLenum
>(c
.internalformat
);
2446 GLsizei width
= static_cast<GLsizei
>(c
.width
);
2447 GLsizei height
= static_cast<GLsizei
>(c
.height
);
2448 if (!validators_
->render_buffer_target
.IsValid(target
)) {
2449 LOCAL_SET_GL_ERROR_INVALID_ENUM("glRenderbufferStorage", target
, "target");
2450 return error::kNoError
;
2452 if (!validators_
->render_buffer_format
.IsValid(internalformat
)) {
2453 LOCAL_SET_GL_ERROR_INVALID_ENUM("glRenderbufferStorage", internalformat
,
2455 return error::kNoError
;
2458 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE
, "glRenderbufferStorage", "width < 0");
2459 return error::kNoError
;
2462 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE
, "glRenderbufferStorage", "height < 0");
2463 return error::kNoError
;
2465 DoRenderbufferStorage(target
, internalformat
, width
, height
);
2466 return error::kNoError
;
2469 error::Error
GLES2DecoderImpl::HandleResumeTransformFeedback(
2470 uint32_t immediate_data_size
,
2471 const void* cmd_data
) {
2472 if (!unsafe_es3_apis_enabled())
2473 return error::kUnknownCommand
;
2474 const gles2::cmds::ResumeTransformFeedback
& c
=
2475 *static_cast<const gles2::cmds::ResumeTransformFeedback
*>(cmd_data
);
2477 glResumeTransformFeedback();
2478 return error::kNoError
;
2481 error::Error
GLES2DecoderImpl::HandleSampleCoverage(
2482 uint32_t immediate_data_size
,
2483 const void* cmd_data
) {
2484 const gles2::cmds::SampleCoverage
& c
=
2485 *static_cast<const gles2::cmds::SampleCoverage
*>(cmd_data
);
2487 GLclampf value
= static_cast<GLclampf
>(c
.value
);
2488 GLboolean invert
= static_cast<GLboolean
>(c
.invert
);
2489 DoSampleCoverage(value
, invert
);
2490 return error::kNoError
;
2493 error::Error
GLES2DecoderImpl::HandleSamplerParameterf(
2494 uint32_t immediate_data_size
,
2495 const void* cmd_data
) {
2496 if (!unsafe_es3_apis_enabled())
2497 return error::kUnknownCommand
;
2498 const gles2::cmds::SamplerParameterf
& c
=
2499 *static_cast<const gles2::cmds::SamplerParameterf
*>(cmd_data
);
2501 GLuint sampler
= c
.sampler
;
2502 GLenum pname
= static_cast<GLenum
>(c
.pname
);
2503 GLfloat param
= static_cast<GLfloat
>(c
.param
);
2504 if (!group_
->GetSamplerServiceId(sampler
, &sampler
)) {
2505 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION
, "glSamplerParameterf",
2506 "invalid sampler id");
2507 return error::kNoError
;
2509 glSamplerParameterf(sampler
, pname
, param
);
2510 return error::kNoError
;
2513 error::Error
GLES2DecoderImpl::HandleSamplerParameterfvImmediate(
2514 uint32_t immediate_data_size
,
2515 const void* cmd_data
) {
2516 if (!unsafe_es3_apis_enabled())
2517 return error::kUnknownCommand
;
2518 const gles2::cmds::SamplerParameterfvImmediate
& c
=
2519 *static_cast<const gles2::cmds::SamplerParameterfvImmediate
*>(cmd_data
);
2521 GLuint sampler
= c
.sampler
;
2522 GLenum pname
= static_cast<GLenum
>(c
.pname
);
2524 if (!ComputeDataSize(1, sizeof(GLfloat
), 1, &data_size
)) {
2525 return error::kOutOfBounds
;
2527 if (data_size
> immediate_data_size
) {
2528 return error::kOutOfBounds
;
2530 const GLfloat
* params
=
2531 GetImmediateDataAs
<const GLfloat
*>(c
, data_size
, immediate_data_size
);
2532 if (params
== NULL
) {
2533 return error::kOutOfBounds
;
2535 group_
->GetSamplerServiceId(sampler
, &sampler
);
2536 DoSamplerParameterfv(sampler
, pname
, params
);
2537 return error::kNoError
;
2540 error::Error
GLES2DecoderImpl::HandleSamplerParameteri(
2541 uint32_t immediate_data_size
,
2542 const void* cmd_data
) {
2543 if (!unsafe_es3_apis_enabled())
2544 return error::kUnknownCommand
;
2545 const gles2::cmds::SamplerParameteri
& c
=
2546 *static_cast<const gles2::cmds::SamplerParameteri
*>(cmd_data
);
2548 GLuint sampler
= c
.sampler
;
2549 GLenum pname
= static_cast<GLenum
>(c
.pname
);
2550 GLint param
= static_cast<GLint
>(c
.param
);
2551 if (!group_
->GetSamplerServiceId(sampler
, &sampler
)) {
2552 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION
, "glSamplerParameteri",
2553 "invalid sampler id");
2554 return error::kNoError
;
2556 glSamplerParameteri(sampler
, pname
, param
);
2557 return error::kNoError
;
2560 error::Error
GLES2DecoderImpl::HandleSamplerParameterivImmediate(
2561 uint32_t immediate_data_size
,
2562 const void* cmd_data
) {
2563 if (!unsafe_es3_apis_enabled())
2564 return error::kUnknownCommand
;
2565 const gles2::cmds::SamplerParameterivImmediate
& c
=
2566 *static_cast<const gles2::cmds::SamplerParameterivImmediate
*>(cmd_data
);
2568 GLuint sampler
= c
.sampler
;
2569 GLenum pname
= static_cast<GLenum
>(c
.pname
);
2571 if (!ComputeDataSize(1, sizeof(GLint
), 1, &data_size
)) {
2572 return error::kOutOfBounds
;
2574 if (data_size
> immediate_data_size
) {
2575 return error::kOutOfBounds
;
2577 const GLint
* params
=
2578 GetImmediateDataAs
<const GLint
*>(c
, data_size
, immediate_data_size
);
2579 if (params
== NULL
) {
2580 return error::kOutOfBounds
;
2582 DoSamplerParameteriv(sampler
, pname
, params
);
2583 return error::kNoError
;
2586 error::Error
GLES2DecoderImpl::HandleScissor(uint32_t immediate_data_size
,
2587 const void* cmd_data
) {
2588 const gles2::cmds::Scissor
& c
=
2589 *static_cast<const gles2::cmds::Scissor
*>(cmd_data
);
2591 GLint x
= static_cast<GLint
>(c
.x
);
2592 GLint y
= static_cast<GLint
>(c
.y
);
2593 GLsizei width
= static_cast<GLsizei
>(c
.width
);
2594 GLsizei height
= static_cast<GLsizei
>(c
.height
);
2596 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE
, "glScissor", "width < 0");
2597 return error::kNoError
;
2600 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE
, "glScissor", "height < 0");
2601 return error::kNoError
;
2603 if (state_
.scissor_x
!= x
|| state_
.scissor_y
!= y
||
2604 state_
.scissor_width
!= width
|| state_
.scissor_height
!= height
) {
2605 state_
.scissor_x
= x
;
2606 state_
.scissor_y
= y
;
2607 state_
.scissor_width
= width
;
2608 state_
.scissor_height
= height
;
2609 glScissor(x
, y
, width
, height
);
2611 return error::kNoError
;
2614 error::Error
GLES2DecoderImpl::HandleShaderSourceBucket(
2615 uint32_t immediate_data_size
,
2616 const void* cmd_data
) {
2617 const gles2::cmds::ShaderSourceBucket
& c
=
2618 *static_cast<const gles2::cmds::ShaderSourceBucket
*>(cmd_data
);
2620 GLuint shader
= static_cast<GLuint
>(c
.shader
);
2622 Bucket
* bucket
= GetBucket(c
.str_bucket_id
);
2624 return error::kInvalidArguments
;
2627 std::vector
<char*> strs
;
2628 std::vector
<GLint
> len
;
2629 if (!bucket
->GetAsStrings(&count
, &strs
, &len
)) {
2630 return error::kInvalidArguments
;
2633 strs
.size() > 0 ? const_cast<const char**>(&strs
[0]) : NULL
;
2634 const GLint
* length
=
2635 len
.size() > 0 ? const_cast<const GLint
*>(&len
[0]) : NULL
;
2637 DoShaderSource(shader
, count
, str
, length
);
2638 return error::kNoError
;
2641 error::Error
GLES2DecoderImpl::HandleStencilFunc(uint32_t immediate_data_size
,
2642 const void* cmd_data
) {
2643 const gles2::cmds::StencilFunc
& c
=
2644 *static_cast<const gles2::cmds::StencilFunc
*>(cmd_data
);
2646 GLenum func
= static_cast<GLenum
>(c
.func
);
2647 GLint ref
= static_cast<GLint
>(c
.ref
);
2648 GLuint mask
= static_cast<GLuint
>(c
.mask
);
2649 if (!validators_
->cmp_function
.IsValid(func
)) {
2650 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilFunc", func
, "func");
2651 return error::kNoError
;
2653 if (state_
.stencil_front_func
!= func
|| state_
.stencil_front_ref
!= ref
||
2654 state_
.stencil_front_mask
!= mask
|| state_
.stencil_back_func
!= func
||
2655 state_
.stencil_back_ref
!= ref
|| state_
.stencil_back_mask
!= mask
) {
2656 state_
.stencil_front_func
= func
;
2657 state_
.stencil_front_ref
= ref
;
2658 state_
.stencil_front_mask
= mask
;
2659 state_
.stencil_back_func
= func
;
2660 state_
.stencil_back_ref
= ref
;
2661 state_
.stencil_back_mask
= mask
;
2662 glStencilFunc(func
, ref
, mask
);
2664 return error::kNoError
;
2667 error::Error
GLES2DecoderImpl::HandleStencilFuncSeparate(
2668 uint32_t immediate_data_size
,
2669 const void* cmd_data
) {
2670 const gles2::cmds::StencilFuncSeparate
& c
=
2671 *static_cast<const gles2::cmds::StencilFuncSeparate
*>(cmd_data
);
2673 GLenum face
= static_cast<GLenum
>(c
.face
);
2674 GLenum func
= static_cast<GLenum
>(c
.func
);
2675 GLint ref
= static_cast<GLint
>(c
.ref
);
2676 GLuint mask
= static_cast<GLuint
>(c
.mask
);
2677 if (!validators_
->face_type
.IsValid(face
)) {
2678 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilFuncSeparate", face
, "face");
2679 return error::kNoError
;
2681 if (!validators_
->cmp_function
.IsValid(func
)) {
2682 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilFuncSeparate", func
, "func");
2683 return error::kNoError
;
2685 bool changed
= false;
2686 if (face
== GL_FRONT
|| face
== GL_FRONT_AND_BACK
) {
2687 changed
|= state_
.stencil_front_func
!= func
||
2688 state_
.stencil_front_ref
!= ref
||
2689 state_
.stencil_front_mask
!= mask
;
2691 if (face
== GL_BACK
|| face
== GL_FRONT_AND_BACK
) {
2692 changed
|= state_
.stencil_back_func
!= func
||
2693 state_
.stencil_back_ref
!= ref
||
2694 state_
.stencil_back_mask
!= mask
;
2697 if (face
== GL_FRONT
|| face
== GL_FRONT_AND_BACK
) {
2698 state_
.stencil_front_func
= func
;
2699 state_
.stencil_front_ref
= ref
;
2700 state_
.stencil_front_mask
= mask
;
2702 if (face
== GL_BACK
|| face
== GL_FRONT_AND_BACK
) {
2703 state_
.stencil_back_func
= func
;
2704 state_
.stencil_back_ref
= ref
;
2705 state_
.stencil_back_mask
= mask
;
2707 glStencilFuncSeparate(face
, func
, ref
, mask
);
2709 return error::kNoError
;
2712 error::Error
GLES2DecoderImpl::HandleStencilMask(uint32_t immediate_data_size
,
2713 const void* cmd_data
) {
2714 const gles2::cmds::StencilMask
& c
=
2715 *static_cast<const gles2::cmds::StencilMask
*>(cmd_data
);
2717 GLuint mask
= static_cast<GLuint
>(c
.mask
);
2718 if (state_
.stencil_front_writemask
!= mask
||
2719 state_
.stencil_back_writemask
!= mask
) {
2720 state_
.stencil_front_writemask
= mask
;
2721 state_
.stencil_back_writemask
= mask
;
2722 framebuffer_state_
.clear_state_dirty
= true;
2724 return error::kNoError
;
2727 error::Error
GLES2DecoderImpl::HandleStencilMaskSeparate(
2728 uint32_t immediate_data_size
,
2729 const void* cmd_data
) {
2730 const gles2::cmds::StencilMaskSeparate
& c
=
2731 *static_cast<const gles2::cmds::StencilMaskSeparate
*>(cmd_data
);
2733 GLenum face
= static_cast<GLenum
>(c
.face
);
2734 GLuint mask
= static_cast<GLuint
>(c
.mask
);
2735 if (!validators_
->face_type
.IsValid(face
)) {
2736 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilMaskSeparate", face
, "face");
2737 return error::kNoError
;
2739 bool changed
= false;
2740 if (face
== GL_FRONT
|| face
== GL_FRONT_AND_BACK
) {
2741 changed
|= state_
.stencil_front_writemask
!= mask
;
2743 if (face
== GL_BACK
|| face
== GL_FRONT_AND_BACK
) {
2744 changed
|= state_
.stencil_back_writemask
!= mask
;
2747 if (face
== GL_FRONT
|| face
== GL_FRONT_AND_BACK
) {
2748 state_
.stencil_front_writemask
= mask
;
2750 if (face
== GL_BACK
|| face
== GL_FRONT_AND_BACK
) {
2751 state_
.stencil_back_writemask
= mask
;
2753 framebuffer_state_
.clear_state_dirty
= true;
2755 return error::kNoError
;
2758 error::Error
GLES2DecoderImpl::HandleStencilOp(uint32_t immediate_data_size
,
2759 const void* cmd_data
) {
2760 const gles2::cmds::StencilOp
& c
=
2761 *static_cast<const gles2::cmds::StencilOp
*>(cmd_data
);
2763 GLenum fail
= static_cast<GLenum
>(c
.fail
);
2764 GLenum zfail
= static_cast<GLenum
>(c
.zfail
);
2765 GLenum zpass
= static_cast<GLenum
>(c
.zpass
);
2766 if (!validators_
->stencil_op
.IsValid(fail
)) {
2767 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilOp", fail
, "fail");
2768 return error::kNoError
;
2770 if (!validators_
->stencil_op
.IsValid(zfail
)) {
2771 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilOp", zfail
, "zfail");
2772 return error::kNoError
;
2774 if (!validators_
->stencil_op
.IsValid(zpass
)) {
2775 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilOp", zpass
, "zpass");
2776 return error::kNoError
;
2778 if (state_
.stencil_front_fail_op
!= fail
||
2779 state_
.stencil_front_z_fail_op
!= zfail
||
2780 state_
.stencil_front_z_pass_op
!= zpass
||
2781 state_
.stencil_back_fail_op
!= fail
||
2782 state_
.stencil_back_z_fail_op
!= zfail
||
2783 state_
.stencil_back_z_pass_op
!= zpass
) {
2784 state_
.stencil_front_fail_op
= fail
;
2785 state_
.stencil_front_z_fail_op
= zfail
;
2786 state_
.stencil_front_z_pass_op
= zpass
;
2787 state_
.stencil_back_fail_op
= fail
;
2788 state_
.stencil_back_z_fail_op
= zfail
;
2789 state_
.stencil_back_z_pass_op
= zpass
;
2790 glStencilOp(fail
, zfail
, zpass
);
2792 return error::kNoError
;
2795 error::Error
GLES2DecoderImpl::HandleStencilOpSeparate(
2796 uint32_t immediate_data_size
,
2797 const void* cmd_data
) {
2798 const gles2::cmds::StencilOpSeparate
& c
=
2799 *static_cast<const gles2::cmds::StencilOpSeparate
*>(cmd_data
);
2801 GLenum face
= static_cast<GLenum
>(c
.face
);
2802 GLenum fail
= static_cast<GLenum
>(c
.fail
);
2803 GLenum zfail
= static_cast<GLenum
>(c
.zfail
);
2804 GLenum zpass
= static_cast<GLenum
>(c
.zpass
);
2805 if (!validators_
->face_type
.IsValid(face
)) {
2806 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilOpSeparate", face
, "face");
2807 return error::kNoError
;
2809 if (!validators_
->stencil_op
.IsValid(fail
)) {
2810 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilOpSeparate", fail
, "fail");
2811 return error::kNoError
;
2813 if (!validators_
->stencil_op
.IsValid(zfail
)) {
2814 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilOpSeparate", zfail
, "zfail");
2815 return error::kNoError
;
2817 if (!validators_
->stencil_op
.IsValid(zpass
)) {
2818 LOCAL_SET_GL_ERROR_INVALID_ENUM("glStencilOpSeparate", zpass
, "zpass");
2819 return error::kNoError
;
2821 bool changed
= false;
2822 if (face
== GL_FRONT
|| face
== GL_FRONT_AND_BACK
) {
2823 changed
|= state_
.stencil_front_fail_op
!= fail
||
2824 state_
.stencil_front_z_fail_op
!= zfail
||
2825 state_
.stencil_front_z_pass_op
!= zpass
;
2827 if (face
== GL_BACK
|| face
== GL_FRONT_AND_BACK
) {
2828 changed
|= state_
.stencil_back_fail_op
!= fail
||
2829 state_
.stencil_back_z_fail_op
!= zfail
||
2830 state_
.stencil_back_z_pass_op
!= zpass
;
2833 if (face
== GL_FRONT
|| face
== GL_FRONT_AND_BACK
) {
2834 state_
.stencil_front_fail_op
= fail
;
2835 state_
.stencil_front_z_fail_op
= zfail
;
2836 state_
.stencil_front_z_pass_op
= zpass
;
2838 if (face
== GL_BACK
|| face
== GL_FRONT_AND_BACK
) {
2839 state_
.stencil_back_fail_op
= fail
;
2840 state_
.stencil_back_z_fail_op
= zfail
;
2841 state_
.stencil_back_z_pass_op
= zpass
;
2843 glStencilOpSeparate(face
, fail
, zfail
, zpass
);
2845 return error::kNoError
;
2848 error::Error
GLES2DecoderImpl::HandleTexParameterf(uint32_t immediate_data_size
,
2849 const void* cmd_data
) {
2850 const gles2::cmds::TexParameterf
& c
=
2851 *static_cast<const gles2::cmds::TexParameterf
*>(cmd_data
);
2853 GLenum target
= static_cast<GLenum
>(c
.target
);
2854 GLenum pname
= static_cast<GLenum
>(c
.pname
);
2855 GLfloat param
= static_cast<GLfloat
>(c
.param
);
2856 if (!validators_
->texture_bind_target
.IsValid(target
)) {
2857 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexParameterf", target
, "target");
2858 return error::kNoError
;
2860 if (!validators_
->texture_parameter
.IsValid(pname
)) {
2861 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexParameterf", pname
, "pname");
2862 return error::kNoError
;
2864 DoTexParameterf(target
, pname
, param
);
2865 return error::kNoError
;
2868 error::Error
GLES2DecoderImpl::HandleTexParameterfvImmediate(
2869 uint32_t immediate_data_size
,
2870 const void* cmd_data
) {
2871 const gles2::cmds::TexParameterfvImmediate
& c
=
2872 *static_cast<const gles2::cmds::TexParameterfvImmediate
*>(cmd_data
);
2874 GLenum target
= static_cast<GLenum
>(c
.target
);
2875 GLenum pname
= static_cast<GLenum
>(c
.pname
);
2877 if (!ComputeDataSize(1, sizeof(GLfloat
), 1, &data_size
)) {
2878 return error::kOutOfBounds
;
2880 if (data_size
> immediate_data_size
) {
2881 return error::kOutOfBounds
;
2883 const GLfloat
* params
=
2884 GetImmediateDataAs
<const GLfloat
*>(c
, data_size
, immediate_data_size
);
2885 if (!validators_
->texture_bind_target
.IsValid(target
)) {
2886 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexParameterfv", target
, "target");
2887 return error::kNoError
;
2889 if (!validators_
->texture_parameter
.IsValid(pname
)) {
2890 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexParameterfv", pname
, "pname");
2891 return error::kNoError
;
2893 if (params
== NULL
) {
2894 return error::kOutOfBounds
;
2896 DoTexParameterfv(target
, pname
, params
);
2897 return error::kNoError
;
2900 error::Error
GLES2DecoderImpl::HandleTexParameteri(uint32_t immediate_data_size
,
2901 const void* cmd_data
) {
2902 const gles2::cmds::TexParameteri
& c
=
2903 *static_cast<const gles2::cmds::TexParameteri
*>(cmd_data
);
2905 GLenum target
= static_cast<GLenum
>(c
.target
);
2906 GLenum pname
= static_cast<GLenum
>(c
.pname
);
2907 GLint param
= static_cast<GLint
>(c
.param
);
2908 if (!validators_
->texture_bind_target
.IsValid(target
)) {
2909 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexParameteri", target
, "target");
2910 return error::kNoError
;
2912 if (!validators_
->texture_parameter
.IsValid(pname
)) {
2913 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexParameteri", pname
, "pname");
2914 return error::kNoError
;
2916 DoTexParameteri(target
, pname
, param
);
2917 return error::kNoError
;
2920 error::Error
GLES2DecoderImpl::HandleTexParameterivImmediate(
2921 uint32_t immediate_data_size
,
2922 const void* cmd_data
) {
2923 const gles2::cmds::TexParameterivImmediate
& c
=
2924 *static_cast<const gles2::cmds::TexParameterivImmediate
*>(cmd_data
);
2926 GLenum target
= static_cast<GLenum
>(c
.target
);
2927 GLenum pname
= static_cast<GLenum
>(c
.pname
);
2929 if (!ComputeDataSize(1, sizeof(GLint
), 1, &data_size
)) {
2930 return error::kOutOfBounds
;
2932 if (data_size
> immediate_data_size
) {
2933 return error::kOutOfBounds
;
2935 const GLint
* params
=
2936 GetImmediateDataAs
<const GLint
*>(c
, data_size
, immediate_data_size
);
2937 if (!validators_
->texture_bind_target
.IsValid(target
)) {
2938 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexParameteriv", target
, "target");
2939 return error::kNoError
;
2941 if (!validators_
->texture_parameter
.IsValid(pname
)) {
2942 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexParameteriv", pname
, "pname");
2943 return error::kNoError
;
2945 if (params
== NULL
) {
2946 return error::kOutOfBounds
;
2948 DoTexParameteriv(target
, pname
, params
);
2949 return error::kNoError
;
2952 error::Error
GLES2DecoderImpl::HandleTexStorage3D(uint32_t immediate_data_size
,
2953 const void* cmd_data
) {
2954 if (!unsafe_es3_apis_enabled())
2955 return error::kUnknownCommand
;
2956 const gles2::cmds::TexStorage3D
& c
=
2957 *static_cast<const gles2::cmds::TexStorage3D
*>(cmd_data
);
2959 GLenum target
= static_cast<GLenum
>(c
.target
);
2960 GLsizei levels
= static_cast<GLsizei
>(c
.levels
);
2961 GLenum internalFormat
= static_cast<GLenum
>(c
.internalFormat
);
2962 GLsizei width
= static_cast<GLsizei
>(c
.width
);
2963 GLsizei height
= static_cast<GLsizei
>(c
.height
);
2964 GLsizei depth
= static_cast<GLsizei
>(c
.depth
);
2965 glTexStorage3D(target
, levels
, internalFormat
, width
, height
, depth
);
2966 return error::kNoError
;
2969 error::Error
GLES2DecoderImpl::HandleTransformFeedbackVaryingsBucket(
2970 uint32_t immediate_data_size
,
2971 const void* cmd_data
) {
2972 if (!unsafe_es3_apis_enabled())
2973 return error::kUnknownCommand
;
2974 const gles2::cmds::TransformFeedbackVaryingsBucket
& c
=
2975 *static_cast<const gles2::cmds::TransformFeedbackVaryingsBucket
*>(
2978 GLuint program
= static_cast<GLuint
>(c
.program
);
2980 Bucket
* bucket
= GetBucket(c
.varyings_bucket_id
);
2982 return error::kInvalidArguments
;
2985 std::vector
<char*> strs
;
2986 std::vector
<GLint
> len
;
2987 if (!bucket
->GetAsStrings(&count
, &strs
, &len
)) {
2988 return error::kInvalidArguments
;
2990 const char** varyings
=
2991 strs
.size() > 0 ? const_cast<const char**>(&strs
[0]) : NULL
;
2992 const GLint
* length
=
2993 len
.size() > 0 ? const_cast<const GLint
*>(&len
[0]) : NULL
;
2995 GLenum buffermode
= static_cast<GLenum
>(c
.buffermode
);
2996 DoTransformFeedbackVaryings(program
, count
, varyings
, buffermode
);
2997 return error::kNoError
;
3000 error::Error
GLES2DecoderImpl::HandleUniform1f(uint32_t immediate_data_size
,
3001 const void* cmd_data
) {
3002 const gles2::cmds::Uniform1f
& c
=
3003 *static_cast<const gles2::cmds::Uniform1f
*>(cmd_data
);
3005 GLint location
= static_cast<GLint
>(c
.location
);
3006 GLfloat x
= static_cast<GLfloat
>(c
.x
);
3010 DoUniform1fv(location
, 1, &temp
[0]);
3011 return error::kNoError
;
3014 error::Error
GLES2DecoderImpl::HandleUniform1fvImmediate(
3015 uint32_t immediate_data_size
,
3016 const void* cmd_data
) {
3017 const gles2::cmds::Uniform1fvImmediate
& c
=
3018 *static_cast<const gles2::cmds::Uniform1fvImmediate
*>(cmd_data
);
3020 GLint location
= static_cast<GLint
>(c
.location
);
3021 GLsizei count
= static_cast<GLsizei
>(c
.count
);
3023 if (!ComputeDataSize(count
, sizeof(GLfloat
), 1, &data_size
)) {
3024 return error::kOutOfBounds
;
3026 if (data_size
> immediate_data_size
) {
3027 return error::kOutOfBounds
;
3030 GetImmediateDataAs
<const GLfloat
*>(c
, data_size
, immediate_data_size
);
3032 return error::kOutOfBounds
;
3034 DoUniform1fv(location
, count
, v
);
3035 return error::kNoError
;
3038 error::Error
GLES2DecoderImpl::HandleUniform1i(uint32_t immediate_data_size
,
3039 const void* cmd_data
) {
3040 const gles2::cmds::Uniform1i
& c
=
3041 *static_cast<const gles2::cmds::Uniform1i
*>(cmd_data
);
3043 GLint location
= static_cast<GLint
>(c
.location
);
3044 GLint x
= static_cast<GLint
>(c
.x
);
3045 DoUniform1i(location
, x
);
3046 return error::kNoError
;
3049 error::Error
GLES2DecoderImpl::HandleUniform1ivImmediate(
3050 uint32_t immediate_data_size
,
3051 const void* cmd_data
) {
3052 const gles2::cmds::Uniform1ivImmediate
& c
=
3053 *static_cast<const gles2::cmds::Uniform1ivImmediate
*>(cmd_data
);
3055 GLint location
= static_cast<GLint
>(c
.location
);
3056 GLsizei count
= static_cast<GLsizei
>(c
.count
);
3058 if (!ComputeDataSize(count
, sizeof(GLint
), 1, &data_size
)) {
3059 return error::kOutOfBounds
;
3061 if (data_size
> immediate_data_size
) {
3062 return error::kOutOfBounds
;
3065 GetImmediateDataAs
<const GLint
*>(c
, data_size
, immediate_data_size
);
3067 return error::kOutOfBounds
;
3069 DoUniform1iv(location
, count
, v
);
3070 return error::kNoError
;
3073 error::Error
GLES2DecoderImpl::HandleUniform1ui(uint32_t immediate_data_size
,
3074 const void* cmd_data
) {
3075 if (!unsafe_es3_apis_enabled())
3076 return error::kUnknownCommand
;
3077 const gles2::cmds::Uniform1ui
& c
=
3078 *static_cast<const gles2::cmds::Uniform1ui
*>(cmd_data
);
3080 GLint location
= static_cast<GLint
>(c
.location
);
3081 GLuint x
= static_cast<GLuint
>(c
.x
);
3085 glUniform1uiv(location
, 1, &temp
[0]);
3086 return error::kNoError
;
3089 error::Error
GLES2DecoderImpl::HandleUniform1uivImmediate(
3090 uint32_t immediate_data_size
,
3091 const void* cmd_data
) {
3092 if (!unsafe_es3_apis_enabled())
3093 return error::kUnknownCommand
;
3094 const gles2::cmds::Uniform1uivImmediate
& c
=
3095 *static_cast<const gles2::cmds::Uniform1uivImmediate
*>(cmd_data
);
3097 GLint location
= static_cast<GLint
>(c
.location
);
3098 GLsizei count
= static_cast<GLsizei
>(c
.count
);
3100 if (!ComputeDataSize(count
, sizeof(GLuint
), 1, &data_size
)) {
3101 return error::kOutOfBounds
;
3103 if (data_size
> immediate_data_size
) {
3104 return error::kOutOfBounds
;
3107 GetImmediateDataAs
<const GLuint
*>(c
, data_size
, immediate_data_size
);
3109 return error::kOutOfBounds
;
3111 glUniform1uiv(location
, count
, v
);
3112 return error::kNoError
;
3115 error::Error
GLES2DecoderImpl::HandleUniform2f(uint32_t immediate_data_size
,
3116 const void* cmd_data
) {
3117 const gles2::cmds::Uniform2f
& c
=
3118 *static_cast<const gles2::cmds::Uniform2f
*>(cmd_data
);
3120 GLint location
= static_cast<GLint
>(c
.location
);
3121 GLfloat x
= static_cast<GLfloat
>(c
.x
);
3122 GLfloat y
= static_cast<GLfloat
>(c
.y
);
3126 DoUniform2fv(location
, 1, &temp
[0]);
3127 return error::kNoError
;
3130 error::Error
GLES2DecoderImpl::HandleUniform2fvImmediate(
3131 uint32_t immediate_data_size
,
3132 const void* cmd_data
) {
3133 const gles2::cmds::Uniform2fvImmediate
& c
=
3134 *static_cast<const gles2::cmds::Uniform2fvImmediate
*>(cmd_data
);
3136 GLint location
= static_cast<GLint
>(c
.location
);
3137 GLsizei count
= static_cast<GLsizei
>(c
.count
);
3139 if (!ComputeDataSize(count
, sizeof(GLfloat
), 2, &data_size
)) {
3140 return error::kOutOfBounds
;
3142 if (data_size
> immediate_data_size
) {
3143 return error::kOutOfBounds
;
3146 GetImmediateDataAs
<const GLfloat
*>(c
, data_size
, immediate_data_size
);
3148 return error::kOutOfBounds
;
3150 DoUniform2fv(location
, count
, v
);
3151 return error::kNoError
;
3154 error::Error
GLES2DecoderImpl::HandleUniform2i(uint32_t immediate_data_size
,
3155 const void* cmd_data
) {
3156 const gles2::cmds::Uniform2i
& c
=
3157 *static_cast<const gles2::cmds::Uniform2i
*>(cmd_data
);
3159 GLint location
= static_cast<GLint
>(c
.location
);
3160 GLint x
= static_cast<GLint
>(c
.x
);
3161 GLint y
= static_cast<GLint
>(c
.y
);
3165 DoUniform2iv(location
, 1, &temp
[0]);
3166 return error::kNoError
;
3169 error::Error
GLES2DecoderImpl::HandleUniform2ivImmediate(
3170 uint32_t immediate_data_size
,
3171 const void* cmd_data
) {
3172 const gles2::cmds::Uniform2ivImmediate
& c
=
3173 *static_cast<const gles2::cmds::Uniform2ivImmediate
*>(cmd_data
);
3175 GLint location
= static_cast<GLint
>(c
.location
);
3176 GLsizei count
= static_cast<GLsizei
>(c
.count
);
3178 if (!ComputeDataSize(count
, sizeof(GLint
), 2, &data_size
)) {
3179 return error::kOutOfBounds
;
3181 if (data_size
> immediate_data_size
) {
3182 return error::kOutOfBounds
;
3185 GetImmediateDataAs
<const GLint
*>(c
, data_size
, immediate_data_size
);
3187 return error::kOutOfBounds
;
3189 DoUniform2iv(location
, count
, v
);
3190 return error::kNoError
;
3193 error::Error
GLES2DecoderImpl::HandleUniform2ui(uint32_t immediate_data_size
,
3194 const void* cmd_data
) {
3195 if (!unsafe_es3_apis_enabled())
3196 return error::kUnknownCommand
;
3197 const gles2::cmds::Uniform2ui
& c
=
3198 *static_cast<const gles2::cmds::Uniform2ui
*>(cmd_data
);
3200 GLint location
= static_cast<GLint
>(c
.location
);
3201 GLuint x
= static_cast<GLuint
>(c
.x
);
3202 GLuint y
= static_cast<GLuint
>(c
.y
);
3206 glUniform2uiv(location
, 1, &temp
[0]);
3207 return error::kNoError
;
3210 error::Error
GLES2DecoderImpl::HandleUniform2uivImmediate(
3211 uint32_t immediate_data_size
,
3212 const void* cmd_data
) {
3213 if (!unsafe_es3_apis_enabled())
3214 return error::kUnknownCommand
;
3215 const gles2::cmds::Uniform2uivImmediate
& c
=
3216 *static_cast<const gles2::cmds::Uniform2uivImmediate
*>(cmd_data
);
3218 GLint location
= static_cast<GLint
>(c
.location
);
3219 GLsizei count
= static_cast<GLsizei
>(c
.count
);
3221 if (!ComputeDataSize(count
, sizeof(GLuint
), 2, &data_size
)) {
3222 return error::kOutOfBounds
;
3224 if (data_size
> immediate_data_size
) {
3225 return error::kOutOfBounds
;
3228 GetImmediateDataAs
<const GLuint
*>(c
, data_size
, immediate_data_size
);
3230 return error::kOutOfBounds
;
3232 glUniform2uiv(location
, count
, v
);
3233 return error::kNoError
;
3236 error::Error
GLES2DecoderImpl::HandleUniform3f(uint32_t immediate_data_size
,
3237 const void* cmd_data
) {
3238 const gles2::cmds::Uniform3f
& c
=
3239 *static_cast<const gles2::cmds::Uniform3f
*>(cmd_data
);
3241 GLint location
= static_cast<GLint
>(c
.location
);
3242 GLfloat x
= static_cast<GLfloat
>(c
.x
);
3243 GLfloat y
= static_cast<GLfloat
>(c
.y
);
3244 GLfloat z
= static_cast<GLfloat
>(c
.z
);
3248 DoUniform3fv(location
, 1, &temp
[0]);
3249 return error::kNoError
;
3252 error::Error
GLES2DecoderImpl::HandleUniform3fvImmediate(
3253 uint32_t immediate_data_size
,
3254 const void* cmd_data
) {
3255 const gles2::cmds::Uniform3fvImmediate
& c
=
3256 *static_cast<const gles2::cmds::Uniform3fvImmediate
*>(cmd_data
);
3258 GLint location
= static_cast<GLint
>(c
.location
);
3259 GLsizei count
= static_cast<GLsizei
>(c
.count
);
3261 if (!ComputeDataSize(count
, sizeof(GLfloat
), 3, &data_size
)) {
3262 return error::kOutOfBounds
;
3264 if (data_size
> immediate_data_size
) {
3265 return error::kOutOfBounds
;
3268 GetImmediateDataAs
<const GLfloat
*>(c
, data_size
, immediate_data_size
);
3270 return error::kOutOfBounds
;
3272 DoUniform3fv(location
, count
, v
);
3273 return error::kNoError
;
3276 error::Error
GLES2DecoderImpl::HandleUniform3i(uint32_t immediate_data_size
,
3277 const void* cmd_data
) {
3278 const gles2::cmds::Uniform3i
& c
=
3279 *static_cast<const gles2::cmds::Uniform3i
*>(cmd_data
);
3281 GLint location
= static_cast<GLint
>(c
.location
);
3282 GLint x
= static_cast<GLint
>(c
.x
);
3283 GLint y
= static_cast<GLint
>(c
.y
);
3284 GLint z
= static_cast<GLint
>(c
.z
);
3288 DoUniform3iv(location
, 1, &temp
[0]);
3289 return error::kNoError
;
3292 error::Error
GLES2DecoderImpl::HandleUniform3ivImmediate(
3293 uint32_t immediate_data_size
,
3294 const void* cmd_data
) {
3295 const gles2::cmds::Uniform3ivImmediate
& c
=
3296 *static_cast<const gles2::cmds::Uniform3ivImmediate
*>(cmd_data
);
3298 GLint location
= static_cast<GLint
>(c
.location
);
3299 GLsizei count
= static_cast<GLsizei
>(c
.count
);
3301 if (!ComputeDataSize(count
, sizeof(GLint
), 3, &data_size
)) {
3302 return error::kOutOfBounds
;
3304 if (data_size
> immediate_data_size
) {
3305 return error::kOutOfBounds
;
3308 GetImmediateDataAs
<const GLint
*>(c
, data_size
, immediate_data_size
);
3310 return error::kOutOfBounds
;
3312 DoUniform3iv(location
, count
, v
);
3313 return error::kNoError
;
3316 error::Error
GLES2DecoderImpl::HandleUniform3ui(uint32_t immediate_data_size
,
3317 const void* cmd_data
) {
3318 if (!unsafe_es3_apis_enabled())
3319 return error::kUnknownCommand
;
3320 const gles2::cmds::Uniform3ui
& c
=
3321 *static_cast<const gles2::cmds::Uniform3ui
*>(cmd_data
);
3323 GLint location
= static_cast<GLint
>(c
.location
);
3324 GLuint x
= static_cast<GLuint
>(c
.x
);
3325 GLuint y
= static_cast<GLuint
>(c
.y
);
3326 GLuint z
= static_cast<GLuint
>(c
.z
);
3330 glUniform3uiv(location
, 1, &temp
[0]);
3331 return error::kNoError
;
3334 error::Error
GLES2DecoderImpl::HandleUniform3uivImmediate(
3335 uint32_t immediate_data_size
,
3336 const void* cmd_data
) {
3337 if (!unsafe_es3_apis_enabled())
3338 return error::kUnknownCommand
;
3339 const gles2::cmds::Uniform3uivImmediate
& c
=
3340 *static_cast<const gles2::cmds::Uniform3uivImmediate
*>(cmd_data
);
3342 GLint location
= static_cast<GLint
>(c
.location
);
3343 GLsizei count
= static_cast<GLsizei
>(c
.count
);
3345 if (!ComputeDataSize(count
, sizeof(GLuint
), 3, &data_size
)) {
3346 return error::kOutOfBounds
;
3348 if (data_size
> immediate_data_size
) {
3349 return error::kOutOfBounds
;
3352 GetImmediateDataAs
<const GLuint
*>(c
, data_size
, immediate_data_size
);
3354 return error::kOutOfBounds
;
3356 glUniform3uiv(location
, count
, v
);
3357 return error::kNoError
;
3360 error::Error
GLES2DecoderImpl::HandleUniform4f(uint32_t immediate_data_size
,
3361 const void* cmd_data
) {
3362 const gles2::cmds::Uniform4f
& c
=
3363 *static_cast<const gles2::cmds::Uniform4f
*>(cmd_data
);
3365 GLint location
= static_cast<GLint
>(c
.location
);
3366 GLfloat x
= static_cast<GLfloat
>(c
.x
);
3367 GLfloat y
= static_cast<GLfloat
>(c
.y
);
3368 GLfloat z
= static_cast<GLfloat
>(c
.z
);
3369 GLfloat w
= static_cast<GLfloat
>(c
.w
);
3373 DoUniform4fv(location
, 1, &temp
[0]);
3374 return error::kNoError
;
3377 error::Error
GLES2DecoderImpl::HandleUniform4fvImmediate(
3378 uint32_t immediate_data_size
,
3379 const void* cmd_data
) {
3380 const gles2::cmds::Uniform4fvImmediate
& c
=
3381 *static_cast<const gles2::cmds::Uniform4fvImmediate
*>(cmd_data
);
3383 GLint location
= static_cast<GLint
>(c
.location
);
3384 GLsizei count
= static_cast<GLsizei
>(c
.count
);
3386 if (!ComputeDataSize(count
, sizeof(GLfloat
), 4, &data_size
)) {
3387 return error::kOutOfBounds
;
3389 if (data_size
> immediate_data_size
) {
3390 return error::kOutOfBounds
;
3393 GetImmediateDataAs
<const GLfloat
*>(c
, data_size
, immediate_data_size
);
3395 return error::kOutOfBounds
;
3397 DoUniform4fv(location
, count
, v
);
3398 return error::kNoError
;
3401 error::Error
GLES2DecoderImpl::HandleUniform4i(uint32_t immediate_data_size
,
3402 const void* cmd_data
) {
3403 const gles2::cmds::Uniform4i
& c
=
3404 *static_cast<const gles2::cmds::Uniform4i
*>(cmd_data
);
3406 GLint location
= static_cast<GLint
>(c
.location
);
3407 GLint x
= static_cast<GLint
>(c
.x
);
3408 GLint y
= static_cast<GLint
>(c
.y
);
3409 GLint z
= static_cast<GLint
>(c
.z
);
3410 GLint w
= static_cast<GLint
>(c
.w
);
3414 DoUniform4iv(location
, 1, &temp
[0]);
3415 return error::kNoError
;
3418 error::Error
GLES2DecoderImpl::HandleUniform4ivImmediate(
3419 uint32_t immediate_data_size
,
3420 const void* cmd_data
) {
3421 const gles2::cmds::Uniform4ivImmediate
& c
=
3422 *static_cast<const gles2::cmds::Uniform4ivImmediate
*>(cmd_data
);
3424 GLint location
= static_cast<GLint
>(c
.location
);
3425 GLsizei count
= static_cast<GLsizei
>(c
.count
);
3427 if (!ComputeDataSize(count
, sizeof(GLint
), 4, &data_size
)) {
3428 return error::kOutOfBounds
;
3430 if (data_size
> immediate_data_size
) {
3431 return error::kOutOfBounds
;
3434 GetImmediateDataAs
<const GLint
*>(c
, data_size
, immediate_data_size
);
3436 return error::kOutOfBounds
;
3438 DoUniform4iv(location
, count
, v
);
3439 return error::kNoError
;
3442 error::Error
GLES2DecoderImpl::HandleUniform4ui(uint32_t immediate_data_size
,
3443 const void* cmd_data
) {
3444 if (!unsafe_es3_apis_enabled())
3445 return error::kUnknownCommand
;
3446 const gles2::cmds::Uniform4ui
& c
=
3447 *static_cast<const gles2::cmds::Uniform4ui
*>(cmd_data
);
3449 GLint location
= static_cast<GLint
>(c
.location
);
3450 GLuint x
= static_cast<GLuint
>(c
.x
);
3451 GLuint y
= static_cast<GLuint
>(c
.y
);
3452 GLuint z
= static_cast<GLuint
>(c
.z
);
3453 GLuint w
= static_cast<GLuint
>(c
.w
);
3457 glUniform4uiv(location
, 1, &temp
[0]);
3458 return error::kNoError
;
3461 error::Error
GLES2DecoderImpl::HandleUniform4uivImmediate(
3462 uint32_t immediate_data_size
,
3463 const void* cmd_data
) {
3464 if (!unsafe_es3_apis_enabled())
3465 return error::kUnknownCommand
;
3466 const gles2::cmds::Uniform4uivImmediate
& c
=
3467 *static_cast<const gles2::cmds::Uniform4uivImmediate
*>(cmd_data
);
3469 GLint location
= static_cast<GLint
>(c
.location
);
3470 GLsizei count
= static_cast<GLsizei
>(c
.count
);
3472 if (!ComputeDataSize(count
, sizeof(GLuint
), 4, &data_size
)) {
3473 return error::kOutOfBounds
;
3475 if (data_size
> immediate_data_size
) {
3476 return error::kOutOfBounds
;
3479 GetImmediateDataAs
<const GLuint
*>(c
, data_size
, immediate_data_size
);
3481 return error::kOutOfBounds
;
3483 glUniform4uiv(location
, count
, v
);
3484 return error::kNoError
;
3487 error::Error
GLES2DecoderImpl::HandleUniformMatrix2fvImmediate(
3488 uint32_t immediate_data_size
,
3489 const void* cmd_data
) {
3490 const gles2::cmds::UniformMatrix2fvImmediate
& c
=
3491 *static_cast<const gles2::cmds::UniformMatrix2fvImmediate
*>(cmd_data
);
3493 GLint location
= static_cast<GLint
>(c
.location
);
3494 GLsizei count
= static_cast<GLsizei
>(c
.count
);
3495 GLboolean transpose
= static_cast<GLboolean
>(c
.transpose
);
3497 if (!ComputeDataSize(count
, sizeof(GLfloat
), 4, &data_size
)) {
3498 return error::kOutOfBounds
;
3500 if (data_size
> immediate_data_size
) {
3501 return error::kOutOfBounds
;
3503 const GLfloat
* value
=
3504 GetImmediateDataAs
<const GLfloat
*>(c
, data_size
, immediate_data_size
);
3505 if (value
== NULL
) {
3506 return error::kOutOfBounds
;
3508 DoUniformMatrix2fv(location
, count
, transpose
, value
);
3509 return error::kNoError
;
3512 error::Error
GLES2DecoderImpl::HandleUniformMatrix2x3fvImmediate(
3513 uint32_t immediate_data_size
,
3514 const void* cmd_data
) {
3515 if (!unsafe_es3_apis_enabled())
3516 return error::kUnknownCommand
;
3517 const gles2::cmds::UniformMatrix2x3fvImmediate
& c
=
3518 *static_cast<const gles2::cmds::UniformMatrix2x3fvImmediate
*>(cmd_data
);
3520 GLint location
= static_cast<GLint
>(c
.location
);
3521 GLsizei count
= static_cast<GLsizei
>(c
.count
);
3522 GLboolean transpose
= static_cast<GLboolean
>(c
.transpose
);
3524 if (!ComputeDataSize(count
, sizeof(GLfloat
), 6, &data_size
)) {
3525 return error::kOutOfBounds
;
3527 if (data_size
> immediate_data_size
) {
3528 return error::kOutOfBounds
;
3530 const GLfloat
* value
=
3531 GetImmediateDataAs
<const GLfloat
*>(c
, data_size
, immediate_data_size
);
3532 if (value
== NULL
) {
3533 return error::kOutOfBounds
;
3535 glUniformMatrix2x3fv(location
, count
, transpose
, value
);
3536 return error::kNoError
;
3539 error::Error
GLES2DecoderImpl::HandleUniformMatrix2x4fvImmediate(
3540 uint32_t immediate_data_size
,
3541 const void* cmd_data
) {
3542 if (!unsafe_es3_apis_enabled())
3543 return error::kUnknownCommand
;
3544 const gles2::cmds::UniformMatrix2x4fvImmediate
& c
=
3545 *static_cast<const gles2::cmds::UniformMatrix2x4fvImmediate
*>(cmd_data
);
3547 GLint location
= static_cast<GLint
>(c
.location
);
3548 GLsizei count
= static_cast<GLsizei
>(c
.count
);
3549 GLboolean transpose
= static_cast<GLboolean
>(c
.transpose
);
3551 if (!ComputeDataSize(count
, sizeof(GLfloat
), 8, &data_size
)) {
3552 return error::kOutOfBounds
;
3554 if (data_size
> immediate_data_size
) {
3555 return error::kOutOfBounds
;
3557 const GLfloat
* value
=
3558 GetImmediateDataAs
<const GLfloat
*>(c
, data_size
, immediate_data_size
);
3559 if (value
== NULL
) {
3560 return error::kOutOfBounds
;
3562 glUniformMatrix2x4fv(location
, count
, transpose
, value
);
3563 return error::kNoError
;
3566 error::Error
GLES2DecoderImpl::HandleUniformMatrix3fvImmediate(
3567 uint32_t immediate_data_size
,
3568 const void* cmd_data
) {
3569 const gles2::cmds::UniformMatrix3fvImmediate
& c
=
3570 *static_cast<const gles2::cmds::UniformMatrix3fvImmediate
*>(cmd_data
);
3572 GLint location
= static_cast<GLint
>(c
.location
);
3573 GLsizei count
= static_cast<GLsizei
>(c
.count
);
3574 GLboolean transpose
= static_cast<GLboolean
>(c
.transpose
);
3576 if (!ComputeDataSize(count
, sizeof(GLfloat
), 9, &data_size
)) {
3577 return error::kOutOfBounds
;
3579 if (data_size
> immediate_data_size
) {
3580 return error::kOutOfBounds
;
3582 const GLfloat
* value
=
3583 GetImmediateDataAs
<const GLfloat
*>(c
, data_size
, immediate_data_size
);
3584 if (value
== NULL
) {
3585 return error::kOutOfBounds
;
3587 DoUniformMatrix3fv(location
, count
, transpose
, value
);
3588 return error::kNoError
;
3591 error::Error
GLES2DecoderImpl::HandleUniformMatrix3x2fvImmediate(
3592 uint32_t immediate_data_size
,
3593 const void* cmd_data
) {
3594 if (!unsafe_es3_apis_enabled())
3595 return error::kUnknownCommand
;
3596 const gles2::cmds::UniformMatrix3x2fvImmediate
& c
=
3597 *static_cast<const gles2::cmds::UniformMatrix3x2fvImmediate
*>(cmd_data
);
3599 GLint location
= static_cast<GLint
>(c
.location
);
3600 GLsizei count
= static_cast<GLsizei
>(c
.count
);
3601 GLboolean transpose
= static_cast<GLboolean
>(c
.transpose
);
3603 if (!ComputeDataSize(count
, sizeof(GLfloat
), 6, &data_size
)) {
3604 return error::kOutOfBounds
;
3606 if (data_size
> immediate_data_size
) {
3607 return error::kOutOfBounds
;
3609 const GLfloat
* value
=
3610 GetImmediateDataAs
<const GLfloat
*>(c
, data_size
, immediate_data_size
);
3611 if (value
== NULL
) {
3612 return error::kOutOfBounds
;
3614 glUniformMatrix3x2fv(location
, count
, transpose
, value
);
3615 return error::kNoError
;
3618 error::Error
GLES2DecoderImpl::HandleUniformMatrix3x4fvImmediate(
3619 uint32_t immediate_data_size
,
3620 const void* cmd_data
) {
3621 if (!unsafe_es3_apis_enabled())
3622 return error::kUnknownCommand
;
3623 const gles2::cmds::UniformMatrix3x4fvImmediate
& c
=
3624 *static_cast<const gles2::cmds::UniformMatrix3x4fvImmediate
*>(cmd_data
);
3626 GLint location
= static_cast<GLint
>(c
.location
);
3627 GLsizei count
= static_cast<GLsizei
>(c
.count
);
3628 GLboolean transpose
= static_cast<GLboolean
>(c
.transpose
);
3630 if (!ComputeDataSize(count
, sizeof(GLfloat
), 12, &data_size
)) {
3631 return error::kOutOfBounds
;
3633 if (data_size
> immediate_data_size
) {
3634 return error::kOutOfBounds
;
3636 const GLfloat
* value
=
3637 GetImmediateDataAs
<const GLfloat
*>(c
, data_size
, immediate_data_size
);
3638 if (value
== NULL
) {
3639 return error::kOutOfBounds
;
3641 glUniformMatrix3x4fv(location
, count
, transpose
, value
);
3642 return error::kNoError
;
3645 error::Error
GLES2DecoderImpl::HandleUniformMatrix4fvImmediate(
3646 uint32_t immediate_data_size
,
3647 const void* cmd_data
) {
3648 const gles2::cmds::UniformMatrix4fvImmediate
& c
=
3649 *static_cast<const gles2::cmds::UniformMatrix4fvImmediate
*>(cmd_data
);
3651 GLint location
= static_cast<GLint
>(c
.location
);
3652 GLsizei count
= static_cast<GLsizei
>(c
.count
);
3653 GLboolean transpose
= static_cast<GLboolean
>(c
.transpose
);
3655 if (!ComputeDataSize(count
, sizeof(GLfloat
), 16, &data_size
)) {
3656 return error::kOutOfBounds
;
3658 if (data_size
> immediate_data_size
) {
3659 return error::kOutOfBounds
;
3661 const GLfloat
* value
=
3662 GetImmediateDataAs
<const GLfloat
*>(c
, data_size
, immediate_data_size
);
3663 if (value
== NULL
) {
3664 return error::kOutOfBounds
;
3666 DoUniformMatrix4fv(location
, count
, transpose
, value
);
3667 return error::kNoError
;
3670 error::Error
GLES2DecoderImpl::HandleUniformMatrix4x2fvImmediate(
3671 uint32_t immediate_data_size
,
3672 const void* cmd_data
) {
3673 if (!unsafe_es3_apis_enabled())
3674 return error::kUnknownCommand
;
3675 const gles2::cmds::UniformMatrix4x2fvImmediate
& c
=
3676 *static_cast<const gles2::cmds::UniformMatrix4x2fvImmediate
*>(cmd_data
);
3678 GLint location
= static_cast<GLint
>(c
.location
);
3679 GLsizei count
= static_cast<GLsizei
>(c
.count
);
3680 GLboolean transpose
= static_cast<GLboolean
>(c
.transpose
);
3682 if (!ComputeDataSize(count
, sizeof(GLfloat
), 8, &data_size
)) {
3683 return error::kOutOfBounds
;
3685 if (data_size
> immediate_data_size
) {
3686 return error::kOutOfBounds
;
3688 const GLfloat
* value
=
3689 GetImmediateDataAs
<const GLfloat
*>(c
, data_size
, immediate_data_size
);
3690 if (value
== NULL
) {
3691 return error::kOutOfBounds
;
3693 glUniformMatrix4x2fv(location
, count
, transpose
, value
);
3694 return error::kNoError
;
3697 error::Error
GLES2DecoderImpl::HandleUniformMatrix4x3fvImmediate(
3698 uint32_t immediate_data_size
,
3699 const void* cmd_data
) {
3700 if (!unsafe_es3_apis_enabled())
3701 return error::kUnknownCommand
;
3702 const gles2::cmds::UniformMatrix4x3fvImmediate
& c
=
3703 *static_cast<const gles2::cmds::UniformMatrix4x3fvImmediate
*>(cmd_data
);
3705 GLint location
= static_cast<GLint
>(c
.location
);
3706 GLsizei count
= static_cast<GLsizei
>(c
.count
);
3707 GLboolean transpose
= static_cast<GLboolean
>(c
.transpose
);
3709 if (!ComputeDataSize(count
, sizeof(GLfloat
), 12, &data_size
)) {
3710 return error::kOutOfBounds
;
3712 if (data_size
> immediate_data_size
) {
3713 return error::kOutOfBounds
;
3715 const GLfloat
* value
=
3716 GetImmediateDataAs
<const GLfloat
*>(c
, data_size
, immediate_data_size
);
3717 if (value
== NULL
) {
3718 return error::kOutOfBounds
;
3720 glUniformMatrix4x3fv(location
, count
, transpose
, value
);
3721 return error::kNoError
;
3724 error::Error
GLES2DecoderImpl::HandleUseProgram(uint32_t immediate_data_size
,
3725 const void* cmd_data
) {
3726 const gles2::cmds::UseProgram
& c
=
3727 *static_cast<const gles2::cmds::UseProgram
*>(cmd_data
);
3729 GLuint program
= c
.program
;
3730 DoUseProgram(program
);
3731 return error::kNoError
;
3734 error::Error
GLES2DecoderImpl::HandleValidateProgram(
3735 uint32_t immediate_data_size
,
3736 const void* cmd_data
) {
3737 const gles2::cmds::ValidateProgram
& c
=
3738 *static_cast<const gles2::cmds::ValidateProgram
*>(cmd_data
);
3740 GLuint program
= c
.program
;
3741 DoValidateProgram(program
);
3742 return error::kNoError
;
3745 error::Error
GLES2DecoderImpl::HandleVertexAttrib1f(
3746 uint32_t immediate_data_size
,
3747 const void* cmd_data
) {
3748 const gles2::cmds::VertexAttrib1f
& c
=
3749 *static_cast<const gles2::cmds::VertexAttrib1f
*>(cmd_data
);
3751 GLuint indx
= static_cast<GLuint
>(c
.indx
);
3752 GLfloat x
= static_cast<GLfloat
>(c
.x
);
3753 DoVertexAttrib1f(indx
, x
);
3754 return error::kNoError
;
3757 error::Error
GLES2DecoderImpl::HandleVertexAttrib1fvImmediate(
3758 uint32_t immediate_data_size
,
3759 const void* cmd_data
) {
3760 const gles2::cmds::VertexAttrib1fvImmediate
& c
=
3761 *static_cast<const gles2::cmds::VertexAttrib1fvImmediate
*>(cmd_data
);
3763 GLuint indx
= static_cast<GLuint
>(c
.indx
);
3765 if (!ComputeDataSize(1, sizeof(GLfloat
), 1, &data_size
)) {
3766 return error::kOutOfBounds
;
3768 if (data_size
> immediate_data_size
) {
3769 return error::kOutOfBounds
;
3771 const GLfloat
* values
=
3772 GetImmediateDataAs
<const GLfloat
*>(c
, data_size
, immediate_data_size
);
3773 if (values
== NULL
) {
3774 return error::kOutOfBounds
;
3776 DoVertexAttrib1fv(indx
, values
);
3777 return error::kNoError
;
3780 error::Error
GLES2DecoderImpl::HandleVertexAttrib2f(
3781 uint32_t immediate_data_size
,
3782 const void* cmd_data
) {
3783 const gles2::cmds::VertexAttrib2f
& c
=
3784 *static_cast<const gles2::cmds::VertexAttrib2f
*>(cmd_data
);
3786 GLuint indx
= static_cast<GLuint
>(c
.indx
);
3787 GLfloat x
= static_cast<GLfloat
>(c
.x
);
3788 GLfloat y
= static_cast<GLfloat
>(c
.y
);
3789 DoVertexAttrib2f(indx
, x
, y
);
3790 return error::kNoError
;
3793 error::Error
GLES2DecoderImpl::HandleVertexAttrib2fvImmediate(
3794 uint32_t immediate_data_size
,
3795 const void* cmd_data
) {
3796 const gles2::cmds::VertexAttrib2fvImmediate
& c
=
3797 *static_cast<const gles2::cmds::VertexAttrib2fvImmediate
*>(cmd_data
);
3799 GLuint indx
= static_cast<GLuint
>(c
.indx
);
3801 if (!ComputeDataSize(1, sizeof(GLfloat
), 2, &data_size
)) {
3802 return error::kOutOfBounds
;
3804 if (data_size
> immediate_data_size
) {
3805 return error::kOutOfBounds
;
3807 const GLfloat
* values
=
3808 GetImmediateDataAs
<const GLfloat
*>(c
, data_size
, immediate_data_size
);
3809 if (values
== NULL
) {
3810 return error::kOutOfBounds
;
3812 DoVertexAttrib2fv(indx
, values
);
3813 return error::kNoError
;
3816 error::Error
GLES2DecoderImpl::HandleVertexAttrib3f(
3817 uint32_t immediate_data_size
,
3818 const void* cmd_data
) {
3819 const gles2::cmds::VertexAttrib3f
& c
=
3820 *static_cast<const gles2::cmds::VertexAttrib3f
*>(cmd_data
);
3822 GLuint indx
= static_cast<GLuint
>(c
.indx
);
3823 GLfloat x
= static_cast<GLfloat
>(c
.x
);
3824 GLfloat y
= static_cast<GLfloat
>(c
.y
);
3825 GLfloat z
= static_cast<GLfloat
>(c
.z
);
3826 DoVertexAttrib3f(indx
, x
, y
, z
);
3827 return error::kNoError
;
3830 error::Error
GLES2DecoderImpl::HandleVertexAttrib3fvImmediate(
3831 uint32_t immediate_data_size
,
3832 const void* cmd_data
) {
3833 const gles2::cmds::VertexAttrib3fvImmediate
& c
=
3834 *static_cast<const gles2::cmds::VertexAttrib3fvImmediate
*>(cmd_data
);
3836 GLuint indx
= static_cast<GLuint
>(c
.indx
);
3838 if (!ComputeDataSize(1, sizeof(GLfloat
), 3, &data_size
)) {
3839 return error::kOutOfBounds
;
3841 if (data_size
> immediate_data_size
) {
3842 return error::kOutOfBounds
;
3844 const GLfloat
* values
=
3845 GetImmediateDataAs
<const GLfloat
*>(c
, data_size
, immediate_data_size
);
3846 if (values
== NULL
) {
3847 return error::kOutOfBounds
;
3849 DoVertexAttrib3fv(indx
, values
);
3850 return error::kNoError
;
3853 error::Error
GLES2DecoderImpl::HandleVertexAttrib4f(
3854 uint32_t immediate_data_size
,
3855 const void* cmd_data
) {
3856 const gles2::cmds::VertexAttrib4f
& c
=
3857 *static_cast<const gles2::cmds::VertexAttrib4f
*>(cmd_data
);
3859 GLuint indx
= static_cast<GLuint
>(c
.indx
);
3860 GLfloat x
= static_cast<GLfloat
>(c
.x
);
3861 GLfloat y
= static_cast<GLfloat
>(c
.y
);
3862 GLfloat z
= static_cast<GLfloat
>(c
.z
);
3863 GLfloat w
= static_cast<GLfloat
>(c
.w
);
3864 DoVertexAttrib4f(indx
, x
, y
, z
, w
);
3865 return error::kNoError
;
3868 error::Error
GLES2DecoderImpl::HandleVertexAttrib4fvImmediate(
3869 uint32_t immediate_data_size
,
3870 const void* cmd_data
) {
3871 const gles2::cmds::VertexAttrib4fvImmediate
& c
=
3872 *static_cast<const gles2::cmds::VertexAttrib4fvImmediate
*>(cmd_data
);
3874 GLuint indx
= static_cast<GLuint
>(c
.indx
);
3876 if (!ComputeDataSize(1, sizeof(GLfloat
), 4, &data_size
)) {
3877 return error::kOutOfBounds
;
3879 if (data_size
> immediate_data_size
) {
3880 return error::kOutOfBounds
;
3882 const GLfloat
* values
=
3883 GetImmediateDataAs
<const GLfloat
*>(c
, data_size
, immediate_data_size
);
3884 if (values
== NULL
) {
3885 return error::kOutOfBounds
;
3887 DoVertexAttrib4fv(indx
, values
);
3888 return error::kNoError
;
3891 error::Error
GLES2DecoderImpl::HandleVertexAttribI4i(
3892 uint32_t immediate_data_size
,
3893 const void* cmd_data
) {
3894 if (!unsafe_es3_apis_enabled())
3895 return error::kUnknownCommand
;
3896 const gles2::cmds::VertexAttribI4i
& c
=
3897 *static_cast<const gles2::cmds::VertexAttribI4i
*>(cmd_data
);
3899 GLuint indx
= static_cast<GLuint
>(c
.indx
);
3900 GLint x
= static_cast<GLint
>(c
.x
);
3901 GLint y
= static_cast<GLint
>(c
.y
);
3902 GLint z
= static_cast<GLint
>(c
.z
);
3903 GLint w
= static_cast<GLint
>(c
.w
);
3904 DoVertexAttribI4i(indx
, x
, y
, z
, w
);
3905 return error::kNoError
;
3908 error::Error
GLES2DecoderImpl::HandleVertexAttribI4ivImmediate(
3909 uint32_t immediate_data_size
,
3910 const void* cmd_data
) {
3911 if (!unsafe_es3_apis_enabled())
3912 return error::kUnknownCommand
;
3913 const gles2::cmds::VertexAttribI4ivImmediate
& c
=
3914 *static_cast<const gles2::cmds::VertexAttribI4ivImmediate
*>(cmd_data
);
3916 GLuint indx
= static_cast<GLuint
>(c
.indx
);
3918 if (!ComputeDataSize(1, sizeof(GLint
), 4, &data_size
)) {
3919 return error::kOutOfBounds
;
3921 if (data_size
> immediate_data_size
) {
3922 return error::kOutOfBounds
;
3924 const GLint
* values
=
3925 GetImmediateDataAs
<const GLint
*>(c
, data_size
, immediate_data_size
);
3926 if (values
== NULL
) {
3927 return error::kOutOfBounds
;
3929 DoVertexAttribI4iv(indx
, values
);
3930 return error::kNoError
;
3933 error::Error
GLES2DecoderImpl::HandleVertexAttribI4ui(
3934 uint32_t immediate_data_size
,
3935 const void* cmd_data
) {
3936 if (!unsafe_es3_apis_enabled())
3937 return error::kUnknownCommand
;
3938 const gles2::cmds::VertexAttribI4ui
& c
=
3939 *static_cast<const gles2::cmds::VertexAttribI4ui
*>(cmd_data
);
3941 GLuint indx
= static_cast<GLuint
>(c
.indx
);
3942 GLuint x
= static_cast<GLuint
>(c
.x
);
3943 GLuint y
= static_cast<GLuint
>(c
.y
);
3944 GLuint z
= static_cast<GLuint
>(c
.z
);
3945 GLuint w
= static_cast<GLuint
>(c
.w
);
3946 DoVertexAttribI4ui(indx
, x
, y
, z
, w
);
3947 return error::kNoError
;
3950 error::Error
GLES2DecoderImpl::HandleVertexAttribI4uivImmediate(
3951 uint32_t immediate_data_size
,
3952 const void* cmd_data
) {
3953 if (!unsafe_es3_apis_enabled())
3954 return error::kUnknownCommand
;
3955 const gles2::cmds::VertexAttribI4uivImmediate
& c
=
3956 *static_cast<const gles2::cmds::VertexAttribI4uivImmediate
*>(cmd_data
);
3958 GLuint indx
= static_cast<GLuint
>(c
.indx
);
3960 if (!ComputeDataSize(1, sizeof(GLuint
), 4, &data_size
)) {
3961 return error::kOutOfBounds
;
3963 if (data_size
> immediate_data_size
) {
3964 return error::kOutOfBounds
;
3966 const GLuint
* values
=
3967 GetImmediateDataAs
<const GLuint
*>(c
, data_size
, immediate_data_size
);
3968 if (values
== NULL
) {
3969 return error::kOutOfBounds
;
3971 DoVertexAttribI4uiv(indx
, values
);
3972 return error::kNoError
;
3975 error::Error
GLES2DecoderImpl::HandleViewport(uint32_t immediate_data_size
,
3976 const void* cmd_data
) {
3977 const gles2::cmds::Viewport
& c
=
3978 *static_cast<const gles2::cmds::Viewport
*>(cmd_data
);
3980 GLint x
= static_cast<GLint
>(c
.x
);
3981 GLint y
= static_cast<GLint
>(c
.y
);
3982 GLsizei width
= static_cast<GLsizei
>(c
.width
);
3983 GLsizei height
= static_cast<GLsizei
>(c
.height
);
3985 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE
, "glViewport", "width < 0");
3986 return error::kNoError
;
3989 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE
, "glViewport", "height < 0");
3990 return error::kNoError
;
3992 DoViewport(x
, y
, width
, height
);
3993 return error::kNoError
;
3996 error::Error
GLES2DecoderImpl::HandleBlitFramebufferCHROMIUM(
3997 uint32_t immediate_data_size
,
3998 const void* cmd_data
) {
3999 const gles2::cmds::BlitFramebufferCHROMIUM
& c
=
4000 *static_cast<const gles2::cmds::BlitFramebufferCHROMIUM
*>(cmd_data
);
4002 if (!features().chromium_framebuffer_multisample
) {
4003 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION
, "glBlitFramebufferCHROMIUM",
4004 "function not available");
4005 return error::kNoError
;
4009 error
= WillAccessBoundFramebufferForDraw();
4010 if (error
!= error::kNoError
)
4012 error
= WillAccessBoundFramebufferForRead();
4013 if (error
!= error::kNoError
)
4015 GLint srcX0
= static_cast<GLint
>(c
.srcX0
);
4016 GLint srcY0
= static_cast<GLint
>(c
.srcY0
);
4017 GLint srcX1
= static_cast<GLint
>(c
.srcX1
);
4018 GLint srcY1
= static_cast<GLint
>(c
.srcY1
);
4019 GLint dstX0
= static_cast<GLint
>(c
.dstX0
);
4020 GLint dstY0
= static_cast<GLint
>(c
.dstY0
);
4021 GLint dstX1
= static_cast<GLint
>(c
.dstX1
);
4022 GLint dstY1
= static_cast<GLint
>(c
.dstY1
);
4023 GLbitfield mask
= static_cast<GLbitfield
>(c
.mask
);
4024 GLenum filter
= static_cast<GLenum
>(c
.filter
);
4025 if (!validators_
->blit_filter
.IsValid(filter
)) {
4026 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBlitFramebufferCHROMIUM", filter
,
4028 return error::kNoError
;
4030 DoBlitFramebufferCHROMIUM(srcX0
, srcY0
, srcX1
, srcY1
, dstX0
, dstY0
, dstX1
,
4031 dstY1
, mask
, filter
);
4032 return error::kNoError
;
4035 error::Error
GLES2DecoderImpl::HandleRenderbufferStorageMultisampleCHROMIUM(
4036 uint32_t immediate_data_size
,
4037 const void* cmd_data
) {
4038 const gles2::cmds::RenderbufferStorageMultisampleCHROMIUM
& c
=
4039 *static_cast<const gles2::cmds::RenderbufferStorageMultisampleCHROMIUM
*>(
4042 if (!features().chromium_framebuffer_multisample
) {
4043 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION
,
4044 "glRenderbufferStorageMultisampleCHROMIUM",
4045 "function not available");
4046 return error::kNoError
;
4049 GLenum target
= static_cast<GLenum
>(c
.target
);
4050 GLsizei samples
= static_cast<GLsizei
>(c
.samples
);
4051 GLenum internalformat
= static_cast<GLenum
>(c
.internalformat
);
4052 GLsizei width
= static_cast<GLsizei
>(c
.width
);
4053 GLsizei height
= static_cast<GLsizei
>(c
.height
);
4054 if (!validators_
->render_buffer_target
.IsValid(target
)) {
4055 LOCAL_SET_GL_ERROR_INVALID_ENUM("glRenderbufferStorageMultisampleCHROMIUM",
4057 return error::kNoError
;
4060 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE
,
4061 "glRenderbufferStorageMultisampleCHROMIUM",
4063 return error::kNoError
;
4065 if (!validators_
->render_buffer_format
.IsValid(internalformat
)) {
4066 LOCAL_SET_GL_ERROR_INVALID_ENUM("glRenderbufferStorageMultisampleCHROMIUM",
4067 internalformat
, "internalformat");
4068 return error::kNoError
;
4071 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE
,
4072 "glRenderbufferStorageMultisampleCHROMIUM", "width < 0");
4073 return error::kNoError
;
4076 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE
,
4077 "glRenderbufferStorageMultisampleCHROMIUM",
4079 return error::kNoError
;
4081 DoRenderbufferStorageMultisampleCHROMIUM(target
, samples
, internalformat
,
4083 return error::kNoError
;
4086 error::Error
GLES2DecoderImpl::HandleRenderbufferStorageMultisampleEXT(
4087 uint32_t immediate_data_size
,
4088 const void* cmd_data
) {
4089 const gles2::cmds::RenderbufferStorageMultisampleEXT
& c
=
4090 *static_cast<const gles2::cmds::RenderbufferStorageMultisampleEXT
*>(
4093 if (!features().multisampled_render_to_texture
) {
4094 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION
,
4095 "glRenderbufferStorageMultisampleEXT",
4096 "function not available");
4097 return error::kNoError
;
4100 GLenum target
= static_cast<GLenum
>(c
.target
);
4101 GLsizei samples
= static_cast<GLsizei
>(c
.samples
);
4102 GLenum internalformat
= static_cast<GLenum
>(c
.internalformat
);
4103 GLsizei width
= static_cast<GLsizei
>(c
.width
);
4104 GLsizei height
= static_cast<GLsizei
>(c
.height
);
4105 if (!validators_
->render_buffer_target
.IsValid(target
)) {
4106 LOCAL_SET_GL_ERROR_INVALID_ENUM("glRenderbufferStorageMultisampleEXT",
4108 return error::kNoError
;
4111 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE
, "glRenderbufferStorageMultisampleEXT",
4113 return error::kNoError
;
4115 if (!validators_
->render_buffer_format
.IsValid(internalformat
)) {
4116 LOCAL_SET_GL_ERROR_INVALID_ENUM("glRenderbufferStorageMultisampleEXT",
4117 internalformat
, "internalformat");
4118 return error::kNoError
;
4121 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE
, "glRenderbufferStorageMultisampleEXT",
4123 return error::kNoError
;
4126 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE
, "glRenderbufferStorageMultisampleEXT",
4128 return error::kNoError
;
4130 DoRenderbufferStorageMultisampleEXT(target
, samples
, internalformat
, width
,
4132 return error::kNoError
;
4135 error::Error
GLES2DecoderImpl::HandleFramebufferTexture2DMultisampleEXT(
4136 uint32_t immediate_data_size
,
4137 const void* cmd_data
) {
4138 const gles2::cmds::FramebufferTexture2DMultisampleEXT
& c
=
4139 *static_cast<const gles2::cmds::FramebufferTexture2DMultisampleEXT
*>(
4142 if (!features().multisampled_render_to_texture
) {
4143 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION
,
4144 "glFramebufferTexture2DMultisampleEXT",
4145 "function not available");
4146 return error::kNoError
;
4149 GLenum target
= static_cast<GLenum
>(c
.target
);
4150 GLenum attachment
= static_cast<GLenum
>(c
.attachment
);
4151 GLenum textarget
= static_cast<GLenum
>(c
.textarget
);
4152 GLuint texture
= c
.texture
;
4153 GLint level
= static_cast<GLint
>(c
.level
);
4154 GLsizei samples
= static_cast<GLsizei
>(c
.samples
);
4155 if (!validators_
->frame_buffer_target
.IsValid(target
)) {
4156 LOCAL_SET_GL_ERROR_INVALID_ENUM("glFramebufferTexture2DMultisampleEXT",
4158 return error::kNoError
;
4160 if (!validators_
->attachment
.IsValid(attachment
)) {
4161 LOCAL_SET_GL_ERROR_INVALID_ENUM("glFramebufferTexture2DMultisampleEXT",
4162 attachment
, "attachment");
4163 return error::kNoError
;
4165 if (!validators_
->texture_target
.IsValid(textarget
)) {
4166 LOCAL_SET_GL_ERROR_INVALID_ENUM("glFramebufferTexture2DMultisampleEXT",
4167 textarget
, "textarget");
4168 return error::kNoError
;
4171 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE
, "glFramebufferTexture2DMultisampleEXT",
4173 return error::kNoError
;
4175 DoFramebufferTexture2DMultisample(target
, attachment
, textarget
, texture
,
4177 return error::kNoError
;
4180 error::Error
GLES2DecoderImpl::HandleTexStorage2DEXT(
4181 uint32_t immediate_data_size
,
4182 const void* cmd_data
) {
4183 const gles2::cmds::TexStorage2DEXT
& c
=
4184 *static_cast<const gles2::cmds::TexStorage2DEXT
*>(cmd_data
);
4186 GLenum target
= static_cast<GLenum
>(c
.target
);
4187 GLsizei levels
= static_cast<GLsizei
>(c
.levels
);
4188 GLenum internalFormat
= static_cast<GLenum
>(c
.internalFormat
);
4189 GLsizei width
= static_cast<GLsizei
>(c
.width
);
4190 GLsizei height
= static_cast<GLsizei
>(c
.height
);
4191 if (!validators_
->texture_bind_target
.IsValid(target
)) {
4192 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexStorage2DEXT", target
, "target");
4193 return error::kNoError
;
4196 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE
, "glTexStorage2DEXT", "levels < 0");
4197 return error::kNoError
;
4199 if (!validators_
->texture_internal_format_storage
.IsValid(internalFormat
)) {
4200 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexStorage2DEXT", internalFormat
,
4202 return error::kNoError
;
4205 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE
, "glTexStorage2DEXT", "width < 0");
4206 return error::kNoError
;
4209 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE
, "glTexStorage2DEXT", "height < 0");
4210 return error::kNoError
;
4212 DoTexStorage2DEXT(target
, levels
, internalFormat
, width
, height
);
4213 return error::kNoError
;
4216 error::Error
GLES2DecoderImpl::HandleGenQueriesEXTImmediate(
4217 uint32_t immediate_data_size
,
4218 const void* cmd_data
) {
4219 const gles2::cmds::GenQueriesEXTImmediate
& c
=
4220 *static_cast<const gles2::cmds::GenQueriesEXTImmediate
*>(cmd_data
);
4222 GLsizei n
= static_cast<GLsizei
>(c
.n
);
4224 if (!SafeMultiplyUint32(n
, sizeof(GLuint
), &data_size
)) {
4225 return error::kOutOfBounds
;
4228 GetImmediateDataAs
<GLuint
*>(c
, data_size
, immediate_data_size
);
4229 if (queries
== NULL
) {
4230 return error::kOutOfBounds
;
4232 if (!GenQueriesEXTHelper(n
, queries
)) {
4233 return error::kInvalidArguments
;
4235 return error::kNoError
;
4238 error::Error
GLES2DecoderImpl::HandleDeleteQueriesEXTImmediate(
4239 uint32_t immediate_data_size
,
4240 const void* cmd_data
) {
4241 const gles2::cmds::DeleteQueriesEXTImmediate
& c
=
4242 *static_cast<const gles2::cmds::DeleteQueriesEXTImmediate
*>(cmd_data
);
4244 GLsizei n
= static_cast<GLsizei
>(c
.n
);
4246 if (!SafeMultiplyUint32(n
, sizeof(GLuint
), &data_size
)) {
4247 return error::kOutOfBounds
;
4249 const GLuint
* queries
=
4250 GetImmediateDataAs
<const GLuint
*>(c
, data_size
, immediate_data_size
);
4251 if (queries
== NULL
) {
4252 return error::kOutOfBounds
;
4254 DeleteQueriesEXTHelper(n
, queries
);
4255 return error::kNoError
;
4258 error::Error
GLES2DecoderImpl::HandleBeginTransformFeedback(
4259 uint32_t immediate_data_size
,
4260 const void* cmd_data
) {
4261 if (!unsafe_es3_apis_enabled())
4262 return error::kUnknownCommand
;
4263 const gles2::cmds::BeginTransformFeedback
& c
=
4264 *static_cast<const gles2::cmds::BeginTransformFeedback
*>(cmd_data
);
4266 GLenum primitivemode
= static_cast<GLenum
>(c
.primitivemode
);
4267 glBeginTransformFeedback(primitivemode
);
4268 return error::kNoError
;
4271 error::Error
GLES2DecoderImpl::HandleEndTransformFeedback(
4272 uint32_t immediate_data_size
,
4273 const void* cmd_data
) {
4274 if (!unsafe_es3_apis_enabled())
4275 return error::kUnknownCommand
;
4276 const gles2::cmds::EndTransformFeedback
& c
=
4277 *static_cast<const gles2::cmds::EndTransformFeedback
*>(cmd_data
);
4279 glEndTransformFeedback();
4280 return error::kNoError
;
4283 error::Error
GLES2DecoderImpl::HandleInsertEventMarkerEXT(
4284 uint32_t immediate_data_size
,
4285 const void* cmd_data
) {
4286 const gles2::cmds::InsertEventMarkerEXT
& c
=
4287 *static_cast<const gles2::cmds::InsertEventMarkerEXT
*>(cmd_data
);
4290 GLuint bucket_id
= static_cast<GLuint
>(c
.bucket_id
);
4291 Bucket
* bucket
= GetBucket(bucket_id
);
4292 if (!bucket
|| bucket
->size() == 0) {
4293 return error::kInvalidArguments
;
4296 if (!bucket
->GetAsString(&str
)) {
4297 return error::kInvalidArguments
;
4299 DoInsertEventMarkerEXT(0, str
.c_str());
4300 return error::kNoError
;
4303 error::Error
GLES2DecoderImpl::HandlePushGroupMarkerEXT(
4304 uint32_t immediate_data_size
,
4305 const void* cmd_data
) {
4306 const gles2::cmds::PushGroupMarkerEXT
& c
=
4307 *static_cast<const gles2::cmds::PushGroupMarkerEXT
*>(cmd_data
);
4310 GLuint bucket_id
= static_cast<GLuint
>(c
.bucket_id
);
4311 Bucket
* bucket
= GetBucket(bucket_id
);
4312 if (!bucket
|| bucket
->size() == 0) {
4313 return error::kInvalidArguments
;
4316 if (!bucket
->GetAsString(&str
)) {
4317 return error::kInvalidArguments
;
4319 DoPushGroupMarkerEXT(0, str
.c_str());
4320 return error::kNoError
;
4323 error::Error
GLES2DecoderImpl::HandlePopGroupMarkerEXT(
4324 uint32_t immediate_data_size
,
4325 const void* cmd_data
) {
4326 const gles2::cmds::PopGroupMarkerEXT
& c
=
4327 *static_cast<const gles2::cmds::PopGroupMarkerEXT
*>(cmd_data
);
4329 DoPopGroupMarkerEXT();
4330 return error::kNoError
;
4333 error::Error
GLES2DecoderImpl::HandleGenVertexArraysOESImmediate(
4334 uint32_t immediate_data_size
,
4335 const void* cmd_data
) {
4336 const gles2::cmds::GenVertexArraysOESImmediate
& c
=
4337 *static_cast<const gles2::cmds::GenVertexArraysOESImmediate
*>(cmd_data
);
4339 GLsizei n
= static_cast<GLsizei
>(c
.n
);
4341 if (!SafeMultiplyUint32(n
, sizeof(GLuint
), &data_size
)) {
4342 return error::kOutOfBounds
;
4345 GetImmediateDataAs
<GLuint
*>(c
, data_size
, immediate_data_size
);
4346 if (arrays
== NULL
) {
4347 return error::kOutOfBounds
;
4349 if (!GenVertexArraysOESHelper(n
, arrays
)) {
4350 return error::kInvalidArguments
;
4352 return error::kNoError
;
4355 error::Error
GLES2DecoderImpl::HandleDeleteVertexArraysOESImmediate(
4356 uint32_t immediate_data_size
,
4357 const void* cmd_data
) {
4358 const gles2::cmds::DeleteVertexArraysOESImmediate
& c
=
4359 *static_cast<const gles2::cmds::DeleteVertexArraysOESImmediate
*>(
4362 GLsizei n
= static_cast<GLsizei
>(c
.n
);
4364 if (!SafeMultiplyUint32(n
, sizeof(GLuint
), &data_size
)) {
4365 return error::kOutOfBounds
;
4367 const GLuint
* arrays
=
4368 GetImmediateDataAs
<const GLuint
*>(c
, data_size
, immediate_data_size
);
4369 if (arrays
== NULL
) {
4370 return error::kOutOfBounds
;
4372 DeleteVertexArraysOESHelper(n
, arrays
);
4373 return error::kNoError
;
4376 error::Error
GLES2DecoderImpl::HandleIsVertexArrayOES(
4377 uint32_t immediate_data_size
,
4378 const void* cmd_data
) {
4379 const gles2::cmds::IsVertexArrayOES
& c
=
4380 *static_cast<const gles2::cmds::IsVertexArrayOES
*>(cmd_data
);
4382 GLuint array
= c
.array
;
4383 typedef cmds::IsVertexArrayOES::Result Result
;
4384 Result
* result_dst
= GetSharedMemoryAs
<Result
*>(
4385 c
.result_shm_id
, c
.result_shm_offset
, sizeof(*result_dst
));
4387 return error::kOutOfBounds
;
4389 *result_dst
= DoIsVertexArrayOES(array
);
4390 return error::kNoError
;
4393 error::Error
GLES2DecoderImpl::HandleBindVertexArrayOES(
4394 uint32_t immediate_data_size
,
4395 const void* cmd_data
) {
4396 const gles2::cmds::BindVertexArrayOES
& c
=
4397 *static_cast<const gles2::cmds::BindVertexArrayOES
*>(cmd_data
);
4399 GLuint array
= c
.array
;
4400 DoBindVertexArrayOES(array
);
4401 return error::kNoError
;
4404 error::Error
GLES2DecoderImpl::HandleSwapBuffers(uint32_t immediate_data_size
,
4405 const void* cmd_data
) {
4406 const gles2::cmds::SwapBuffers
& c
=
4407 *static_cast<const gles2::cmds::SwapBuffers
*>(cmd_data
);
4410 return error::kNoError
;
4413 error::Error
GLES2DecoderImpl::HandleGetMaxValueInBufferCHROMIUM(
4414 uint32_t immediate_data_size
,
4415 const void* cmd_data
) {
4416 const gles2::cmds::GetMaxValueInBufferCHROMIUM
& c
=
4417 *static_cast<const gles2::cmds::GetMaxValueInBufferCHROMIUM
*>(cmd_data
);
4419 GLuint buffer_id
= c
.buffer_id
;
4420 GLsizei count
= static_cast<GLsizei
>(c
.count
);
4421 GLenum type
= static_cast<GLenum
>(c
.type
);
4422 GLuint offset
= static_cast<GLuint
>(c
.offset
);
4423 typedef cmds::GetMaxValueInBufferCHROMIUM::Result Result
;
4424 Result
* result_dst
= GetSharedMemoryAs
<Result
*>(
4425 c
.result_shm_id
, c
.result_shm_offset
, sizeof(*result_dst
));
4427 return error::kOutOfBounds
;
4430 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE
, "glGetMaxValueInBufferCHROMIUM",
4432 return error::kNoError
;
4434 if (!validators_
->get_max_index_type
.IsValid(type
)) {
4435 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetMaxValueInBufferCHROMIUM", type
,
4437 return error::kNoError
;
4439 *result_dst
= DoGetMaxValueInBufferCHROMIUM(buffer_id
, count
, type
, offset
);
4440 return error::kNoError
;
4443 error::Error
GLES2DecoderImpl::HandleTexImageIOSurface2DCHROMIUM(
4444 uint32_t immediate_data_size
,
4445 const void* cmd_data
) {
4446 const gles2::cmds::TexImageIOSurface2DCHROMIUM
& c
=
4447 *static_cast<const gles2::cmds::TexImageIOSurface2DCHROMIUM
*>(cmd_data
);
4449 GLenum target
= static_cast<GLenum
>(c
.target
);
4450 GLsizei width
= static_cast<GLsizei
>(c
.width
);
4451 GLsizei height
= static_cast<GLsizei
>(c
.height
);
4452 GLuint ioSurfaceId
= static_cast<GLuint
>(c
.ioSurfaceId
);
4453 GLuint plane
= static_cast<GLuint
>(c
.plane
);
4454 if (!validators_
->texture_bind_target
.IsValid(target
)) {
4455 LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexImageIOSurface2DCHROMIUM", target
,
4457 return error::kNoError
;
4460 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE
, "glTexImageIOSurface2DCHROMIUM",
4462 return error::kNoError
;
4465 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE
, "glTexImageIOSurface2DCHROMIUM",
4467 return error::kNoError
;
4469 DoTexImageIOSurface2DCHROMIUM(target
, width
, height
, ioSurfaceId
, plane
);
4470 return error::kNoError
;
4473 error::Error
GLES2DecoderImpl::HandleCopyTextureCHROMIUM(
4474 uint32_t immediate_data_size
,
4475 const void* cmd_data
) {
4476 const gles2::cmds::CopyTextureCHROMIUM
& c
=
4477 *static_cast<const gles2::cmds::CopyTextureCHROMIUM
*>(cmd_data
);
4479 GLenum target
= static_cast<GLenum
>(c
.target
);
4480 GLenum source_id
= static_cast<GLenum
>(c
.source_id
);
4481 GLenum dest_id
= static_cast<GLenum
>(c
.dest_id
);
4482 GLint internalformat
= static_cast<GLint
>(c
.internalformat
);
4483 GLenum dest_type
= static_cast<GLenum
>(c
.dest_type
);
4484 GLboolean unpack_flip_y
= static_cast<GLboolean
>(c
.unpack_flip_y
);
4485 GLboolean unpack_premultiply_alpha
=
4486 static_cast<GLboolean
>(c
.unpack_premultiply_alpha
);
4487 GLboolean unpack_unmultiply_alpha
=
4488 static_cast<GLboolean
>(c
.unpack_unmultiply_alpha
);
4489 if (!validators_
->texture_internal_format
.IsValid(internalformat
)) {
4490 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE
, "glCopyTextureCHROMIUM",
4491 "internalformat GL_INVALID_VALUE");
4492 return error::kNoError
;
4494 if (!validators_
->pixel_type
.IsValid(dest_type
)) {
4495 LOCAL_SET_GL_ERROR_INVALID_ENUM("glCopyTextureCHROMIUM", dest_type
,
4497 return error::kNoError
;
4499 DoCopyTextureCHROMIUM(target
, source_id
, dest_id
, internalformat
, dest_type
,
4500 unpack_flip_y
, unpack_premultiply_alpha
,
4501 unpack_unmultiply_alpha
);
4502 return error::kNoError
;
4505 error::Error
GLES2DecoderImpl::HandleCopySubTextureCHROMIUM(
4506 uint32_t immediate_data_size
,
4507 const void* cmd_data
) {
4508 const gles2::cmds::CopySubTextureCHROMIUM
& c
=
4509 *static_cast<const gles2::cmds::CopySubTextureCHROMIUM
*>(cmd_data
);
4511 GLenum target
= static_cast<GLenum
>(c
.target
);
4512 GLenum source_id
= static_cast<GLenum
>(c
.source_id
);
4513 GLenum dest_id
= static_cast<GLenum
>(c
.dest_id
);
4514 GLint xoffset
= static_cast<GLint
>(c
.xoffset
);
4515 GLint yoffset
= static_cast<GLint
>(c
.yoffset
);
4516 GLint x
= static_cast<GLint
>(c
.x
);
4517 GLint y
= static_cast<GLint
>(c
.y
);
4518 GLsizei width
= static_cast<GLsizei
>(c
.width
);
4519 GLsizei height
= static_cast<GLsizei
>(c
.height
);
4520 GLboolean unpack_flip_y
= static_cast<GLboolean
>(c
.unpack_flip_y
);
4521 GLboolean unpack_premultiply_alpha
=
4522 static_cast<GLboolean
>(c
.unpack_premultiply_alpha
);
4523 GLboolean unpack_unmultiply_alpha
=
4524 static_cast<GLboolean
>(c
.unpack_unmultiply_alpha
);
4526 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE
, "glCopySubTextureCHROMIUM",
4528 return error::kNoError
;
4531 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE
, "glCopySubTextureCHROMIUM",
4533 return error::kNoError
;
4535 DoCopySubTextureCHROMIUM(target
, source_id
, dest_id
, xoffset
, yoffset
, x
, y
,
4536 width
, height
, unpack_flip_y
,
4537 unpack_premultiply_alpha
, unpack_unmultiply_alpha
);
4538 return error::kNoError
;
4541 error::Error
GLES2DecoderImpl::HandleCompressedCopyTextureCHROMIUM(
4542 uint32_t immediate_data_size
,
4543 const void* cmd_data
) {
4544 const gles2::cmds::CompressedCopyTextureCHROMIUM
& c
=
4545 *static_cast<const gles2::cmds::CompressedCopyTextureCHROMIUM
*>(cmd_data
);
4547 GLenum target
= static_cast<GLenum
>(c
.target
);
4548 GLenum source_id
= static_cast<GLenum
>(c
.source_id
);
4549 GLenum dest_id
= static_cast<GLenum
>(c
.dest_id
);
4550 DoCompressedCopyTextureCHROMIUM(target
, source_id
, dest_id
);
4551 return error::kNoError
;
4554 error::Error
GLES2DecoderImpl::HandleProduceTextureCHROMIUMImmediate(
4555 uint32_t immediate_data_size
,
4556 const void* cmd_data
) {
4557 const gles2::cmds::ProduceTextureCHROMIUMImmediate
& c
=
4558 *static_cast<const gles2::cmds::ProduceTextureCHROMIUMImmediate
*>(
4561 GLenum target
= static_cast<GLenum
>(c
.target
);
4563 if (!ComputeDataSize(1, sizeof(GLbyte
), 64, &data_size
)) {
4564 return error::kOutOfBounds
;
4566 if (data_size
> immediate_data_size
) {
4567 return error::kOutOfBounds
;
4569 const GLbyte
* mailbox
=
4570 GetImmediateDataAs
<const GLbyte
*>(c
, data_size
, immediate_data_size
);
4571 if (!validators_
->texture_bind_target
.IsValid(target
)) {
4572 LOCAL_SET_GL_ERROR_INVALID_ENUM("glProduceTextureCHROMIUM", target
,
4574 return error::kNoError
;
4576 if (mailbox
== NULL
) {
4577 return error::kOutOfBounds
;
4579 DoProduceTextureCHROMIUM(target
, mailbox
);
4580 return error::kNoError
;
4583 error::Error
GLES2DecoderImpl::HandleProduceTextureDirectCHROMIUMImmediate(
4584 uint32_t immediate_data_size
,
4585 const void* cmd_data
) {
4586 const gles2::cmds::ProduceTextureDirectCHROMIUMImmediate
& c
=
4587 *static_cast<const gles2::cmds::ProduceTextureDirectCHROMIUMImmediate
*>(
4590 GLuint texture
= c
.texture
;
4591 GLenum target
= static_cast<GLenum
>(c
.target
);
4593 if (!ComputeDataSize(1, sizeof(GLbyte
), 64, &data_size
)) {
4594 return error::kOutOfBounds
;
4596 if (data_size
> immediate_data_size
) {
4597 return error::kOutOfBounds
;
4599 const GLbyte
* mailbox
=
4600 GetImmediateDataAs
<const GLbyte
*>(c
, data_size
, immediate_data_size
);
4601 if (!validators_
->texture_bind_target
.IsValid(target
)) {
4602 LOCAL_SET_GL_ERROR_INVALID_ENUM("glProduceTextureDirectCHROMIUM", target
,
4604 return error::kNoError
;
4606 if (mailbox
== NULL
) {
4607 return error::kOutOfBounds
;
4609 DoProduceTextureDirectCHROMIUM(texture
, target
, mailbox
);
4610 return error::kNoError
;
4613 error::Error
GLES2DecoderImpl::HandleConsumeTextureCHROMIUMImmediate(
4614 uint32_t immediate_data_size
,
4615 const void* cmd_data
) {
4616 const gles2::cmds::ConsumeTextureCHROMIUMImmediate
& c
=
4617 *static_cast<const gles2::cmds::ConsumeTextureCHROMIUMImmediate
*>(
4620 GLenum target
= static_cast<GLenum
>(c
.target
);
4622 if (!ComputeDataSize(1, sizeof(GLbyte
), 64, &data_size
)) {
4623 return error::kOutOfBounds
;
4625 if (data_size
> immediate_data_size
) {
4626 return error::kOutOfBounds
;
4628 const GLbyte
* mailbox
=
4629 GetImmediateDataAs
<const GLbyte
*>(c
, data_size
, immediate_data_size
);
4630 if (!validators_
->texture_bind_target
.IsValid(target
)) {
4631 LOCAL_SET_GL_ERROR_INVALID_ENUM("glConsumeTextureCHROMIUM", target
,
4633 return error::kNoError
;
4635 if (mailbox
== NULL
) {
4636 return error::kOutOfBounds
;
4638 DoConsumeTextureCHROMIUM(target
, mailbox
);
4639 return error::kNoError
;
4642 error::Error
GLES2DecoderImpl::HandleGenValuebuffersCHROMIUMImmediate(
4643 uint32_t immediate_data_size
,
4644 const void* cmd_data
) {
4645 const gles2::cmds::GenValuebuffersCHROMIUMImmediate
& c
=
4646 *static_cast<const gles2::cmds::GenValuebuffersCHROMIUMImmediate
*>(
4649 GLsizei n
= static_cast<GLsizei
>(c
.n
);
4651 if (!SafeMultiplyUint32(n
, sizeof(GLuint
), &data_size
)) {
4652 return error::kOutOfBounds
;
4655 GetImmediateDataAs
<GLuint
*>(c
, data_size
, immediate_data_size
);
4656 if (buffers
== NULL
) {
4657 return error::kOutOfBounds
;
4659 if (!GenValuebuffersCHROMIUMHelper(n
, buffers
)) {
4660 return error::kInvalidArguments
;
4662 return error::kNoError
;
4665 error::Error
GLES2DecoderImpl::HandleDeleteValuebuffersCHROMIUMImmediate(
4666 uint32_t immediate_data_size
,
4667 const void* cmd_data
) {
4668 const gles2::cmds::DeleteValuebuffersCHROMIUMImmediate
& c
=
4669 *static_cast<const gles2::cmds::DeleteValuebuffersCHROMIUMImmediate
*>(
4672 GLsizei n
= static_cast<GLsizei
>(c
.n
);
4674 if (!SafeMultiplyUint32(n
, sizeof(GLuint
), &data_size
)) {
4675 return error::kOutOfBounds
;
4677 const GLuint
* valuebuffers
=
4678 GetImmediateDataAs
<const GLuint
*>(c
, data_size
, immediate_data_size
);
4679 if (valuebuffers
== NULL
) {
4680 return error::kOutOfBounds
;
4682 DeleteValuebuffersCHROMIUMHelper(n
, valuebuffers
);
4683 return error::kNoError
;
4686 error::Error
GLES2DecoderImpl::HandleIsValuebufferCHROMIUM(
4687 uint32_t immediate_data_size
,
4688 const void* cmd_data
) {
4689 const gles2::cmds::IsValuebufferCHROMIUM
& c
=
4690 *static_cast<const gles2::cmds::IsValuebufferCHROMIUM
*>(cmd_data
);
4692 GLuint valuebuffer
= c
.valuebuffer
;
4693 typedef cmds::IsValuebufferCHROMIUM::Result Result
;
4694 Result
* result_dst
= GetSharedMemoryAs
<Result
*>(
4695 c
.result_shm_id
, c
.result_shm_offset
, sizeof(*result_dst
));
4697 return error::kOutOfBounds
;
4699 *result_dst
= DoIsValuebufferCHROMIUM(valuebuffer
);
4700 return error::kNoError
;
4703 error::Error
GLES2DecoderImpl::HandleBindValuebufferCHROMIUM(
4704 uint32_t immediate_data_size
,
4705 const void* cmd_data
) {
4706 const gles2::cmds::BindValuebufferCHROMIUM
& c
=
4707 *static_cast<const gles2::cmds::BindValuebufferCHROMIUM
*>(cmd_data
);
4709 GLenum target
= static_cast<GLenum
>(c
.target
);
4710 GLuint valuebuffer
= c
.valuebuffer
;
4711 if (!validators_
->value_buffer_target
.IsValid(target
)) {
4712 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBindValuebufferCHROMIUM", target
,
4714 return error::kNoError
;
4716 DoBindValueBufferCHROMIUM(target
, valuebuffer
);
4717 return error::kNoError
;
4720 error::Error
GLES2DecoderImpl::HandleSubscribeValueCHROMIUM(
4721 uint32_t immediate_data_size
,
4722 const void* cmd_data
) {
4723 const gles2::cmds::SubscribeValueCHROMIUM
& c
=
4724 *static_cast<const gles2::cmds::SubscribeValueCHROMIUM
*>(cmd_data
);
4726 GLenum target
= static_cast<GLenum
>(c
.target
);
4727 GLenum subscription
= static_cast<GLenum
>(c
.subscription
);
4728 if (!validators_
->value_buffer_target
.IsValid(target
)) {
4729 LOCAL_SET_GL_ERROR_INVALID_ENUM("glSubscribeValueCHROMIUM", target
,
4731 return error::kNoError
;
4733 if (!validators_
->subscription_target
.IsValid(subscription
)) {
4734 LOCAL_SET_GL_ERROR_INVALID_ENUM("glSubscribeValueCHROMIUM", subscription
,
4736 return error::kNoError
;
4738 DoSubscribeValueCHROMIUM(target
, subscription
);
4739 return error::kNoError
;
4742 error::Error
GLES2DecoderImpl::HandlePopulateSubscribedValuesCHROMIUM(
4743 uint32_t immediate_data_size
,
4744 const void* cmd_data
) {
4745 const gles2::cmds::PopulateSubscribedValuesCHROMIUM
& c
=
4746 *static_cast<const gles2::cmds::PopulateSubscribedValuesCHROMIUM
*>(
4749 GLenum target
= static_cast<GLenum
>(c
.target
);
4750 if (!validators_
->value_buffer_target
.IsValid(target
)) {
4751 LOCAL_SET_GL_ERROR_INVALID_ENUM("glPopulateSubscribedValuesCHROMIUM",
4753 return error::kNoError
;
4755 DoPopulateSubscribedValuesCHROMIUM(target
);
4756 return error::kNoError
;
4759 error::Error
GLES2DecoderImpl::HandleUniformValuebufferCHROMIUM(
4760 uint32_t immediate_data_size
,
4761 const void* cmd_data
) {
4762 const gles2::cmds::UniformValuebufferCHROMIUM
& c
=
4763 *static_cast<const gles2::cmds::UniformValuebufferCHROMIUM
*>(cmd_data
);
4765 GLint location
= static_cast<GLint
>(c
.location
);
4766 GLenum target
= static_cast<GLenum
>(c
.target
);
4767 GLenum subscription
= static_cast<GLenum
>(c
.subscription
);
4768 if (!validators_
->value_buffer_target
.IsValid(target
)) {
4769 LOCAL_SET_GL_ERROR_INVALID_ENUM("glUniformValuebufferCHROMIUM", target
,
4771 return error::kNoError
;
4773 if (!validators_
->subscription_target
.IsValid(subscription
)) {
4774 LOCAL_SET_GL_ERROR_INVALID_ENUM("glUniformValuebufferCHROMIUM",
4775 subscription
, "subscription");
4776 return error::kNoError
;
4778 DoUniformValueBufferCHROMIUM(location
, target
, subscription
);
4779 return error::kNoError
;
4782 error::Error
GLES2DecoderImpl::HandleBindTexImage2DCHROMIUM(
4783 uint32_t immediate_data_size
,
4784 const void* cmd_data
) {
4785 const gles2::cmds::BindTexImage2DCHROMIUM
& c
=
4786 *static_cast<const gles2::cmds::BindTexImage2DCHROMIUM
*>(cmd_data
);
4788 GLenum target
= static_cast<GLenum
>(c
.target
);
4789 GLint imageId
= static_cast<GLint
>(c
.imageId
);
4790 if (!validators_
->texture_bind_target
.IsValid(target
)) {
4791 LOCAL_SET_GL_ERROR_INVALID_ENUM("glBindTexImage2DCHROMIUM", target
,
4793 return error::kNoError
;
4795 DoBindTexImage2DCHROMIUM(target
, imageId
);
4796 return error::kNoError
;
4799 error::Error
GLES2DecoderImpl::HandleReleaseTexImage2DCHROMIUM(
4800 uint32_t immediate_data_size
,
4801 const void* cmd_data
) {
4802 const gles2::cmds::ReleaseTexImage2DCHROMIUM
& c
=
4803 *static_cast<const gles2::cmds::ReleaseTexImage2DCHROMIUM
*>(cmd_data
);
4805 GLenum target
= static_cast<GLenum
>(c
.target
);
4806 GLint imageId
= static_cast<GLint
>(c
.imageId
);
4807 if (!validators_
->texture_bind_target
.IsValid(target
)) {
4808 LOCAL_SET_GL_ERROR_INVALID_ENUM("glReleaseTexImage2DCHROMIUM", target
,
4810 return error::kNoError
;
4812 DoReleaseTexImage2DCHROMIUM(target
, imageId
);
4813 return error::kNoError
;
4816 error::Error
GLES2DecoderImpl::HandleTraceEndCHROMIUM(
4817 uint32_t immediate_data_size
,
4818 const void* cmd_data
) {
4819 const gles2::cmds::TraceEndCHROMIUM
& c
=
4820 *static_cast<const gles2::cmds::TraceEndCHROMIUM
*>(cmd_data
);
4822 DoTraceEndCHROMIUM();
4823 return error::kNoError
;
4826 error::Error
GLES2DecoderImpl::HandleDiscardFramebufferEXTImmediate(
4827 uint32_t immediate_data_size
,
4828 const void* cmd_data
) {
4829 const gles2::cmds::DiscardFramebufferEXTImmediate
& c
=
4830 *static_cast<const gles2::cmds::DiscardFramebufferEXTImmediate
*>(
4833 if (!features().ext_discard_framebuffer
) {
4834 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION
, "glDiscardFramebufferEXT",
4835 "function not available");
4836 return error::kNoError
;
4839 GLenum target
= static_cast<GLenum
>(c
.target
);
4840 GLsizei count
= static_cast<GLsizei
>(c
.count
);
4842 if (!ComputeDataSize(count
, sizeof(GLenum
), 1, &data_size
)) {
4843 return error::kOutOfBounds
;
4845 if (data_size
> immediate_data_size
) {
4846 return error::kOutOfBounds
;
4848 const GLenum
* attachments
=
4849 GetImmediateDataAs
<const GLenum
*>(c
, data_size
, immediate_data_size
);
4851 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE
, "glDiscardFramebufferEXT",
4853 return error::kNoError
;
4855 if (attachments
== NULL
) {
4856 return error::kOutOfBounds
;
4858 DoDiscardFramebufferEXT(target
, count
, attachments
);
4859 return error::kNoError
;
4862 error::Error
GLES2DecoderImpl::HandleLoseContextCHROMIUM(
4863 uint32_t immediate_data_size
,
4864 const void* cmd_data
) {
4865 const gles2::cmds::LoseContextCHROMIUM
& c
=
4866 *static_cast<const gles2::cmds::LoseContextCHROMIUM
*>(cmd_data
);
4868 GLenum current
= static_cast<GLenum
>(c
.current
);
4869 GLenum other
= static_cast<GLenum
>(c
.other
);
4870 if (!validators_
->reset_status
.IsValid(current
)) {
4871 LOCAL_SET_GL_ERROR_INVALID_ENUM("glLoseContextCHROMIUM", current
,
4873 return error::kNoError
;
4875 if (!validators_
->reset_status
.IsValid(other
)) {
4876 LOCAL_SET_GL_ERROR_INVALID_ENUM("glLoseContextCHROMIUM", other
, "other");
4877 return error::kNoError
;
4879 DoLoseContextCHROMIUM(current
, other
);
4880 return error::kNoError
;
4883 error::Error
GLES2DecoderImpl::HandleDrawBuffersEXTImmediate(
4884 uint32_t immediate_data_size
,
4885 const void* cmd_data
) {
4886 const gles2::cmds::DrawBuffersEXTImmediate
& c
=
4887 *static_cast<const gles2::cmds::DrawBuffersEXTImmediate
*>(cmd_data
);
4889 GLsizei count
= static_cast<GLsizei
>(c
.count
);
4891 if (!ComputeDataSize(count
, sizeof(GLenum
), 1, &data_size
)) {
4892 return error::kOutOfBounds
;
4894 if (data_size
> immediate_data_size
) {
4895 return error::kOutOfBounds
;
4897 const GLenum
* bufs
=
4898 GetImmediateDataAs
<const GLenum
*>(c
, data_size
, immediate_data_size
);
4900 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE
, "glDrawBuffersEXT", "count < 0");
4901 return error::kNoError
;
4904 return error::kOutOfBounds
;
4906 DoDrawBuffersEXT(count
, bufs
);
4907 return error::kNoError
;
4910 error::Error
GLES2DecoderImpl::HandleSwapInterval(uint32_t immediate_data_size
,
4911 const void* cmd_data
) {
4912 const gles2::cmds::SwapInterval
& c
=
4913 *static_cast<const gles2::cmds::SwapInterval
*>(cmd_data
);
4915 GLint interval
= static_cast<GLint
>(c
.interval
);
4916 DoSwapInterval(interval
);
4917 return error::kNoError
;
4920 error::Error
GLES2DecoderImpl::HandleFlushDriverCachesCHROMIUM(
4921 uint32_t immediate_data_size
,
4922 const void* cmd_data
) {
4923 const gles2::cmds::FlushDriverCachesCHROMIUM
& c
=
4924 *static_cast<const gles2::cmds::FlushDriverCachesCHROMIUM
*>(cmd_data
);
4926 DoFlushDriverCachesCHROMIUM();
4927 return error::kNoError
;
4930 error::Error
GLES2DecoderImpl::HandleMatrixLoadfCHROMIUMImmediate(
4931 uint32_t immediate_data_size
,
4932 const void* cmd_data
) {
4933 const gles2::cmds::MatrixLoadfCHROMIUMImmediate
& c
=
4934 *static_cast<const gles2::cmds::MatrixLoadfCHROMIUMImmediate
*>(cmd_data
);
4936 if (!features().chromium_path_rendering
) {
4937 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION
, "glMatrixLoadfCHROMIUM",
4938 "function not available");
4939 return error::kNoError
;
4942 GLenum matrixMode
= static_cast<GLenum
>(c
.matrixMode
);
4944 if (!ComputeDataSize(1, sizeof(GLfloat
), 16, &data_size
)) {
4945 return error::kOutOfBounds
;
4947 if (data_size
> immediate_data_size
) {
4948 return error::kOutOfBounds
;
4951 GetImmediateDataAs
<const GLfloat
*>(c
, data_size
, immediate_data_size
);
4952 if (!validators_
->matrix_mode
.IsValid(matrixMode
)) {
4953 LOCAL_SET_GL_ERROR_INVALID_ENUM("glMatrixLoadfCHROMIUM", matrixMode
,
4955 return error::kNoError
;
4958 return error::kOutOfBounds
;
4960 DoMatrixLoadfCHROMIUM(matrixMode
, m
);
4961 return error::kNoError
;
4964 error::Error
GLES2DecoderImpl::HandleMatrixLoadIdentityCHROMIUM(
4965 uint32_t immediate_data_size
,
4966 const void* cmd_data
) {
4967 const gles2::cmds::MatrixLoadIdentityCHROMIUM
& c
=
4968 *static_cast<const gles2::cmds::MatrixLoadIdentityCHROMIUM
*>(cmd_data
);
4970 if (!features().chromium_path_rendering
) {
4971 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION
, "glMatrixLoadIdentityCHROMIUM",
4972 "function not available");
4973 return error::kNoError
;
4976 GLenum matrixMode
= static_cast<GLenum
>(c
.matrixMode
);
4977 if (!validators_
->matrix_mode
.IsValid(matrixMode
)) {
4978 LOCAL_SET_GL_ERROR_INVALID_ENUM("glMatrixLoadIdentityCHROMIUM", matrixMode
,
4980 return error::kNoError
;
4982 DoMatrixLoadIdentityCHROMIUM(matrixMode
);
4983 return error::kNoError
;
4986 error::Error
GLES2DecoderImpl::HandleIsPathCHROMIUM(
4987 uint32_t immediate_data_size
,
4988 const void* cmd_data
) {
4989 const gles2::cmds::IsPathCHROMIUM
& c
=
4990 *static_cast<const gles2::cmds::IsPathCHROMIUM
*>(cmd_data
);
4992 if (!features().chromium_path_rendering
) {
4993 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION
, "glIsPathCHROMIUM",
4994 "function not available");
4995 return error::kNoError
;
4998 GLuint path
= c
.path
;
4999 typedef cmds::IsPathCHROMIUM::Result Result
;
5000 Result
* result_dst
= GetSharedMemoryAs
<Result
*>(
5001 c
.result_shm_id
, c
.result_shm_offset
, sizeof(*result_dst
));
5003 return error::kOutOfBounds
;
5005 *result_dst
= DoIsPathCHROMIUM(path
);
5006 return error::kNoError
;
5009 error::Error
GLES2DecoderImpl::HandlePathStencilFuncCHROMIUM(
5010 uint32_t immediate_data_size
,
5011 const void* cmd_data
) {
5012 const gles2::cmds::PathStencilFuncCHROMIUM
& c
=
5013 *static_cast<const gles2::cmds::PathStencilFuncCHROMIUM
*>(cmd_data
);
5015 if (!features().chromium_path_rendering
) {
5016 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION
, "glPathStencilFuncCHROMIUM",
5017 "function not available");
5018 return error::kNoError
;
5021 GLenum func
= static_cast<GLenum
>(c
.func
);
5022 GLint ref
= static_cast<GLint
>(c
.ref
);
5023 GLuint mask
= static_cast<GLuint
>(c
.mask
);
5024 if (!validators_
->cmp_function
.IsValid(func
)) {
5025 LOCAL_SET_GL_ERROR_INVALID_ENUM("glPathStencilFuncCHROMIUM", func
, "func");
5026 return error::kNoError
;
5028 if (state_
.stencil_path_func
!= func
|| state_
.stencil_path_ref
!= ref
||
5029 state_
.stencil_path_mask
!= mask
) {
5030 state_
.stencil_path_func
= func
;
5031 state_
.stencil_path_ref
= ref
;
5032 state_
.stencil_path_mask
= mask
;
5033 glPathStencilFuncNV(func
, ref
, mask
);
5035 return error::kNoError
;
5038 error::Error
GLES2DecoderImpl::HandleBlendBarrierKHR(
5039 uint32_t immediate_data_size
,
5040 const void* cmd_data
) {
5041 const gles2::cmds::BlendBarrierKHR
& c
=
5042 *static_cast<const gles2::cmds::BlendBarrierKHR
*>(cmd_data
);
5044 if (!features().blend_equation_advanced
) {
5045 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION
, "glBlendBarrierKHR",
5046 "function not available");
5047 return error::kNoError
;
5050 glBlendBarrierKHR();
5051 return error::kNoError
;
5054 bool GLES2DecoderImpl::SetCapabilityState(GLenum cap
, bool enabled
) {
5057 state_
.enable_flags
.blend
= enabled
;
5058 if (state_
.enable_flags
.cached_blend
!= enabled
||
5059 state_
.ignore_cached_state
) {
5060 state_
.enable_flags
.cached_blend
= enabled
;
5065 state_
.enable_flags
.cull_face
= enabled
;
5066 if (state_
.enable_flags
.cached_cull_face
!= enabled
||
5067 state_
.ignore_cached_state
) {
5068 state_
.enable_flags
.cached_cull_face
= enabled
;
5073 state_
.enable_flags
.depth_test
= enabled
;
5074 if (state_
.enable_flags
.cached_depth_test
!= enabled
||
5075 state_
.ignore_cached_state
) {
5076 framebuffer_state_
.clear_state_dirty
= true;
5080 state_
.enable_flags
.dither
= enabled
;
5081 if (state_
.enable_flags
.cached_dither
!= enabled
||
5082 state_
.ignore_cached_state
) {
5083 state_
.enable_flags
.cached_dither
= enabled
;
5087 case GL_POLYGON_OFFSET_FILL
:
5088 state_
.enable_flags
.polygon_offset_fill
= enabled
;
5089 if (state_
.enable_flags
.cached_polygon_offset_fill
!= enabled
||
5090 state_
.ignore_cached_state
) {
5091 state_
.enable_flags
.cached_polygon_offset_fill
= enabled
;
5095 case GL_SAMPLE_ALPHA_TO_COVERAGE
:
5096 state_
.enable_flags
.sample_alpha_to_coverage
= enabled
;
5097 if (state_
.enable_flags
.cached_sample_alpha_to_coverage
!= enabled
||
5098 state_
.ignore_cached_state
) {
5099 state_
.enable_flags
.cached_sample_alpha_to_coverage
= enabled
;
5103 case GL_SAMPLE_COVERAGE
:
5104 state_
.enable_flags
.sample_coverage
= enabled
;
5105 if (state_
.enable_flags
.cached_sample_coverage
!= enabled
||
5106 state_
.ignore_cached_state
) {
5107 state_
.enable_flags
.cached_sample_coverage
= enabled
;
5111 case GL_SCISSOR_TEST
:
5112 state_
.enable_flags
.scissor_test
= enabled
;
5113 if (state_
.enable_flags
.cached_scissor_test
!= enabled
||
5114 state_
.ignore_cached_state
) {
5115 state_
.enable_flags
.cached_scissor_test
= enabled
;
5119 case GL_STENCIL_TEST
:
5120 state_
.enable_flags
.stencil_test
= enabled
;
5121 if (state_
.enable_flags
.cached_stencil_test
!= enabled
||
5122 state_
.ignore_cached_state
) {
5123 framebuffer_state_
.clear_state_dirty
= true;
5126 case GL_RASTERIZER_DISCARD
:
5127 state_
.enable_flags
.rasterizer_discard
= enabled
;
5128 if (state_
.enable_flags
.cached_rasterizer_discard
!= enabled
||
5129 state_
.ignore_cached_state
) {
5130 state_
.enable_flags
.cached_rasterizer_discard
= enabled
;
5134 case GL_PRIMITIVE_RESTART_FIXED_INDEX
:
5135 state_
.enable_flags
.primitive_restart_fixed_index
= enabled
;
5136 if (state_
.enable_flags
.cached_primitive_restart_fixed_index
!= enabled
||
5137 state_
.ignore_cached_state
) {
5138 state_
.enable_flags
.cached_primitive_restart_fixed_index
= enabled
;
5147 #endif // GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_AUTOGEN_H_