1 //
2 // Copyright 2023 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6
7 // context_private_call_gles.cpp:
8 // Helpers that set/get state that is entirely locally accessed by the context.
9
10 #include "libANGLE/context_private_call_gles_autogen.h"
11
12 #include "common/debug.h"
13 #include "libANGLE/queryconversions.h"
14 #include "libANGLE/queryutils.h"
15
16 namespace
17 {
FixedMatrixToMat4(const GLfixed * m)18 angle::Mat4 FixedMatrixToMat4(const GLfixed *m)
19 {
20 angle::Mat4 matrixAsFloat;
21 GLfloat *floatData = matrixAsFloat.data();
22
23 for (int i = 0; i < 16; i++)
24 {
25 floatData[i] = gl::ConvertFixedToFloat(m[i]);
26 }
27
28 return matrixAsFloat;
29 }
30 } // namespace
31
32 namespace gl
33 {
ContextPrivateClearColor(PrivateState * privateState,PrivateStateCache * privateStateCache,GLfloat red,GLfloat green,GLfloat blue,GLfloat alpha)34 void ContextPrivateClearColor(PrivateState *privateState,
35 PrivateStateCache *privateStateCache,
36 GLfloat red,
37 GLfloat green,
38 GLfloat blue,
39 GLfloat alpha)
40 {
41 privateState->setColorClearValue(red, green, blue, alpha);
42 }
43
ContextPrivateClearDepthf(PrivateState * privateState,PrivateStateCache * privateStateCache,GLfloat depth)44 void ContextPrivateClearDepthf(PrivateState *privateState,
45 PrivateStateCache *privateStateCache,
46 GLfloat depth)
47 {
48 privateState->setDepthClearValue(clamp01(depth));
49 }
50
ContextPrivateClearStencil(PrivateState * privateState,PrivateStateCache * privateStateCache,GLint stencil)51 void ContextPrivateClearStencil(PrivateState *privateState,
52 PrivateStateCache *privateStateCache,
53 GLint stencil)
54 {
55 privateState->setStencilClearValue(stencil);
56 }
57
ContextPrivateClearColorx(PrivateState * privateState,PrivateStateCache * privateStateCache,GLfixed red,GLfixed green,GLfixed blue,GLfixed alpha)58 void ContextPrivateClearColorx(PrivateState *privateState,
59 PrivateStateCache *privateStateCache,
60 GLfixed red,
61 GLfixed green,
62 GLfixed blue,
63 GLfixed alpha)
64 {
65 ContextPrivateClearColor(privateState, privateStateCache, ConvertFixedToFloat(red),
66 ConvertFixedToFloat(green), ConvertFixedToFloat(blue),
67 ConvertFixedToFloat(alpha));
68 }
69
ContextPrivateClearDepthx(PrivateState * privateState,PrivateStateCache * privateStateCache,GLfixed depth)70 void ContextPrivateClearDepthx(PrivateState *privateState,
71 PrivateStateCache *privateStateCache,
72 GLfixed depth)
73 {
74 ContextPrivateClearDepthf(privateState, privateStateCache, ConvertFixedToFloat(depth));
75 }
76
ContextPrivateColorMask(PrivateState * privateState,PrivateStateCache * privateStateCache,GLboolean red,GLboolean green,GLboolean blue,GLboolean alpha)77 void ContextPrivateColorMask(PrivateState *privateState,
78 PrivateStateCache *privateStateCache,
79 GLboolean red,
80 GLboolean green,
81 GLboolean blue,
82 GLboolean alpha)
83 {
84 privateState->setColorMask(ConvertToBool(red), ConvertToBool(green), ConvertToBool(blue),
85 ConvertToBool(alpha));
86 privateStateCache->onColorMaskChange();
87 }
88
ContextPrivateColorMaski(PrivateState * privateState,PrivateStateCache * privateStateCache,GLuint index,GLboolean r,GLboolean g,GLboolean b,GLboolean a)89 void ContextPrivateColorMaski(PrivateState *privateState,
90 PrivateStateCache *privateStateCache,
91 GLuint index,
92 GLboolean r,
93 GLboolean g,
94 GLboolean b,
95 GLboolean a)
96 {
97 privateState->setColorMaskIndexed(ConvertToBool(r), ConvertToBool(g), ConvertToBool(b),
98 ConvertToBool(a), index);
99 privateStateCache->onColorMaskChange();
100 }
101
ContextPrivateDepthMask(PrivateState * privateState,PrivateStateCache * privateStateCache,GLboolean flag)102 void ContextPrivateDepthMask(PrivateState *privateState,
103 PrivateStateCache *privateStateCache,
104 GLboolean flag)
105 {
106 privateState->setDepthMask(ConvertToBool(flag));
107 }
108
ContextPrivateDisable(PrivateState * privateState,PrivateStateCache * privateStateCache,GLenum cap)109 void ContextPrivateDisable(PrivateState *privateState,
110 PrivateStateCache *privateStateCache,
111 GLenum cap)
112 {
113 privateState->setEnableFeature(cap, false);
114 privateStateCache->onCapChange();
115 }
116
ContextPrivateDisablei(PrivateState * privateState,PrivateStateCache * privateStateCache,GLenum target,GLuint index)117 void ContextPrivateDisablei(PrivateState *privateState,
118 PrivateStateCache *privateStateCache,
119 GLenum target,
120 GLuint index)
121 {
122 privateState->setEnableFeatureIndexed(target, false, index);
123 privateStateCache->onCapChange();
124 }
125
ContextPrivateEnable(PrivateState * privateState,PrivateStateCache * privateStateCache,GLenum cap)126 void ContextPrivateEnable(PrivateState *privateState,
127 PrivateStateCache *privateStateCache,
128 GLenum cap)
129 {
130 privateState->setEnableFeature(cap, true);
131 privateStateCache->onCapChange();
132 }
133
ContextPrivateEnablei(PrivateState * privateState,PrivateStateCache * privateStateCache,GLenum target,GLuint index)134 void ContextPrivateEnablei(PrivateState *privateState,
135 PrivateStateCache *privateStateCache,
136 GLenum target,
137 GLuint index)
138 {
139 privateState->setEnableFeatureIndexed(target, true, index);
140 privateStateCache->onCapChange();
141 }
142
ContextPrivateActiveTexture(PrivateState * privateState,PrivateStateCache * privateStateCache,GLenum texture)143 void ContextPrivateActiveTexture(PrivateState *privateState,
144 PrivateStateCache *privateStateCache,
145 GLenum texture)
146 {
147 privateState->setActiveSampler(texture - GL_TEXTURE0);
148 }
149
ContextPrivateCullFace(PrivateState * privateState,PrivateStateCache * privateStateCache,CullFaceMode mode)150 void ContextPrivateCullFace(PrivateState *privateState,
151 PrivateStateCache *privateStateCache,
152 CullFaceMode mode)
153 {
154 privateState->setCullMode(mode);
155 }
156
ContextPrivateDepthFunc(PrivateState * privateState,PrivateStateCache * privateStateCache,GLenum func)157 void ContextPrivateDepthFunc(PrivateState *privateState,
158 PrivateStateCache *privateStateCache,
159 GLenum func)
160 {
161 privateState->setDepthFunc(func);
162 }
163
ContextPrivateDepthRangef(PrivateState * privateState,PrivateStateCache * privateStateCache,GLfloat zNear,GLfloat zFar)164 void ContextPrivateDepthRangef(PrivateState *privateState,
165 PrivateStateCache *privateStateCache,
166 GLfloat zNear,
167 GLfloat zFar)
168 {
169 privateState->setDepthRange(clamp01(zNear), clamp01(zFar));
170 }
171
ContextPrivateDepthRangex(PrivateState * privateState,PrivateStateCache * privateStateCache,GLfixed zNear,GLfixed zFar)172 void ContextPrivateDepthRangex(PrivateState *privateState,
173 PrivateStateCache *privateStateCache,
174 GLfixed zNear,
175 GLfixed zFar)
176 {
177 ContextPrivateDepthRangef(privateState, privateStateCache, ConvertFixedToFloat(zNear),
178 ConvertFixedToFloat(zFar));
179 }
180
ContextPrivateFrontFace(PrivateState * privateState,PrivateStateCache * privateStateCache,GLenum mode)181 void ContextPrivateFrontFace(PrivateState *privateState,
182 PrivateStateCache *privateStateCache,
183 GLenum mode)
184 {
185 privateState->setFrontFace(mode);
186 }
187
ContextPrivateLineWidth(PrivateState * privateState,PrivateStateCache * privateStateCache,GLfloat width)188 void ContextPrivateLineWidth(PrivateState *privateState,
189 PrivateStateCache *privateStateCache,
190 GLfloat width)
191 {
192 privateState->setLineWidth(width);
193 }
194
ContextPrivateLineWidthx(PrivateState * privateState,PrivateStateCache * privateStateCache,GLfixed width)195 void ContextPrivateLineWidthx(PrivateState *privateState,
196 PrivateStateCache *privateStateCache,
197 GLfixed width)
198 {
199 ContextPrivateLineWidth(privateState, privateStateCache, ConvertFixedToFloat(width));
200 }
201
ContextPrivatePolygonOffset(PrivateState * privateState,PrivateStateCache * privateStateCache,GLfloat factor,GLfloat units)202 void ContextPrivatePolygonOffset(PrivateState *privateState,
203 PrivateStateCache *privateStateCache,
204 GLfloat factor,
205 GLfloat units)
206 {
207 privateState->setPolygonOffsetParams(factor, units, 0.0f);
208 }
209
ContextPrivatePolygonOffsetClamp(PrivateState * privateState,PrivateStateCache * privateStateCache,GLfloat factor,GLfloat units,GLfloat clamp)210 void ContextPrivatePolygonOffsetClamp(PrivateState *privateState,
211 PrivateStateCache *privateStateCache,
212 GLfloat factor,
213 GLfloat units,
214 GLfloat clamp)
215 {
216 privateState->setPolygonOffsetParams(factor, units, clamp);
217 }
218
ContextPrivatePolygonOffsetx(PrivateState * privateState,PrivateStateCache * privateStateCache,GLfixed factor,GLfixed units)219 void ContextPrivatePolygonOffsetx(PrivateState *privateState,
220 PrivateStateCache *privateStateCache,
221 GLfixed factor,
222 GLfixed units)
223 {
224 ContextPrivatePolygonOffsetClamp(privateState, privateStateCache, ConvertFixedToFloat(factor),
225 ConvertFixedToFloat(units), 0.0f);
226 }
227
ContextPrivateSampleCoverage(PrivateState * privateState,PrivateStateCache * privateStateCache,GLfloat value,GLboolean invert)228 void ContextPrivateSampleCoverage(PrivateState *privateState,
229 PrivateStateCache *privateStateCache,
230 GLfloat value,
231 GLboolean invert)
232 {
233 privateState->setSampleCoverageParams(clamp01(value), ConvertToBool(invert));
234 }
235
ContextPrivateSampleCoveragex(PrivateState * privateState,PrivateStateCache * privateStateCache,GLclampx value,GLboolean invert)236 void ContextPrivateSampleCoveragex(PrivateState *privateState,
237 PrivateStateCache *privateStateCache,
238 GLclampx value,
239 GLboolean invert)
240 {
241 ContextPrivateSampleCoverage(privateState, privateStateCache, ConvertFixedToFloat(value),
242 invert);
243 }
244
ContextPrivateScissor(PrivateState * privateState,PrivateStateCache * privateStateCache,GLint x,GLint y,GLsizei width,GLsizei height)245 void ContextPrivateScissor(PrivateState *privateState,
246 PrivateStateCache *privateStateCache,
247 GLint x,
248 GLint y,
249 GLsizei width,
250 GLsizei height)
251 {
252 privateState->setScissorParams(x, y, width, height);
253 }
254
ContextPrivateVertexAttrib1f(PrivateState * privateState,PrivateStateCache * privateStateCache,GLuint index,GLfloat x)255 void ContextPrivateVertexAttrib1f(PrivateState *privateState,
256 PrivateStateCache *privateStateCache,
257 GLuint index,
258 GLfloat x)
259 {
260 GLfloat vals[4] = {x, 0, 0, 1};
261 privateState->setVertexAttribf(index, vals);
262 privateStateCache->onDefaultVertexAttributeChange();
263 }
264
ContextPrivateVertexAttrib1fv(PrivateState * privateState,PrivateStateCache * privateStateCache,GLuint index,const GLfloat * values)265 void ContextPrivateVertexAttrib1fv(PrivateState *privateState,
266 PrivateStateCache *privateStateCache,
267 GLuint index,
268 const GLfloat *values)
269 {
270 GLfloat vals[4] = {values[0], 0, 0, 1};
271 privateState->setVertexAttribf(index, vals);
272 privateStateCache->onDefaultVertexAttributeChange();
273 }
274
ContextPrivateVertexAttrib2f(PrivateState * privateState,PrivateStateCache * privateStateCache,GLuint index,GLfloat x,GLfloat y)275 void ContextPrivateVertexAttrib2f(PrivateState *privateState,
276 PrivateStateCache *privateStateCache,
277 GLuint index,
278 GLfloat x,
279 GLfloat y)
280 {
281 GLfloat vals[4] = {x, y, 0, 1};
282 privateState->setVertexAttribf(index, vals);
283 privateStateCache->onDefaultVertexAttributeChange();
284 }
285
ContextPrivateVertexAttrib2fv(PrivateState * privateState,PrivateStateCache * privateStateCache,GLuint index,const GLfloat * values)286 void ContextPrivateVertexAttrib2fv(PrivateState *privateState,
287 PrivateStateCache *privateStateCache,
288 GLuint index,
289 const GLfloat *values)
290 {
291 GLfloat vals[4] = {values[0], values[1], 0, 1};
292 privateState->setVertexAttribf(index, vals);
293 privateStateCache->onDefaultVertexAttributeChange();
294 }
295
ContextPrivateVertexAttrib3f(PrivateState * privateState,PrivateStateCache * privateStateCache,GLuint index,GLfloat x,GLfloat y,GLfloat z)296 void ContextPrivateVertexAttrib3f(PrivateState *privateState,
297 PrivateStateCache *privateStateCache,
298 GLuint index,
299 GLfloat x,
300 GLfloat y,
301 GLfloat z)
302 {
303 GLfloat vals[4] = {x, y, z, 1};
304 privateState->setVertexAttribf(index, vals);
305 privateStateCache->onDefaultVertexAttributeChange();
306 }
307
ContextPrivateVertexAttrib3fv(PrivateState * privateState,PrivateStateCache * privateStateCache,GLuint index,const GLfloat * values)308 void ContextPrivateVertexAttrib3fv(PrivateState *privateState,
309 PrivateStateCache *privateStateCache,
310 GLuint index,
311 const GLfloat *values)
312 {
313 GLfloat vals[4] = {values[0], values[1], values[2], 1};
314 privateState->setVertexAttribf(index, vals);
315 privateStateCache->onDefaultVertexAttributeChange();
316 }
317
ContextPrivateVertexAttrib4f(PrivateState * privateState,PrivateStateCache * privateStateCache,GLuint index,GLfloat x,GLfloat y,GLfloat z,GLfloat w)318 void ContextPrivateVertexAttrib4f(PrivateState *privateState,
319 PrivateStateCache *privateStateCache,
320 GLuint index,
321 GLfloat x,
322 GLfloat y,
323 GLfloat z,
324 GLfloat w)
325 {
326 GLfloat vals[4] = {x, y, z, w};
327 privateState->setVertexAttribf(index, vals);
328 privateStateCache->onDefaultVertexAttributeChange();
329 }
330
ContextPrivateVertexAttrib4fv(PrivateState * privateState,PrivateStateCache * privateStateCache,GLuint index,const GLfloat * values)331 void ContextPrivateVertexAttrib4fv(PrivateState *privateState,
332 PrivateStateCache *privateStateCache,
333 GLuint index,
334 const GLfloat *values)
335 {
336 privateState->setVertexAttribf(index, values);
337 privateStateCache->onDefaultVertexAttributeChange();
338 }
339
ContextPrivateVertexAttribI4i(PrivateState * privateState,PrivateStateCache * privateStateCache,GLuint index,GLint x,GLint y,GLint z,GLint w)340 void ContextPrivateVertexAttribI4i(PrivateState *privateState,
341 PrivateStateCache *privateStateCache,
342 GLuint index,
343 GLint x,
344 GLint y,
345 GLint z,
346 GLint w)
347 {
348 GLint vals[4] = {x, y, z, w};
349 privateState->setVertexAttribi(index, vals);
350 privateStateCache->onDefaultVertexAttributeChange();
351 }
352
ContextPrivateVertexAttribI4iv(PrivateState * privateState,PrivateStateCache * privateStateCache,GLuint index,const GLint * values)353 void ContextPrivateVertexAttribI4iv(PrivateState *privateState,
354 PrivateStateCache *privateStateCache,
355 GLuint index,
356 const GLint *values)
357 {
358 privateState->setVertexAttribi(index, values);
359 privateStateCache->onDefaultVertexAttributeChange();
360 }
361
ContextPrivateVertexAttribI4ui(PrivateState * privateState,PrivateStateCache * privateStateCache,GLuint index,GLuint x,GLuint y,GLuint z,GLuint w)362 void ContextPrivateVertexAttribI4ui(PrivateState *privateState,
363 PrivateStateCache *privateStateCache,
364 GLuint index,
365 GLuint x,
366 GLuint y,
367 GLuint z,
368 GLuint w)
369 {
370 GLuint vals[4] = {x, y, z, w};
371 privateState->setVertexAttribu(index, vals);
372 privateStateCache->onDefaultVertexAttributeChange();
373 }
374
ContextPrivateVertexAttribI4uiv(PrivateState * privateState,PrivateStateCache * privateStateCache,GLuint index,const GLuint * values)375 void ContextPrivateVertexAttribI4uiv(PrivateState *privateState,
376 PrivateStateCache *privateStateCache,
377 GLuint index,
378 const GLuint *values)
379 {
380 privateState->setVertexAttribu(index, values);
381 privateStateCache->onDefaultVertexAttributeChange();
382 }
383
ContextPrivateViewport(PrivateState * privateState,PrivateStateCache * privateStateCache,GLint x,GLint y,GLsizei width,GLsizei height)384 void ContextPrivateViewport(PrivateState *privateState,
385 PrivateStateCache *privateStateCache,
386 GLint x,
387 GLint y,
388 GLsizei width,
389 GLsizei height)
390 {
391 privateState->setViewportParams(x, y, width, height);
392 }
393
ContextPrivateSampleMaski(PrivateState * privateState,PrivateStateCache * privateStateCache,GLuint maskNumber,GLbitfield mask)394 void ContextPrivateSampleMaski(PrivateState *privateState,
395 PrivateStateCache *privateStateCache,
396 GLuint maskNumber,
397 GLbitfield mask)
398 {
399 privateState->setSampleMaskParams(maskNumber, mask);
400 }
401
ContextPrivateMinSampleShading(PrivateState * privateState,PrivateStateCache * privateStateCache,GLfloat value)402 void ContextPrivateMinSampleShading(PrivateState *privateState,
403 PrivateStateCache *privateStateCache,
404 GLfloat value)
405 {
406 privateState->setMinSampleShading(value);
407 }
408
ContextPrivatePrimitiveBoundingBox(PrivateState * privateState,PrivateStateCache * privateStateCache,GLfloat minX,GLfloat minY,GLfloat minZ,GLfloat minW,GLfloat maxX,GLfloat maxY,GLfloat maxZ,GLfloat maxW)409 void ContextPrivatePrimitiveBoundingBox(PrivateState *privateState,
410 PrivateStateCache *privateStateCache,
411 GLfloat minX,
412 GLfloat minY,
413 GLfloat minZ,
414 GLfloat minW,
415 GLfloat maxX,
416 GLfloat maxY,
417 GLfloat maxZ,
418 GLfloat maxW)
419 {
420 privateState->setBoundingBox(minX, minY, minZ, minW, maxX, maxY, maxZ, maxW);
421 }
422
ContextPrivateLogicOp(PrivateState * privateState,PrivateStateCache * privateStateCache,LogicalOperation opcode)423 void ContextPrivateLogicOp(PrivateState *privateState,
424 PrivateStateCache *privateStateCache,
425 LogicalOperation opcode)
426 {
427 privateState->getMutableGLES1State()->setLogicOp(opcode);
428 }
429
ContextPrivateLogicOpANGLE(PrivateState * privateState,PrivateStateCache * privateStateCache,LogicalOperation opcode)430 void ContextPrivateLogicOpANGLE(PrivateState *privateState,
431 PrivateStateCache *privateStateCache,
432 LogicalOperation opcode)
433 {
434 privateState->setLogicOp(opcode);
435 }
436
ContextPrivatePolygonMode(PrivateState * privateState,PrivateStateCache * privateStateCache,GLenum face,PolygonMode mode)437 void ContextPrivatePolygonMode(PrivateState *privateState,
438 PrivateStateCache *privateStateCache,
439 GLenum face,
440 PolygonMode mode)
441 {
442 ASSERT(face == GL_FRONT_AND_BACK);
443 privateState->setPolygonMode(mode);
444 }
445
ContextPrivatePolygonModeNV(PrivateState * privateState,PrivateStateCache * privateStateCache,GLenum face,PolygonMode mode)446 void ContextPrivatePolygonModeNV(PrivateState *privateState,
447 PrivateStateCache *privateStateCache,
448 GLenum face,
449 PolygonMode mode)
450 {
451 ContextPrivatePolygonMode(privateState, privateStateCache, face, mode);
452 }
453
ContextPrivateProvokingVertex(PrivateState * privateState,PrivateStateCache * privateStateCache,ProvokingVertexConvention provokeMode)454 void ContextPrivateProvokingVertex(PrivateState *privateState,
455 PrivateStateCache *privateStateCache,
456 ProvokingVertexConvention provokeMode)
457 {
458 privateState->setProvokingVertex(provokeMode);
459 }
460
ContextPrivateCoverageModulation(PrivateState * privateState,PrivateStateCache * privateStateCache,GLenum components)461 void ContextPrivateCoverageModulation(PrivateState *privateState,
462 PrivateStateCache *privateStateCache,
463 GLenum components)
464 {
465 privateState->setCoverageModulation(components);
466 }
467
ContextPrivateClipControl(PrivateState * privateState,PrivateStateCache * privateStateCache,ClipOrigin origin,ClipDepthMode depth)468 void ContextPrivateClipControl(PrivateState *privateState,
469 PrivateStateCache *privateStateCache,
470 ClipOrigin origin,
471 ClipDepthMode depth)
472 {
473 privateState->setClipControl(origin, depth);
474 }
475
ContextPrivateShadingRate(PrivateState * privateState,PrivateStateCache * privateStateCache,GLenum rate)476 void ContextPrivateShadingRate(PrivateState *privateState,
477 PrivateStateCache *privateStateCache,
478 GLenum rate)
479 {
480 privateState->setShadingRate(rate);
481 }
482
ContextPrivateBlendColor(PrivateState * privateState,PrivateStateCache * privateStateCache,GLfloat red,GLfloat green,GLfloat blue,GLfloat alpha)483 void ContextPrivateBlendColor(PrivateState *privateState,
484 PrivateStateCache *privateStateCache,
485 GLfloat red,
486 GLfloat green,
487 GLfloat blue,
488 GLfloat alpha)
489 {
490 privateState->setBlendColor(red, green, blue, alpha);
491 }
492
ContextPrivateBlendEquation(PrivateState * privateState,PrivateStateCache * privateStateCache,GLenum mode)493 void ContextPrivateBlendEquation(PrivateState *privateState,
494 PrivateStateCache *privateStateCache,
495 GLenum mode)
496 {
497 privateState->setBlendEquation(mode, mode);
498 privateStateCache->onBlendEquationChange();
499 }
500
ContextPrivateBlendEquationi(PrivateState * privateState,PrivateStateCache * privateStateCache,GLuint buf,GLenum mode)501 void ContextPrivateBlendEquationi(PrivateState *privateState,
502 PrivateStateCache *privateStateCache,
503 GLuint buf,
504 GLenum mode)
505 {
506 privateState->setBlendEquationIndexed(mode, mode, buf);
507 privateStateCache->onBlendEquationChange();
508 }
509
ContextPrivateBlendEquationSeparate(PrivateState * privateState,PrivateStateCache * privateStateCache,GLenum modeRGB,GLenum modeAlpha)510 void ContextPrivateBlendEquationSeparate(PrivateState *privateState,
511 PrivateStateCache *privateStateCache,
512 GLenum modeRGB,
513 GLenum modeAlpha)
514 {
515 privateState->setBlendEquation(modeRGB, modeAlpha);
516 privateStateCache->onBlendEquationChange();
517 }
518
ContextPrivateBlendEquationSeparatei(PrivateState * privateState,PrivateStateCache * privateStateCache,GLuint buf,GLenum modeRGB,GLenum modeAlpha)519 void ContextPrivateBlendEquationSeparatei(PrivateState *privateState,
520 PrivateStateCache *privateStateCache,
521 GLuint buf,
522 GLenum modeRGB,
523 GLenum modeAlpha)
524 {
525 privateState->setBlendEquationIndexed(modeRGB, modeAlpha, buf);
526 privateStateCache->onBlendEquationChange();
527 }
528
ContextPrivateBlendFunc(PrivateState * privateState,PrivateStateCache * privateStateCache,GLenum sfactor,GLenum dfactor)529 void ContextPrivateBlendFunc(PrivateState *privateState,
530 PrivateStateCache *privateStateCache,
531 GLenum sfactor,
532 GLenum dfactor)
533 {
534 privateState->setBlendFactors(sfactor, dfactor, sfactor, dfactor);
535 }
536
ContextPrivateBlendFunci(PrivateState * privateState,PrivateStateCache * privateStateCache,GLuint buf,GLenum src,GLenum dst)537 void ContextPrivateBlendFunci(PrivateState *privateState,
538 PrivateStateCache *privateStateCache,
539 GLuint buf,
540 GLenum src,
541 GLenum dst)
542 {
543 privateState->setBlendFactorsIndexed(src, dst, src, dst, buf);
544 if (privateState->noSimultaneousConstantColorAndAlphaBlendFunc())
545 {
546 privateStateCache->onBlendFuncIndexedChange();
547 }
548 }
549
ContextPrivateBlendFuncSeparate(PrivateState * privateState,PrivateStateCache * privateStateCache,GLenum srcRGB,GLenum dstRGB,GLenum srcAlpha,GLenum dstAlpha)550 void ContextPrivateBlendFuncSeparate(PrivateState *privateState,
551 PrivateStateCache *privateStateCache,
552 GLenum srcRGB,
553 GLenum dstRGB,
554 GLenum srcAlpha,
555 GLenum dstAlpha)
556 {
557 privateState->setBlendFactors(srcRGB, dstRGB, srcAlpha, dstAlpha);
558 }
559
ContextPrivateBlendFuncSeparatei(PrivateState * privateState,PrivateStateCache * privateStateCache,GLuint buf,GLenum srcRGB,GLenum dstRGB,GLenum srcAlpha,GLenum dstAlpha)560 void ContextPrivateBlendFuncSeparatei(PrivateState *privateState,
561 PrivateStateCache *privateStateCache,
562 GLuint buf,
563 GLenum srcRGB,
564 GLenum dstRGB,
565 GLenum srcAlpha,
566 GLenum dstAlpha)
567 {
568 privateState->setBlendFactorsIndexed(srcRGB, dstRGB, srcAlpha, dstAlpha, buf);
569 if (privateState->noSimultaneousConstantColorAndAlphaBlendFunc())
570 {
571 privateStateCache->onBlendFuncIndexedChange();
572 }
573 }
574
ContextPrivateStencilFunc(PrivateState * privateState,PrivateStateCache * privateStateCache,GLenum func,GLint ref,GLuint mask)575 void ContextPrivateStencilFunc(PrivateState *privateState,
576 PrivateStateCache *privateStateCache,
577 GLenum func,
578 GLint ref,
579 GLuint mask)
580 {
581 ContextPrivateStencilFuncSeparate(privateState, privateStateCache, GL_FRONT_AND_BACK, func, ref,
582 mask);
583 }
584
ContextPrivateStencilFuncSeparate(PrivateState * privateState,PrivateStateCache * privateStateCache,GLenum face,GLenum func,GLint ref,GLuint mask)585 void ContextPrivateStencilFuncSeparate(PrivateState *privateState,
586 PrivateStateCache *privateStateCache,
587 GLenum face,
588 GLenum func,
589 GLint ref,
590 GLuint mask)
591 {
592 GLint clampedRef = gl::clamp(ref, 0, std::numeric_limits<uint8_t>::max());
593 if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
594 {
595 privateState->setStencilParams(func, clampedRef, mask);
596 }
597
598 if (face == GL_BACK || face == GL_FRONT_AND_BACK)
599 {
600 privateState->setStencilBackParams(func, clampedRef, mask);
601 }
602
603 privateStateCache->onStencilStateChange();
604 }
605
ContextPrivateStencilMask(PrivateState * privateState,PrivateStateCache * privateStateCache,GLuint mask)606 void ContextPrivateStencilMask(PrivateState *privateState,
607 PrivateStateCache *privateStateCache,
608 GLuint mask)
609 {
610 ContextPrivateStencilMaskSeparate(privateState, privateStateCache, GL_FRONT_AND_BACK, mask);
611 }
612
ContextPrivateStencilMaskSeparate(PrivateState * privateState,PrivateStateCache * privateStateCache,GLenum face,GLuint mask)613 void ContextPrivateStencilMaskSeparate(PrivateState *privateState,
614 PrivateStateCache *privateStateCache,
615 GLenum face,
616 GLuint mask)
617 {
618 if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
619 {
620 privateState->setStencilWritemask(mask);
621 }
622
623 if (face == GL_BACK || face == GL_FRONT_AND_BACK)
624 {
625 privateState->setStencilBackWritemask(mask);
626 }
627
628 privateStateCache->onStencilStateChange();
629 }
630
ContextPrivateStencilOp(PrivateState * privateState,PrivateStateCache * privateStateCache,GLenum fail,GLenum zfail,GLenum zpass)631 void ContextPrivateStencilOp(PrivateState *privateState,
632 PrivateStateCache *privateStateCache,
633 GLenum fail,
634 GLenum zfail,
635 GLenum zpass)
636 {
637 ContextPrivateStencilOpSeparate(privateState, privateStateCache, GL_FRONT_AND_BACK, fail, zfail,
638 zpass);
639 }
640
ContextPrivateStencilOpSeparate(PrivateState * privateState,PrivateStateCache * privateStateCache,GLenum face,GLenum fail,GLenum zfail,GLenum zpass)641 void ContextPrivateStencilOpSeparate(PrivateState *privateState,
642 PrivateStateCache *privateStateCache,
643 GLenum face,
644 GLenum fail,
645 GLenum zfail,
646 GLenum zpass)
647 {
648 if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
649 {
650 privateState->setStencilOperations(fail, zfail, zpass);
651 }
652
653 if (face == GL_BACK || face == GL_FRONT_AND_BACK)
654 {
655 privateState->setStencilBackOperations(fail, zfail, zpass);
656 }
657 }
658
ContextPrivatePixelStorei(PrivateState * privateState,PrivateStateCache * privateStateCache,GLenum pname,GLint param)659 void ContextPrivatePixelStorei(PrivateState *privateState,
660 PrivateStateCache *privateStateCache,
661 GLenum pname,
662 GLint param)
663 {
664 switch (pname)
665 {
666 case GL_UNPACK_ALIGNMENT:
667 privateState->setUnpackAlignment(param);
668 break;
669
670 case GL_PACK_ALIGNMENT:
671 privateState->setPackAlignment(param);
672 break;
673
674 case GL_PACK_REVERSE_ROW_ORDER_ANGLE:
675 privateState->setPackReverseRowOrder(param != 0);
676 break;
677
678 case GL_UNPACK_ROW_LENGTH:
679 ASSERT(privateState->getClientMajorVersion() >= 3 ||
680 privateState->getExtensions().unpackSubimageEXT);
681 privateState->setUnpackRowLength(param);
682 break;
683
684 case GL_UNPACK_IMAGE_HEIGHT:
685 ASSERT(privateState->getClientMajorVersion() >= 3);
686 privateState->setUnpackImageHeight(param);
687 break;
688
689 case GL_UNPACK_SKIP_IMAGES:
690 ASSERT(privateState->getClientMajorVersion() >= 3);
691 privateState->setUnpackSkipImages(param);
692 break;
693
694 case GL_UNPACK_SKIP_ROWS:
695 ASSERT((privateState->getClientMajorVersion() >= 3) ||
696 privateState->getExtensions().unpackSubimageEXT);
697 privateState->setUnpackSkipRows(param);
698 break;
699
700 case GL_UNPACK_SKIP_PIXELS:
701 ASSERT((privateState->getClientMajorVersion() >= 3) ||
702 privateState->getExtensions().unpackSubimageEXT);
703 privateState->setUnpackSkipPixels(param);
704 break;
705
706 case GL_PACK_ROW_LENGTH:
707 ASSERT((privateState->getClientMajorVersion() >= 3) ||
708 privateState->getExtensions().packSubimageNV);
709 privateState->setPackRowLength(param);
710 break;
711
712 case GL_PACK_SKIP_ROWS:
713 ASSERT((privateState->getClientMajorVersion() >= 3) ||
714 privateState->getExtensions().packSubimageNV);
715 privateState->setPackSkipRows(param);
716 break;
717
718 case GL_PACK_SKIP_PIXELS:
719 ASSERT((privateState->getClientMajorVersion() >= 3) ||
720 privateState->getExtensions().packSubimageNV);
721 privateState->setPackSkipPixels(param);
722 break;
723
724 default:
725 UNREACHABLE();
726 return;
727 }
728 }
729
ContextPrivateHint(PrivateState * privateState,PrivateStateCache * privateStateCache,GLenum target,GLenum mode)730 void ContextPrivateHint(PrivateState *privateState,
731 PrivateStateCache *privateStateCache,
732 GLenum target,
733 GLenum mode)
734 {
735 switch (target)
736 {
737 case GL_GENERATE_MIPMAP_HINT:
738 privateState->setGenerateMipmapHint(mode);
739 break;
740
741 case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES:
742 privateState->setFragmentShaderDerivativeHint(mode);
743 break;
744
745 case GL_PERSPECTIVE_CORRECTION_HINT:
746 case GL_POINT_SMOOTH_HINT:
747 case GL_LINE_SMOOTH_HINT:
748 case GL_FOG_HINT:
749 privateState->getMutableGLES1State()->setHint(target, mode);
750 break;
751 case GL_TEXTURE_FILTERING_HINT_CHROMIUM:
752 privateState->setTextureFilteringHint(mode);
753 break;
754 default:
755 UNREACHABLE();
756 return;
757 }
758 }
759
ContextPrivateIsEnabled(PrivateState * privateState,PrivateStateCache * privateStateCache,GLenum cap)760 GLboolean ContextPrivateIsEnabled(PrivateState *privateState,
761 PrivateStateCache *privateStateCache,
762 GLenum cap)
763 {
764 return privateState->getEnableFeature(cap);
765 }
766
ContextPrivateIsEnabledi(PrivateState * privateState,PrivateStateCache * privateStateCache,GLenum target,GLuint index)767 GLboolean ContextPrivateIsEnabledi(PrivateState *privateState,
768 PrivateStateCache *privateStateCache,
769 GLenum target,
770 GLuint index)
771 {
772 return privateState->getEnableFeatureIndexed(target, index);
773 }
774
ContextPrivatePatchParameteri(PrivateState * privateState,PrivateStateCache * privateStateCache,GLenum pname,GLint value)775 void ContextPrivatePatchParameteri(PrivateState *privateState,
776 PrivateStateCache *privateStateCache,
777 GLenum pname,
778 GLint value)
779 {
780 switch (pname)
781 {
782 case GL_PATCH_VERTICES:
783 privateState->setPatchVertices(value);
784 break;
785 default:
786 break;
787 }
788 }
789
ContextPrivateAlphaFunc(PrivateState * privateState,PrivateStateCache * privateStateCache,AlphaTestFunc func,GLfloat ref)790 void ContextPrivateAlphaFunc(PrivateState *privateState,
791 PrivateStateCache *privateStateCache,
792 AlphaTestFunc func,
793 GLfloat ref)
794 {
795 privateState->getMutableGLES1State()->setAlphaTestParameters(func, ref);
796 }
797
ContextPrivateAlphaFuncx(PrivateState * privateState,PrivateStateCache * privateStateCache,AlphaTestFunc func,GLfixed ref)798 void ContextPrivateAlphaFuncx(PrivateState *privateState,
799 PrivateStateCache *privateStateCache,
800 AlphaTestFunc func,
801 GLfixed ref)
802 {
803 ContextPrivateAlphaFunc(privateState, privateStateCache, func, ConvertFixedToFloat(ref));
804 }
805
ContextPrivateClipPlanef(PrivateState * privateState,PrivateStateCache * privateStateCache,GLenum p,const GLfloat * eqn)806 void ContextPrivateClipPlanef(PrivateState *privateState,
807 PrivateStateCache *privateStateCache,
808 GLenum p,
809 const GLfloat *eqn)
810 {
811 privateState->getMutableGLES1State()->setClipPlane(p - GL_CLIP_PLANE0, eqn);
812 }
813
ContextPrivateClipPlanex(PrivateState * privateState,PrivateStateCache * privateStateCache,GLenum plane,const GLfixed * equation)814 void ContextPrivateClipPlanex(PrivateState *privateState,
815 PrivateStateCache *privateStateCache,
816 GLenum plane,
817 const GLfixed *equation)
818 {
819 const GLfloat equationf[4] = {
820 ConvertFixedToFloat(equation[0]),
821 ConvertFixedToFloat(equation[1]),
822 ConvertFixedToFloat(equation[2]),
823 ConvertFixedToFloat(equation[3]),
824 };
825
826 ContextPrivateClipPlanef(privateState, privateStateCache, plane, equationf);
827 }
828
ContextPrivateColor4f(PrivateState * privateState,PrivateStateCache * privateStateCache,GLfloat red,GLfloat green,GLfloat blue,GLfloat alpha)829 void ContextPrivateColor4f(PrivateState *privateState,
830 PrivateStateCache *privateStateCache,
831 GLfloat red,
832 GLfloat green,
833 GLfloat blue,
834 GLfloat alpha)
835 {
836 privateState->getMutableGLES1State()->setCurrentColor({red, green, blue, alpha});
837 }
838
ContextPrivateColor4ub(PrivateState * privateState,PrivateStateCache * privateStateCache,GLubyte red,GLubyte green,GLubyte blue,GLubyte alpha)839 void ContextPrivateColor4ub(PrivateState *privateState,
840 PrivateStateCache *privateStateCache,
841 GLubyte red,
842 GLubyte green,
843 GLubyte blue,
844 GLubyte alpha)
845 {
846 ContextPrivateColor4f(privateState, privateStateCache, normalizedToFloat<uint8_t>(red),
847 normalizedToFloat<uint8_t>(green), normalizedToFloat<uint8_t>(blue),
848 normalizedToFloat<uint8_t>(alpha));
849 }
850
ContextPrivateColor4x(PrivateState * privateState,PrivateStateCache * privateStateCache,GLfixed red,GLfixed green,GLfixed blue,GLfixed alpha)851 void ContextPrivateColor4x(PrivateState *privateState,
852 PrivateStateCache *privateStateCache,
853 GLfixed red,
854 GLfixed green,
855 GLfixed blue,
856 GLfixed alpha)
857 {
858 ContextPrivateColor4f(privateState, privateStateCache, ConvertFixedToFloat(red),
859 ConvertFixedToFloat(green), ConvertFixedToFloat(blue),
860 ConvertFixedToFloat(alpha));
861 }
862
ContextPrivateFogf(PrivateState * privateState,PrivateStateCache * privateStateCache,GLenum pname,GLfloat param)863 void ContextPrivateFogf(PrivateState *privateState,
864 PrivateStateCache *privateStateCache,
865 GLenum pname,
866 GLfloat param)
867 {
868 ContextPrivateFogfv(privateState, privateStateCache, pname, ¶m);
869 }
870
ContextPrivateFogfv(PrivateState * privateState,PrivateStateCache * privateStateCache,GLenum pname,const GLfloat * params)871 void ContextPrivateFogfv(PrivateState *privateState,
872 PrivateStateCache *privateStateCache,
873 GLenum pname,
874 const GLfloat *params)
875 {
876 SetFogParameters(privateState->getMutableGLES1State(), pname, params);
877 }
878
ContextPrivateFogx(PrivateState * privateState,PrivateStateCache * privateStateCache,GLenum pname,GLfixed param)879 void ContextPrivateFogx(PrivateState *privateState,
880 PrivateStateCache *privateStateCache,
881 GLenum pname,
882 GLfixed param)
883 {
884 if (GetFogParameterCount(pname) == 1)
885 {
886 GLfloat paramf = pname == GL_FOG_MODE ? ConvertToGLenum(param) : ConvertFixedToFloat(param);
887 ContextPrivateFogfv(privateState, privateStateCache, pname, ¶mf);
888 }
889 else
890 {
891 UNREACHABLE();
892 }
893 }
894
ContextPrivateFogxv(PrivateState * privateState,PrivateStateCache * privateStateCache,GLenum pname,const GLfixed * params)895 void ContextPrivateFogxv(PrivateState *privateState,
896 PrivateStateCache *privateStateCache,
897 GLenum pname,
898 const GLfixed *params)
899 {
900 int paramCount = GetFogParameterCount(pname);
901
902 if (paramCount > 0)
903 {
904 GLfloat paramsf[4];
905 for (int i = 0; i < paramCount; i++)
906 {
907 paramsf[i] =
908 pname == GL_FOG_MODE ? ConvertToGLenum(params[i]) : ConvertFixedToFloat(params[i]);
909 }
910 ContextPrivateFogfv(privateState, privateStateCache, pname, paramsf);
911 }
912 else
913 {
914 UNREACHABLE();
915 }
916 }
917
ContextPrivateFrustumf(PrivateState * privateState,PrivateStateCache * privateStateCache,GLfloat l,GLfloat r,GLfloat b,GLfloat t,GLfloat n,GLfloat f)918 void ContextPrivateFrustumf(PrivateState *privateState,
919 PrivateStateCache *privateStateCache,
920 GLfloat l,
921 GLfloat r,
922 GLfloat b,
923 GLfloat t,
924 GLfloat n,
925 GLfloat f)
926 {
927 privateState->getMutableGLES1State()->multMatrix(angle::Mat4::Frustum(l, r, b, t, n, f));
928 }
929
ContextPrivateFrustumx(PrivateState * privateState,PrivateStateCache * privateStateCache,GLfixed l,GLfixed r,GLfixed b,GLfixed t,GLfixed n,GLfixed f)930 void ContextPrivateFrustumx(PrivateState *privateState,
931 PrivateStateCache *privateStateCache,
932 GLfixed l,
933 GLfixed r,
934 GLfixed b,
935 GLfixed t,
936 GLfixed n,
937 GLfixed f)
938 {
939 ContextPrivateFrustumf(privateState, privateStateCache, ConvertFixedToFloat(l),
940 ConvertFixedToFloat(r), ConvertFixedToFloat(b), ConvertFixedToFloat(t),
941 ConvertFixedToFloat(n), ConvertFixedToFloat(f));
942 }
943
ContextPrivateGetClipPlanef(PrivateState * privateState,PrivateStateCache * privateStateCache,GLenum plane,GLfloat * equation)944 void ContextPrivateGetClipPlanef(PrivateState *privateState,
945 PrivateStateCache *privateStateCache,
946 GLenum plane,
947 GLfloat *equation)
948 {
949 privateState->gles1().getClipPlane(plane - GL_CLIP_PLANE0, equation);
950 }
951
ContextPrivateGetClipPlanex(PrivateState * privateState,PrivateStateCache * privateStateCache,GLenum plane,GLfixed * equation)952 void ContextPrivateGetClipPlanex(PrivateState *privateState,
953 PrivateStateCache *privateStateCache,
954 GLenum plane,
955 GLfixed *equation)
956 {
957 GLfloat equationf[4] = {};
958
959 ContextPrivateGetClipPlanef(privateState, privateStateCache, plane, equationf);
960
961 for (int i = 0; i < 4; i++)
962 {
963 equation[i] = ConvertFloatToFixed(equationf[i]);
964 }
965 }
966
ContextPrivateGetLightfv(PrivateState * privateState,PrivateStateCache * privateStateCache,GLenum light,LightParameter pname,GLfloat * params)967 void ContextPrivateGetLightfv(PrivateState *privateState,
968 PrivateStateCache *privateStateCache,
969 GLenum light,
970 LightParameter pname,
971 GLfloat *params)
972 {
973 GetLightParameters(privateState->getMutableGLES1State(), light, pname, params);
974 }
975
ContextPrivateGetLightxv(PrivateState * privateState,PrivateStateCache * privateStateCache,GLenum light,LightParameter pname,GLfixed * params)976 void ContextPrivateGetLightxv(PrivateState *privateState,
977 PrivateStateCache *privateStateCache,
978 GLenum light,
979 LightParameter pname,
980 GLfixed *params)
981 {
982 GLfloat paramsf[4];
983 ContextPrivateGetLightfv(privateState, privateStateCache, light, pname, paramsf);
984
985 for (unsigned int i = 0; i < GetLightParameterCount(pname); i++)
986 {
987 params[i] = ConvertFloatToFixed(paramsf[i]);
988 }
989 }
990
ContextPrivateGetMaterialfv(PrivateState * privateState,PrivateStateCache * privateStateCache,GLenum face,MaterialParameter pname,GLfloat * params)991 void ContextPrivateGetMaterialfv(PrivateState *privateState,
992 PrivateStateCache *privateStateCache,
993 GLenum face,
994 MaterialParameter pname,
995 GLfloat *params)
996 {
997 GetMaterialParameters(privateState->getMutableGLES1State(), face, pname, params);
998 }
999
ContextPrivateGetMaterialxv(PrivateState * privateState,PrivateStateCache * privateStateCache,GLenum face,MaterialParameter pname,GLfixed * params)1000 void ContextPrivateGetMaterialxv(PrivateState *privateState,
1001 PrivateStateCache *privateStateCache,
1002 GLenum face,
1003 MaterialParameter pname,
1004 GLfixed *params)
1005 {
1006 GLfloat paramsf[4];
1007 ContextPrivateGetMaterialfv(privateState, privateStateCache, face, pname, paramsf);
1008
1009 for (unsigned int i = 0; i < GetMaterialParameterCount(pname); i++)
1010 {
1011 params[i] = ConvertFloatToFixed(paramsf[i]);
1012 }
1013 }
1014
ContextPrivateGetTexEnvfv(PrivateState * privateState,PrivateStateCache * privateStateCache,TextureEnvTarget target,TextureEnvParameter pname,GLfloat * params)1015 void ContextPrivateGetTexEnvfv(PrivateState *privateState,
1016 PrivateStateCache *privateStateCache,
1017 TextureEnvTarget target,
1018 TextureEnvParameter pname,
1019 GLfloat *params)
1020 {
1021 GetTextureEnv(privateState->getActiveSampler(), privateState->getMutableGLES1State(), target,
1022 pname, params);
1023 }
1024
ContextPrivateGetTexEnviv(PrivateState * privateState,PrivateStateCache * privateStateCache,TextureEnvTarget target,TextureEnvParameter pname,GLint * params)1025 void ContextPrivateGetTexEnviv(PrivateState *privateState,
1026 PrivateStateCache *privateStateCache,
1027 TextureEnvTarget target,
1028 TextureEnvParameter pname,
1029 GLint *params)
1030 {
1031 GLfloat paramsf[4];
1032 ContextPrivateGetTexEnvfv(privateState, privateStateCache, target, pname, paramsf);
1033 ConvertTextureEnvToInt(pname, paramsf, params);
1034 }
1035
ContextPrivateGetTexEnvxv(PrivateState * privateState,PrivateStateCache * privateStateCache,TextureEnvTarget target,TextureEnvParameter pname,GLfixed * params)1036 void ContextPrivateGetTexEnvxv(PrivateState *privateState,
1037 PrivateStateCache *privateStateCache,
1038 TextureEnvTarget target,
1039 TextureEnvParameter pname,
1040 GLfixed *params)
1041 {
1042 GLfloat paramsf[4];
1043 ContextPrivateGetTexEnvfv(privateState, privateStateCache, target, pname, paramsf);
1044 ConvertTextureEnvToFixed(pname, paramsf, params);
1045 }
1046
ContextPrivateLightModelf(PrivateState * privateState,PrivateStateCache * privateStateCache,GLenum pname,GLfloat param)1047 void ContextPrivateLightModelf(PrivateState *privateState,
1048 PrivateStateCache *privateStateCache,
1049 GLenum pname,
1050 GLfloat param)
1051 {
1052 ContextPrivateLightModelfv(privateState, privateStateCache, pname, ¶m);
1053 }
1054
ContextPrivateLightModelfv(PrivateState * privateState,PrivateStateCache * privateStateCache,GLenum pname,const GLfloat * params)1055 void ContextPrivateLightModelfv(PrivateState *privateState,
1056 PrivateStateCache *privateStateCache,
1057 GLenum pname,
1058 const GLfloat *params)
1059 {
1060 SetLightModelParameters(privateState->getMutableGLES1State(), pname, params);
1061 }
1062
ContextPrivateLightModelx(PrivateState * privateState,PrivateStateCache * privateStateCache,GLenum pname,GLfixed param)1063 void ContextPrivateLightModelx(PrivateState *privateState,
1064 PrivateStateCache *privateStateCache,
1065 GLenum pname,
1066 GLfixed param)
1067 {
1068 ContextPrivateLightModelf(privateState, privateStateCache, pname, ConvertFixedToFloat(param));
1069 }
1070
ContextPrivateLightModelxv(PrivateState * privateState,PrivateStateCache * privateStateCache,GLenum pname,const GLfixed * param)1071 void ContextPrivateLightModelxv(PrivateState *privateState,
1072 PrivateStateCache *privateStateCache,
1073 GLenum pname,
1074 const GLfixed *param)
1075 {
1076 GLfloat paramsf[4];
1077
1078 for (unsigned int i = 0; i < GetLightModelParameterCount(pname); i++)
1079 {
1080 paramsf[i] = ConvertFixedToFloat(param[i]);
1081 }
1082
1083 ContextPrivateLightModelfv(privateState, privateStateCache, pname, paramsf);
1084 }
1085
ContextPrivateLightf(PrivateState * privateState,PrivateStateCache * privateStateCache,GLenum light,LightParameter pname,GLfloat param)1086 void ContextPrivateLightf(PrivateState *privateState,
1087 PrivateStateCache *privateStateCache,
1088 GLenum light,
1089 LightParameter pname,
1090 GLfloat param)
1091 {
1092 ContextPrivateLightfv(privateState, privateStateCache, light, pname, ¶m);
1093 }
1094
ContextPrivateLightfv(PrivateState * privateState,PrivateStateCache * privateStateCache,GLenum light,LightParameter pname,const GLfloat * params)1095 void ContextPrivateLightfv(PrivateState *privateState,
1096 PrivateStateCache *privateStateCache,
1097 GLenum light,
1098 LightParameter pname,
1099 const GLfloat *params)
1100 {
1101 SetLightParameters(privateState->getMutableGLES1State(), light, pname, params);
1102 }
1103
ContextPrivateLightx(PrivateState * privateState,PrivateStateCache * privateStateCache,GLenum light,LightParameter pname,GLfixed param)1104 void ContextPrivateLightx(PrivateState *privateState,
1105 PrivateStateCache *privateStateCache,
1106 GLenum light,
1107 LightParameter pname,
1108 GLfixed param)
1109 {
1110 ContextPrivateLightf(privateState, privateStateCache, light, pname, ConvertFixedToFloat(param));
1111 }
1112
ContextPrivateLightxv(PrivateState * privateState,PrivateStateCache * privateStateCache,GLenum light,LightParameter pname,const GLfixed * params)1113 void ContextPrivateLightxv(PrivateState *privateState,
1114 PrivateStateCache *privateStateCache,
1115 GLenum light,
1116 LightParameter pname,
1117 const GLfixed *params)
1118 {
1119 GLfloat paramsf[4];
1120
1121 for (unsigned int i = 0; i < GetLightParameterCount(pname); i++)
1122 {
1123 paramsf[i] = ConvertFixedToFloat(params[i]);
1124 }
1125
1126 ContextPrivateLightfv(privateState, privateStateCache, light, pname, paramsf);
1127 }
1128
ContextPrivateLoadIdentity(PrivateState * privateState,PrivateStateCache * privateStateCache)1129 void ContextPrivateLoadIdentity(PrivateState *privateState, PrivateStateCache *privateStateCache)
1130 {
1131 privateState->getMutableGLES1State()->loadMatrix(angle::Mat4());
1132 }
1133
ContextPrivateLoadMatrixf(PrivateState * privateState,PrivateStateCache * privateStateCache,const GLfloat * m)1134 void ContextPrivateLoadMatrixf(PrivateState *privateState,
1135 PrivateStateCache *privateStateCache,
1136 const GLfloat *m)
1137 {
1138 privateState->getMutableGLES1State()->loadMatrix(angle::Mat4(m));
1139 }
1140
ContextPrivateLoadMatrixx(PrivateState * privateState,PrivateStateCache * privateStateCache,const GLfixed * m)1141 void ContextPrivateLoadMatrixx(PrivateState *privateState,
1142 PrivateStateCache *privateStateCache,
1143 const GLfixed *m)
1144 {
1145 privateState->getMutableGLES1State()->loadMatrix(FixedMatrixToMat4(m));
1146 }
1147
ContextPrivateMaterialf(PrivateState * privateState,PrivateStateCache * privateStateCache,GLenum face,MaterialParameter pname,GLfloat param)1148 void ContextPrivateMaterialf(PrivateState *privateState,
1149 PrivateStateCache *privateStateCache,
1150 GLenum face,
1151 MaterialParameter pname,
1152 GLfloat param)
1153 {
1154 ContextPrivateMaterialfv(privateState, privateStateCache, face, pname, ¶m);
1155 }
1156
ContextPrivateMaterialfv(PrivateState * privateState,PrivateStateCache * privateStateCache,GLenum face,MaterialParameter pname,const GLfloat * params)1157 void ContextPrivateMaterialfv(PrivateState *privateState,
1158 PrivateStateCache *privateStateCache,
1159 GLenum face,
1160 MaterialParameter pname,
1161 const GLfloat *params)
1162 {
1163 SetMaterialParameters(privateState->getMutableGLES1State(), face, pname, params);
1164 }
1165
ContextPrivateMaterialx(PrivateState * privateState,PrivateStateCache * privateStateCache,GLenum face,MaterialParameter pname,GLfixed param)1166 void ContextPrivateMaterialx(PrivateState *privateState,
1167 PrivateStateCache *privateStateCache,
1168 GLenum face,
1169 MaterialParameter pname,
1170 GLfixed param)
1171 {
1172 ContextPrivateMaterialf(privateState, privateStateCache, face, pname,
1173 ConvertFixedToFloat(param));
1174 }
1175
ContextPrivateMaterialxv(PrivateState * privateState,PrivateStateCache * privateStateCache,GLenum face,MaterialParameter pname,const GLfixed * param)1176 void ContextPrivateMaterialxv(PrivateState *privateState,
1177 PrivateStateCache *privateStateCache,
1178 GLenum face,
1179 MaterialParameter pname,
1180 const GLfixed *param)
1181 {
1182 GLfloat paramsf[4];
1183
1184 for (unsigned int i = 0; i < GetMaterialParameterCount(pname); i++)
1185 {
1186 paramsf[i] = ConvertFixedToFloat(param[i]);
1187 }
1188
1189 ContextPrivateMaterialfv(privateState, privateStateCache, face, pname, paramsf);
1190 }
1191
ContextPrivateMatrixMode(PrivateState * privateState,PrivateStateCache * privateStateCache,MatrixType mode)1192 void ContextPrivateMatrixMode(PrivateState *privateState,
1193 PrivateStateCache *privateStateCache,
1194 MatrixType mode)
1195 {
1196 privateState->getMutableGLES1State()->setMatrixMode(mode);
1197 }
1198
ContextPrivateMultMatrixf(PrivateState * privateState,PrivateStateCache * privateStateCache,const GLfloat * m)1199 void ContextPrivateMultMatrixf(PrivateState *privateState,
1200 PrivateStateCache *privateStateCache,
1201 const GLfloat *m)
1202 {
1203 privateState->getMutableGLES1State()->multMatrix(angle::Mat4(m));
1204 }
1205
ContextPrivateMultMatrixx(PrivateState * privateState,PrivateStateCache * privateStateCache,const GLfixed * m)1206 void ContextPrivateMultMatrixx(PrivateState *privateState,
1207 PrivateStateCache *privateStateCache,
1208 const GLfixed *m)
1209 {
1210 privateState->getMutableGLES1State()->multMatrix(FixedMatrixToMat4(m));
1211 }
1212
ContextPrivateMultiTexCoord4f(PrivateState * privateState,PrivateStateCache * privateStateCache,GLenum target,GLfloat s,GLfloat t,GLfloat r,GLfloat q)1213 void ContextPrivateMultiTexCoord4f(PrivateState *privateState,
1214 PrivateStateCache *privateStateCache,
1215 GLenum target,
1216 GLfloat s,
1217 GLfloat t,
1218 GLfloat r,
1219 GLfloat q)
1220 {
1221 unsigned int unit = target - GL_TEXTURE0;
1222 ASSERT(target >= GL_TEXTURE0 && unit < privateState->getCaps().maxMultitextureUnits);
1223 privateState->getMutableGLES1State()->setCurrentTextureCoords(unit, {s, t, r, q});
1224 }
1225
ContextPrivateMultiTexCoord4x(PrivateState * privateState,PrivateStateCache * privateStateCache,GLenum texture,GLfixed s,GLfixed t,GLfixed r,GLfixed q)1226 void ContextPrivateMultiTexCoord4x(PrivateState *privateState,
1227 PrivateStateCache *privateStateCache,
1228 GLenum texture,
1229 GLfixed s,
1230 GLfixed t,
1231 GLfixed r,
1232 GLfixed q)
1233 {
1234 ContextPrivateMultiTexCoord4f(privateState, privateStateCache, texture, ConvertFixedToFloat(s),
1235 ConvertFixedToFloat(t), ConvertFixedToFloat(r),
1236 ConvertFixedToFloat(q));
1237 }
1238
ContextPrivateNormal3f(PrivateState * privateState,PrivateStateCache * privateStateCache,GLfloat nx,GLfloat ny,GLfloat nz)1239 void ContextPrivateNormal3f(PrivateState *privateState,
1240 PrivateStateCache *privateStateCache,
1241 GLfloat nx,
1242 GLfloat ny,
1243 GLfloat nz)
1244 {
1245 privateState->getMutableGLES1State()->setCurrentNormal({nx, ny, nz});
1246 }
1247
ContextPrivateNormal3x(PrivateState * privateState,PrivateStateCache * privateStateCache,GLfixed nx,GLfixed ny,GLfixed nz)1248 void ContextPrivateNormal3x(PrivateState *privateState,
1249 PrivateStateCache *privateStateCache,
1250 GLfixed nx,
1251 GLfixed ny,
1252 GLfixed nz)
1253 {
1254 ContextPrivateNormal3f(privateState, privateStateCache, ConvertFixedToFloat(nx),
1255 ConvertFixedToFloat(ny), ConvertFixedToFloat(nz));
1256 }
1257
ContextPrivateOrthof(PrivateState * privateState,PrivateStateCache * privateStateCache,GLfloat left,GLfloat right,GLfloat bottom,GLfloat top,GLfloat zNear,GLfloat zFar)1258 void ContextPrivateOrthof(PrivateState *privateState,
1259 PrivateStateCache *privateStateCache,
1260 GLfloat left,
1261 GLfloat right,
1262 GLfloat bottom,
1263 GLfloat top,
1264 GLfloat zNear,
1265 GLfloat zFar)
1266 {
1267 privateState->getMutableGLES1State()->multMatrix(
1268 angle::Mat4::Ortho(left, right, bottom, top, zNear, zFar));
1269 }
1270
ContextPrivateOrthox(PrivateState * privateState,PrivateStateCache * privateStateCache,GLfixed left,GLfixed right,GLfixed bottom,GLfixed top,GLfixed zNear,GLfixed zFar)1271 void ContextPrivateOrthox(PrivateState *privateState,
1272 PrivateStateCache *privateStateCache,
1273 GLfixed left,
1274 GLfixed right,
1275 GLfixed bottom,
1276 GLfixed top,
1277 GLfixed zNear,
1278 GLfixed zFar)
1279 {
1280 ContextPrivateOrthof(privateState, privateStateCache, ConvertFixedToFloat(left),
1281 ConvertFixedToFloat(right), ConvertFixedToFloat(bottom),
1282 ConvertFixedToFloat(top), ConvertFixedToFloat(zNear),
1283 ConvertFixedToFloat(zFar));
1284 }
1285
ContextPrivatePointParameterf(PrivateState * privateState,PrivateStateCache * privateStateCache,PointParameter pname,GLfloat param)1286 void ContextPrivatePointParameterf(PrivateState *privateState,
1287 PrivateStateCache *privateStateCache,
1288 PointParameter pname,
1289 GLfloat param)
1290 {
1291 ContextPrivatePointParameterfv(privateState, privateStateCache, pname, ¶m);
1292 }
1293
ContextPrivatePointParameterfv(PrivateState * privateState,PrivateStateCache * privateStateCache,PointParameter pname,const GLfloat * params)1294 void ContextPrivatePointParameterfv(PrivateState *privateState,
1295 PrivateStateCache *privateStateCache,
1296 PointParameter pname,
1297 const GLfloat *params)
1298 {
1299 SetPointParameter(privateState->getMutableGLES1State(), pname, params);
1300 }
1301
ContextPrivatePointParameterx(PrivateState * privateState,PrivateStateCache * privateStateCache,PointParameter pname,GLfixed param)1302 void ContextPrivatePointParameterx(PrivateState *privateState,
1303 PrivateStateCache *privateStateCache,
1304 PointParameter pname,
1305 GLfixed param)
1306 {
1307 ContextPrivatePointParameterf(privateState, privateStateCache, pname,
1308 ConvertFixedToFloat(param));
1309 }
1310
ContextPrivatePointParameterxv(PrivateState * privateState,PrivateStateCache * privateStateCache,PointParameter pname,const GLfixed * params)1311 void ContextPrivatePointParameterxv(PrivateState *privateState,
1312 PrivateStateCache *privateStateCache,
1313 PointParameter pname,
1314 const GLfixed *params)
1315 {
1316 GLfloat paramsf[4] = {};
1317 for (unsigned int i = 0; i < GetPointParameterCount(pname); i++)
1318 {
1319 paramsf[i] = ConvertFixedToFloat(params[i]);
1320 }
1321 ContextPrivatePointParameterfv(privateState, privateStateCache, pname, paramsf);
1322 }
1323
ContextPrivatePointSize(PrivateState * privateState,PrivateStateCache * privateStateCache,GLfloat size)1324 void ContextPrivatePointSize(PrivateState *privateState,
1325 PrivateStateCache *privateStateCache,
1326 GLfloat size)
1327 {
1328 SetPointSize(privateState->getMutableGLES1State(), size);
1329 }
1330
ContextPrivatePointSizex(PrivateState * privateState,PrivateStateCache * privateStateCache,GLfixed size)1331 void ContextPrivatePointSizex(PrivateState *privateState,
1332 PrivateStateCache *privateStateCache,
1333 GLfixed size)
1334 {
1335 ContextPrivatePointSize(privateState, privateStateCache, ConvertFixedToFloat(size));
1336 }
1337
ContextPrivatePopMatrix(PrivateState * privateState,PrivateStateCache * privateStateCache)1338 void ContextPrivatePopMatrix(PrivateState *privateState, PrivateStateCache *privateStateCache)
1339 {
1340 privateState->getMutableGLES1State()->popMatrix();
1341 }
1342
ContextPrivatePushMatrix(PrivateState * privateState,PrivateStateCache * privateStateCache)1343 void ContextPrivatePushMatrix(PrivateState *privateState, PrivateStateCache *privateStateCache)
1344 {
1345 privateState->getMutableGLES1State()->pushMatrix();
1346 }
1347
ContextPrivateRotatef(PrivateState * privateState,PrivateStateCache * privateStateCache,GLfloat angle,GLfloat x,GLfloat y,GLfloat z)1348 void ContextPrivateRotatef(PrivateState *privateState,
1349 PrivateStateCache *privateStateCache,
1350 GLfloat angle,
1351 GLfloat x,
1352 GLfloat y,
1353 GLfloat z)
1354 {
1355 privateState->getMutableGLES1State()->multMatrix(
1356 angle::Mat4::Rotate(angle, angle::Vector3(x, y, z)));
1357 }
1358
ContextPrivateRotatex(PrivateState * privateState,PrivateStateCache * privateStateCache,GLfixed angle,GLfixed x,GLfixed y,GLfixed z)1359 void ContextPrivateRotatex(PrivateState *privateState,
1360 PrivateStateCache *privateStateCache,
1361 GLfixed angle,
1362 GLfixed x,
1363 GLfixed y,
1364 GLfixed z)
1365 {
1366 ContextPrivateRotatef(privateState, privateStateCache, ConvertFixedToFloat(angle),
1367 ConvertFixedToFloat(x), ConvertFixedToFloat(y), ConvertFixedToFloat(z));
1368 }
1369
ContextPrivateScalef(PrivateState * privateState,PrivateStateCache * privateStateCache,GLfloat x,GLfloat y,GLfloat z)1370 void ContextPrivateScalef(PrivateState *privateState,
1371 PrivateStateCache *privateStateCache,
1372 GLfloat x,
1373 GLfloat y,
1374 GLfloat z)
1375 {
1376 privateState->getMutableGLES1State()->multMatrix(angle::Mat4::Scale(angle::Vector3(x, y, z)));
1377 }
1378
ContextPrivateScalex(PrivateState * privateState,PrivateStateCache * privateStateCache,GLfixed x,GLfixed y,GLfixed z)1379 void ContextPrivateScalex(PrivateState *privateState,
1380 PrivateStateCache *privateStateCache,
1381 GLfixed x,
1382 GLfixed y,
1383 GLfixed z)
1384 {
1385 ContextPrivateScalef(privateState, privateStateCache, ConvertFixedToFloat(x),
1386 ConvertFixedToFloat(y), ConvertFixedToFloat(z));
1387 }
1388
ContextPrivateShadeModel(PrivateState * privateState,PrivateStateCache * privateStateCache,ShadingModel model)1389 void ContextPrivateShadeModel(PrivateState *privateState,
1390 PrivateStateCache *privateStateCache,
1391 ShadingModel model)
1392 {
1393 privateState->getMutableGLES1State()->setShadeModel(model);
1394 }
1395
ContextPrivateTexEnvf(PrivateState * privateState,PrivateStateCache * privateStateCache,TextureEnvTarget target,TextureEnvParameter pname,GLfloat param)1396 void ContextPrivateTexEnvf(PrivateState *privateState,
1397 PrivateStateCache *privateStateCache,
1398 TextureEnvTarget target,
1399 TextureEnvParameter pname,
1400 GLfloat param)
1401 {
1402 ContextPrivateTexEnvfv(privateState, privateStateCache, target, pname, ¶m);
1403 }
1404
ContextPrivateTexEnvfv(PrivateState * privateState,PrivateStateCache * privateStateCache,TextureEnvTarget target,TextureEnvParameter pname,const GLfloat * params)1405 void ContextPrivateTexEnvfv(PrivateState *privateState,
1406 PrivateStateCache *privateStateCache,
1407 TextureEnvTarget target,
1408 TextureEnvParameter pname,
1409 const GLfloat *params)
1410 {
1411 SetTextureEnv(privateState->getActiveSampler(), privateState->getMutableGLES1State(), target,
1412 pname, params);
1413 }
1414
ContextPrivateTexEnvi(PrivateState * privateState,PrivateStateCache * privateStateCache,TextureEnvTarget target,TextureEnvParameter pname,GLint param)1415 void ContextPrivateTexEnvi(PrivateState *privateState,
1416 PrivateStateCache *privateStateCache,
1417 TextureEnvTarget target,
1418 TextureEnvParameter pname,
1419 GLint param)
1420 {
1421 ContextPrivateTexEnviv(privateState, privateStateCache, target, pname, ¶m);
1422 }
1423
ContextPrivateTexEnviv(PrivateState * privateState,PrivateStateCache * privateStateCache,TextureEnvTarget target,TextureEnvParameter pname,const GLint * params)1424 void ContextPrivateTexEnviv(PrivateState *privateState,
1425 PrivateStateCache *privateStateCache,
1426 TextureEnvTarget target,
1427 TextureEnvParameter pname,
1428 const GLint *params)
1429 {
1430 GLfloat paramsf[4] = {};
1431 ConvertTextureEnvFromInt(pname, params, paramsf);
1432 ContextPrivateTexEnvfv(privateState, privateStateCache, target, pname, paramsf);
1433 }
1434
ContextPrivateTexEnvx(PrivateState * privateState,PrivateStateCache * privateStateCache,TextureEnvTarget target,TextureEnvParameter pname,GLfixed param)1435 void ContextPrivateTexEnvx(PrivateState *privateState,
1436 PrivateStateCache *privateStateCache,
1437 TextureEnvTarget target,
1438 TextureEnvParameter pname,
1439 GLfixed param)
1440 {
1441 ContextPrivateTexEnvxv(privateState, privateStateCache, target, pname, ¶m);
1442 }
1443
ContextPrivateTexEnvxv(PrivateState * privateState,PrivateStateCache * privateStateCache,TextureEnvTarget target,TextureEnvParameter pname,const GLfixed * params)1444 void ContextPrivateTexEnvxv(PrivateState *privateState,
1445 PrivateStateCache *privateStateCache,
1446 TextureEnvTarget target,
1447 TextureEnvParameter pname,
1448 const GLfixed *params)
1449 {
1450 GLfloat paramsf[4] = {};
1451 ConvertTextureEnvFromFixed(pname, params, paramsf);
1452 ContextPrivateTexEnvfv(privateState, privateStateCache, target, pname, paramsf);
1453 }
1454
ContextPrivateTranslatef(PrivateState * privateState,PrivateStateCache * privateStateCache,GLfloat x,GLfloat y,GLfloat z)1455 void ContextPrivateTranslatef(PrivateState *privateState,
1456 PrivateStateCache *privateStateCache,
1457 GLfloat x,
1458 GLfloat y,
1459 GLfloat z)
1460 {
1461 privateState->getMutableGLES1State()->multMatrix(
1462 angle::Mat4::Translate(angle::Vector3(x, y, z)));
1463 }
1464
ContextPrivateTranslatex(PrivateState * privateState,PrivateStateCache * privateStateCache,GLfixed x,GLfixed y,GLfixed z)1465 void ContextPrivateTranslatex(PrivateState *privateState,
1466 PrivateStateCache *privateStateCache,
1467 GLfixed x,
1468 GLfixed y,
1469 GLfixed z)
1470 {
1471 ContextPrivateTranslatef(privateState, privateStateCache, ConvertFixedToFloat(x),
1472 ConvertFixedToFloat(y), ConvertFixedToFloat(z));
1473 }
1474 } // namespace gl
1475