Hash :
51320fab
Author :
Date :
2023-07-06T16:01:58
Make most GLES1 entry points lockless These entry points only set context-local state and thus don't require locking. Bug: angleproject:8224 Change-Id: I80223340348d62a56109324ab3e4f935e53419b3 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4670407 Reviewed-by: Igor Nazarov <i.nazarov@samsung.com> Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249
//
// Copyright 2018 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Context_gles_1_0.cpp: Implements the GLES1-specific parts of Context.
#include "libANGLE/Context.h"
#include "common/mathutil.h"
#include "common/utilities.h"
#include "libANGLE/GLES1Renderer.h"
#include "libANGLE/queryconversions.h"
#include "libANGLE/queryutils.h"
namespace gl
{
void Context::clientActiveTexture(GLenum texture)
{
getMutableGLES1State()->setClientTextureUnit(texture - GL_TEXTURE0);
mStateCache.onGLES1ClientStateChange(this);
}
void Context::colorPointer(GLint size, VertexAttribType type, GLsizei stride, const void *ptr)
{
// Note that we normalize data for UnsignedByte types. This is to match the behavior
// of current native GLES drivers.
vertexAttribPointer(vertexArrayIndex(ClientVertexArrayType::Color), size, type,
type == VertexAttribType::UnsignedByte, stride, ptr);
}
void Context::disableClientState(ClientVertexArrayType clientState)
{
getMutableGLES1State()->setClientStateEnabled(clientState, false);
disableVertexAttribArray(vertexArrayIndex(clientState));
mStateCache.onGLES1ClientStateChange(this);
}
void Context::enableClientState(ClientVertexArrayType clientState)
{
getMutableGLES1State()->setClientStateEnabled(clientState, true);
enableVertexAttribArray(vertexArrayIndex(clientState));
mStateCache.onGLES1ClientStateChange(this);
}
void Context::getFixedv(GLenum pname, GLfixed *params)
{
GLenum nativeType;
unsigned int numParams = 0;
getQueryParameterInfo(pname, &nativeType, &numParams);
std::vector<GLfloat> paramsf(numParams, 0);
CastStateValues(this, nativeType, pname, numParams, paramsf.data());
for (unsigned int i = 0; i < numParams; i++)
{
params[i] = ConvertFloatToFixed(paramsf[i]);
}
}
void Context::getTexParameterxv(TextureType target, GLenum pname, GLfixed *params)
{
const Texture *const texture = getTextureByType(target);
QueryTexParameterxv(this, texture, pname, params);
}
void Context::normalPointer(VertexAttribType type, GLsizei stride, const void *ptr)
{
vertexAttribPointer(vertexArrayIndex(ClientVertexArrayType::Normal), 3, type, GL_FALSE, stride,
ptr);
}
void Context::texCoordPointer(GLint size, VertexAttribType type, GLsizei stride, const void *ptr)
{
vertexAttribPointer(vertexArrayIndex(ClientVertexArrayType::TextureCoord), size, type, GL_FALSE,
stride, ptr);
}
void Context::texParameterx(TextureType target, GLenum pname, GLfixed param)
{
Texture *const texture = getTextureByType(target);
SetTexParameterx(this, texture, pname, param);
}
void Context::texParameterxv(TextureType target, GLenum pname, const GLfixed *params)
{
Texture *const texture = getTextureByType(target);
SetTexParameterxv(this, texture, pname, params);
}
void Context::vertexPointer(GLint size, VertexAttribType type, GLsizei stride, const void *ptr)
{
vertexAttribPointer(vertexArrayIndex(ClientVertexArrayType::Vertex), size, type, GL_FALSE,
stride, ptr);
}
// GL_OES_draw_texture
void Context::drawTexf(float x, float y, float z, float width, float height)
{
mGLES1Renderer->drawTexture(this, &mState, getMutableGLES1State(), x, y, z, width, height);
}
void Context::drawTexfv(const GLfloat *coords)
{
mGLES1Renderer->drawTexture(this, &mState, getMutableGLES1State(), coords[0], coords[1],
coords[2], coords[3], coords[4]);
}
void Context::drawTexi(GLint x, GLint y, GLint z, GLint width, GLint height)
{
mGLES1Renderer->drawTexture(this, &mState, getMutableGLES1State(), static_cast<GLfloat>(x),
static_cast<GLfloat>(y), static_cast<GLfloat>(z),
static_cast<GLfloat>(width), static_cast<GLfloat>(height));
}
void Context::drawTexiv(const GLint *coords)
{
mGLES1Renderer->drawTexture(this, &mState, getMutableGLES1State(),
static_cast<GLfloat>(coords[0]), static_cast<GLfloat>(coords[1]),
static_cast<GLfloat>(coords[2]), static_cast<GLfloat>(coords[3]),
static_cast<GLfloat>(coords[4]));
}
void Context::drawTexs(GLshort x, GLshort y, GLshort z, GLshort width, GLshort height)
{
mGLES1Renderer->drawTexture(this, &mState, getMutableGLES1State(), static_cast<GLfloat>(x),
static_cast<GLfloat>(y), static_cast<GLfloat>(z),
static_cast<GLfloat>(width), static_cast<GLfloat>(height));
}
void Context::drawTexsv(const GLshort *coords)
{
mGLES1Renderer->drawTexture(this, &mState, getMutableGLES1State(),
static_cast<GLfloat>(coords[0]), static_cast<GLfloat>(coords[1]),
static_cast<GLfloat>(coords[2]), static_cast<GLfloat>(coords[3]),
static_cast<GLfloat>(coords[4]));
}
void Context::drawTexx(GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height)
{
mGLES1Renderer->drawTexture(this, &mState, getMutableGLES1State(), ConvertFixedToFloat(x),
ConvertFixedToFloat(y), ConvertFixedToFloat(z),
ConvertFixedToFloat(width), ConvertFixedToFloat(height));
}
void Context::drawTexxv(const GLfixed *coords)
{
mGLES1Renderer->drawTexture(this, &mState, getMutableGLES1State(),
ConvertFixedToFloat(coords[0]), ConvertFixedToFloat(coords[1]),
ConvertFixedToFloat(coords[2]), ConvertFixedToFloat(coords[3]),
ConvertFixedToFloat(coords[4]));
}
// GL_OES_matrix_palette
void Context::currentPaletteMatrix(GLuint matrixpaletteindex)
{
UNIMPLEMENTED();
}
void Context::loadPaletteFromModelViewMatrix()
{
UNIMPLEMENTED();
}
void Context::matrixIndexPointer(GLint size, GLenum type, GLsizei stride, const void *pointer)
{
UNIMPLEMENTED();
}
void Context::weightPointer(GLint size, GLenum type, GLsizei stride, const void *pointer)
{
UNIMPLEMENTED();
}
// GL_OES_point_size_array
void Context::pointSizePointer(VertexAttribType type, GLsizei stride, const void *ptr)
{
vertexAttribPointer(vertexArrayIndex(ClientVertexArrayType::PointSize), 1, type, GL_FALSE,
stride, ptr);
}
// GL_OES_query_matrix
GLbitfield Context::queryMatrixx(GLfixed *mantissa, GLint *exponent)
{
UNIMPLEMENTED();
return 0;
}
// GL_OES_texture_cube_map
void Context::getTexGenfv(GLenum coord, GLenum pname, GLfloat *params)
{
UNIMPLEMENTED();
}
void Context::getTexGeniv(GLenum coord, GLenum pname, GLint *params)
{
UNIMPLEMENTED();
}
void Context::getTexGenxv(GLenum coord, GLenum pname, GLfixed *params)
{
UNIMPLEMENTED();
}
void Context::texGenf(GLenum coord, GLenum pname, GLfloat param)
{
UNIMPLEMENTED();
}
void Context::texGenfv(GLenum coord, GLenum pname, const GLfloat *params)
{
UNIMPLEMENTED();
}
void Context::texGeni(GLenum coord, GLenum pname, GLint param)
{
UNIMPLEMENTED();
}
void Context::texGeniv(GLenum coord, GLenum pname, const GLint *params)
{
UNIMPLEMENTED();
}
void Context::texGenx(GLenum coord, GLenum pname, GLfixed param)
{
UNIMPLEMENTED();
}
void Context::texGenxv(GLenum coord, GLenum pname, const GLint *params)
{
UNIMPLEMENTED();
}
int Context::vertexArrayIndex(ClientVertexArrayType type) const
{
return GLES1Renderer::VertexArrayIndex(type, mState.gles1());
}
// static
int Context::TexCoordArrayIndex(unsigned int unit)
{
return GLES1Renderer::TexCoordArrayIndex(unit);
}
} // namespace gl