OpenGLES2: remove RenderCopy and RenderCopyEx from back-end
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 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394
diff --git a/src/render/opengles2/SDL_render_gles2.c b/src/render/opengles2/SDL_render_gles2.c
index e56f618..f48691a 100644
--- a/src/render/opengles2/SDL_render_gles2.c
+++ b/src/render/opengles2/SDL_render_gles2.c
@@ -91,8 +91,6 @@ typedef enum
GLES2_ATTRIBUTE_POSITION = 0,
GLES2_ATTRIBUTE_COLOR = 1,
GLES2_ATTRIBUTE_TEXCOORD = 2,
- GLES2_ATTRIBUTE_ANGLE = 3,
- GLES2_ATTRIBUTE_CENTER = 4,
} GLES2_Attribute;
typedef enum
@@ -129,7 +127,6 @@ typedef struct
SDL_bool cliprect_dirty;
SDL_Rect cliprect;
SDL_bool texturing;
- SDL_bool is_copy_ex;
Uint32 clear_color;
int drawablew;
int drawableh;
@@ -422,8 +419,6 @@ GLES2_CacheProgram(GLES2_RenderData *data, GLuint vertex, GLuint fragment)
data->glBindAttribLocation(entry->id, GLES2_ATTRIBUTE_POSITION, "a_position");
data->glBindAttribLocation(entry->id, GLES2_ATTRIBUTE_COLOR, "a_color");
data->glBindAttribLocation(entry->id, GLES2_ATTRIBUTE_TEXCOORD, "a_texCoord");
- data->glBindAttribLocation(entry->id, GLES2_ATTRIBUTE_ANGLE, "a_angle");
- data->glBindAttribLocation(entry->id, GLES2_ATTRIBUTE_CENTER, "a_center");
data->glLinkProgram(entry->id);
data->glGetProgramiv(entry->id, GL_LINK_STATUS, &linkSuccessful);
if (!linkSuccessful) {
@@ -781,203 +776,6 @@ GLES2_QueueFillRects(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_
}
static int
-GLES2_QueueCopy(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * texture,
- const SDL_Rect * srcrect, const SDL_FRect * dstrect)
-{
- const SDL_bool colorswap = (renderer->target && (renderer->target->format == SDL_PIXELFORMAT_ARGB8888 || renderer->target->format == SDL_PIXELFORMAT_RGB888));
- int color;
- GLfloat minx, miny, maxx, maxy;
- GLfloat minu, maxu, minv, maxv;
- const size_t vertlen = 6 * (2 * sizeof (float) + sizeof (int) + 2 * sizeof (float));
- GLfloat *verts = (GLfloat *) SDL_AllocateRenderVertices(renderer, vertlen, 0, &cmd->data.draw.first);
-
- if (!verts) {
- return -1;
- }
-
- if (colorswap == 0) {
- color = (cmd->data.draw.r << 0) | (cmd->data.draw.g << 8) | (cmd->data.draw.b << 16) | (cmd->data.draw.a << 24);
- } else {
- color = (cmd->data.draw.r << 16) | (cmd->data.draw.g << 8) | (cmd->data.draw.b << 0) | (cmd->data.draw.a << 24);
- }
-
- cmd->data.draw.count = 1;
-
- minx = dstrect->x;
- miny = dstrect->y;
- maxx = dstrect->x + dstrect->w;
- maxy = dstrect->y + dstrect->h;
-
- minu = (GLfloat) srcrect->x / texture->w;
- maxu = (GLfloat) (srcrect->x + srcrect->w) / texture->w;
- minv = (GLfloat) srcrect->y / texture->h;
- maxv = (GLfloat) (srcrect->y + srcrect->h) / texture->h;
-
- /* set these up as GL_TRIANGLES instead of GL_TRIANGLE_STRIP; it's more
- vertices, but we can then draw unconnected pieces in a single draw
- call if there are several draws in a row using the same texture
- (such as a particle system or texture atlas). */
- *(verts++) = minx;
- *(verts++) = miny;
- *((int *)verts++) = color;
- *(verts++) = minu;
- *(verts++) = minv;
-
- *(verts++) = maxx;
- *(verts++) = miny;
- *((int *)verts++) = color;
- *(verts++) = maxu;
- *(verts++) = minv;
-
- *(verts++) = minx;
- *(verts++) = maxy;
- *((int *)verts++) = color;
- *(verts++) = minu;
- *(verts++) = maxv;
-
-
- *(verts++) = maxx;
- *(verts++) = miny;
- *((int *)verts++) = color;
- *(verts++) = maxu;
- *(verts++) = minv;
-
- *(verts++) = minx;
- *(verts++) = maxy;
- *((int *)verts++) = color;
- *(verts++) = minu;
- *(verts++) = maxv;
-
- *(verts++) = maxx;
- *(verts++) = maxy;
- *((int *)verts++) = color;
- *(verts++) = maxu;
- *(verts++) = maxv;
-
- return 0;
-}
-
-static int
-GLES2_QueueCopyEx(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * texture,
- const SDL_Rect * srcquad, const SDL_FRect * dstrect,
- const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip)
-{
- const SDL_bool colorswap = (renderer->target && (renderer->target->format == SDL_PIXELFORMAT_ARGB8888 || renderer->target->format == SDL_PIXELFORMAT_RGB888));
- int color;
- /* render expects cos value - 1 (see GLES2_Vertex_Default) */
- const float radian_angle = (float)(M_PI * (360.0 - angle) / 180.0);
- const GLfloat s = (GLfloat) SDL_sin(radian_angle);
- const GLfloat c = (GLfloat) SDL_cos(radian_angle) - 1.0f;
- const GLfloat centerx = center->x + dstrect->x;
- const GLfloat centery = center->y + dstrect->y;
- GLfloat minx, miny, maxx, maxy;
- GLfloat minu, maxu, minv, maxv;
- const size_t vertlen = 6 * (2 * sizeof (float) + sizeof (int) + (2 + 2 + 2) * sizeof (float));
- GLfloat *verts = (GLfloat *) SDL_AllocateRenderVertices(renderer, vertlen, 0, &cmd->data.draw.first);
-
- if (!verts) {
- return -1;
- }
-
- if (colorswap == 0) {
- color = (cmd->data.draw.r << 0) | (cmd->data.draw.g << 8) | (cmd->data.draw.b << 16) | (cmd->data.draw.a << 24);
- } else {
- color = (cmd->data.draw.r << 16) | (cmd->data.draw.g << 8) | (cmd->data.draw.b << 0) | (cmd->data.draw.a << 24);
- }
-
- if (flip & SDL_FLIP_HORIZONTAL) {
- minx = dstrect->x + dstrect->w;
- maxx = dstrect->x;
- } else {
- minx = dstrect->x;
- maxx = dstrect->x + dstrect->w;
- }
-
- if (flip & SDL_FLIP_VERTICAL) {
- miny = dstrect->y + dstrect->h;
- maxy = dstrect->y;
- } else {
- miny = dstrect->y;
- maxy = dstrect->y + dstrect->h;
- }
-
- minu = ((GLfloat) srcquad->x) / ((GLfloat) texture->w);
- maxu = ((GLfloat) (srcquad->x + srcquad->w)) / ((GLfloat) texture->w);
- minv = ((GLfloat) srcquad->y) / ((GLfloat) texture->h);
- maxv = ((GLfloat) (srcquad->y + srcquad->h)) / ((GLfloat) texture->h);
-
- cmd->data.draw.count = 1;
-
- /* set these up as GL_TRIANGLES instead of GL_TRIANGLE_STRIP; it's more
- vertices, but we can then draw unconnected pieces in a single draw
- call if there are several draws in a row using the same texture
- (such as a particle system or texture atlas). */
-
- *(verts++) = minx;
- *(verts++) = miny;
- *((int *)verts++) = color;
- *(verts++) = minu;
- *(verts++) = minv;
- *(verts++) = s;
- *(verts++) = c;
- *(verts++) = centerx;
- *(verts++) = centery;
-
- *(verts++) = maxx;
- *(verts++) = miny;
- *((int *)verts++) = color;
- *(verts++) = maxu;
- *(verts++) = minv;
- *(verts++) = s;
- *(verts++) = c;
- *(verts++) = centerx;
- *(verts++) = centery;
-
- *(verts++) = minx;
- *(verts++) = maxy;
- *((int *)verts++) = color;
- *(verts++) = minu;
- *(verts++) = maxv;
- *(verts++) = s;
- *(verts++) = c;
- *(verts++) = centerx;
- *(verts++) = centery;
-
- *(verts++) = maxx;
- *(verts++) = miny;
- *((int *)verts++) = color;
- *(verts++) = maxu;
- *(verts++) = minv;
- *(verts++) = s;
- *(verts++) = c;
- *(verts++) = centerx;
- *(verts++) = centery;
-
- *(verts++) = minx;
- *(verts++) = maxy;
- *((int *)verts++) = color;
- *(verts++) = minu;
- *(verts++) = maxv;
- *(verts++) = s;
- *(verts++) = c;
- *(verts++) = centerx;
- *(verts++) = centery;
-
- *(verts++) = maxx;
- *(verts++) = maxy;
- *((int *)verts++) = color;
- *(verts++) = maxu;
- *(verts++) = maxv;
- *(verts++) = s;
- *(verts++) = c;
- *(verts++) = centerx;
- *(verts++) = centery;
-
- return 0;
-}
-
-#if SDL_HAVE_RENDER_GEOMETRY
-static int
GLES2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
const float *xy, int xy_stride, const int *color, int color_stride, const float *uv, int uv_stride,
int num_vertices, const void *indices, int num_indices, int size_indices,
@@ -1037,13 +835,10 @@ GLES2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture
return 0;
}
-#endif
static int
SetDrawState(GLES2_RenderData *data, const SDL_RenderCommand *cmd, const GLES2_ImageSource imgsrc)
{
- const SDL_bool was_copy_ex = data->drawstate.is_copy_ex;
- const SDL_bool is_copy_ex = (cmd->command == SDL_RENDERCMD_COPY_EX);
SDL_Texture *texture = cmd->data.draw.texture;
const SDL_BlendMode blend = cmd->data.draw.blend;
GLES2_ProgramCacheEntry *program;
@@ -1121,10 +916,6 @@ SetDrawState(GLES2_RenderData *data, const SDL_RenderCommand *cmd, const GLES2_I
stride += sizeof (GLfloat) * 2; /* tex coord */
}
- if (is_copy_ex) {
- stride += sizeof (GLfloat) * (2 /* angle sin/cos */ + 2 /* center */);
- }
-
if (texture) {
data->glVertexAttribPointer(GLES2_ATTRIBUTE_TEXCOORD, 2, GL_FLOAT, GL_FALSE, stride, (const GLvoid *) (uintptr_t) (cmd->data.draw.first + sizeof (GLfloat) * (2 + 1)));
}
@@ -1161,22 +952,6 @@ SetDrawState(GLES2_RenderData *data, const SDL_RenderCommand *cmd, const GLES2_I
data->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, stride, (const GLvoid *) (uintptr_t) cmd->data.draw.first);
data->glVertexAttribPointer(GLES2_ATTRIBUTE_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE /* Normalized */, stride, (const GLvoid *) (uintptr_t) (cmd->data.draw.first + sizeof (GLfloat) * 2));
- if (is_copy_ex != was_copy_ex) {
- if (is_copy_ex) {
- data->glEnableVertexAttribArray((GLenum) GLES2_ATTRIBUTE_ANGLE);
- data->glEnableVertexAttribArray((GLenum) GLES2_ATTRIBUTE_CENTER);
- } else {
- data->glDisableVertexAttribArray((GLenum) GLES2_ATTRIBUTE_ANGLE);
- data->glDisableVertexAttribArray((GLenum) GLES2_ATTRIBUTE_CENTER);
- }
- data->drawstate.is_copy_ex = is_copy_ex;
- }
-
- if (is_copy_ex) {
- data->glVertexAttribPointer(GLES2_ATTRIBUTE_ANGLE, 2, GL_FLOAT, GL_FALSE, stride, (const GLvoid *) (uintptr_t) (cmd->data.draw.first + sizeof (GLfloat) * (2 + 1 + 2)));
- data->glVertexAttribPointer(GLES2_ATTRIBUTE_CENTER, 2, GL_FLOAT, GL_FALSE, stride, (const GLvoid *) (uintptr_t) (cmd->data.draw.first + sizeof (GLfloat) * (2 + 1 + 2 + 2)));
- }
-
return 0;
}
@@ -1414,15 +1189,21 @@ GLES2_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *ver
break;
}
- case SDL_RENDERCMD_COPY:
- case SDL_RENDERCMD_COPY_EX: {
+ case SDL_RENDERCMD_COPY: /* unused */
+ break;
+
+ case SDL_RENDERCMD_COPY_EX: /* unused */
+ break;
+
+ case SDL_RENDERCMD_GEOMETRY: {
/* as long as we have the same copy command in a row, with the
same texture, we can combine them all into a single draw call. */
SDL_Texture *thistexture = cmd->data.draw.texture;
const SDL_RenderCommandType thiscmdtype = cmd->command;
SDL_RenderCommand *finalcmd = cmd;
SDL_RenderCommand *nextcmd = cmd->next;
- int quads = 1;
+ size_t count = cmd->data.draw.count;
+ int ret;
while (nextcmd != NULL) {
const SDL_RenderCommandType nextcmdtype = nextcmd->command;
if (nextcmdtype != thiscmdtype) {
@@ -1434,26 +1215,12 @@ GLES2_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *ver
break; /* can't go any further on this draw call, different texture copy up next. */
} else {
finalcmd = nextcmd; /* we can combine copy operations here. Mark this one as the furthest okay command. */
- quads++;
+ count += cmd->data.draw.count;
}
nextcmd = nextcmd->next;
}
- if (SetCopyState(renderer, cmd) == 0) {
- data->glDrawArrays(GL_TRIANGLES, 0, quads * 6);
- }
-
- cmd = finalcmd; /* skip any copy commands we just combined in here. */
- break;
- }
-
- case SDL_RENDERCMD_GEOMETRY: {
-#if SDL_HAVE_RENDER_GEOMETRY
- SDL_Texture *texture = cmd->data.draw.texture;
- const size_t count = cmd->data.draw.count;
- int ret;
-
- if (texture) {
+ if (thistexture) {
ret = SetCopyState(renderer, cmd);
} else {
ret = SetDrawState(data, cmd, GLES2_IMAGESOURCE_SOLID);
@@ -1462,7 +1229,8 @@ GLES2_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *ver
if (ret == 0) {
data->glDrawArrays(GL_TRIANGLES, 0, (GLsizei) count);
}
-#endif
+
+ cmd = finalcmd; /* skip any copy commands we just combined in here. */
break;
}
@@ -2278,11 +2046,7 @@ GLES2_CreateRenderer(SDL_Window *window, Uint32 flags)
renderer->QueueDrawPoints = GLES2_QueueDrawPoints;
renderer->QueueDrawLines = GLES2_QueueDrawLines;
renderer->QueueFillRects = GLES2_QueueFillRects;
- renderer->QueueCopy = GLES2_QueueCopy;
- renderer->QueueCopyEx = GLES2_QueueCopyEx;
-#if SDL_HAVE_RENDER_GEOMETRY
renderer->QueueGeometry = GLES2_QueueGeometry;
-#endif
renderer->RunCommandQueue = GLES2_RunCommandQueue;
renderer->RenderReadPixels = GLES2_RenderReadPixels;
renderer->RenderPresent = GLES2_RenderPresent;
diff --git a/src/render/opengles2/SDL_shaders_gles2.c b/src/render/opengles2/SDL_shaders_gles2.c
index cf91599..0a2b1a7 100644
--- a/src/render/opengles2/SDL_shaders_gles2.c
+++ b/src/render/opengles2/SDL_shaders_gles2.c
@@ -30,30 +30,18 @@
/*************************************************************************************************
* Vertex/fragment shader source *
*************************************************************************************************/
-/* Notes on a_angle:
- * It is a vector containing sin and cos for rotation matrix
- * To get correct rotation for most cases when a_angle is disabled cos
- value is decremented by 1.0 to get proper output with 0.0 which is
- default value
-*/
static const Uint8 GLES2_Vertex_Default[] = " \
uniform mat4 u_projection; \
attribute vec2 a_position; \
attribute vec4 a_color; \
attribute vec2 a_texCoord; \
- attribute vec2 a_angle; \
- attribute vec2 a_center; \
varying vec2 v_texCoord; \
varying vec4 v_color; \
\
void main() \
{ \
- float s = a_angle[0]; \
- float c = a_angle[1] + 1.0; \
- mat2 rotationMatrix = mat2(c, -s, s, c); \
- vec2 position = rotationMatrix * (a_position - a_center) + a_center; \
v_texCoord = a_texCoord; \
- gl_Position = u_projection * vec4(position, 0.0, 1.0);\
+ gl_Position = u_projection * vec4(a_position, 0.0, 1.0);\
gl_PointSize = 1.0; \
v_color = a_color; \
} \