this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Initial work on multitexture blit support

+439 -2
+30 -1
include/SDL_gpu.h
··· 517 517 } GPU_AttributeSource; 518 518 519 519 520 + /*! \ingroup ShaderInterface */ 521 + typedef struct GPU_MultitextureBlock 522 + { 523 + int num_textures; 524 + char** image_names; /* array of char* */ 525 + char** texcoord_names; /* array of char* */ 526 + } GPU_MultitextureBlock; 527 + 528 + 520 529 /*! \ingroup Logging 521 530 * Type enumeration for error codes. 522 531 * \see GPU_PushErrorCode() ··· 588 597 589 598 /*! 0 for inverted, 1 for mathematical */ 590 599 Uint8 coordinate_mode; 591 - 600 + 601 + struct GPU_MultitextureBlock* multitexture_block; 602 + int multitexture_texCoord_buffers[32]; 603 + 592 604 struct GPU_RendererImpl* impl; 593 605 }; 594 606 ··· 1017 1029 /*! Sets the modulation color for subsequent drawing of the given image. */ 1018 1030 DECLSPEC void SDLCALL GPU_SetColor(GPU_Image* image, SDL_Color color); 1019 1031 1032 + /*! Gets the modulation color for subsequent drawing of the given image. */ 1033 + DECLSPEC SDL_Color SDLCALL GPU_GetColor(GPU_Image* image); 1034 + 1020 1035 /*! Sets the modulation color for subsequent drawing of the given image. */ 1021 1036 DECLSPEC void SDLCALL GPU_SetRGB(GPU_Image* image, Uint8 r, Uint8 g, Uint8 b); 1022 1037 ··· 1222 1237 * \param flags Bit flags to control the interpretation of the 'values' array parameters. 1223 1238 */ 1224 1239 DECLSPEC void SDLCALL GPU_TriangleBatch(GPU_Image* image, GPU_Target* target, unsigned short num_vertices, float* values, unsigned int num_indices, unsigned short* indices, GPU_BatchFlagEnum flags); 1240 + 1241 + DECLSPEC void SDLCALL GPU_BlitBatch(GPU_Image* image, GPU_Target* target, Uint32 num_sprites, 1242 + float* values, GPU_BatchFlagEnum flags); 1243 + 1244 + DECLSPEC void SDLCALL GPU_BlitBatchSeparate(GPU_Image* image, GPU_Target* target, Uint32 num_sprites, 1245 + float* positions, float* src_rects, float* colors, GPU_BatchFlagEnum flags); 1225 1246 1226 1247 /*! Send all buffered blitting data to the current context target. */ 1227 1248 DECLSPEC void SDLCALL GPU_FlushBlitBuffer(void); ··· 1506 1527 \param location The uniform location of a texture sampler 1507 1528 \param image_unit The index of the texture unit to set. 0 is the first unit, which is used by SDL_gpu's blitting functions. 1 would be the second unit. */ 1508 1529 DECLSPEC void SDLCALL GPU_SetShaderImage(GPU_Image* image, int location, int image_unit); 1530 + 1531 + DECLSPEC GPU_MultitextureBlock SDLCALL GPU_LoadMultitextureBlock(int count, char** image_names, char** texcoord_names); 1532 + 1533 + DECLSPEC void SDLCALL GPU_SetMultitextureBlock(GPU_MultitextureBlock* value); 1534 + 1535 + DECLSPEC void SDLCALL GPU_FreeMultitextureBlock(GPU_MultitextureBlock* value); 1536 + 1537 + DECLSPEC void SDLCALL GPU_MultitextureBlit(GPU_Image** images, GPU_Rect* rects, GPU_Target* target, float x, float y); 1509 1538 1510 1539 /*! Fills "values" with the value of the uniform shader variable at the given location. */ 1511 1540 DECLSPEC void SDLCALL GPU_GetUniformiv(Uint32 program_object, int location, int* values);
+2
include/SDL_gpu_RendererImpl.h
··· 118 118 /*! \see GPU_BlitTransformX() */ 119 119 void (SDLCALL *BlitTransformX)(GPU_Renderer* renderer, GPU_Image* image, GPU_Rect* src_rect, GPU_Target* target, float x, float y, float pivot_x, float pivot_y, float degrees, float scaleX, float scaleY); 120 120 121 + void (SDLCALL *MultitextureBlit)(GPU_Renderer* renderer, GPU_Image** images, GPU_Rect* rects, GPU_Target* target, float x, float y); 122 + 121 123 /*! \see GPU_TriangleBatch() */ 122 124 void (SDLCALL *TriangleBatch)(GPU_Renderer* renderer, GPU_Image* image, GPU_Target* target, unsigned short num_vertices, float* values, unsigned int num_indices, unsigned short* indices, GPU_BatchFlagEnum flags); 123 125
+66
src/SDL_gpu.c
··· 1397 1397 1398 1398 1399 1399 1400 + SDL_Color GPU_GetColor(GPU_Image* image) 1401 + { 1402 + return image->color; 1403 + } 1404 + 1405 + 1400 1406 1401 1407 void GPU_SetColor(GPU_Image* image, SDL_Color color) 1402 1408 { ··· 1999 2005 return; 2000 2006 2001 2007 _gpu_current_renderer->impl->SetShaderImage(_gpu_current_renderer, image, location, image_unit); 2008 + } 2009 + 2010 + GPU_MultitextureBlock GPU_LoadMultitextureBlock(int count, char** image_names, char** texcoord_names) 2011 + { 2012 + GPU_MultitextureBlock result; 2013 + result.image_names = (char**)SDL_malloc(count * sizeof(char*)); 2014 + result.texcoord_names = (char**)SDL_malloc(count * sizeof(char*)); 2015 + for (int i = 0; i < count; ++i) 2016 + { 2017 + result.image_names[i] = (char*)SDL_malloc(strlen(image_names[i]) + 1); 2018 + result.texcoord_names[i] = (char*)SDL_malloc(strlen(texcoord_names[i]) + 1); 2019 + strcpy(result.image_names[i], image_names[i]); 2020 + strcpy(result.texcoord_names[i], texcoord_names[i]); 2021 + } 2022 + result.num_textures = count; 2023 + return result; 2024 + } 2025 + 2026 + void GPU_FreeMultitextureBlock(GPU_MultitextureBlock* value) 2027 + { 2028 + int count = value->num_textures; 2029 + for (int i = 0; i < count; ++i) 2030 + { 2031 + SDL_free(value->image_names[i]); 2032 + SDL_free(value->texcoord_names[i]); 2033 + } 2034 + SDL_free(value->image_names); 2035 + SDL_free(value->texcoord_names); 2036 + } 2037 + 2038 + void GPU_SetMultitextureBlock(GPU_MultitextureBlock* value) 2039 + { 2040 + _gpu_current_renderer->multitexture_block = value; 2041 + } 2042 + 2043 + void GPU_MultitextureBlit(GPU_Image** images, GPU_Rect* rects, GPU_Target* target, float x, float y) 2044 + { 2045 + if (!CHECK_RENDERER) 2046 + RETURN_ERROR(GPU_ERROR_USER_ERROR, "NULL renderer"); 2047 + MAKE_CURRENT_IF_NONE(target); 2048 + if (!CHECK_CONTEXT) 2049 + RETURN_ERROR(GPU_ERROR_USER_ERROR, "NULL context"); 2050 + 2051 + if (images == NULL) 2052 + RETURN_ERROR(GPU_ERROR_NULL_ARGUMENT, "images"); 2053 + if (rects == NULL) 2054 + RETURN_ERROR(GPU_ERROR_NULL_ARGUMENT, "rects"); 2055 + if (target == NULL) 2056 + RETURN_ERROR(GPU_ERROR_NULL_ARGUMENT, "target"); 2057 + 2058 + _gpu_current_renderer->impl->MultitextureBlit(_gpu_current_renderer, images, rects, target, x, y); 2059 + } 2060 + 2061 + void GPU_BlitBatch(GPU_Image* image, GPU_Target* target, Uint32 num_sprites, 2062 + float* values, GPU_BatchFlagEnum flags) 2063 + {} 2064 + 2065 + void GPU_BlitBatchSeparate(GPU_Image* image, GPU_Target* target, Uint32 num_sprites, 2066 + float* positions, float* src_rects, float* colors, GPU_BatchFlagEnum flags) 2067 + { 2002 2068 } 2003 2069 2004 2070 void GPU_GetUniformiv(Uint32 program_object, int location, int* values)
+341 -1
src/renderer_GL_common.inl
··· 222 222 223 223 static SDL_PixelFormat* AllocFormat(GLenum glFormat); 224 224 static void FreeFormat(SDL_PixelFormat* format); 225 - 225 + static void refresh_attribute_data(GPU_CONTEXT_DATA* cdata); 226 + static void MultitextureFlush(GPU_Renderer* renderer, float** buffers); 226 227 227 228 static char shader_message[256]; 228 229 ··· 4319 4320 cdata->blit_buffer_num_vertices += GPU_BLIT_BUFFER_VERTICES_PER_SPRITE; 4320 4321 } 4321 4322 4323 + static void MultitextureBlit(GPU_Renderer* renderer, GPU_Image** images, GPU_Rect* rects, GPU_Target* target, float x, float y) 4324 + { 4325 + Uint32 tex_w, tex_h; 4326 + float w; 4327 + float h; 4328 + float x1, y1, x2, y2; 4329 + float dx1, dy1, dx2, dy2; 4330 + GPU_CONTEXT_DATA* cdata; 4331 + float* blit_buffer; 4332 + float** buffers[32]; 4333 + unsigned short blit_buffer_starting_index; 4334 + int vert_index; 4335 + int tex_index; 4336 + int i; 4337 + int color_index; 4338 + float r, g, b, a; 4339 + GPU_Image* image; 4322 4340 4341 + if(images == NULL) 4342 + { 4343 + GPU_PushErrorCode("GPU_MultitextureBlit", GPU_ERROR_NULL_ARGUMENT, "images"); 4344 + return; 4345 + } 4346 + 4347 + if(target == NULL) 4348 + { 4349 + GPU_PushErrorCode("GPU_MultitextureBlit", GPU_ERROR_NULL_ARGUMENT, "target"); 4350 + return; 4351 + } 4352 + 4353 + if (renderer->multitexture_block == NULL) 4354 + { 4355 + GPU_PushErrorCode("GPU_MultitextureBlit", GPU_ERROR_USER_ERROR, "No multitexture block available"); 4356 + } 4357 + 4358 + for (i = 0; i < renderer->multitexture_block->num_textures; ++i) 4359 + if(renderer != images[i]->renderer || renderer != target->renderer) 4360 + { 4361 + GPU_PushErrorCode("GPU_MultitextureBlit", GPU_ERROR_USER_ERROR, "Mismatched renderer"); 4362 + return; 4363 + } 4364 + 4365 + renderer->impl->FlushBlitBuffer(renderer); 4366 + for (i = 1; i < renderer->multitexture_block->num_textures; ++i) 4367 + { 4368 + // Bind the texture to which subsequent calls refer 4369 + int image_loc = renderer->impl->GetUniformLocation(renderer, renderer->current_context_target->context->current_shader_program, renderer->multitexture_block->image_names[i]); 4370 + image = images[i]; 4371 + renderer->impl->SetShaderImage(renderer, image, image_loc, i); 4372 + int coord_loc = renderer->impl->GetAttributeLocation(renderer, renderer->current_context_target->context->current_shader_program, renderer->multitexture_block->texcoord_names[i]); 4373 + int coord_buffer = renderer->multitexture_texCoord_buffers[i]; 4374 + if (coord_buffer == 0) 4375 + { 4376 + //initialize a buffer and make sure it's big enough to hold our data 4377 + float dummy[1024 / sizeof(float)]; 4378 + glGenBuffers(1, &renderer->multitexture_texCoord_buffers[i]); 4379 + glBindBuffer(GL_ARRAY_BUFFER, renderer->multitexture_texCoord_buffers[i]); 4380 + glBufferData(GL_ARRAY_BUFFER, 1024, &dummy, GL_STREAM_DRAW); 4381 + coord_buffer = renderer->multitexture_texCoord_buffers[i]; 4382 + } 4383 + renderer->impl->SetAttributei(renderer, coord_loc, coord_buffer); 4384 + } 4385 + 4386 + renderer->impl->Blit(renderer, images[0], &rects[0], target, x, y); 4387 + buffers[0] = ((GPU_CONTEXT_DATA*)renderer->current_context_target->context->data)->blit_buffer; 4388 + 4389 + for (i = 1; i < renderer->multitexture_block->num_textures; ++i) 4390 + { 4391 + // Bind the texture to which subsequent calls refer 4392 + int coord_loc; 4393 + int coord_buffer; 4394 + image = images[i]; 4395 + GPU_Rect* src_rect = &rects[i]; 4396 + 4397 + tex_w = image->texture_w; 4398 + tex_h = image->texture_h; 4399 + 4400 + if (image->snap_mode == GPU_SNAP_POSITION || image->snap_mode == GPU_SNAP_POSITION_AND_DIMENSIONS) 4401 + { 4402 + // Avoid rounding errors in texture sampling by insisting on integral pixel positions 4403 + x = floorf(x); 4404 + y = floorf(y); 4405 + } 4406 + 4407 + // Scale src_rect tex coords according to actual texture dims 4408 + x1 = src_rect->x / (float)tex_w; 4409 + y1 = src_rect->y / (float)tex_h; 4410 + x2 = (src_rect->x + src_rect->w) / (float)tex_w; 4411 + y2 = (src_rect->y + src_rect->h) / (float)tex_h; 4412 + w = src_rect->w; 4413 + h = src_rect->h; 4414 + 4415 + if (image->using_virtual_resolution) 4416 + { 4417 + // Scale texture coords to fit the original dims 4418 + x1 *= image->base_w / (float)image->w; 4419 + y1 *= image->base_h / (float)image->h; 4420 + x2 *= image->base_w / (float)image->w; 4421 + y2 *= image->base_h / (float)image->h; 4422 + } 4423 + 4424 + // Center the image on the given coords 4425 + dx1 = x - w / 2.0f; 4426 + dy1 = y - h / 2.0f; 4427 + dx2 = x + w / 2.0f; 4428 + dy2 = y + h / 2.0f; 4429 + 4430 + if (image->snap_mode == GPU_SNAP_DIMENSIONS || image->snap_mode == GPU_SNAP_POSITION_AND_DIMENSIONS) 4431 + { 4432 + float fractional; 4433 + fractional = w / 2.0f - floorf(w / 2.0f); 4434 + dx1 += fractional; 4435 + dx2 += fractional; 4436 + fractional = h / 2.0f - floorf(h / 2.0f); 4437 + dy1 += fractional; 4438 + dy2 += fractional; 4439 + } 4440 + 4441 + if (renderer->coordinate_mode == 1) 4442 + { 4443 + float temp = dy1; 4444 + dy1 = dy2; 4445 + dy2 = temp; 4446 + } 4447 + 4448 + blit_buffer = (float *)SDL_malloc(4 * GPU_BLIT_BUFFER_FLOATS_PER_VERTEX * sizeof(float)); 4449 + blit_buffer_starting_index = 0; 4450 + 4451 + vert_index = GPU_BLIT_BUFFER_VERTEX_OFFSET; 4452 + tex_index = GPU_BLIT_BUFFER_TEX_COORD_OFFSET; 4453 + color_index = GPU_BLIT_BUFFER_COLOR_OFFSET; 4454 + if (target->use_color) 4455 + { 4456 + r = MIX_COLOR_COMPONENT_NORMALIZED_RESULT(target->color.r, image->color.r); 4457 + g = MIX_COLOR_COMPONENT_NORMALIZED_RESULT(target->color.g, image->color.g); 4458 + b = MIX_COLOR_COMPONENT_NORMALIZED_RESULT(target->color.b, image->color.b); 4459 + a = MIX_COLOR_COMPONENT_NORMALIZED_RESULT(GET_ALPHA(target->color), GET_ALPHA(image->color)); 4460 + } 4461 + else 4462 + { 4463 + r = image->color.r / 255.0f; 4464 + g = image->color.g / 255.0f; 4465 + b = image->color.b / 255.0f; 4466 + a = GET_ALPHA(image->color) / 255.0f; 4467 + } 4468 + 4469 + // 4 Quad vertices 4470 + SET_TEXTURED_VERTEX_UNINDEXED(dx1, dy1, x1, y1, r, g, b, a); 4471 + SET_TEXTURED_VERTEX_UNINDEXED(dx2, dy1, x2, y1, r, g, b, a); 4472 + SET_TEXTURED_VERTEX_UNINDEXED(dx2, dy2, x2, y2, r, g, b, a); 4473 + SET_TEXTURED_VERTEX_UNINDEXED(dx1, dy2, x1, y2, r, g, b, a); 4474 + 4475 + buffers[i] = blit_buffer; 4476 + } 4477 + MultitextureFlush(renderer, buffers); 4478 + for (i = 1; i < renderer->multitexture_block->num_textures; ++i) 4479 + SDL_free(buffers[i]); 4480 + } 4323 4481 4324 4482 #ifdef SDL_GPU_USE_BUFFER_PIPELINE 4325 4483 ··· 5204 5362 #endif 5205 5363 } 5206 5364 5365 + static void DoMultitextureFlush(GPU_Renderer* renderer, GPU_CONTEXT_DATA* cdata, unsigned short num_vertices, float** blit_buffers, unsigned int num_indices, unsigned short* index_buffer) 5366 + { 5367 + (void)renderer; 5368 + int i; 5369 + int count = renderer->multitexture_block->num_textures; 5370 + #ifdef SDL_GPU_USE_ARRAY_PIPELINE 5371 + for (i = 0; i < count; ++i) 5372 + { 5373 + float* blit_buffer = blit_buffers[i]; 5374 + glClientActiveTexture(GL_TEXTURE0 + i); 5375 + glEnableClientState(GL_VERTEX_ARRAY); 5376 + glEnableClientState(GL_TEXTURE_COORD_ARRAY); 5377 + glEnableClientState(GL_COLOR_ARRAY); 5378 + 5379 + if (i == 0) 5380 + { 5381 + glVertexPointer(2, GL_FLOAT, GPU_BLIT_BUFFER_STRIDE, blit_buffer + GPU_BLIT_BUFFER_VERTEX_OFFSET); 5382 + glColorPointer(4, GL_FLOAT, GPU_BLIT_BUFFER_STRIDE, blit_buffer + GPU_BLIT_BUFFER_COLOR_OFFSET); 5383 + } 5384 + glTexCoordPointer(2, GL_FLOAT, GPU_BLIT_BUFFER_STRIDE, blit_buffer + GPU_BLIT_BUFFER_TEX_COORD_OFFSET); 5385 + } 5386 + 5387 + glDrawElements(cdata->last_shape, num_indices, GL_UNSIGNED_SHORT, index_buffer); 5388 + 5389 + for (i = count - 1; i >= 0; --i) 5390 + { 5391 + glClientActiveTexture(GL_TEXTURE0 + i); 5392 + glDisableClientState(GL_COLOR_ARRAY); 5393 + glDisableClientState(GL_TEXTURE_COORD_ARRAY); 5394 + glDisableClientState(GL_VERTEX_ARRAY); 5395 + } 5396 + return; 5397 + #endif 5398 + 5399 + 5400 + 5401 + 5402 + #ifdef SDL_GPU_USE_BUFFER_PIPELINE_FALLBACK 5403 + if (!IsFeatureEnabled(renderer, GPU_FEATURE_VERTEX_SHADER)) 5404 + #endif 5405 + #ifdef SDL_GPU_USE_FIXED_FUNCTION_PIPELINE 5406 + { 5407 + unsigned int index; 5408 + float* vertex_pointer = blit_buffers[0] + GPU_BLIT_BUFFER_VERTEX_OFFSET; 5409 + float* color_pointer = blit_buffers[0] + GPU_BLIT_BUFFER_COLOR_OFFSET; 5410 + 5411 + glBegin(cdata->last_shape); 5412 + for (i = 0; i < num_indices; i++) 5413 + { 5414 + index = index_buffer[i] * GPU_BLIT_BUFFER_FLOATS_PER_VERTEX; 5415 + glColor4f(color_pointer[index], color_pointer[index + 1], color_pointer[index + 2], color_pointer[index + 3]); 5416 + for (j = 0; j < count; ++j) 5417 + { 5418 + float* texcoord_pointer = blit_buffers[j] + GPU_BLIT_BUFFER_TEX_COORD_OFFSET; 5419 + glMultiTexCoord2f(GL_TEXTURE0 + j, texcoord_pointer[index], texcoord_pointer[index + 1]); 5420 + } 5421 + glVertex3f(vertex_pointer[index], vertex_pointer[index + 1], 0.0f); 5422 + } 5423 + glEnd(); 5424 + 5425 + return; 5426 + } 5427 + #endif 5428 + 5429 + 5430 + 5431 + 5432 + #ifdef SDL_GPU_USE_BUFFER_PIPELINE 5433 + { 5434 + // Update the vertex array object's buffers 5435 + #if !defined(SDL_GPU_NO_VAO) 5436 + glBindVertexArray(cdata->blit_VAO); 5437 + #endif 5438 + 5439 + // Upload our modelviewprojection matrix 5440 + if (cdata->current_shader_block.modelViewProjection_loc >= 0) 5441 + { 5442 + float mvp[16]; 5443 + GPU_GetModelViewProjection(mvp); 5444 + glUniformMatrix4fv(cdata->current_shader_block.modelViewProjection_loc, 1, 0, mvp); 5445 + } 5446 + 5447 + renderer->multitexture_texCoord_buffers[0] = cdata->blit_VBO[cdata->blit_VBO_flop]; 5448 + cdata->blit_VBO_flop = !cdata->blit_VBO_flop; 5449 + for (i = count - 1; i >= 0; --i) 5450 + { 5451 + // Upload blit buffer to a single buffer object 5452 + glBindBuffer(GL_ARRAY_BUFFER, renderer->multitexture_texCoord_buffers[i]); 5453 + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, cdata->blit_IBO); 5454 + 5455 + // Copy the whole blit buffer to the GPU 5456 + submit_buffer_data(GPU_BLIT_BUFFER_STRIDE * num_vertices, blit_buffers[i], sizeof(unsigned short)*num_indices, index_buffer); // Fills GPU buffer with data. 5457 + 5458 + // Specify the formatting of the blit buffer 5459 + if (cdata->current_shader_block.texcoord_loc >= 0) 5460 + { 5461 + glEnableVertexAttribArray(cdata->current_shader_block.texcoord_loc); 5462 + glVertexAttribPointer(cdata->current_shader_block.texcoord_loc, 2, GL_FLOAT, GL_FALSE, GPU_BLIT_BUFFER_STRIDE, (void*)(GPU_BLIT_BUFFER_TEX_COORD_OFFSET * sizeof(float))); 5463 + } 5464 + } 5465 + if (cdata->current_shader_block.position_loc >= 0) 5466 + { 5467 + glEnableVertexAttribArray(cdata->current_shader_block.position_loc); // Tell GL to use client-side attribute data 5468 + glVertexAttribPointer(cdata->current_shader_block.position_loc, 2, GL_FLOAT, GL_FALSE, GPU_BLIT_BUFFER_STRIDE, 0); // Tell how the data is formatted 5469 + } 5470 + if (cdata->current_shader_block.color_loc >= 0) 5471 + { 5472 + glEnableVertexAttribArray(cdata->current_shader_block.color_loc); 5473 + glVertexAttribPointer(cdata->current_shader_block.color_loc, 4, GL_FLOAT, GL_FALSE, GPU_BLIT_BUFFER_STRIDE, (void*)(GPU_BLIT_BUFFER_COLOR_OFFSET * sizeof(float))); 5474 + } 5475 + 5476 + upload_attribute_data(cdata, num_vertices); 5477 + 5478 + glDrawElements(cdata->last_shape, num_indices, GL_UNSIGNED_SHORT, (void*)0); 5479 + 5480 + // Disable the vertex arrays again 5481 + if (cdata->current_shader_block.position_loc >= 0) 5482 + glDisableVertexAttribArray(cdata->current_shader_block.position_loc); 5483 + if (cdata->current_shader_block.texcoord_loc >= 0) 5484 + glDisableVertexAttribArray(cdata->current_shader_block.texcoord_loc); 5485 + if (cdata->current_shader_block.color_loc >= 0) 5486 + glDisableVertexAttribArray(cdata->current_shader_block.color_loc); 5487 + 5488 + disable_attribute_data(cdata); 5489 + 5490 + #if !defined(SDL_GPU_NO_VAO) 5491 + glBindVertexArray(0); 5492 + #endif 5493 + } 5494 + #endif 5495 + } 5496 + 5207 5497 #define MAX(a, b) ((a) > (b)? (a) : (b)) 5208 5498 5209 5499 static void FlushBlitBuffer(GPU_Renderer* renderer) ··· 5265 5555 5266 5556 unsetClipRect(renderer, dest); 5267 5557 } 5558 + } 5559 + 5560 + static void MultitextureFlush(GPU_Renderer* renderer, float** buffers) 5561 + { 5562 + GPU_CONTEXT_DATA* cdata; 5563 + if (renderer->current_context_target == NULL) 5564 + return; 5565 + 5566 + cdata = (GPU_CONTEXT_DATA*)renderer->current_context_target->context->data; 5567 + if (cdata->blit_buffer_num_vertices > 0 && cdata->last_target != NULL) 5568 + { 5569 + GPU_Target* dest = cdata->last_target; 5570 + int num_vertices; 5571 + int num_indices; 5572 + float* blit_buffer; 5573 + unsigned short* index_buffer; 5574 + 5575 + changeViewport(dest); 5576 + changeCamera(dest); 5577 + 5578 + applyTexturing(renderer); 5579 + 5580 + #ifdef SDL_GPU_APPLY_TRANSFORMS_TO_GL_STACK 5581 + if (!IsFeatureEnabled(renderer, GPU_FEATURE_VERTEX_SHADER)) 5582 + applyTransforms(); 5583 + #endif 5584 + 5585 + setClipRect(renderer, dest); 5586 + 5587 + #ifdef SDL_GPU_USE_BUFFER_PIPELINE 5588 + refresh_attribute_data(cdata); 5589 + #endif 5590 + 5591 + index_buffer = cdata->index_buffer; 5592 + num_vertices = MAX(cdata->blit_buffer_num_vertices, get_lowest_attribute_num_values(cdata, cdata->blit_buffer_num_vertices)); 5593 + num_indices = num_vertices * 3 / 2; // 6 indices per sprite / 4 vertices per sprite = 3/2 5594 + 5595 + DoMultitextureFlush(renderer, cdata, num_vertices, buffers, num_indices, index_buffer); 5596 + 5597 + cdata->blit_buffer_num_vertices -= num_vertices; 5598 + // Move our pointers ahead 5599 + blit_buffer += GPU_BLIT_BUFFER_FLOATS_PER_VERTEX*num_vertices; 5600 + index_buffer += num_indices; 5601 + 5602 + cdata->blit_buffer_num_vertices = 0; 5603 + cdata->index_buffer_num_vertices = 0; 5604 + 5605 + unsetClipRect(renderer, dest); 5606 + } 5268 5607 } 5269 5608 5270 5609 static void Flip(GPU_Renderer* renderer, GPU_Target* target) ··· 6463 6802 impl->BlitScale = &BlitScale; \ 6464 6803 impl->BlitTransform = &BlitTransform; \ 6465 6804 impl->BlitTransformX = &BlitTransformX; \ 6805 + impl->MultitextureBlit = &MultitextureBlit; \ 6466 6806 impl->TriangleBatch = &TriangleBatch; \ 6467 6807 \ 6468 6808 impl->GenerateMipmaps = &GenerateMipmaps; \