early-access version 1667
This commit is contained in:
2
externals/SDL/src/render/SDL_d3dmath.c
vendored
2
externals/SDL/src/render/SDL_d3dmath.c
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
2
externals/SDL/src/render/SDL_d3dmath.h
vendored
2
externals/SDL/src/render/SDL_d3dmath.h
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
297
externals/SDL/src/render/SDL_render.c
vendored
297
externals/SDL/src/render/SDL_render.c
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@@ -32,6 +32,18 @@
|
||||
# include "../core/android/SDL_android.h"
|
||||
#endif
|
||||
|
||||
/* as a courtesy to iOS apps, we don't try to draw when in the background, as
|
||||
that will crash the app. However, these apps _should_ have used
|
||||
SDL_AddEventWatch to catch SDL_APP_WILLENTERBACKGROUND events and stopped
|
||||
drawing themselves. Other platforms still draw, as the compositor can use it,
|
||||
and more importantly: drawing to render targets isn't lost. But I still think
|
||||
this should probably be removed at some point in the future. --ryan. */
|
||||
#if defined(__IPHONEOS__) || defined(__TVOS__) || defined(__ANDROID__)
|
||||
#define DONT_DRAW_WHILE_HIDDEN 1
|
||||
#else
|
||||
#define DONT_DRAW_WHILE_HIDDEN 0
|
||||
#endif
|
||||
|
||||
#define SDL_WINDOWRENDERDATA "_SDL_WindowRenderData"
|
||||
|
||||
#define CHECK_RENDERER_MAGIC(renderer, retval) \
|
||||
@@ -104,6 +116,12 @@ static const SDL_RenderDriver *render_drivers[] = {
|
||||
#if SDL_VIDEO_RENDER_PSP
|
||||
&PSP_RenderDriver,
|
||||
#endif
|
||||
#if SDL_VIDEO_RENDER_VITA_GXM
|
||||
&VITA_GXM_RenderDriver,
|
||||
#endif
|
||||
#if SDL_VIDEO_RENDER_VITA_GLES2
|
||||
&VITA_GLES2_RenderDriver,
|
||||
#endif
|
||||
#if SDL_VIDEO_RENDER_SW
|
||||
&SW_RenderDriver
|
||||
#endif
|
||||
@@ -274,7 +292,9 @@ SDL_AllocateRenderVertices(SDL_Renderer *renderer, const size_t numbytes, const
|
||||
while (newsize < needed) {
|
||||
newsize *= 2;
|
||||
}
|
||||
|
||||
ptr = SDL_realloc(renderer->vertex_data, newsize);
|
||||
|
||||
if (ptr == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
@@ -371,7 +391,7 @@ QueueCmdSetDrawColor(SDL_Renderer *renderer, const Uint8 r, const Uint8 g, const
|
||||
{
|
||||
const Uint32 color = ((a << 24) | (r << 16) | (g << 8) | b);
|
||||
int retval = 0;
|
||||
|
||||
|
||||
if (!renderer->color_queued || (color != renderer->last_queued_color)) {
|
||||
SDL_RenderCommand *cmd = AllocateRenderCommand(renderer);
|
||||
retval = -1;
|
||||
@@ -640,7 +660,7 @@ SDL_RendererEventWatch(void *userdata, SDL_Event *event)
|
||||
}
|
||||
} else if (event->window.event == SDL_WINDOWEVENT_MINIMIZED) {
|
||||
renderer->hidden = SDL_TRUE;
|
||||
} else if (event->window.event == SDL_WINDOWEVENT_RESTORED ||
|
||||
} else if (event->window.event == SDL_WINDOWEVENT_RESTORED ||
|
||||
event->window.event == SDL_WINDOWEVENT_MAXIMIZED) {
|
||||
if (!(SDL_GetWindowFlags(window) & SDL_WINDOW_HIDDEN)) {
|
||||
renderer->hidden = SDL_FALSE;
|
||||
@@ -687,7 +707,7 @@ SDL_RendererEventWatch(void *userdata, SDL_Event *event)
|
||||
event->button.x = (int)(event->button.x / (scale.x * renderer->dpi_scale.x));
|
||||
event->button.y = (int)(event->button.y / (scale.y * renderer->dpi_scale.y));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (event->type == SDL_FINGERDOWN ||
|
||||
event->type == SDL_FINGERUP ||
|
||||
event->type == SDL_FINGERMOTION) {
|
||||
@@ -1066,6 +1086,7 @@ SDL_Texture *
|
||||
SDL_CreateTexture(SDL_Renderer * renderer, Uint32 format, int access, int w, int h)
|
||||
{
|
||||
SDL_Texture *texture;
|
||||
SDL_bool texture_is_fourcc_and_target;
|
||||
|
||||
CHECK_RENDERER_MAGIC(renderer, NULL);
|
||||
|
||||
@@ -1111,15 +1132,24 @@ SDL_CreateTexture(SDL_Renderer * renderer, Uint32 format, int access, int w, int
|
||||
}
|
||||
renderer->textures = texture;
|
||||
|
||||
if (IsSupportedFormat(renderer, format)) {
|
||||
/* FOURCC format cannot be used directly by renderer back-ends for target texture */
|
||||
texture_is_fourcc_and_target = (access == SDL_TEXTUREACCESS_TARGET && SDL_ISPIXELFORMAT_FOURCC(texture->format));
|
||||
|
||||
if (texture_is_fourcc_and_target == SDL_FALSE && IsSupportedFormat(renderer, format)) {
|
||||
if (renderer->CreateTexture(renderer, texture) < 0) {
|
||||
SDL_DestroyTexture(texture);
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
texture->native = SDL_CreateTexture(renderer,
|
||||
GetClosestSupportedFormat(renderer, format),
|
||||
access, w, h);
|
||||
int closest_format;
|
||||
|
||||
if (texture_is_fourcc_and_target == SDL_FALSE) {
|
||||
closest_format = GetClosestSupportedFormat(renderer, format);
|
||||
} else {
|
||||
closest_format = renderer->info.texture_formats[0];
|
||||
}
|
||||
|
||||
texture->native = SDL_CreateTexture(renderer, closest_format, access, w, h);
|
||||
if (!texture->native) {
|
||||
SDL_DestroyTexture(texture);
|
||||
return NULL;
|
||||
@@ -1540,7 +1570,7 @@ int
|
||||
SDL_UpdateTexture(SDL_Texture * texture, const SDL_Rect * rect,
|
||||
const void *pixels, int pitch)
|
||||
{
|
||||
SDL_Rect full_rect;
|
||||
SDL_Rect real_rect;
|
||||
|
||||
CHECK_TEXTURE_MAGIC(texture, -1);
|
||||
|
||||
@@ -1551,28 +1581,30 @@ SDL_UpdateTexture(SDL_Texture * texture, const SDL_Rect * rect,
|
||||
return SDL_InvalidParamError("pitch");
|
||||
}
|
||||
|
||||
if (!rect) {
|
||||
full_rect.x = 0;
|
||||
full_rect.y = 0;
|
||||
full_rect.w = texture->w;
|
||||
full_rect.h = texture->h;
|
||||
rect = &full_rect;
|
||||
real_rect.x = 0;
|
||||
real_rect.y = 0;
|
||||
real_rect.w = texture->w;
|
||||
real_rect.h = texture->h;
|
||||
if (rect) {
|
||||
if (!SDL_IntersectRect(rect, &real_rect, &real_rect)) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ((rect->w == 0) || (rect->h == 0)) {
|
||||
if (real_rect.w == 0 || real_rect.h == 0) {
|
||||
return 0; /* nothing to do. */
|
||||
#if SDL_HAVE_YUV
|
||||
} else if (texture->yuv) {
|
||||
return SDL_UpdateTextureYUV(texture, rect, pixels, pitch);
|
||||
return SDL_UpdateTextureYUV(texture, &real_rect, pixels, pitch);
|
||||
#endif
|
||||
} else if (texture->native) {
|
||||
return SDL_UpdateTextureNative(texture, rect, pixels, pitch);
|
||||
return SDL_UpdateTextureNative(texture, &real_rect, pixels, pitch);
|
||||
} else {
|
||||
SDL_Renderer *renderer = texture->renderer;
|
||||
if (FlushRenderCommandsIfTextureNeeded(texture) < 0) {
|
||||
return -1;
|
||||
}
|
||||
return renderer->UpdateTexture(renderer, texture, rect, pixels, pitch);
|
||||
return renderer->UpdateTexture(renderer, texture, &real_rect, pixels, pitch);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1628,6 +1660,59 @@ SDL_UpdateTextureYUVPlanar(SDL_Texture * texture, const SDL_Rect * rect,
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SDL_UpdateTextureNVPlanar(SDL_Texture * texture, const SDL_Rect * rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *UVplane, int UVpitch)
|
||||
{
|
||||
SDL_Texture *native = texture->native;
|
||||
SDL_Rect full_rect;
|
||||
|
||||
if (SDL_SW_UpdateNVTexturePlanar(texture->yuv, rect, Yplane, Ypitch, UVplane, UVpitch) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
full_rect.x = 0;
|
||||
full_rect.y = 0;
|
||||
full_rect.w = texture->w;
|
||||
full_rect.h = texture->h;
|
||||
rect = &full_rect;
|
||||
|
||||
if (!rect->w || !rect->h) {
|
||||
return 0; /* nothing to do. */
|
||||
}
|
||||
|
||||
if (texture->access == SDL_TEXTUREACCESS_STREAMING) {
|
||||
/* We can lock the texture and copy to it */
|
||||
void *native_pixels = NULL;
|
||||
int native_pitch = 0;
|
||||
|
||||
if (SDL_LockTexture(native, rect, &native_pixels, &native_pitch) < 0) {
|
||||
return -1;
|
||||
}
|
||||
SDL_SW_CopyYUVToRGB(texture->yuv, rect, native->format,
|
||||
rect->w, rect->h, native_pixels, native_pitch);
|
||||
SDL_UnlockTexture(native);
|
||||
} else {
|
||||
/* Use a temporary buffer for updating */
|
||||
const int temp_pitch = (((rect->w * SDL_BYTESPERPIXEL(native->format)) + 3) & ~3);
|
||||
const size_t alloclen = rect->h * temp_pitch;
|
||||
if (alloclen > 0) {
|
||||
void *temp_pixels = SDL_malloc(alloclen);
|
||||
if (!temp_pixels) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
SDL_SW_CopyYUVToRGB(texture->yuv, rect, native->format,
|
||||
rect->w, rect->h, temp_pixels, temp_pitch);
|
||||
SDL_UpdateTexture(native, rect, temp_pixels, temp_pitch);
|
||||
SDL_free(temp_pixels);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#endif /* SDL_HAVE_YUV */
|
||||
|
||||
int SDL_UpdateYUVTexture(SDL_Texture * texture, const SDL_Rect * rect,
|
||||
@@ -1637,7 +1722,7 @@ int SDL_UpdateYUVTexture(SDL_Texture * texture, const SDL_Rect * rect,
|
||||
{
|
||||
#if SDL_HAVE_YUV
|
||||
SDL_Renderer *renderer;
|
||||
SDL_Rect full_rect;
|
||||
SDL_Rect real_rect;
|
||||
|
||||
CHECK_TEXTURE_MAGIC(texture, -1);
|
||||
|
||||
@@ -1665,20 +1750,20 @@ int SDL_UpdateYUVTexture(SDL_Texture * texture, const SDL_Rect * rect,
|
||||
return SDL_SetError("Texture format must by YV12 or IYUV");
|
||||
}
|
||||
|
||||
if (!rect) {
|
||||
full_rect.x = 0;
|
||||
full_rect.y = 0;
|
||||
full_rect.w = texture->w;
|
||||
full_rect.h = texture->h;
|
||||
rect = &full_rect;
|
||||
real_rect.x = 0;
|
||||
real_rect.y = 0;
|
||||
real_rect.w = texture->w;
|
||||
real_rect.h = texture->h;
|
||||
if (rect) {
|
||||
SDL_IntersectRect(rect, &real_rect, &real_rect);
|
||||
}
|
||||
|
||||
if (!rect->w || !rect->h) {
|
||||
if (real_rect.w == 0 || real_rect.h == 0) {
|
||||
return 0; /* nothing to do. */
|
||||
}
|
||||
|
||||
if (texture->yuv) {
|
||||
return SDL_UpdateTextureYUVPlanar(texture, rect, Yplane, Ypitch, Uplane, Upitch, Vplane, Vpitch);
|
||||
return SDL_UpdateTextureYUVPlanar(texture, &real_rect, Yplane, Ypitch, Uplane, Upitch, Vplane, Vpitch);
|
||||
} else {
|
||||
SDL_assert(!texture->native);
|
||||
renderer = texture->renderer;
|
||||
@@ -1687,7 +1772,7 @@ int SDL_UpdateYUVTexture(SDL_Texture * texture, const SDL_Rect * rect,
|
||||
if (FlushRenderCommandsIfTextureNeeded(texture) < 0) {
|
||||
return -1;
|
||||
}
|
||||
return renderer->UpdateTextureYUV(renderer, texture, rect, Yplane, Ypitch, Uplane, Upitch, Vplane, Vpitch);
|
||||
return renderer->UpdateTextureYUV(renderer, texture, &real_rect, Yplane, Ypitch, Uplane, Upitch, Vplane, Vpitch);
|
||||
} else {
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
@@ -1697,6 +1782,68 @@ int SDL_UpdateYUVTexture(SDL_Texture * texture, const SDL_Rect * rect,
|
||||
#endif
|
||||
}
|
||||
|
||||
int SDL_UpdateNVTexture(SDL_Texture * texture, const SDL_Rect * rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *UVplane, int UVpitch)
|
||||
{
|
||||
#if SDL_HAVE_YUV
|
||||
SDL_Renderer *renderer;
|
||||
SDL_Rect real_rect;
|
||||
|
||||
CHECK_TEXTURE_MAGIC(texture, -1);
|
||||
|
||||
if (!Yplane) {
|
||||
return SDL_InvalidParamError("Yplane");
|
||||
}
|
||||
if (!Ypitch) {
|
||||
return SDL_InvalidParamError("Ypitch");
|
||||
}
|
||||
if (!UVplane) {
|
||||
return SDL_InvalidParamError("UVplane");
|
||||
}
|
||||
if (!UVpitch) {
|
||||
return SDL_InvalidParamError("UVpitch");
|
||||
}
|
||||
|
||||
if (texture->format != SDL_PIXELFORMAT_NV12 &&
|
||||
texture->format != SDL_PIXELFORMAT_NV21) {
|
||||
return SDL_SetError("Texture format must by NV12 or NV21");
|
||||
}
|
||||
|
||||
real_rect.x = 0;
|
||||
real_rect.y = 0;
|
||||
real_rect.w = texture->w;
|
||||
real_rect.h = texture->h;
|
||||
if (rect) {
|
||||
SDL_IntersectRect(rect, &real_rect, &real_rect);
|
||||
}
|
||||
|
||||
if (real_rect.w == 0 || real_rect.h == 0) {
|
||||
return 0; /* nothing to do. */
|
||||
}
|
||||
|
||||
if (texture->yuv) {
|
||||
return SDL_UpdateTextureNVPlanar(texture, &real_rect, Yplane, Ypitch, UVplane, UVpitch);
|
||||
} else {
|
||||
SDL_assert(!texture->native);
|
||||
renderer = texture->renderer;
|
||||
SDL_assert(renderer->UpdateTextureNV);
|
||||
if (renderer->UpdateTextureNV) {
|
||||
if (FlushRenderCommandsIfTextureNeeded(texture) < 0) {
|
||||
return -1;
|
||||
}
|
||||
return renderer->UpdateTextureNV(renderer, texture, &real_rect, Yplane, Ypitch, UVplane, UVpitch);
|
||||
} else {
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
}
|
||||
#else
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if SDL_HAVE_YUV
|
||||
static int
|
||||
SDL_LockTextureYUV(SDL_Texture * texture, const SDL_Rect * rect,
|
||||
@@ -1775,7 +1922,6 @@ SDL_LockTextureToSurface(SDL_Texture *texture, const SDL_Rect *rect,
|
||||
real_rect.y = 0;
|
||||
real_rect.w = texture->w;
|
||||
real_rect.h = texture->h;
|
||||
|
||||
if (rect) {
|
||||
SDL_IntersectRect(rect, &real_rect, &real_rect);
|
||||
}
|
||||
@@ -2007,9 +2153,9 @@ UpdateLogicalSize(SDL_Renderer *renderer)
|
||||
} else {
|
||||
scale = (float)(h / renderer->logical_h);
|
||||
}
|
||||
viewport.w = (int)SDL_ceil(renderer->logical_w * scale);
|
||||
viewport.w = (int)SDL_floor(renderer->logical_w * scale);
|
||||
viewport.x = (w - viewport.w) / 2;
|
||||
viewport.h = (int)SDL_ceil(renderer->logical_h * scale);
|
||||
viewport.h = (int)SDL_floor(renderer->logical_h * scale);
|
||||
viewport.y = (h - viewport.h) / 2;
|
||||
|
||||
SDL_RenderSetViewport(renderer, &viewport);
|
||||
@@ -2026,7 +2172,7 @@ UpdateLogicalSize(SDL_Renderer *renderer)
|
||||
scale = (float)h / renderer->logical_h;
|
||||
viewport.y = 0;
|
||||
viewport.h = h;
|
||||
viewport.w = (int)SDL_ceil(renderer->logical_w * scale);
|
||||
viewport.w = (int)SDL_floor(renderer->logical_w * scale);
|
||||
viewport.x = (w - viewport.w) / 2;
|
||||
SDL_RenderSetViewport(renderer, &viewport);
|
||||
} else {
|
||||
@@ -2034,7 +2180,7 @@ UpdateLogicalSize(SDL_Renderer *renderer)
|
||||
scale = (float)w / renderer->logical_w;
|
||||
viewport.x = 0;
|
||||
viewport.w = w;
|
||||
viewport.h = (int)SDL_ceil(renderer->logical_h * scale);
|
||||
viewport.h = (int)SDL_floor(renderer->logical_h * scale);
|
||||
viewport.y = (h - viewport.h) / 2;
|
||||
SDL_RenderSetViewport(renderer, &viewport);
|
||||
}
|
||||
@@ -2047,7 +2193,7 @@ UpdateLogicalSize(SDL_Renderer *renderer)
|
||||
scale = (float)w / renderer->logical_w;
|
||||
viewport.x = 0;
|
||||
viewport.w = w;
|
||||
viewport.h = (int)SDL_ceil(renderer->logical_h * scale);
|
||||
viewport.h = (int)SDL_floor(renderer->logical_h * scale);
|
||||
viewport.y = (h - viewport.h) / 2;
|
||||
SDL_RenderSetViewport(renderer, &viewport);
|
||||
} else {
|
||||
@@ -2055,7 +2201,7 @@ UpdateLogicalSize(SDL_Renderer *renderer)
|
||||
scale = (float)h / renderer->logical_h;
|
||||
viewport.y = 0;
|
||||
viewport.h = h;
|
||||
viewport.w = (int)SDL_ceil(renderer->logical_w * scale);
|
||||
viewport.w = (int)SDL_floor(renderer->logical_w * scale);
|
||||
viewport.x = (w - viewport.w) / 2;
|
||||
SDL_RenderSetViewport(renderer, &viewport);
|
||||
}
|
||||
@@ -2127,8 +2273,8 @@ SDL_RenderSetViewport(SDL_Renderer * renderer, const SDL_Rect * rect)
|
||||
if (rect) {
|
||||
renderer->viewport.x = (int)SDL_floor(rect->x * renderer->scale.x);
|
||||
renderer->viewport.y = (int)SDL_floor(rect->y * renderer->scale.y);
|
||||
renderer->viewport.w = (int)SDL_ceil(rect->w * renderer->scale.x);
|
||||
renderer->viewport.h = (int)SDL_ceil(rect->h * renderer->scale.y);
|
||||
renderer->viewport.w = (int)SDL_floor(rect->w * renderer->scale.x);
|
||||
renderer->viewport.h = (int)SDL_floor(rect->h * renderer->scale.y);
|
||||
} else {
|
||||
renderer->viewport.x = 0;
|
||||
renderer->viewport.y = 0;
|
||||
@@ -2153,6 +2299,15 @@ SDL_RenderGetViewport(SDL_Renderer * renderer, SDL_Rect * rect)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
RenderGetViewportSize(SDL_Renderer * renderer, SDL_FRect * rect)
|
||||
{
|
||||
rect->x = 0.0f;
|
||||
rect->y = 0.0f;
|
||||
rect->w = renderer->viewport.w / renderer->scale.x;
|
||||
rect->h = renderer->viewport.h / renderer->scale.y;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_RenderSetClipRect(SDL_Renderer * renderer, const SDL_Rect * rect)
|
||||
{
|
||||
@@ -2163,8 +2318,8 @@ SDL_RenderSetClipRect(SDL_Renderer * renderer, const SDL_Rect * rect)
|
||||
renderer->clipping_enabled = SDL_TRUE;
|
||||
renderer->clip_rect.x = (int)SDL_floor(rect->x * renderer->scale.x);
|
||||
renderer->clip_rect.y = (int)SDL_floor(rect->y * renderer->scale.y);
|
||||
renderer->clip_rect.w = (int)SDL_ceil(rect->w * renderer->scale.x);
|
||||
renderer->clip_rect.h = (int)SDL_ceil(rect->h * renderer->scale.y);
|
||||
renderer->clip_rect.w = (int)SDL_floor(rect->w * renderer->scale.x);
|
||||
renderer->clip_rect.h = (int)SDL_floor(rect->h * renderer->scale.y);
|
||||
} else {
|
||||
renderer->clipping_enabled = SDL_FALSE;
|
||||
SDL_zero(renderer->clip_rect);
|
||||
@@ -2348,10 +2503,12 @@ SDL_RenderDrawPoints(SDL_Renderer * renderer,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if DONT_DRAW_WHILE_HIDDEN
|
||||
/* Don't draw while we're hidden */
|
||||
if (renderer->hidden) {
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (renderer->scale.x != 1.0f || renderer->scale.y != 1.0f) {
|
||||
return RenderDrawPointsWithRects(renderer, points, count);
|
||||
@@ -2418,10 +2575,12 @@ SDL_RenderDrawPointsF(SDL_Renderer * renderer,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if DONT_DRAW_WHILE_HIDDEN
|
||||
/* Don't draw while we're hidden */
|
||||
if (renderer->hidden) {
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (renderer->scale.x != 1.0f || renderer->scale.y != 1.0f) {
|
||||
return RenderDrawPointsWithRectsF(renderer, points, count);
|
||||
@@ -2593,10 +2752,12 @@ SDL_RenderDrawLines(SDL_Renderer * renderer,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if DONT_DRAW_WHILE_HIDDEN
|
||||
/* Don't draw while we're hidden */
|
||||
if (renderer->hidden) {
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (renderer->scale.x != 1.0f || renderer->scale.y != 1.0f) {
|
||||
return RenderDrawLinesWithRects(renderer, points, count);
|
||||
@@ -2636,10 +2797,12 @@ SDL_RenderDrawLinesF(SDL_Renderer * renderer,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if DONT_DRAW_WHILE_HIDDEN
|
||||
/* Don't draw while we're hidden */
|
||||
if (renderer->hidden) {
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (renderer->scale.x != 1.0f || renderer->scale.y != 1.0f) {
|
||||
return RenderDrawLinesWithRectsF(renderer, points, count);
|
||||
@@ -2688,12 +2851,7 @@ SDL_RenderDrawRectF(SDL_Renderer * renderer, const SDL_FRect * rect)
|
||||
|
||||
/* If 'rect' == NULL, then outline the whole surface */
|
||||
if (!rect) {
|
||||
SDL_Rect r;
|
||||
SDL_RenderGetViewport(renderer, &r);
|
||||
frect.x = 0.0f;
|
||||
frect.y = 0.0f;
|
||||
frect.w = (float) r.w;
|
||||
frect.h = (float) r.h;
|
||||
RenderGetViewportSize(renderer, &frect);
|
||||
rect = &frect;
|
||||
}
|
||||
|
||||
@@ -2725,10 +2883,12 @@ SDL_RenderDrawRects(SDL_Renderer * renderer,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if DONT_DRAW_WHILE_HIDDEN
|
||||
/* Don't draw while we're hidden */
|
||||
if (renderer->hidden) {
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
for (i = 0; i < count; ++i) {
|
||||
if (SDL_RenderDrawRect(renderer, &rects[i]) < 0) {
|
||||
@@ -2753,10 +2913,12 @@ SDL_RenderDrawRectsF(SDL_Renderer * renderer,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if DONT_DRAW_WHILE_HIDDEN
|
||||
/* Don't draw while we're hidden */
|
||||
if (renderer->hidden) {
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
for (i = 0; i < count; ++i) {
|
||||
if (SDL_RenderDrawRectF(renderer, &rects[i]) < 0) {
|
||||
@@ -2780,13 +2942,7 @@ SDL_RenderFillRect(SDL_Renderer * renderer, const SDL_Rect * rect)
|
||||
frect.w = (float) rect->w;
|
||||
frect.h = (float) rect->h;
|
||||
} else {
|
||||
SDL_Rect r;
|
||||
SDL_zero(r);
|
||||
SDL_RenderGetViewport(renderer, &r);
|
||||
frect.x = 0.0f;
|
||||
frect.y = 0.0f;
|
||||
frect.w = (float) r.w;
|
||||
frect.h = (float) r.h;
|
||||
RenderGetViewportSize(renderer, &frect);
|
||||
}
|
||||
return SDL_RenderFillRectsF(renderer, &frect, 1);
|
||||
}
|
||||
@@ -2800,13 +2956,7 @@ SDL_RenderFillRectF(SDL_Renderer * renderer, const SDL_FRect * rect)
|
||||
|
||||
/* If 'rect' == NULL, then outline the whole surface */
|
||||
if (!rect) {
|
||||
SDL_Rect r;
|
||||
SDL_zero(r);
|
||||
SDL_RenderGetViewport(renderer, &r);
|
||||
frect.x = 0.0f;
|
||||
frect.y = 0.0f;
|
||||
frect.w = (float) r.w;
|
||||
frect.h = (float) r.h;
|
||||
RenderGetViewportSize(renderer, &frect);
|
||||
rect = &frect;
|
||||
}
|
||||
return SDL_RenderFillRectsF(renderer, rect, 1);
|
||||
@@ -2830,10 +2980,12 @@ SDL_RenderFillRects(SDL_Renderer * renderer,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if DONT_DRAW_WHILE_HIDDEN
|
||||
/* Don't draw while we're hidden */
|
||||
if (renderer->hidden) {
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
frects = SDL_small_alloc(SDL_FRect, count, &isstack);
|
||||
if (!frects) {
|
||||
@@ -2871,10 +3023,12 @@ SDL_RenderFillRectsF(SDL_Renderer * renderer,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if DONT_DRAW_WHILE_HIDDEN
|
||||
/* Don't draw while we're hidden */
|
||||
if (renderer->hidden) {
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
frects = SDL_small_alloc(SDL_FRect, count, &isstack);
|
||||
if (!frects) {
|
||||
@@ -2970,7 +3124,6 @@ SDL_RenderCopyF(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
{
|
||||
SDL_Rect real_srcrect;
|
||||
SDL_FRect real_dstrect;
|
||||
SDL_Rect r;
|
||||
int retval;
|
||||
|
||||
CHECK_RENDERER_MAGIC(renderer, -1);
|
||||
@@ -2980,10 +3133,12 @@ SDL_RenderCopyF(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
return SDL_SetError("Texture was not created with this renderer");
|
||||
}
|
||||
|
||||
#if DONT_DRAW_WHILE_HIDDEN
|
||||
/* Don't draw while we're hidden */
|
||||
if (renderer->hidden) {
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
real_srcrect.x = 0;
|
||||
real_srcrect.y = 0;
|
||||
@@ -2995,12 +3150,7 @@ SDL_RenderCopyF(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
}
|
||||
}
|
||||
|
||||
SDL_zero(r);
|
||||
SDL_RenderGetViewport(renderer, &r);
|
||||
real_dstrect.x = 0.0f;
|
||||
real_dstrect.y = 0.0f;
|
||||
real_dstrect.w = (float) r.w;
|
||||
real_dstrect.h = (float) r.h;
|
||||
RenderGetViewportSize(renderer, &real_dstrect);
|
||||
if (dstrect) {
|
||||
if (!SDL_HasIntersectionF(dstrect, &real_dstrect)) {
|
||||
return 0;
|
||||
@@ -3074,10 +3224,12 @@ SDL_RenderCopyExF(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
return SDL_SetError("Renderer does not support RenderCopyEx");
|
||||
}
|
||||
|
||||
#if DONT_DRAW_WHILE_HIDDEN
|
||||
/* Don't draw while we're hidden */
|
||||
if (renderer->hidden) {
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
real_srcrect.x = 0;
|
||||
real_srcrect.y = 0;
|
||||
@@ -3093,13 +3245,7 @@ SDL_RenderCopyExF(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
if (dstrect) {
|
||||
real_dstrect = *dstrect;
|
||||
} else {
|
||||
SDL_Rect r;
|
||||
SDL_zero(r);
|
||||
SDL_RenderGetViewport(renderer, &r);
|
||||
real_dstrect.x = 0.0f;
|
||||
real_dstrect.y = 0.0f;
|
||||
real_dstrect.w = (float) r.w;
|
||||
real_dstrect.h = (float) r.h;
|
||||
RenderGetViewportSize(renderer, &real_dstrect);
|
||||
}
|
||||
|
||||
if (texture->native) {
|
||||
@@ -3173,10 +3319,13 @@ SDL_RenderPresent(SDL_Renderer * renderer)
|
||||
|
||||
FlushRenderCommands(renderer); /* time to send everything to the GPU! */
|
||||
|
||||
#if DONT_DRAW_WHILE_HIDDEN
|
||||
/* Don't present while we're hidden */
|
||||
if (renderer->hidden) {
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
renderer->RenderPresent(renderer);
|
||||
}
|
||||
|
||||
|
13
externals/SDL/src/render/SDL_sysrender.h
vendored
13
externals/SDL/src/render/SDL_sysrender.h
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@@ -131,11 +131,17 @@ struct SDL_Renderer
|
||||
int (*UpdateTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect, const void *pixels,
|
||||
int pitch);
|
||||
#if SDL_HAVE_YUV
|
||||
int (*UpdateTextureYUV) (SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *Uplane, int Upitch,
|
||||
const Uint8 *Vplane, int Vpitch);
|
||||
int (*UpdateTextureNV) (SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *UVplane, int UVpitch);
|
||||
#endif
|
||||
int (*LockTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect, void **pixels, int *pitch);
|
||||
void (*UnlockTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
|
||||
@@ -244,6 +250,8 @@ extern SDL_RenderDriver DirectFB_RenderDriver;
|
||||
extern SDL_RenderDriver METAL_RenderDriver;
|
||||
extern SDL_RenderDriver PSP_RenderDriver;
|
||||
extern SDL_RenderDriver SW_RenderDriver;
|
||||
extern SDL_RenderDriver VITA_GLES2_RenderDriver;
|
||||
extern SDL_RenderDriver VITA_GXM_RenderDriver;
|
||||
|
||||
/* Blend mode functions */
|
||||
extern SDL_BlendFactor SDL_GetBlendModeSrcColorFactor(SDL_BlendMode blendMode);
|
||||
@@ -258,6 +266,9 @@ extern SDL_BlendOperation SDL_GetBlendModeAlphaOperation(SDL_BlendMode blendMode
|
||||
the next call, because it might be in an array that gets realloc()'d. */
|
||||
extern void *SDL_AllocateRenderVertices(SDL_Renderer *renderer, const size_t numbytes, const size_t alignment, size_t *offset);
|
||||
|
||||
extern int SDL_PrivateLowerBlitScaled(SDL_Surface * src, SDL_Rect * srcrect, SDL_Surface * dst, SDL_Rect * dstrect, SDL_ScaleMode scaleMode);
|
||||
extern int SDL_PrivateUpperBlitScaled(SDL_Surface * src, const SDL_Rect * srcrect, SDL_Surface * dst, SDL_Rect * dstrect, SDL_ScaleMode scaleMode);
|
||||
|
||||
#endif /* SDL_sysrender_h_ */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
41
externals/SDL/src/render/SDL_yuv_sw.c
vendored
41
externals/SDL/src/render/SDL_yuv_sw.c
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
|
||||
#include "SDL_yuv_sw_c.h"
|
||||
#include "SDL_cpuinfo.h"
|
||||
|
||||
|
||||
SDL_SW_YUVTexture *
|
||||
@@ -84,7 +85,7 @@ SDL_SW_CreateYUVTexture(Uint32 format, int w, int h)
|
||||
SDL_assert(0 && "We should never get here (caught above)");
|
||||
break;
|
||||
}
|
||||
swdata->pixels = (Uint8 *) SDL_malloc(dst_size);
|
||||
swdata->pixels = (Uint8 *) SDL_SIMDAlloc(dst_size);
|
||||
if (!swdata->pixels) {
|
||||
SDL_SW_DestroyYUVTexture(swdata);
|
||||
SDL_OutOfMemory();
|
||||
@@ -299,6 +300,40 @@ SDL_SW_UpdateYUVTexturePlanar(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SDL_SW_UpdateNVTexturePlanar(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *UVplane, int UVpitch)
|
||||
{
|
||||
const Uint8 *src;
|
||||
Uint8 *dst;
|
||||
int row;
|
||||
size_t length;
|
||||
|
||||
/* Copy the Y plane */
|
||||
src = Yplane;
|
||||
dst = swdata->pixels + rect->y * swdata->w + rect->x;
|
||||
length = rect->w;
|
||||
for (row = 0; row < rect->h; ++row) {
|
||||
SDL_memcpy(dst, src, length);
|
||||
src += Ypitch;
|
||||
dst += swdata->w;
|
||||
}
|
||||
|
||||
/* Copy the UV or VU plane */
|
||||
src = UVplane;
|
||||
dst = swdata->pixels + swdata->h * swdata->w;
|
||||
dst += rect->y * ((swdata->w + 1)/2) + rect->x;
|
||||
length = (rect->w + 1) / 2;
|
||||
length *= 2;
|
||||
for (row = 0; row < (rect->h + 1)/2; ++row) {
|
||||
SDL_memcpy(dst, src, length);
|
||||
src += UVpitch;
|
||||
dst += 2 * ((swdata->w + 1)/2);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SW_LockYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect,
|
||||
void **pixels, int *pitch)
|
||||
@@ -405,7 +440,7 @@ void
|
||||
SDL_SW_DestroyYUVTexture(SDL_SW_YUVTexture * swdata)
|
||||
{
|
||||
if (swdata) {
|
||||
SDL_free(swdata->pixels);
|
||||
SDL_SIMDFree(swdata->pixels);
|
||||
SDL_FreeSurface(swdata->stretch);
|
||||
SDL_FreeSurface(swdata->display);
|
||||
SDL_free(swdata);
|
||||
|
10
externals/SDL/src/render/SDL_yuv_sw_c.h
vendored
10
externals/SDL/src/render/SDL_yuv_sw_c.h
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@@ -55,6 +55,9 @@ int SDL_SW_UpdateYUVTexturePlanar(SDL_SW_YUVTexture * swdata, const SDL_Rect * r
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *Uplane, int Upitch,
|
||||
const Uint8 *Vplane, int Vpitch);
|
||||
int SDL_SW_UpdateNVTexturePlanar(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *UVplane, int UVpitch);
|
||||
int SDL_SW_LockYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect,
|
||||
void **pixels, int *pitch);
|
||||
void SDL_SW_UnlockYUVTexture(SDL_SW_YUVTexture * swdata);
|
||||
@@ -63,11 +66,6 @@ int SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture * swdata, const SDL_Rect * srcrect,
|
||||
int pitch);
|
||||
void SDL_SW_DestroyYUVTexture(SDL_SW_YUVTexture * swdata);
|
||||
|
||||
/* FIXME: This breaks on various versions of GCC and should be rewritten using intrinsics */
|
||||
#if 0 /* (__GNUC__ > 2) && defined(__i386__) && __OPTIMIZE__ && SDL_ASSEMBLY_ROUTINES && !defined(__clang__) */
|
||||
#define USE_MMX_ASSEMBLY 1
|
||||
#endif
|
||||
|
||||
#endif /* SDL_yuv_sw_c_h_ */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@@ -610,6 +610,7 @@ D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if SDL_HAVE_YUV
|
||||
static int
|
||||
D3D_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect,
|
||||
@@ -636,6 +637,7 @@ D3D_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int
|
||||
D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
@@ -1710,7 +1712,9 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||
renderer->SupportsBlendMode = D3D_SupportsBlendMode;
|
||||
renderer->CreateTexture = D3D_CreateTexture;
|
||||
renderer->UpdateTexture = D3D_UpdateTexture;
|
||||
#if SDL_HAVE_YUV
|
||||
renderer->UpdateTextureYUV = D3D_UpdateTextureYUV;
|
||||
#endif
|
||||
renderer->LockTexture = D3D_LockTexture;
|
||||
renderer->UnlockTexture = D3D_UnlockTexture;
|
||||
renderer->SetTextureScaleMode = D3D_SetTextureScaleMode;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@@ -20,6 +20,9 @@
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#include "SDL_render.h"
|
||||
#include "SDL_system.h"
|
||||
|
||||
#if SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED
|
||||
|
||||
#define COBJMACROS
|
||||
@@ -51,7 +54,11 @@ extern ISwapChainBackgroundPanelNative * WINRT_GlobalSwapChainBackgroundPanelNat
|
||||
#endif /* __WINRT__ */
|
||||
|
||||
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
#define SDL_COMPOSE_ERROR(str) __FUNCTION__ ", " str
|
||||
#else
|
||||
#define SDL_COMPOSE_ERROR(str) SDL_STRINGIFY_ARG(__FUNCTION__) ", " str
|
||||
#endif
|
||||
|
||||
#define SAFE_RELEASE(X) if ((X)) { IUnknown_Release(SDL_static_cast(IUnknown*, X)); X = NULL; }
|
||||
|
||||
@@ -1240,6 +1247,8 @@ D3D11_DestroyTexture(SDL_Renderer * renderer,
|
||||
SAFE_RELEASE(data->mainTextureResourceViewU);
|
||||
SAFE_RELEASE(data->mainTextureV);
|
||||
SAFE_RELEASE(data->mainTextureResourceViewV);
|
||||
SAFE_RELEASE(data->mainTextureNV);
|
||||
SAFE_RELEASE(data->mainTextureResourceViewNV);
|
||||
SDL_free(data->pixels);
|
||||
SDL_free(data);
|
||||
texture->driverdata = NULL;
|
||||
@@ -1371,6 +1380,7 @@ D3D11_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if SDL_HAVE_YUV
|
||||
static int
|
||||
D3D11_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect,
|
||||
@@ -1398,6 +1408,31 @@ D3D11_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
D3D11_UpdateTextureNV(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *UVplane, int UVpitch)
|
||||
{
|
||||
D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->driverdata;
|
||||
D3D11_TextureData *textureData = (D3D11_TextureData *)texture->driverdata;
|
||||
|
||||
if (!textureData) {
|
||||
SDL_SetError("Texture is not currently available");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (D3D11_UpdateTextureInternal(rendererData, textureData->mainTexture, SDL_BYTESPERPIXEL(texture->format), rect->x, rect->y, rect->w, rect->h, Yplane, Ypitch) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (D3D11_UpdateTextureInternal(rendererData, textureData->mainTextureNV, 2, rect->x / 2, rect->y / 2, ((rect->w + 1) / 2), (rect->h + 1) / 2, UVplane, UVpitch) < 0) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int
|
||||
D3D11_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect, void **pixels, int *pitch)
|
||||
@@ -2510,7 +2545,10 @@ D3D11_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||
renderer->SupportsBlendMode = D3D11_SupportsBlendMode;
|
||||
renderer->CreateTexture = D3D11_CreateTexture;
|
||||
renderer->UpdateTexture = D3D11_UpdateTexture;
|
||||
#if SDL_HAVE_YUV
|
||||
renderer->UpdateTextureYUV = D3D11_UpdateTextureYUV;
|
||||
renderer->UpdateTextureNV = D3D11_UpdateTextureNV;
|
||||
#endif
|
||||
renderer->LockTexture = D3D11_LockTexture;
|
||||
renderer->UnlockTexture = D3D11_UnlockTexture;
|
||||
renderer->SetTextureScaleMode = D3D11_SetTextureScaleMode;
|
||||
@@ -2593,4 +2631,30 @@ SDL_RenderDriver D3D11_RenderDriver = {
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED */
|
||||
|
||||
#ifdef __WIN32__
|
||||
/* This function needs to always exist on Windows, for the Dynamic API. */
|
||||
ID3D11Device *
|
||||
SDL_RenderGetD3D11Device(SDL_Renderer * renderer)
|
||||
{
|
||||
ID3D11Device *device = NULL;
|
||||
|
||||
#if SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED
|
||||
D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata;
|
||||
|
||||
/* Make sure that this is a D3D renderer */
|
||||
if (renderer->DestroyRenderer != D3D11_DestroyRenderer) {
|
||||
SDL_SetError("Renderer is not a D3D11 renderer");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
device = (ID3D11Device *)data->d3dDevice;
|
||||
if (device) {
|
||||
ID3D11Device_AddRef(device);
|
||||
}
|
||||
#endif /* SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED */
|
||||
|
||||
return device;
|
||||
}
|
||||
#endif /* __WIN32__ */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@@ -59,7 +59,7 @@ extern int SDL_RecreateWindow(SDL_Window * window, Uint32 flags);
|
||||
|
||||
/* macOS requires constants in a buffer to have a 256 byte alignment. */
|
||||
/* Use native type alignments from https://developer.apple.com/metal/Metal-Shading-Language-Specification.pdf */
|
||||
#if defined(__MACOSX__) || TARGET_OS_SIMULATOR
|
||||
#if defined(__MACOSX__) || TARGET_OS_SIMULATOR || TARGET_OS_MACCATALYST
|
||||
#define CONSTANT_ALIGN(x) (256)
|
||||
#else
|
||||
#define CONSTANT_ALIGN(x) (x < 4 ? 4 : x)
|
||||
@@ -803,6 +803,7 @@ METAL_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
return 0;
|
||||
}}
|
||||
|
||||
#if SDL_HAVE_YUV
|
||||
static int
|
||||
METAL_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect,
|
||||
@@ -835,6 +836,34 @@ METAL_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
return 0;
|
||||
}}
|
||||
|
||||
static int
|
||||
METAL_UpdateTextureNV(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *UVplane, int UVpitch)
|
||||
{ @autoreleasepool {
|
||||
METAL_TextureData *texturedata = (__bridge METAL_TextureData *)texture->driverdata;
|
||||
SDL_Rect UVrect = {rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2};
|
||||
|
||||
/* Bail out if we're supposed to update an empty rectangle */
|
||||
if (rect->w <= 0 || rect->h <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (METAL_UpdateTextureInternal(renderer, texturedata, texturedata.mtltexture, *rect, 0, Yplane, Ypitch) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (METAL_UpdateTextureInternal(renderer, texturedata, texturedata.mtltexture_uv, UVrect, 0, UVplane, UVpitch) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
texturedata.hasdata = YES;
|
||||
|
||||
return 0;
|
||||
}}
|
||||
#endif
|
||||
|
||||
static int
|
||||
METAL_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect, void **pixels, int *pitch)
|
||||
@@ -1850,7 +1879,10 @@ METAL_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||
renderer->SupportsBlendMode = METAL_SupportsBlendMode;
|
||||
renderer->CreateTexture = METAL_CreateTexture;
|
||||
renderer->UpdateTexture = METAL_UpdateTexture;
|
||||
#if SDL_HAVE_YUV
|
||||
renderer->UpdateTextureYUV = METAL_UpdateTextureYUV;
|
||||
renderer->UpdateTextureNV = METAL_UpdateTextureNV;
|
||||
#endif
|
||||
renderer->LockTexture = METAL_LockTexture;
|
||||
renderer->UnlockTexture = METAL_UnlockTexture;
|
||||
renderer->SetTextureScaleMode = METAL_SetTextureScaleMode;
|
||||
@@ -1875,7 +1907,7 @@ METAL_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||
|
||||
renderer->always_batch = SDL_TRUE;
|
||||
|
||||
#if defined(__MACOSX__) && defined(MAC_OS_X_VERSION_10_13)
|
||||
#if (defined(__MACOSX__) && defined(MAC_OS_X_VERSION_10_13)) || TARGET_OS_MACCATALYST
|
||||
if (@available(macOS 10.13, *)) {
|
||||
data.mtllayer.displaySyncEnabled = (flags & SDL_RENDERER_PRESENTVSYNC) != 0;
|
||||
if (data.mtllayer.displaySyncEnabled) {
|
||||
@@ -1889,7 +1921,7 @@ METAL_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||
|
||||
/* https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf */
|
||||
int maxtexsize = 4096;
|
||||
#if defined(__MACOSX__)
|
||||
#if defined(__MACOSX__) || TARGET_OS_MACCATALYST
|
||||
maxtexsize = 16384;
|
||||
#elif defined(__TVOS__)
|
||||
maxtexsize = 8192;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
61
externals/SDL/src/render/opengl/SDL_render_gl.c
vendored
61
externals/SDL/src/render/opengl/SDL_render_gl.c
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@@ -128,11 +128,13 @@ typedef struct
|
||||
int pitch;
|
||||
SDL_Rect locked_rect;
|
||||
|
||||
#if SDL_HAVE_YUV
|
||||
/* YUV texture support */
|
||||
SDL_bool yuv;
|
||||
SDL_bool nv12;
|
||||
GLuint utexture;
|
||||
GLuint vtexture;
|
||||
#endif
|
||||
|
||||
GL_FBOList *fbo;
|
||||
} GL_TextureData;
|
||||
@@ -577,6 +579,7 @@ GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
return -1;
|
||||
}
|
||||
|
||||
#if SDL_HAVE_YUV
|
||||
if (texture->format == SDL_PIXELFORMAT_YV12 ||
|
||||
texture->format == SDL_PIXELFORMAT_IYUV) {
|
||||
data->yuv = SDL_TRUE;
|
||||
@@ -626,6 +629,7 @@ GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
renderdata->glTexImage2D(textype, 0, GL_LUMINANCE_ALPHA, (texture_w+1)/2,
|
||||
(texture_h+1)/2, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
return GL_CheckError("", renderer);
|
||||
}
|
||||
@@ -651,6 +655,7 @@ GL_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
renderdata->glTexSubImage2D(textype, 0, rect->x, rect->y, rect->w,
|
||||
rect->h, data->format, data->formattype,
|
||||
pixels);
|
||||
#if SDL_HAVE_YUV
|
||||
if (data->yuv) {
|
||||
renderdata->glPixelStorei(GL_UNPACK_ROW_LENGTH, ((pitch + 1) / 2));
|
||||
|
||||
@@ -687,10 +692,11 @@ GL_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
(rect->w + 1)/2, (rect->h + 1)/2,
|
||||
GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, pixels);
|
||||
}
|
||||
|
||||
#endif
|
||||
return GL_CheckError("glTexSubImage2D()", renderer);
|
||||
}
|
||||
|
||||
#if SDL_HAVE_YUV
|
||||
static int
|
||||
GL_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect,
|
||||
@@ -728,6 +734,38 @@ GL_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
return GL_CheckError("glTexSubImage2D()", renderer);
|
||||
}
|
||||
|
||||
static int
|
||||
GL_UpdateTextureNV(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *UVplane, int UVpitch)
|
||||
{
|
||||
GL_RenderData *renderdata = (GL_RenderData *) renderer->driverdata;
|
||||
const GLenum textype = renderdata->textype;
|
||||
GL_TextureData *data = (GL_TextureData *) texture->driverdata;
|
||||
|
||||
GL_ActivateRenderer(renderer);
|
||||
|
||||
renderdata->drawstate.texture = NULL; /* we trash this state. */
|
||||
|
||||
renderdata->glBindTexture(textype, data->texture);
|
||||
renderdata->glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
renderdata->glPixelStorei(GL_UNPACK_ROW_LENGTH, Ypitch);
|
||||
renderdata->glTexSubImage2D(textype, 0, rect->x, rect->y, rect->w,
|
||||
rect->h, data->format, data->formattype,
|
||||
Yplane);
|
||||
|
||||
|
||||
renderdata->glPixelStorei(GL_UNPACK_ROW_LENGTH, UVpitch / 2);
|
||||
renderdata->glBindTexture(textype, data->utexture);
|
||||
renderdata->glTexSubImage2D(textype, 0, rect->x/2, rect->y/2,
|
||||
(rect->w + 1)/2, (rect->h + 1)/2,
|
||||
GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, UVplane);
|
||||
|
||||
return GL_CheckError("glTexSubImage2D()", renderer);
|
||||
}
|
||||
#endif
|
||||
|
||||
static int
|
||||
GL_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect, void **pixels, int *pitch)
|
||||
@@ -768,6 +806,7 @@ GL_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture, SDL_Scale
|
||||
renderdata->glTexParameteri(textype, GL_TEXTURE_MIN_FILTER, glScaleMode);
|
||||
renderdata->glTexParameteri(textype, GL_TEXTURE_MAG_FILTER, glScaleMode);
|
||||
|
||||
#if SDL_HAVE_YUV
|
||||
if (texture->format == SDL_PIXELFORMAT_YV12 ||
|
||||
texture->format == SDL_PIXELFORMAT_IYUV) {
|
||||
renderdata->glBindTexture(textype, data->utexture);
|
||||
@@ -785,6 +824,7 @@ GL_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture, SDL_Scale
|
||||
renderdata->glTexParameteri(textype, GL_TEXTURE_MIN_FILTER, glScaleMode);
|
||||
renderdata->glTexParameteri(textype, GL_TEXTURE_MAG_FILTER, glScaleMode);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -874,9 +914,9 @@ GL_QueueDrawLines(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPo
|
||||
const GLfloat yend = verts[3];
|
||||
|
||||
if (ystart == yend) { /* horizontal line */
|
||||
verts[2] += (xend > xstart) ? 1.0f : -1.0f;
|
||||
verts[(xend > xstart) ? 2 : 0] += 1.0f;
|
||||
} else if (xstart == xend) { /* vertical line */
|
||||
verts[3] += (yend > ystart) ? 1.0f : -1.0f;
|
||||
verts[(yend > ystart) ? 3 : 1] += 1.0f;
|
||||
} else { /* bump a pixel in the direction we are moving in. */
|
||||
const GLfloat deltax = xend - xstart;
|
||||
const GLfloat deltay = yend - ystart;
|
||||
@@ -1096,6 +1136,7 @@ SetCopyState(GL_RenderData *data, const SDL_RenderCommand *cmd)
|
||||
shader = SHADER_RGB;
|
||||
}
|
||||
|
||||
#if SDL_HAVE_YUV
|
||||
if (data->shaders) {
|
||||
if (texturedata->yuv || texturedata->nv12) {
|
||||
switch (SDL_GetYUVConversionModeForResolution(texture->w, texture->h)) {
|
||||
@@ -1132,11 +1173,13 @@ SetCopyState(GL_RenderData *data, const SDL_RenderCommand *cmd)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
SetDrawState(data, cmd, shader);
|
||||
|
||||
if (texture != data->drawstate.texture) {
|
||||
const GLenum textype = data->textype;
|
||||
#if SDL_HAVE_YUV
|
||||
if (texturedata->yuv) {
|
||||
data->glActiveTextureARB(GL_TEXTURE2_ARB);
|
||||
data->glBindTexture(textype, texturedata->vtexture);
|
||||
@@ -1148,6 +1191,7 @@ SetCopyState(GL_RenderData *data, const SDL_RenderCommand *cmd)
|
||||
data->glActiveTextureARB(GL_TEXTURE1_ARB);
|
||||
data->glBindTexture(textype, texturedata->utexture);
|
||||
}
|
||||
#endif
|
||||
data->glActiveTextureARB(GL_TEXTURE0_ARB);
|
||||
data->glBindTexture(textype, texturedata->texture);
|
||||
|
||||
@@ -1439,10 +1483,12 @@ GL_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
if (data->texture) {
|
||||
renderdata->glDeleteTextures(1, &data->texture);
|
||||
}
|
||||
#if SDL_HAVE_YUV
|
||||
if (data->yuv) {
|
||||
renderdata->glDeleteTextures(1, &data->utexture);
|
||||
renderdata->glDeleteTextures(1, &data->vtexture);
|
||||
}
|
||||
#endif
|
||||
SDL_free(data->pixels);
|
||||
SDL_free(data);
|
||||
texture->driverdata = NULL;
|
||||
@@ -1496,6 +1542,7 @@ GL_BindTexture (SDL_Renderer * renderer, SDL_Texture *texture, float *texw, floa
|
||||
GL_ActivateRenderer(renderer);
|
||||
|
||||
data->glEnable(textype);
|
||||
#if SDL_HAVE_YUV
|
||||
if (texturedata->yuv) {
|
||||
data->glActiveTextureARB(GL_TEXTURE2_ARB);
|
||||
data->glBindTexture(textype, texturedata->vtexture);
|
||||
@@ -1505,6 +1552,7 @@ GL_BindTexture (SDL_Renderer * renderer, SDL_Texture *texture, float *texw, floa
|
||||
|
||||
data->glActiveTextureARB(GL_TEXTURE0_ARB);
|
||||
}
|
||||
#endif
|
||||
data->glBindTexture(textype, texturedata->texture);
|
||||
|
||||
data->drawstate.texturing = SDL_TRUE;
|
||||
@@ -1525,6 +1573,7 @@ GL_UnbindTexture (SDL_Renderer * renderer, SDL_Texture *texture)
|
||||
|
||||
GL_ActivateRenderer(renderer);
|
||||
|
||||
#if SDL_HAVE_YUV
|
||||
if (texturedata->yuv) {
|
||||
data->glActiveTextureARB(GL_TEXTURE2_ARB);
|
||||
data->glDisable(textype);
|
||||
@@ -1534,6 +1583,7 @@ GL_UnbindTexture (SDL_Renderer * renderer, SDL_Texture *texture)
|
||||
|
||||
data->glActiveTextureARB(GL_TEXTURE0_ARB);
|
||||
}
|
||||
#endif
|
||||
|
||||
data->glDisable(textype);
|
||||
|
||||
@@ -1589,7 +1639,10 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||
renderer->SupportsBlendMode = GL_SupportsBlendMode;
|
||||
renderer->CreateTexture = GL_CreateTexture;
|
||||
renderer->UpdateTexture = GL_UpdateTexture;
|
||||
#if SDL_HAVE_YUV
|
||||
renderer->UpdateTextureYUV = GL_UpdateTextureYUV;
|
||||
renderer->UpdateTextureNV = GL_UpdateTextureNV;
|
||||
#endif
|
||||
renderer->LockTexture = GL_LockTexture;
|
||||
renderer->UnlockTexture = GL_UnlockTexture;
|
||||
renderer->SetTextureScaleMode = GL_SetTextureScaleMode;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@@ -587,9 +587,9 @@ GLES_QueueDrawLines(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_F
|
||||
const GLfloat yend = verts[3];
|
||||
|
||||
if (ystart == yend) { /* horizontal line */
|
||||
verts[2] += (xend > xstart) ? 1.0f : -1.0f;
|
||||
verts[(xend > xstart) ? 2 : 0] += 1.0f;
|
||||
} else if (xstart == xend) { /* vertical line */
|
||||
verts[3] += (yend > ystart) ? 1.0f : -1.0f;
|
||||
verts[(yend > ystart) ? 3 : 1] += 1.0f;
|
||||
} else { /* bump a pixel in the direction we are moving in. */
|
||||
const GLfloat deltax = xend - xstart;
|
||||
const GLfloat deltay = yend - ystart;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@@ -41,7 +41,6 @@ SDL_PROC(void, glEnableVertexAttribArray, (GLuint))
|
||||
SDL_PROC(void, glFinish, (void))
|
||||
SDL_PROC(void, glGenFramebuffers, (GLsizei, GLuint *))
|
||||
SDL_PROC(void, glGenTextures, (GLsizei, GLuint *))
|
||||
SDL_PROC(void, glGetBooleanv, (GLenum, GLboolean *))
|
||||
SDL_PROC(const GLubyte *, glGetString, (GLenum))
|
||||
SDL_PROC(GLenum, glGetError, (void))
|
||||
SDL_PROC(void, glGetIntegerv, (GLenum, GLint *))
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@@ -58,35 +58,21 @@ typedef struct GLES2_TextureData
|
||||
GLenum pixel_type;
|
||||
void *pixel_data;
|
||||
int pitch;
|
||||
#if SDL_HAVE_YUV
|
||||
/* YUV texture support */
|
||||
SDL_bool yuv;
|
||||
SDL_bool nv12;
|
||||
GLenum texture_v;
|
||||
GLenum texture_u;
|
||||
#endif
|
||||
GLES2_FBOList *fbo;
|
||||
} GLES2_TextureData;
|
||||
|
||||
typedef struct GLES2_ShaderCacheEntry
|
||||
{
|
||||
GLuint id;
|
||||
GLES2_ShaderType type;
|
||||
const GLES2_ShaderInstance *instance;
|
||||
int references;
|
||||
struct GLES2_ShaderCacheEntry *prev;
|
||||
struct GLES2_ShaderCacheEntry *next;
|
||||
} GLES2_ShaderCacheEntry;
|
||||
|
||||
typedef struct GLES2_ShaderCache
|
||||
{
|
||||
int count;
|
||||
GLES2_ShaderCacheEntry *head;
|
||||
} GLES2_ShaderCache;
|
||||
|
||||
typedef struct GLES2_ProgramCacheEntry
|
||||
{
|
||||
GLuint id;
|
||||
GLES2_ShaderCacheEntry *vertex_shader;
|
||||
GLES2_ShaderCacheEntry *fragment_shader;
|
||||
GLuint vertex_shader;
|
||||
GLuint fragment_shader;
|
||||
GLuint uniform_locations[16];
|
||||
Uint32 color;
|
||||
GLfloat projection[4][4];
|
||||
@@ -165,9 +151,8 @@ typedef struct GLES2_RenderData
|
||||
GLES2_FBOList *framebuffers;
|
||||
GLuint window_framebuffer;
|
||||
|
||||
int shader_format_count;
|
||||
GLenum *shader_formats;
|
||||
GLES2_ShaderCache shader_cache;
|
||||
GLuint shader_id_cache[GLES2_SHADER_COUNT];
|
||||
|
||||
GLES2_ProgramCache program_cache;
|
||||
Uint8 clear_r, clear_g, clear_b, clear_a;
|
||||
|
||||
@@ -393,32 +378,10 @@ GLES2_SupportsBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
GLES2_EvictShader(GLES2_RenderData *data, GLES2_ShaderCacheEntry *entry)
|
||||
{
|
||||
/* Unlink the shader from the cache */
|
||||
if (entry->next) {
|
||||
entry->next->prev = entry->prev;
|
||||
}
|
||||
if (entry->prev) {
|
||||
entry->prev->next = entry->next;
|
||||
}
|
||||
if (data->shader_cache.head == entry) {
|
||||
data->shader_cache.head = entry->next;
|
||||
}
|
||||
--data->shader_cache.count;
|
||||
|
||||
/* Deallocate the shader */
|
||||
data->glDeleteShader(entry->id);
|
||||
SDL_free(entry);
|
||||
}
|
||||
|
||||
static GLES2_ProgramCacheEntry *
|
||||
GLES2_CacheProgram(GLES2_RenderData *data, GLES2_ShaderCacheEntry *vertex,
|
||||
GLES2_ShaderCacheEntry *fragment)
|
||||
GLES2_CacheProgram(GLES2_RenderData *data, GLuint vertex, GLuint fragment)
|
||||
{
|
||||
GLES2_ProgramCacheEntry *entry;
|
||||
GLES2_ShaderCacheEntry *shaderEntry;
|
||||
GLint linkSuccessful;
|
||||
|
||||
/* Check if we've already cached this program */
|
||||
@@ -456,8 +419,8 @@ GLES2_CacheProgram(GLES2_RenderData *data, GLES2_ShaderCacheEntry *vertex,
|
||||
|
||||
/* Create the program and link it */
|
||||
entry->id = data->glCreateProgram();
|
||||
data->glAttachShader(entry->id, vertex->id);
|
||||
data->glAttachShader(entry->id, fragment->id);
|
||||
data->glAttachShader(entry->id, vertex);
|
||||
data->glAttachShader(entry->id, fragment);
|
||||
data->glBindAttribLocation(entry->id, GLES2_ATTRIBUTE_POSITION, "a_position");
|
||||
data->glBindAttribLocation(entry->id, GLES2_ATTRIBUTE_TEXCOORD, "a_texCoord");
|
||||
data->glBindAttribLocation(entry->id, GLES2_ATTRIBUTE_ANGLE, "a_angle");
|
||||
@@ -512,20 +475,8 @@ GLES2_CacheProgram(GLES2_RenderData *data, GLES2_ShaderCacheEntry *vertex,
|
||||
data->program_cache.head = entry;
|
||||
++data->program_cache.count;
|
||||
|
||||
/* Increment the refcount of the shaders we're using */
|
||||
++vertex->references;
|
||||
++fragment->references;
|
||||
|
||||
/* Evict the last entry from the cache if we exceed the limit */
|
||||
if (data->program_cache.count > GLES2_MAX_CACHED_PROGRAMS) {
|
||||
shaderEntry = data->program_cache.tail->vertex_shader;
|
||||
if (--shaderEntry->references <= 0) {
|
||||
GLES2_EvictShader(data, shaderEntry);
|
||||
}
|
||||
shaderEntry = data->program_cache.tail->fragment_shader;
|
||||
if (--shaderEntry->references <= 0) {
|
||||
GLES2_EvictShader(data, shaderEntry);
|
||||
}
|
||||
data->glDeleteProgram(data->program_cache.tail->id);
|
||||
data->program_cache.tail = data->program_cache.tail->prev;
|
||||
if (data->program_cache.tail != NULL) {
|
||||
@@ -537,80 +488,34 @@ GLES2_CacheProgram(GLES2_RenderData *data, GLES2_ShaderCacheEntry *vertex,
|
||||
return entry;
|
||||
}
|
||||
|
||||
static GLES2_ShaderCacheEntry *
|
||||
GLES2_CacheShader(GLES2_RenderData *data, GLES2_ShaderType type)
|
||||
static GLuint
|
||||
GLES2_CacheShader(GLES2_RenderData *data, GLES2_ShaderType type, GLenum shader_type)
|
||||
{
|
||||
const GLES2_Shader *shader;
|
||||
const GLES2_ShaderInstance *instance = NULL;
|
||||
GLES2_ShaderCacheEntry *entry = NULL;
|
||||
GLuint id;
|
||||
GLint compileSuccessful = GL_FALSE;
|
||||
int i, j;
|
||||
const Uint8 *shader_src = GLES2_GetShader(type);
|
||||
|
||||
/* Find the corresponding shader */
|
||||
shader = GLES2_GetShader(type);
|
||||
if (!shader) {
|
||||
SDL_SetError("No shader matching the requested characteristics was found");
|
||||
return NULL;
|
||||
if (!shader_src) {
|
||||
SDL_SetError("No shader src");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Find a matching shader instance that's supported on this hardware */
|
||||
for (i = 0; i < shader->instance_count && !instance; ++i) {
|
||||
for (j = 0; j < data->shader_format_count && !instance; ++j) {
|
||||
if (!shader->instances[i]) {
|
||||
continue;
|
||||
}
|
||||
if (shader->instances[i]->format != data->shader_formats[j]) {
|
||||
continue;
|
||||
}
|
||||
instance = shader->instances[i];
|
||||
}
|
||||
}
|
||||
if (!instance) {
|
||||
SDL_SetError("The specified shader cannot be loaded on the current platform");
|
||||
return NULL;
|
||||
}
|
||||
/* Compile */
|
||||
id = data->glCreateShader(shader_type);
|
||||
data->glShaderSource(id, 1, (const char**)&shader_src, NULL);
|
||||
data->glCompileShader(id);
|
||||
data->glGetShaderiv(id, GL_COMPILE_STATUS, &compileSuccessful);
|
||||
|
||||
/* Check if we've already cached this shader */
|
||||
entry = data->shader_cache.head;
|
||||
while (entry) {
|
||||
if (entry->instance == instance) {
|
||||
break;
|
||||
}
|
||||
entry = entry->next;
|
||||
}
|
||||
if (entry) {
|
||||
return entry;
|
||||
}
|
||||
|
||||
/* Create a shader cache entry */
|
||||
entry = (GLES2_ShaderCacheEntry *)SDL_calloc(1, sizeof(GLES2_ShaderCacheEntry));
|
||||
if (!entry) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
entry->type = type;
|
||||
entry->instance = instance;
|
||||
|
||||
/* Compile or load the selected shader instance */
|
||||
entry->id = data->glCreateShader(instance->type);
|
||||
if (instance->format == (GLenum)-1) {
|
||||
data->glShaderSource(entry->id, 1, (const char **)(char *)&instance->data, NULL);
|
||||
data->glCompileShader(entry->id);
|
||||
data->glGetShaderiv(entry->id, GL_COMPILE_STATUS, &compileSuccessful);
|
||||
} else {
|
||||
data->glShaderBinary(1, &entry->id, instance->format, instance->data, instance->length);
|
||||
compileSuccessful = GL_TRUE;
|
||||
}
|
||||
if (!compileSuccessful) {
|
||||
SDL_bool isstack = SDL_FALSE;
|
||||
char *info = NULL;
|
||||
int length = 0;
|
||||
|
||||
data->glGetShaderiv(entry->id, GL_INFO_LOG_LENGTH, &length);
|
||||
data->glGetShaderiv(id, GL_INFO_LOG_LENGTH, &length);
|
||||
if (length > 0) {
|
||||
info = SDL_small_alloc(char, length, &isstack);
|
||||
if (info) {
|
||||
data->glGetShaderInfoLog(entry->id, length, &length, info);
|
||||
data->glGetShaderInfoLog(id, length, &length, info);
|
||||
}
|
||||
}
|
||||
if (info) {
|
||||
@@ -619,26 +524,21 @@ GLES2_CacheShader(GLES2_RenderData *data, GLES2_ShaderType type)
|
||||
} else {
|
||||
SDL_SetError("Failed to load the shader");
|
||||
}
|
||||
data->glDeleteShader(entry->id);
|
||||
SDL_free(entry);
|
||||
return NULL;
|
||||
data->glDeleteShader(id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Link the shader entry in at the front of the cache */
|
||||
if (data->shader_cache.head) {
|
||||
entry->next = data->shader_cache.head;
|
||||
data->shader_cache.head->prev = entry;
|
||||
}
|
||||
data->shader_cache.head = entry;
|
||||
++data->shader_cache.count;
|
||||
return entry;
|
||||
/* Cache */
|
||||
data->shader_id_cache[(Uint32)type] = id;
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
static int
|
||||
GLES2_SelectProgram(GLES2_RenderData *data, GLES2_ImageSource source, int w, int h)
|
||||
{
|
||||
GLES2_ShaderCacheEntry *vertex = NULL;
|
||||
GLES2_ShaderCacheEntry *fragment = NULL;
|
||||
GLuint vertex;
|
||||
GLuint fragment;
|
||||
GLES2_ShaderType vtype, ftype;
|
||||
GLES2_ProgramCacheEntry *program;
|
||||
|
||||
@@ -646,30 +546,30 @@ GLES2_SelectProgram(GLES2_RenderData *data, GLES2_ImageSource source, int w, int
|
||||
vtype = GLES2_SHADER_VERTEX_DEFAULT;
|
||||
switch (source) {
|
||||
case GLES2_IMAGESOURCE_SOLID:
|
||||
ftype = GLES2_SHADER_FRAGMENT_SOLID_SRC;
|
||||
ftype = GLES2_SHADER_FRAGMENT_SOLID;
|
||||
break;
|
||||
case GLES2_IMAGESOURCE_TEXTURE_ABGR:
|
||||
ftype = GLES2_SHADER_FRAGMENT_TEXTURE_ABGR_SRC;
|
||||
ftype = GLES2_SHADER_FRAGMENT_TEXTURE_ABGR;
|
||||
break;
|
||||
case GLES2_IMAGESOURCE_TEXTURE_ARGB:
|
||||
ftype = GLES2_SHADER_FRAGMENT_TEXTURE_ARGB_SRC;
|
||||
ftype = GLES2_SHADER_FRAGMENT_TEXTURE_ARGB;
|
||||
break;
|
||||
case GLES2_IMAGESOURCE_TEXTURE_RGB:
|
||||
ftype = GLES2_SHADER_FRAGMENT_TEXTURE_RGB_SRC;
|
||||
ftype = GLES2_SHADER_FRAGMENT_TEXTURE_RGB;
|
||||
break;
|
||||
case GLES2_IMAGESOURCE_TEXTURE_BGR:
|
||||
ftype = GLES2_SHADER_FRAGMENT_TEXTURE_BGR_SRC;
|
||||
ftype = GLES2_SHADER_FRAGMENT_TEXTURE_BGR;
|
||||
break;
|
||||
case GLES2_IMAGESOURCE_TEXTURE_YUV:
|
||||
switch (SDL_GetYUVConversionModeForResolution(w, h)) {
|
||||
case SDL_YUV_CONVERSION_JPEG:
|
||||
ftype = GLES2_SHADER_FRAGMENT_TEXTURE_YUV_JPEG_SRC;
|
||||
ftype = GLES2_SHADER_FRAGMENT_TEXTURE_YUV_JPEG;
|
||||
break;
|
||||
case SDL_YUV_CONVERSION_BT601:
|
||||
ftype = GLES2_SHADER_FRAGMENT_TEXTURE_YUV_BT601_SRC;
|
||||
ftype = GLES2_SHADER_FRAGMENT_TEXTURE_YUV_BT601;
|
||||
break;
|
||||
case SDL_YUV_CONVERSION_BT709:
|
||||
ftype = GLES2_SHADER_FRAGMENT_TEXTURE_YUV_BT709_SRC;
|
||||
ftype = GLES2_SHADER_FRAGMENT_TEXTURE_YUV_BT709;
|
||||
break;
|
||||
default:
|
||||
SDL_SetError("Unsupported YUV conversion mode: %d\n", SDL_GetYUVConversionModeForResolution(w, h));
|
||||
@@ -679,13 +579,13 @@ GLES2_SelectProgram(GLES2_RenderData *data, GLES2_ImageSource source, int w, int
|
||||
case GLES2_IMAGESOURCE_TEXTURE_NV12:
|
||||
switch (SDL_GetYUVConversionModeForResolution(w, h)) {
|
||||
case SDL_YUV_CONVERSION_JPEG:
|
||||
ftype = GLES2_SHADER_FRAGMENT_TEXTURE_NV12_JPEG_SRC;
|
||||
ftype = GLES2_SHADER_FRAGMENT_TEXTURE_NV12_JPEG;
|
||||
break;
|
||||
case SDL_YUV_CONVERSION_BT601:
|
||||
ftype = GLES2_SHADER_FRAGMENT_TEXTURE_NV12_BT601_SRC;
|
||||
ftype = GLES2_SHADER_FRAGMENT_TEXTURE_NV12_BT601;
|
||||
break;
|
||||
case SDL_YUV_CONVERSION_BT709:
|
||||
ftype = GLES2_SHADER_FRAGMENT_TEXTURE_NV12_BT709_SRC;
|
||||
ftype = GLES2_SHADER_FRAGMENT_TEXTURE_NV12_BT709;
|
||||
break;
|
||||
default:
|
||||
SDL_SetError("Unsupported YUV conversion mode: %d\n", SDL_GetYUVConversionModeForResolution(w, h));
|
||||
@@ -695,13 +595,13 @@ GLES2_SelectProgram(GLES2_RenderData *data, GLES2_ImageSource source, int w, int
|
||||
case GLES2_IMAGESOURCE_TEXTURE_NV21:
|
||||
switch (SDL_GetYUVConversionModeForResolution(w, h)) {
|
||||
case SDL_YUV_CONVERSION_JPEG:
|
||||
ftype = GLES2_SHADER_FRAGMENT_TEXTURE_NV21_JPEG_SRC;
|
||||
ftype = GLES2_SHADER_FRAGMENT_TEXTURE_NV21_JPEG;
|
||||
break;
|
||||
case SDL_YUV_CONVERSION_BT601:
|
||||
ftype = GLES2_SHADER_FRAGMENT_TEXTURE_NV21_BT601_SRC;
|
||||
ftype = GLES2_SHADER_FRAGMENT_TEXTURE_NV21_BT601;
|
||||
break;
|
||||
case SDL_YUV_CONVERSION_BT709:
|
||||
ftype = GLES2_SHADER_FRAGMENT_TEXTURE_NV21_BT709_SRC;
|
||||
ftype = GLES2_SHADER_FRAGMENT_TEXTURE_NV21_BT709;
|
||||
break;
|
||||
default:
|
||||
SDL_SetError("Unsupported YUV conversion mode: %d\n", SDL_GetYUVConversionModeForResolution(w, h));
|
||||
@@ -709,20 +609,27 @@ GLES2_SelectProgram(GLES2_RenderData *data, GLES2_ImageSource source, int w, int
|
||||
}
|
||||
break;
|
||||
case GLES2_IMAGESOURCE_TEXTURE_EXTERNAL_OES:
|
||||
ftype = GLES2_SHADER_FRAGMENT_TEXTURE_EXTERNAL_OES_SRC;
|
||||
ftype = GLES2_SHADER_FRAGMENT_TEXTURE_EXTERNAL_OES;
|
||||
break;
|
||||
default:
|
||||
goto fault;
|
||||
}
|
||||
|
||||
/* Load the requested shaders */
|
||||
vertex = GLES2_CacheShader(data, vtype);
|
||||
vertex = data->shader_id_cache[(Uint32)vtype];
|
||||
if (!vertex) {
|
||||
goto fault;
|
||||
vertex = GLES2_CacheShader(data, vtype, GL_VERTEX_SHADER);
|
||||
if (!vertex) {
|
||||
goto fault;
|
||||
}
|
||||
}
|
||||
fragment = GLES2_CacheShader(data, ftype);
|
||||
|
||||
fragment = data->shader_id_cache[(Uint32)ftype];
|
||||
if (!fragment) {
|
||||
goto fault;
|
||||
fragment = GLES2_CacheShader(data, ftype, GL_FRAGMENT_SHADER);
|
||||
if (!fragment) {
|
||||
goto fault;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check if we need to change programs at all */
|
||||
@@ -747,12 +654,6 @@ GLES2_SelectProgram(GLES2_RenderData *data, GLES2_ImageSource source, int w, int
|
||||
/* Clean up and return */
|
||||
return 0;
|
||||
fault:
|
||||
if (vertex && vertex->references <= 0) {
|
||||
GLES2_EvictShader(data, vertex);
|
||||
}
|
||||
if (fragment && fragment->references <= 0) {
|
||||
GLES2_EvictShader(data, fragment);
|
||||
}
|
||||
data->drawstate.program = NULL;
|
||||
return -1;
|
||||
}
|
||||
@@ -809,9 +710,9 @@ GLES2_QueueDrawLines(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_
|
||||
const GLfloat yend = verts[3];
|
||||
|
||||
if (ystart == yend) { /* horizontal line */
|
||||
verts[2] += (xend > xstart) ? 1.0f : -1.0f;
|
||||
verts[(xend > xstart) ? 2 : 0] += 1.0f;
|
||||
} else if (xstart == xend) { /* vertical line */
|
||||
verts[3] += (yend > ystart) ? 1.0f : -1.0f;
|
||||
verts[(yend > ystart) ? 3 : 1] += 1.0f;
|
||||
} else { /* bump a pixel in the direction we are moving in. */
|
||||
const GLfloat deltax = xend - xstart;
|
||||
const GLfloat deltay = yend - ystart;
|
||||
@@ -905,7 +806,7 @@ GLES2_QueueCopyEx(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture *
|
||||
const SDL_Rect * srcquad, const SDL_FRect * dstrect,
|
||||
const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip)
|
||||
{
|
||||
/* render expects cos value - 1 (see GLES2_VertexSrc_Default_) */
|
||||
/* 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;
|
||||
@@ -1037,6 +938,7 @@ SetDrawState(GLES2_RenderData *data, const SDL_RenderCommand *cmd, const GLES2_I
|
||||
|
||||
if (texture) {
|
||||
GLES2_TextureData *tdata = (GLES2_TextureData *) texture->driverdata;
|
||||
#if SDL_HAVE_YUV
|
||||
if (tdata->yuv) {
|
||||
data->glActiveTexture(GL_TEXTURE2);
|
||||
data->glBindTexture(tdata->texture_type, tdata->texture_v);
|
||||
@@ -1051,6 +953,7 @@ SetDrawState(GLES2_RenderData *data, const SDL_RenderCommand *cmd, const GLES2_I
|
||||
|
||||
data->glActiveTexture(GL_TEXTURE0);
|
||||
}
|
||||
#endif
|
||||
data->glBindTexture(tdata->texture_type, tdata->texture);
|
||||
}
|
||||
|
||||
@@ -1382,14 +1285,12 @@ GLES2_DestroyRenderer(SDL_Renderer *renderer)
|
||||
GLES2_ActivateRenderer(renderer);
|
||||
|
||||
{
|
||||
GLES2_ShaderCacheEntry *entry;
|
||||
GLES2_ShaderCacheEntry *next;
|
||||
entry = data->shader_cache.head;
|
||||
while (entry) {
|
||||
data->glDeleteShader(entry->id);
|
||||
next = entry->next;
|
||||
SDL_free(entry);
|
||||
entry = next;
|
||||
int i;
|
||||
for (i = 0; i < GLES2_SHADER_COUNT; i++) {
|
||||
GLuint id = data->shader_id_cache[i];
|
||||
if (id) {
|
||||
data->glDeleteShader(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
@@ -1419,7 +1320,6 @@ GLES2_DestroyRenderer(SDL_Renderer *renderer)
|
||||
SDL_GL_DeleteContext(data->context);
|
||||
}
|
||||
|
||||
SDL_free(data->shader_formats);
|
||||
SDL_free(data);
|
||||
}
|
||||
SDL_free(renderer);
|
||||
@@ -1483,10 +1383,12 @@ GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
#endif
|
||||
data->pixel_format = format;
|
||||
data->pixel_type = type;
|
||||
#if SDL_HAVE_YUV
|
||||
data->yuv = ((texture->format == SDL_PIXELFORMAT_IYUV) || (texture->format == SDL_PIXELFORMAT_YV12));
|
||||
data->nv12 = ((texture->format == SDL_PIXELFORMAT_NV12) || (texture->format == SDL_PIXELFORMAT_NV21));
|
||||
data->texture_u = 0;
|
||||
data->texture_v = 0;
|
||||
#endif
|
||||
scaleMode = (texture->scaleMode == SDL_ScaleModeNearest) ? GL_NEAREST : GL_LINEAR;
|
||||
|
||||
/* Allocate a blob for image renderdata */
|
||||
@@ -1494,6 +1396,7 @@ GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
size_t size;
|
||||
data->pitch = texture->w * SDL_BYTESPERPIXEL(texture->format);
|
||||
size = texture->h * data->pitch;
|
||||
#if SDL_HAVE_YUV
|
||||
if (data->yuv) {
|
||||
/* Need to add size for the U and V planes */
|
||||
size += 2 * ((texture->h + 1) / 2) * ((data->pitch + 1) / 2);
|
||||
@@ -1501,6 +1404,7 @@ GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
/* Need to add size for the U/V plane */
|
||||
size += 2 * ((texture->h + 1) / 2) * ((data->pitch + 1) / 2);
|
||||
}
|
||||
#endif
|
||||
data->pixel_data = SDL_calloc(1, size);
|
||||
if (!data->pixel_data) {
|
||||
SDL_free(data);
|
||||
@@ -1511,6 +1415,7 @@ GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
/* Allocate the texture */
|
||||
GL_CheckError("", renderer);
|
||||
|
||||
#if SDL_HAVE_YUV
|
||||
if (data->yuv) {
|
||||
renderdata->glGenTextures(1, &data->texture_v);
|
||||
if (GL_CheckError("glGenTexures()", renderer) < 0) {
|
||||
@@ -1554,6 +1459,7 @@ GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
renderdata->glGenTextures(1, &data->texture);
|
||||
if (GL_CheckError("glGenTexures()", renderer) < 0) {
|
||||
@@ -1646,6 +1552,7 @@ GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect
|
||||
tdata->pixel_type,
|
||||
pixels, pitch, SDL_BYTESPERPIXEL(texture->format));
|
||||
|
||||
#if SDL_HAVE_YUV
|
||||
if (tdata->yuv) {
|
||||
/* Skip to the correct offset into the next texture */
|
||||
pixels = (const void*)((const Uint8*)pixels + rect->h * pitch);
|
||||
@@ -1692,10 +1599,12 @@ GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect
|
||||
GL_UNSIGNED_BYTE,
|
||||
pixels, 2 * ((pitch + 1) / 2), 2);
|
||||
}
|
||||
#endif
|
||||
|
||||
return GL_CheckError("glTexSubImage2D()", renderer);
|
||||
}
|
||||
|
||||
#if SDL_HAVE_YUV
|
||||
static int
|
||||
GLES2_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect,
|
||||
@@ -1748,6 +1657,48 @@ GLES2_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
return GL_CheckError("glTexSubImage2D()", renderer);
|
||||
}
|
||||
|
||||
static int
|
||||
GLES2_UpdateTextureNV(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *UVplane, int UVpitch)
|
||||
{
|
||||
GLES2_RenderData *data = (GLES2_RenderData *)renderer->driverdata;
|
||||
GLES2_TextureData *tdata = (GLES2_TextureData *)texture->driverdata;
|
||||
|
||||
GLES2_ActivateRenderer(renderer);
|
||||
|
||||
/* Bail out if we're supposed to update an empty rectangle */
|
||||
if (rect->w <= 0 || rect->h <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
data->drawstate.texture = NULL; /* we trash this state. */
|
||||
|
||||
data->glBindTexture(tdata->texture_type, tdata->texture_u);
|
||||
GLES2_TexSubImage2D(data, tdata->texture_type,
|
||||
rect->x / 2,
|
||||
rect->y / 2,
|
||||
(rect->w + 1) / 2,
|
||||
(rect->h + 1) / 2,
|
||||
GL_LUMINANCE_ALPHA,
|
||||
GL_UNSIGNED_BYTE,
|
||||
UVplane, UVpitch, 2);
|
||||
|
||||
data->glBindTexture(tdata->texture_type, tdata->texture);
|
||||
GLES2_TexSubImage2D(data, tdata->texture_type,
|
||||
rect->x,
|
||||
rect->y,
|
||||
rect->w,
|
||||
rect->h,
|
||||
tdata->pixel_format,
|
||||
tdata->pixel_type,
|
||||
Yplane, Ypitch, 1);
|
||||
|
||||
return GL_CheckError("glTexSubImage2D()", renderer);
|
||||
}
|
||||
#endif
|
||||
|
||||
static int
|
||||
GLES2_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect,
|
||||
void **pixels, int *pitch)
|
||||
@@ -1784,6 +1735,7 @@ GLES2_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture, SDL_Sc
|
||||
GLES2_TextureData *data = (GLES2_TextureData *) texture->driverdata;
|
||||
GLenum glScaleMode = (scaleMode == SDL_ScaleModeNearest) ? GL_NEAREST : GL_LINEAR;
|
||||
|
||||
#if SDL_HAVE_YUV
|
||||
if (data->yuv) {
|
||||
renderdata->glActiveTexture(GL_TEXTURE2);
|
||||
renderdata->glBindTexture(data->texture_type, data->texture_v);
|
||||
@@ -1800,6 +1752,7 @@ GLES2_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture, SDL_Sc
|
||||
renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_MIN_FILTER, glScaleMode);
|
||||
renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_MAG_FILTER, glScaleMode);
|
||||
}
|
||||
#endif
|
||||
|
||||
renderdata->glActiveTexture(GL_TEXTURE0);
|
||||
renderdata->glBindTexture(data->texture_type, data->texture);
|
||||
@@ -1850,12 +1803,14 @@ GLES2_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
/* Destroy the texture */
|
||||
if (tdata) {
|
||||
data->glDeleteTextures(1, &tdata->texture);
|
||||
#if SDL_HAVE_YUV
|
||||
if (tdata->texture_v) {
|
||||
data->glDeleteTextures(1, &tdata->texture_v);
|
||||
}
|
||||
if (tdata->texture_u) {
|
||||
data->glDeleteTextures(1, &tdata->texture_u);
|
||||
}
|
||||
#endif
|
||||
SDL_free(tdata->pixel_data);
|
||||
SDL_free(tdata);
|
||||
texture->driverdata = NULL;
|
||||
@@ -1970,20 +1925,11 @@ static int GLES2_UnbindTexture (SDL_Renderer * renderer, SDL_Texture *texture)
|
||||
* Renderer instantiation *
|
||||
*************************************************************************************************/
|
||||
|
||||
#ifdef ZUNE_HD
|
||||
#define GL_NVIDIA_PLATFORM_BINARY_NV 0x890B
|
||||
#endif
|
||||
|
||||
|
||||
static SDL_Renderer *
|
||||
GLES2_CreateRenderer(SDL_Window *window, Uint32 flags)
|
||||
{
|
||||
SDL_Renderer *renderer;
|
||||
GLES2_RenderData *data;
|
||||
GLint nFormats;
|
||||
#ifndef ZUNE_HD
|
||||
GLboolean hasCompiler;
|
||||
#endif
|
||||
Uint32 window_flags = 0; /* -Wconditional-uninitialized */
|
||||
GLint window_framebuffer;
|
||||
GLint value;
|
||||
@@ -2085,33 +2031,6 @@ GLES2_CreateRenderer(SDL_Window *window, Uint32 flags)
|
||||
data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value);
|
||||
renderer->info.max_texture_height = value;
|
||||
|
||||
/* Determine supported shader formats */
|
||||
/* HACK: glGetInteger is broken on the Zune HD's compositor, so we just hardcode this */
|
||||
#ifdef ZUNE_HD
|
||||
nFormats = 1;
|
||||
#else /* !ZUNE_HD */
|
||||
data->glGetIntegerv(GL_NUM_SHADER_BINARY_FORMATS, &nFormats);
|
||||
data->glGetBooleanv(GL_SHADER_COMPILER, &hasCompiler);
|
||||
if (hasCompiler) {
|
||||
++nFormats;
|
||||
}
|
||||
#endif /* ZUNE_HD */
|
||||
data->shader_formats = (GLenum *)SDL_calloc(nFormats, sizeof(GLenum));
|
||||
if (!data->shader_formats) {
|
||||
GLES2_DestroyRenderer(renderer);
|
||||
SDL_OutOfMemory();
|
||||
goto error;
|
||||
}
|
||||
data->shader_format_count = nFormats;
|
||||
#ifdef ZUNE_HD
|
||||
data->shader_formats[0] = GL_NVIDIA_PLATFORM_BINARY_NV;
|
||||
#else /* !ZUNE_HD */
|
||||
data->glGetIntegerv(GL_SHADER_BINARY_FORMATS, (GLint *)data->shader_formats);
|
||||
if (hasCompiler) {
|
||||
data->shader_formats[nFormats - 1] = (GLenum)-1;
|
||||
}
|
||||
#endif /* ZUNE_HD */
|
||||
|
||||
/* we keep a few of these and cycle through them, so data can live for a few frames. */
|
||||
data->glGenBuffers(SDL_arraysize(data->vertex_buffers), data->vertex_buffers);
|
||||
|
||||
@@ -2125,7 +2044,10 @@ GLES2_CreateRenderer(SDL_Window *window, Uint32 flags)
|
||||
renderer->SupportsBlendMode = GLES2_SupportsBlendMode;
|
||||
renderer->CreateTexture = GLES2_CreateTexture;
|
||||
renderer->UpdateTexture = GLES2_UpdateTexture;
|
||||
#if SDL_HAVE_YUV
|
||||
renderer->UpdateTextureYUV = GLES2_UpdateTextureYUV;
|
||||
renderer->UpdateTextureNV = GLES2_UpdateTextureNV;
|
||||
#endif
|
||||
renderer->LockTexture = GLES2_LockTexture;
|
||||
renderer->UnlockTexture = GLES2_UnlockTexture;
|
||||
renderer->SetTextureScaleMode = GLES2_SetTextureScaleMode;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@@ -36,7 +36,7 @@
|
||||
value is decremented by 1.0 to get proper output with 0.0 which is
|
||||
default value
|
||||
*/
|
||||
static const Uint8 GLES2_VertexSrc_Default_[] = " \
|
||||
static const Uint8 GLES2_Vertex_Default[] = " \
|
||||
uniform mat4 u_projection; \
|
||||
attribute vec2 a_position; \
|
||||
attribute vec2 a_texCoord; \
|
||||
@@ -56,7 +56,7 @@ static const Uint8 GLES2_VertexSrc_Default_[] = " \
|
||||
} \
|
||||
";
|
||||
|
||||
static const Uint8 GLES2_FragmentSrc_SolidSrc_[] = " \
|
||||
static const Uint8 GLES2_Fragment_Solid[] = " \
|
||||
precision mediump float; \
|
||||
uniform vec4 u_color; \
|
||||
\
|
||||
@@ -66,7 +66,7 @@ static const Uint8 GLES2_FragmentSrc_SolidSrc_[] = " \
|
||||
} \
|
||||
";
|
||||
|
||||
static const Uint8 GLES2_FragmentSrc_TextureABGRSrc_[] = " \
|
||||
static const Uint8 GLES2_Fragment_TextureABGR[] = " \
|
||||
precision mediump float; \
|
||||
uniform sampler2D u_texture; \
|
||||
uniform vec4 u_color; \
|
||||
@@ -80,7 +80,7 @@ static const Uint8 GLES2_FragmentSrc_TextureABGRSrc_[] = " \
|
||||
";
|
||||
|
||||
/* ARGB to ABGR conversion */
|
||||
static const Uint8 GLES2_FragmentSrc_TextureARGBSrc_[] = " \
|
||||
static const Uint8 GLES2_Fragment_TextureARGB[] = " \
|
||||
precision mediump float; \
|
||||
uniform sampler2D u_texture; \
|
||||
uniform vec4 u_color; \
|
||||
@@ -97,7 +97,7 @@ static const Uint8 GLES2_FragmentSrc_TextureARGBSrc_[] = " \
|
||||
";
|
||||
|
||||
/* RGB to ABGR conversion */
|
||||
static const Uint8 GLES2_FragmentSrc_TextureRGBSrc_[] = " \
|
||||
static const Uint8 GLES2_Fragment_TextureRGB[] = " \
|
||||
precision mediump float; \
|
||||
uniform sampler2D u_texture; \
|
||||
uniform vec4 u_color; \
|
||||
@@ -115,7 +115,7 @@ static const Uint8 GLES2_FragmentSrc_TextureRGBSrc_[] = " \
|
||||
";
|
||||
|
||||
/* BGR to ABGR conversion */
|
||||
static const Uint8 GLES2_FragmentSrc_TextureBGRSrc_[] = " \
|
||||
static const Uint8 GLES2_Fragment_TextureBGR[] = " \
|
||||
precision mediump float; \
|
||||
uniform sampler2D u_texture; \
|
||||
uniform vec4 u_color; \
|
||||
@@ -229,58 +229,58 @@ static const Uint8 GLES2_FragmentSrc_TextureBGRSrc_[] = " \
|
||||
"}" \
|
||||
|
||||
/* YUV to ABGR conversion */
|
||||
static const Uint8 GLES2_FragmentSrc_TextureYUVJPEGSrc_[] = \
|
||||
static const Uint8 GLES2_Fragment_TextureYUVJPEG[] = \
|
||||
YUV_SHADER_PROLOGUE \
|
||||
JPEG_SHADER_CONSTANTS \
|
||||
YUV_SHADER_BODY \
|
||||
;
|
||||
static const Uint8 GLES2_FragmentSrc_TextureYUVBT601Src_[] = \
|
||||
static const Uint8 GLES2_Fragment_TextureYUVBT601[] = \
|
||||
YUV_SHADER_PROLOGUE \
|
||||
BT601_SHADER_CONSTANTS \
|
||||
YUV_SHADER_BODY \
|
||||
;
|
||||
static const Uint8 GLES2_FragmentSrc_TextureYUVBT709Src_[] = \
|
||||
static const Uint8 GLES2_Fragment_TextureYUVBT709[] = \
|
||||
YUV_SHADER_PROLOGUE \
|
||||
BT709_SHADER_CONSTANTS \
|
||||
YUV_SHADER_BODY \
|
||||
;
|
||||
|
||||
/* NV12 to ABGR conversion */
|
||||
static const Uint8 GLES2_FragmentSrc_TextureNV12JPEGSrc_[] = \
|
||||
static const Uint8 GLES2_Fragment_TextureNV12JPEG[] = \
|
||||
YUV_SHADER_PROLOGUE \
|
||||
JPEG_SHADER_CONSTANTS \
|
||||
NV12_SHADER_BODY \
|
||||
;
|
||||
static const Uint8 GLES2_FragmentSrc_TextureNV12BT601Src_[] = \
|
||||
static const Uint8 GLES2_Fragment_TextureNV12BT601[] = \
|
||||
YUV_SHADER_PROLOGUE \
|
||||
BT601_SHADER_CONSTANTS \
|
||||
NV12_SHADER_BODY \
|
||||
;
|
||||
static const Uint8 GLES2_FragmentSrc_TextureNV12BT709Src_[] = \
|
||||
static const Uint8 GLES2_Fragment_TextureNV12BT709[] = \
|
||||
YUV_SHADER_PROLOGUE \
|
||||
BT709_SHADER_CONSTANTS \
|
||||
NV12_SHADER_BODY \
|
||||
;
|
||||
|
||||
/* NV21 to ABGR conversion */
|
||||
static const Uint8 GLES2_FragmentSrc_TextureNV21JPEGSrc_[] = \
|
||||
static const Uint8 GLES2_Fragment_TextureNV21JPEG[] = \
|
||||
YUV_SHADER_PROLOGUE \
|
||||
JPEG_SHADER_CONSTANTS \
|
||||
NV21_SHADER_BODY \
|
||||
;
|
||||
static const Uint8 GLES2_FragmentSrc_TextureNV21BT601Src_[] = \
|
||||
static const Uint8 GLES2_Fragment_TextureNV21BT601[] = \
|
||||
YUV_SHADER_PROLOGUE \
|
||||
BT601_SHADER_CONSTANTS \
|
||||
NV21_SHADER_BODY \
|
||||
;
|
||||
static const Uint8 GLES2_FragmentSrc_TextureNV21BT709Src_[] = \
|
||||
static const Uint8 GLES2_Fragment_TextureNV21BT709[] = \
|
||||
YUV_SHADER_PROLOGUE \
|
||||
BT709_SHADER_CONSTANTS \
|
||||
NV21_SHADER_BODY \
|
||||
;
|
||||
|
||||
/* Custom Android video format texture */
|
||||
static const Uint8 GLES2_FragmentSrc_TextureExternalOESSrc_[] = " \
|
||||
static const Uint8 GLES2_Fragment_TextureExternalOES[] = " \
|
||||
#extension GL_OES_EGL_image_external : require\n\
|
||||
precision mediump float; \
|
||||
uniform samplerExternalOES u_texture; \
|
||||
@@ -294,275 +294,46 @@ static const Uint8 GLES2_FragmentSrc_TextureExternalOESSrc_[] = " \
|
||||
} \
|
||||
";
|
||||
|
||||
static const GLES2_ShaderInstance GLES2_VertexSrc_Default = {
|
||||
GL_VERTEX_SHADER,
|
||||
GLES2_SOURCE_SHADER,
|
||||
sizeof(GLES2_VertexSrc_Default_),
|
||||
GLES2_VertexSrc_Default_
|
||||
};
|
||||
|
||||
static const GLES2_ShaderInstance GLES2_FragmentSrc_SolidSrc = {
|
||||
GL_FRAGMENT_SHADER,
|
||||
GLES2_SOURCE_SHADER,
|
||||
sizeof(GLES2_FragmentSrc_SolidSrc_),
|
||||
GLES2_FragmentSrc_SolidSrc_
|
||||
};
|
||||
|
||||
static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureABGRSrc = {
|
||||
GL_FRAGMENT_SHADER,
|
||||
GLES2_SOURCE_SHADER,
|
||||
sizeof(GLES2_FragmentSrc_TextureABGRSrc_),
|
||||
GLES2_FragmentSrc_TextureABGRSrc_
|
||||
};
|
||||
|
||||
static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureARGBSrc = {
|
||||
GL_FRAGMENT_SHADER,
|
||||
GLES2_SOURCE_SHADER,
|
||||
sizeof(GLES2_FragmentSrc_TextureARGBSrc_),
|
||||
GLES2_FragmentSrc_TextureARGBSrc_
|
||||
};
|
||||
|
||||
static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureRGBSrc = {
|
||||
GL_FRAGMENT_SHADER,
|
||||
GLES2_SOURCE_SHADER,
|
||||
sizeof(GLES2_FragmentSrc_TextureRGBSrc_),
|
||||
GLES2_FragmentSrc_TextureRGBSrc_
|
||||
};
|
||||
|
||||
static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureBGRSrc = {
|
||||
GL_FRAGMENT_SHADER,
|
||||
GLES2_SOURCE_SHADER,
|
||||
sizeof(GLES2_FragmentSrc_TextureBGRSrc_),
|
||||
GLES2_FragmentSrc_TextureBGRSrc_
|
||||
};
|
||||
|
||||
static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureYUVJPEGSrc = {
|
||||
GL_FRAGMENT_SHADER,
|
||||
GLES2_SOURCE_SHADER,
|
||||
sizeof(GLES2_FragmentSrc_TextureYUVJPEGSrc_),
|
||||
GLES2_FragmentSrc_TextureYUVJPEGSrc_
|
||||
};
|
||||
|
||||
static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureYUVBT601Src = {
|
||||
GL_FRAGMENT_SHADER,
|
||||
GLES2_SOURCE_SHADER,
|
||||
sizeof(GLES2_FragmentSrc_TextureYUVBT601Src_),
|
||||
GLES2_FragmentSrc_TextureYUVBT601Src_
|
||||
};
|
||||
|
||||
static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureYUVBT709Src = {
|
||||
GL_FRAGMENT_SHADER,
|
||||
GLES2_SOURCE_SHADER,
|
||||
sizeof(GLES2_FragmentSrc_TextureYUVBT709Src_),
|
||||
GLES2_FragmentSrc_TextureYUVBT709Src_
|
||||
};
|
||||
|
||||
static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureNV12JPEGSrc = {
|
||||
GL_FRAGMENT_SHADER,
|
||||
GLES2_SOURCE_SHADER,
|
||||
sizeof(GLES2_FragmentSrc_TextureNV12JPEGSrc_),
|
||||
GLES2_FragmentSrc_TextureNV12JPEGSrc_
|
||||
};
|
||||
|
||||
static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureNV12BT601Src = {
|
||||
GL_FRAGMENT_SHADER,
|
||||
GLES2_SOURCE_SHADER,
|
||||
sizeof(GLES2_FragmentSrc_TextureNV12BT601Src_),
|
||||
GLES2_FragmentSrc_TextureNV12BT601Src_
|
||||
};
|
||||
|
||||
static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureNV21BT709Src = {
|
||||
GL_FRAGMENT_SHADER,
|
||||
GLES2_SOURCE_SHADER,
|
||||
sizeof(GLES2_FragmentSrc_TextureNV21BT709Src_),
|
||||
GLES2_FragmentSrc_TextureNV21BT709Src_
|
||||
};
|
||||
|
||||
static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureNV21JPEGSrc = {
|
||||
GL_FRAGMENT_SHADER,
|
||||
GLES2_SOURCE_SHADER,
|
||||
sizeof(GLES2_FragmentSrc_TextureNV21JPEGSrc_),
|
||||
GLES2_FragmentSrc_TextureNV21JPEGSrc_
|
||||
};
|
||||
|
||||
static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureNV21BT601Src = {
|
||||
GL_FRAGMENT_SHADER,
|
||||
GLES2_SOURCE_SHADER,
|
||||
sizeof(GLES2_FragmentSrc_TextureNV21BT601Src_),
|
||||
GLES2_FragmentSrc_TextureNV21BT601Src_
|
||||
};
|
||||
|
||||
static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureNV12BT709Src = {
|
||||
GL_FRAGMENT_SHADER,
|
||||
GLES2_SOURCE_SHADER,
|
||||
sizeof(GLES2_FragmentSrc_TextureNV12BT709Src_),
|
||||
GLES2_FragmentSrc_TextureNV12BT709Src_
|
||||
};
|
||||
|
||||
static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureExternalOESSrc = {
|
||||
GL_FRAGMENT_SHADER,
|
||||
GLES2_SOURCE_SHADER,
|
||||
sizeof(GLES2_FragmentSrc_TextureExternalOESSrc_),
|
||||
GLES2_FragmentSrc_TextureExternalOESSrc_
|
||||
};
|
||||
|
||||
|
||||
/*************************************************************************************************
|
||||
* Vertex/fragment shader definitions *
|
||||
*************************************************************************************************/
|
||||
|
||||
static GLES2_Shader GLES2_VertexShader_Default = {
|
||||
1,
|
||||
{
|
||||
&GLES2_VertexSrc_Default
|
||||
}
|
||||
};
|
||||
|
||||
static GLES2_Shader GLES2_FragmentShader_SolidSrc = {
|
||||
1,
|
||||
{
|
||||
&GLES2_FragmentSrc_SolidSrc
|
||||
}
|
||||
};
|
||||
|
||||
static GLES2_Shader GLES2_FragmentShader_TextureABGRSrc = {
|
||||
1,
|
||||
{
|
||||
&GLES2_FragmentSrc_TextureABGRSrc
|
||||
}
|
||||
};
|
||||
|
||||
static GLES2_Shader GLES2_FragmentShader_TextureARGBSrc = {
|
||||
1,
|
||||
{
|
||||
&GLES2_FragmentSrc_TextureARGBSrc
|
||||
}
|
||||
};
|
||||
|
||||
static GLES2_Shader GLES2_FragmentShader_TextureRGBSrc = {
|
||||
1,
|
||||
{
|
||||
&GLES2_FragmentSrc_TextureRGBSrc
|
||||
}
|
||||
};
|
||||
|
||||
static GLES2_Shader GLES2_FragmentShader_TextureBGRSrc = {
|
||||
1,
|
||||
{
|
||||
&GLES2_FragmentSrc_TextureBGRSrc
|
||||
}
|
||||
};
|
||||
|
||||
static GLES2_Shader GLES2_FragmentShader_TextureYUVJPEGSrc = {
|
||||
1,
|
||||
{
|
||||
&GLES2_FragmentSrc_TextureYUVJPEGSrc
|
||||
}
|
||||
};
|
||||
|
||||
static GLES2_Shader GLES2_FragmentShader_TextureYUVBT601Src = {
|
||||
1,
|
||||
{
|
||||
&GLES2_FragmentSrc_TextureYUVBT601Src
|
||||
}
|
||||
};
|
||||
|
||||
static GLES2_Shader GLES2_FragmentShader_TextureYUVBT709Src = {
|
||||
1,
|
||||
{
|
||||
&GLES2_FragmentSrc_TextureYUVBT709Src
|
||||
}
|
||||
};
|
||||
|
||||
static GLES2_Shader GLES2_FragmentShader_TextureNV12JPEGSrc = {
|
||||
1,
|
||||
{
|
||||
&GLES2_FragmentSrc_TextureNV12JPEGSrc
|
||||
}
|
||||
};
|
||||
|
||||
static GLES2_Shader GLES2_FragmentShader_TextureNV12BT601Src = {
|
||||
1,
|
||||
{
|
||||
&GLES2_FragmentSrc_TextureNV12BT601Src
|
||||
}
|
||||
};
|
||||
|
||||
static GLES2_Shader GLES2_FragmentShader_TextureNV12BT709Src = {
|
||||
1,
|
||||
{
|
||||
&GLES2_FragmentSrc_TextureNV12BT709Src
|
||||
}
|
||||
};
|
||||
|
||||
static GLES2_Shader GLES2_FragmentShader_TextureNV21JPEGSrc = {
|
||||
1,
|
||||
{
|
||||
&GLES2_FragmentSrc_TextureNV21JPEGSrc
|
||||
}
|
||||
};
|
||||
|
||||
static GLES2_Shader GLES2_FragmentShader_TextureNV21BT601Src = {
|
||||
1,
|
||||
{
|
||||
&GLES2_FragmentSrc_TextureNV21BT601Src
|
||||
}
|
||||
};
|
||||
|
||||
static GLES2_Shader GLES2_FragmentShader_TextureNV21BT709Src = {
|
||||
1,
|
||||
{
|
||||
&GLES2_FragmentSrc_TextureNV21BT709Src
|
||||
}
|
||||
};
|
||||
|
||||
static GLES2_Shader GLES2_FragmentShader_TextureExternalOESSrc = {
|
||||
1,
|
||||
{
|
||||
&GLES2_FragmentSrc_TextureExternalOESSrc
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/*************************************************************************************************
|
||||
* Shader selector *
|
||||
*************************************************************************************************/
|
||||
|
||||
const GLES2_Shader *GLES2_GetShader(GLES2_ShaderType type)
|
||||
const Uint8 *GLES2_GetShader(GLES2_ShaderType type)
|
||||
{
|
||||
switch (type) {
|
||||
case GLES2_SHADER_VERTEX_DEFAULT:
|
||||
return &GLES2_VertexShader_Default;
|
||||
case GLES2_SHADER_FRAGMENT_SOLID_SRC:
|
||||
return &GLES2_FragmentShader_SolidSrc;
|
||||
case GLES2_SHADER_FRAGMENT_TEXTURE_ABGR_SRC:
|
||||
return &GLES2_FragmentShader_TextureABGRSrc;
|
||||
case GLES2_SHADER_FRAGMENT_TEXTURE_ARGB_SRC:
|
||||
return &GLES2_FragmentShader_TextureARGBSrc;
|
||||
case GLES2_SHADER_FRAGMENT_TEXTURE_RGB_SRC:
|
||||
return &GLES2_FragmentShader_TextureRGBSrc;
|
||||
case GLES2_SHADER_FRAGMENT_TEXTURE_BGR_SRC:
|
||||
return &GLES2_FragmentShader_TextureBGRSrc;
|
||||
case GLES2_SHADER_FRAGMENT_TEXTURE_YUV_JPEG_SRC:
|
||||
return &GLES2_FragmentShader_TextureYUVJPEGSrc;
|
||||
case GLES2_SHADER_FRAGMENT_TEXTURE_YUV_BT601_SRC:
|
||||
return &GLES2_FragmentShader_TextureYUVBT601Src;
|
||||
case GLES2_SHADER_FRAGMENT_TEXTURE_YUV_BT709_SRC:
|
||||
return &GLES2_FragmentShader_TextureYUVBT709Src;
|
||||
case GLES2_SHADER_FRAGMENT_TEXTURE_NV12_JPEG_SRC:
|
||||
return &GLES2_FragmentShader_TextureNV12JPEGSrc;
|
||||
case GLES2_SHADER_FRAGMENT_TEXTURE_NV12_BT601_SRC:
|
||||
return &GLES2_FragmentShader_TextureNV12BT601Src;
|
||||
case GLES2_SHADER_FRAGMENT_TEXTURE_NV12_BT709_SRC:
|
||||
return &GLES2_FragmentShader_TextureNV12BT709Src;
|
||||
case GLES2_SHADER_FRAGMENT_TEXTURE_NV21_JPEG_SRC:
|
||||
return &GLES2_FragmentShader_TextureNV21JPEGSrc;
|
||||
case GLES2_SHADER_FRAGMENT_TEXTURE_NV21_BT601_SRC:
|
||||
return &GLES2_FragmentShader_TextureNV21BT601Src;
|
||||
case GLES2_SHADER_FRAGMENT_TEXTURE_NV21_BT709_SRC:
|
||||
return &GLES2_FragmentShader_TextureNV21BT709Src;
|
||||
case GLES2_SHADER_FRAGMENT_TEXTURE_EXTERNAL_OES_SRC:
|
||||
return &GLES2_FragmentShader_TextureExternalOESSrc;
|
||||
return GLES2_Vertex_Default;
|
||||
case GLES2_SHADER_FRAGMENT_SOLID:
|
||||
return GLES2_Fragment_Solid;
|
||||
case GLES2_SHADER_FRAGMENT_TEXTURE_ABGR:
|
||||
return GLES2_Fragment_TextureABGR;
|
||||
case GLES2_SHADER_FRAGMENT_TEXTURE_ARGB:
|
||||
return GLES2_Fragment_TextureARGB;
|
||||
case GLES2_SHADER_FRAGMENT_TEXTURE_RGB:
|
||||
return GLES2_Fragment_TextureRGB;
|
||||
case GLES2_SHADER_FRAGMENT_TEXTURE_BGR:
|
||||
return GLES2_Fragment_TextureBGR;
|
||||
case GLES2_SHADER_FRAGMENT_TEXTURE_YUV_JPEG:
|
||||
return GLES2_Fragment_TextureYUVJPEG;
|
||||
case GLES2_SHADER_FRAGMENT_TEXTURE_YUV_BT601:
|
||||
return GLES2_Fragment_TextureYUVBT601;
|
||||
case GLES2_SHADER_FRAGMENT_TEXTURE_YUV_BT709:
|
||||
return GLES2_Fragment_TextureYUVBT709;
|
||||
case GLES2_SHADER_FRAGMENT_TEXTURE_NV12_JPEG:
|
||||
return GLES2_Fragment_TextureNV12JPEG;
|
||||
case GLES2_SHADER_FRAGMENT_TEXTURE_NV12_BT601:
|
||||
return GLES2_Fragment_TextureNV12BT601;
|
||||
case GLES2_SHADER_FRAGMENT_TEXTURE_NV12_BT709:
|
||||
return GLES2_Fragment_TextureNV12BT709;
|
||||
case GLES2_SHADER_FRAGMENT_TEXTURE_NV21_JPEG:
|
||||
return GLES2_Fragment_TextureNV21JPEG;
|
||||
case GLES2_SHADER_FRAGMENT_TEXTURE_NV21_BT601:
|
||||
return GLES2_Fragment_TextureNV21BT601;
|
||||
case GLES2_SHADER_FRAGMENT_TEXTURE_NV21_BT709:
|
||||
return GLES2_Fragment_TextureNV21BT709;
|
||||
case GLES2_SHADER_FRAGMENT_TEXTURE_EXTERNAL_OES:
|
||||
return GLES2_Fragment_TextureExternalOES;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@@ -25,43 +25,30 @@
|
||||
|
||||
#if SDL_VIDEO_RENDER_OGL_ES2
|
||||
|
||||
typedef struct GLES2_ShaderInstance
|
||||
{
|
||||
GLenum type;
|
||||
GLenum format;
|
||||
int length;
|
||||
const void *data;
|
||||
} GLES2_ShaderInstance;
|
||||
|
||||
typedef struct GLES2_Shader
|
||||
{
|
||||
int instance_count;
|
||||
const GLES2_ShaderInstance *instances[4];
|
||||
} GLES2_Shader;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GLES2_SHADER_VERTEX_DEFAULT,
|
||||
GLES2_SHADER_FRAGMENT_SOLID_SRC,
|
||||
GLES2_SHADER_FRAGMENT_TEXTURE_ABGR_SRC,
|
||||
GLES2_SHADER_FRAGMENT_TEXTURE_ARGB_SRC,
|
||||
GLES2_SHADER_FRAGMENT_TEXTURE_BGR_SRC,
|
||||
GLES2_SHADER_FRAGMENT_TEXTURE_RGB_SRC,
|
||||
GLES2_SHADER_FRAGMENT_TEXTURE_YUV_JPEG_SRC,
|
||||
GLES2_SHADER_FRAGMENT_TEXTURE_YUV_BT601_SRC,
|
||||
GLES2_SHADER_FRAGMENT_TEXTURE_YUV_BT709_SRC,
|
||||
GLES2_SHADER_FRAGMENT_TEXTURE_NV12_JPEG_SRC,
|
||||
GLES2_SHADER_FRAGMENT_TEXTURE_NV12_BT601_SRC,
|
||||
GLES2_SHADER_FRAGMENT_TEXTURE_NV12_BT709_SRC,
|
||||
GLES2_SHADER_FRAGMENT_TEXTURE_NV21_JPEG_SRC,
|
||||
GLES2_SHADER_FRAGMENT_TEXTURE_NV21_BT601_SRC,
|
||||
GLES2_SHADER_FRAGMENT_TEXTURE_NV21_BT709_SRC,
|
||||
GLES2_SHADER_FRAGMENT_TEXTURE_EXTERNAL_OES_SRC
|
||||
GLES2_SHADER_VERTEX_DEFAULT = 0,
|
||||
GLES2_SHADER_FRAGMENT_SOLID,
|
||||
GLES2_SHADER_FRAGMENT_TEXTURE_ABGR,
|
||||
GLES2_SHADER_FRAGMENT_TEXTURE_ARGB,
|
||||
GLES2_SHADER_FRAGMENT_TEXTURE_BGR,
|
||||
GLES2_SHADER_FRAGMENT_TEXTURE_RGB,
|
||||
GLES2_SHADER_FRAGMENT_TEXTURE_YUV_JPEG,
|
||||
GLES2_SHADER_FRAGMENT_TEXTURE_YUV_BT601,
|
||||
GLES2_SHADER_FRAGMENT_TEXTURE_YUV_BT709,
|
||||
GLES2_SHADER_FRAGMENT_TEXTURE_NV12_JPEG,
|
||||
GLES2_SHADER_FRAGMENT_TEXTURE_NV12_BT601,
|
||||
GLES2_SHADER_FRAGMENT_TEXTURE_NV12_BT709,
|
||||
GLES2_SHADER_FRAGMENT_TEXTURE_NV21_JPEG,
|
||||
GLES2_SHADER_FRAGMENT_TEXTURE_NV21_BT601,
|
||||
GLES2_SHADER_FRAGMENT_TEXTURE_NV21_BT709,
|
||||
GLES2_SHADER_FRAGMENT_TEXTURE_EXTERNAL_OES
|
||||
} GLES2_ShaderType;
|
||||
|
||||
#define GLES2_SOURCE_SHADER (GLenum)-1
|
||||
#define GLES2_SHADER_COUNT 16
|
||||
|
||||
const GLES2_Shader *GLES2_GetShader(GLES2_ShaderType type);
|
||||
const Uint8 *GLES2_GetShader(GLES2_ShaderType type);
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_OGL_ES2 */
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
2
externals/SDL/src/render/software/SDL_draw.h
vendored
2
externals/SDL/src/render/software/SDL_draw.h
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@@ -434,7 +434,7 @@ SW_RenderCopyEx(SDL_Renderer * renderer, SDL_Surface *surface, SDL_Texture * tex
|
||||
retval = -1;
|
||||
} else {
|
||||
SDL_SetSurfaceBlendMode(src_clone, SDL_BLENDMODE_NONE);
|
||||
retval = SDL_BlitScaled(src_clone, srcrect, src_scaled, &scale_rect);
|
||||
retval = SDL_PrivateUpperBlitScaled(src_clone, srcrect, src_scaled, &scale_rect, texture->scaleMode);
|
||||
SDL_FreeSurface(src_clone);
|
||||
src_clone = src_scaled;
|
||||
src_scaled = NULL;
|
||||
@@ -720,7 +720,7 @@ SW_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertic
|
||||
* to avoid potentially frequent RLE encoding/decoding.
|
||||
*/
|
||||
SDL_SetSurfaceRLE(surface, 0);
|
||||
SDL_BlitScaled(src, srcrect, surface, dstrect);
|
||||
SDL_PrivateUpperBlitScaled(src, srcrect, surface, dstrect, texture->scaleMode);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
1185
externals/SDL/src/render/vitagxm/SDL_render_vita_gxm.c
vendored
Executable file
1185
externals/SDL/src/render/vitagxm/SDL_render_vita_gxm.c
vendored
Executable file
File diff suppressed because it is too large
Load Diff
117
externals/SDL/src/render/vitagxm/SDL_render_vita_gxm_memory.c
vendored
Executable file
117
externals/SDL/src/render/vitagxm/SDL_render_vita_gxm_memory.c
vendored
Executable file
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#if SDL_VIDEO_RENDER_VITA_GXM
|
||||
|
||||
#include "SDL_render_vita_gxm_memory.h"
|
||||
|
||||
void *
|
||||
mem_gpu_alloc(SceKernelMemBlockType type, unsigned int size, unsigned int alignment, unsigned int attribs, SceUID *uid)
|
||||
{
|
||||
void *mem;
|
||||
|
||||
if (type == SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW) {
|
||||
size = ALIGN(size, 256*1024);
|
||||
} else {
|
||||
size = ALIGN(size, 4*1024);
|
||||
}
|
||||
|
||||
*uid = sceKernelAllocMemBlock("gpu_mem", type, size, NULL);
|
||||
|
||||
if (*uid < 0)
|
||||
return NULL;
|
||||
|
||||
if (sceKernelGetMemBlockBase(*uid, &mem) < 0)
|
||||
return NULL;
|
||||
|
||||
if (sceGxmMapMemory(mem, size, attribs) < 0)
|
||||
return NULL;
|
||||
|
||||
return mem;
|
||||
}
|
||||
|
||||
void
|
||||
mem_gpu_free(SceUID uid)
|
||||
{
|
||||
void *mem = NULL;
|
||||
if (sceKernelGetMemBlockBase(uid, &mem) < 0)
|
||||
return;
|
||||
sceGxmUnmapMemory(mem);
|
||||
sceKernelFreeMemBlock(uid);
|
||||
}
|
||||
|
||||
void *
|
||||
mem_vertex_usse_alloc(unsigned int size, SceUID *uid, unsigned int *usse_offset)
|
||||
{
|
||||
void *mem = NULL;
|
||||
|
||||
size = ALIGN(size, 4096);
|
||||
*uid = sceKernelAllocMemBlock("vertex_usse", SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE, size, NULL);
|
||||
|
||||
if (sceKernelGetMemBlockBase(*uid, &mem) < 0)
|
||||
return NULL;
|
||||
if (sceGxmMapVertexUsseMemory(mem, size, usse_offset) < 0)
|
||||
return NULL;
|
||||
|
||||
return mem;
|
||||
}
|
||||
|
||||
void
|
||||
mem_vertex_usse_free(SceUID uid)
|
||||
{
|
||||
void *mem = NULL;
|
||||
if (sceKernelGetMemBlockBase(uid, &mem) < 0)
|
||||
return;
|
||||
sceGxmUnmapVertexUsseMemory(mem);
|
||||
sceKernelFreeMemBlock(uid);
|
||||
}
|
||||
|
||||
void *
|
||||
mem_fragment_usse_alloc(unsigned int size, SceUID *uid, unsigned int *usse_offset)
|
||||
{
|
||||
void *mem = NULL;
|
||||
|
||||
size = ALIGN(size, 4096);
|
||||
*uid = sceKernelAllocMemBlock("fragment_usse", SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE, size, NULL);
|
||||
|
||||
if (sceKernelGetMemBlockBase(*uid, &mem) < 0)
|
||||
return NULL;
|
||||
if (sceGxmMapFragmentUsseMemory(mem, size, usse_offset) < 0)
|
||||
return NULL;
|
||||
|
||||
return mem;
|
||||
}
|
||||
|
||||
void
|
||||
mem_fragment_usse_free(SceUID uid)
|
||||
{
|
||||
void *mem = NULL;
|
||||
if (sceKernelGetMemBlockBase(uid, &mem) < 0)
|
||||
return;
|
||||
sceGxmUnmapFragmentUsseMemory(mem);
|
||||
sceKernelFreeMemBlock(uid);
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_VITA_GXM */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
40
externals/SDL/src/render/vitagxm/SDL_render_vita_gxm_memory.h
vendored
Executable file
40
externals/SDL/src/render/vitagxm/SDL_render_vita_gxm_memory.h
vendored
Executable file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef SDL_RENDER_VITA_GXM_MEMORY_H
|
||||
#define SDL_RENDER_VITA_GXM_MEMORY_H
|
||||
|
||||
#include <psp2/gxm.h>
|
||||
#include <psp2/types.h>
|
||||
#include <psp2/kernel/sysmem.h>
|
||||
|
||||
#define ALIGN(x, a) (((x) + ((a) - 1)) & ~((a) - 1))
|
||||
|
||||
void *mem_gpu_alloc(SceKernelMemBlockType type, unsigned int size, unsigned int alignment, unsigned int attribs, SceUID *uid);
|
||||
void mem_gpu_free(SceUID uid);
|
||||
void *mem_vertex_usse_alloc(unsigned int size, SceUID *uid, unsigned int *usse_offset);
|
||||
void mem_vertex_usse_free(SceUID uid);
|
||||
void *mem_fragment_usse_alloc(unsigned int size, SceUID *uid, unsigned int *usse_offset);
|
||||
void mem_fragment_usse_free(SceUID uid);
|
||||
|
||||
#endif /* SDL_RENDER_VITA_GXM_MEMORY_H */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
313
externals/SDL/src/render/vitagxm/SDL_render_vita_gxm_shaders.h
vendored
Executable file
313
externals/SDL/src/render/vitagxm/SDL_render_vita_gxm_shaders.h
vendored
Executable file
@@ -0,0 +1,313 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef SDL_RENDER_VITA_GXM_SHADERS_H
|
||||
#define SDL_RENDER_VITA_GXM_SHADERS_H
|
||||
|
||||
#include <psp2/gxm.h>
|
||||
|
||||
#define gxm_shader_clear_f_size 232
|
||||
static const unsigned char gxm_shader_clear_f[gxm_shader_clear_f_size] = {
|
||||
0x47, 0x58, 0x50, 0x00, 0x01, 0x05, 0x50, 0x03,
|
||||
0xe8, 0x00, 0x00, 0x00, 0xa2, 0x55, 0x22, 0x3e,
|
||||
0xc6, 0x7e, 0x77, 0xf1, 0x01, 0x00, 0x18, 0x00,
|
||||
0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||
0xa4, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00,
|
||||
0x02, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00,
|
||||
0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x68, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
|
||||
0x5c, 0x00, 0x00, 0x00, 0xc0, 0x3d, 0x03, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x04,
|
||||
0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x07, 0x44, 0xfa, 0x02, 0x80, 0x19, 0xf0,
|
||||
0x7e, 0x0d, 0x80, 0x40, 0x0e, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x04, 0x00, 0x10, 0x00, 0x00, 0x00,
|
||||
0x01, 0xe4, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x75, 0x43, 0x6c, 0x65,
|
||||
0x61, 0x72, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x00,
|
||||
};
|
||||
|
||||
#define gxm_shader_clear_v_size 252
|
||||
static const unsigned char gxm_shader_clear_v[gxm_shader_clear_v_size] = {
|
||||
0x47, 0x58, 0x50, 0x00, 0x01, 0x05, 0x50, 0x03,
|
||||
0xfa, 0x00, 0x00, 0x00, 0xdc, 0x25, 0x34, 0x74,
|
||||
0x53, 0x4a, 0x7a, 0x5b, 0x04, 0x00, 0x19, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||
0xb8, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00,
|
||||
0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00,
|
||||
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x74, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x78, 0x00, 0x00, 0x00, 0xc0, 0x3d, 0x03, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x04,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x44, 0xfa,
|
||||
0x01, 0x00, 0x04, 0x90, 0x85, 0x11, 0xa5, 0x08,
|
||||
0x01, 0x80, 0x56, 0x90, 0x81, 0x11, 0x83, 0x08,
|
||||
0x00, 0x00, 0x20, 0xa0, 0x00, 0x50, 0x27, 0xfb,
|
||||
0x10, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x61, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f,
|
||||
0x6e, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
#define gxm_shader_color_f_size 212
|
||||
static const unsigned char gxm_shader_color_f[gxm_shader_color_f_size] = {
|
||||
0x47, 0x58, 0x50, 0x00, 0x01, 0x05, 0x50, 0x03,
|
||||
0xd4, 0x00, 0x00, 0x00, 0x9c, 0xd6, 0x9b, 0xf7,
|
||||
0x78, 0x00, 0x5d, 0x31, 0x01, 0x10, 0x18, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xac, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00,
|
||||
0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00,
|
||||
0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x78, 0x00, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x6c, 0x00, 0x00, 0x00, 0xc0, 0x3d, 0x03, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x04,
|
||||
0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
|
||||
0x0f, 0xa0, 0xd0, 0x0e, 0x00, 0x00, 0x00, 0x00,
|
||||
0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x07, 0x44, 0xfa, 0x02, 0x80, 0x19, 0xa0,
|
||||
0x7e, 0x0d, 0x80, 0x40,
|
||||
};
|
||||
|
||||
#define gxm_shader_color_v_size 344
|
||||
static const unsigned char gxm_shader_color_v[gxm_shader_color_v_size] = {
|
||||
0x47, 0x58, 0x50, 0x00, 0x01, 0x05, 0x50, 0x03,
|
||||
0x55, 0x01, 0x00, 0x00, 0x2e, 0x35, 0x0f, 0x26,
|
||||
0x23, 0x46, 0x37, 0xbb, 0x00, 0x00, 0x19, 0x00,
|
||||
0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
|
||||
0xe8, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00,
|
||||
0x08, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x01, 0x00, 0x09, 0x00, 0x00, 0x00,
|
||||
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x74, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
|
||||
0xa0, 0x00, 0x00, 0x00, 0xc0, 0x3d, 0x03, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x94, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x94, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xf7, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x08,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x44, 0xfa,
|
||||
0x80, 0x00, 0x08, 0x83, 0x21, 0x1d, 0x80, 0x38,
|
||||
0x02, 0x80, 0x81, 0xaf, 0x9c, 0x0d, 0xc0, 0x40,
|
||||
0x0e, 0x86, 0xb9, 0xff, 0xbc, 0x0d, 0xc0, 0x40,
|
||||
0x04, 0x11, 0x49, 0xcf, 0x80, 0x8f, 0xb1, 0x18,
|
||||
0x02, 0x11, 0x45, 0xcf, 0x80, 0x8f, 0xb1, 0x18,
|
||||
0x00, 0x11, 0x01, 0xc0, 0x81, 0x81, 0xb1, 0x18,
|
||||
0x01, 0xd1, 0x42, 0xc0, 0x81, 0x81, 0xb1, 0x18,
|
||||
0x00, 0x00, 0x20, 0xa0, 0x00, 0x50, 0x27, 0xfb,
|
||||
0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
|
||||
0x30, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x2a, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
|
||||
0x21, 0x00, 0x00, 0x00, 0x01, 0xe4, 0x00, 0x00,
|
||||
0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x61, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f,
|
||||
0x6e, 0x00, 0x61, 0x43, 0x6f, 0x6c, 0x6f, 0x72,
|
||||
0x00, 0x77, 0x76, 0x70, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
#define gxm_shader_texture_f_size 256
|
||||
static const unsigned char gxm_shader_texture_f[gxm_shader_texture_f_size] = {
|
||||
0x47, 0x58, 0x50, 0x00, 0x01, 0x05, 0x50, 0x03,
|
||||
0x00, 0x01, 0x00, 0x00, 0x2f, 0x18, 0xe0, 0x2b,
|
||||
0x1f, 0x21, 0x47, 0x49, 0x01, 0x08, 0x18, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||
0xa4, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00,
|
||||
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||
0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x78, 0x00, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x64, 0x00, 0x00, 0x00, 0xc0, 0x3d, 0x03, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00,
|
||||
0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x04,
|
||||
0x01, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00,
|
||||
0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x40, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x07, 0x44, 0xfa, 0x30, 0x00, 0x00, 0x00,
|
||||
0x02, 0x04, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x02, 0x03, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x74, 0x65, 0x78, 0x00,
|
||||
};
|
||||
|
||||
#define gxm_shader_texture_tint_f_size 324
|
||||
static const unsigned char gxm_shader_texture_tint_f[gxm_shader_texture_tint_f_size] = {
|
||||
0x47, 0x58, 0x50, 0x00, 0x01, 0x05, 0x50, 0x03,
|
||||
0x43, 0x01, 0x00, 0x00, 0x44, 0x2f, 0x5d, 0xfe,
|
||||
0x9e, 0xda, 0xf8, 0x6f, 0x05, 0x08, 0x18, 0x00,
|
||||
0x00, 0x00, 0x00, 0x10, 0x01, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
|
||||
0xcc, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00,
|
||||
0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x01, 0x00, 0x05, 0x00, 0x00, 0x00,
|
||||
0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x78, 0x00, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
|
||||
0x84, 0x00, 0x00, 0x00, 0xc0, 0x3d, 0x03, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00,
|
||||
0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x04,
|
||||
0x01, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00,
|
||||
0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xc0, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x07, 0x44, 0xfa, 0x00, 0x00, 0x00, 0x00,
|
||||
0x40, 0x09, 0x00, 0xf8, 0x02, 0x80, 0x99, 0xff,
|
||||
0xbc, 0x0d, 0xc0, 0x40, 0x02, 0x80, 0xb9, 0xaf,
|
||||
0xbc, 0x0d, 0x80, 0x40, 0x7c, 0x0f, 0x04, 0x00,
|
||||
0x86, 0x47, 0xa4, 0x10, 0x0e, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x04, 0x00, 0x40, 0x00, 0x00, 0x00,
|
||||
0x01, 0xe4, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x00, 0x00,
|
||||
0x02, 0x04, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x75, 0x54, 0x69, 0x6e,
|
||||
0x74, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0x74,
|
||||
0x65, 0x78, 0x00, 0x00,
|
||||
};
|
||||
|
||||
#define gxm_shader_texture_v_size 344
|
||||
static const unsigned char gxm_shader_texture_v[gxm_shader_texture_v_size] = {
|
||||
0x47, 0x58, 0x50, 0x00, 0x01, 0x05, 0x50, 0x03,
|
||||
0x58, 0x01, 0x00, 0x00, 0xa3, 0x36, 0x7b, 0x62,
|
||||
0x1b, 0x80, 0x1c, 0xb0, 0x00, 0x00, 0x19, 0x00,
|
||||
0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
|
||||
0xe8, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00,
|
||||
0x08, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x01, 0x00, 0x09, 0x00, 0x00, 0x00,
|
||||
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x74, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
|
||||
0xa0, 0x00, 0x00, 0x00, 0xc0, 0x3d, 0x03, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x94, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x94, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x06,
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x44, 0xfa,
|
||||
0x80, 0x00, 0x08, 0x83, 0x21, 0x0d, 0x80, 0x38,
|
||||
0x02, 0x80, 0x81, 0xaf, 0x9c, 0x0d, 0xc0, 0x40,
|
||||
0x0e, 0x86, 0xb9, 0xff, 0xbc, 0x0d, 0xc0, 0x40,
|
||||
0x04, 0x11, 0x49, 0xcf, 0x80, 0x8f, 0xb1, 0x18,
|
||||
0x02, 0x11, 0x45, 0xcf, 0x80, 0x8f, 0xb1, 0x18,
|
||||
0x00, 0x11, 0x01, 0xc0, 0x81, 0x81, 0xb1, 0x18,
|
||||
0x01, 0xd1, 0x42, 0xc0, 0x81, 0x81, 0xb1, 0x18,
|
||||
0x00, 0x00, 0x20, 0xa0, 0x00, 0x50, 0x27, 0xfb,
|
||||
0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
|
||||
0x30, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x2a, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
|
||||
0x24, 0x00, 0x00, 0x00, 0x01, 0xe4, 0x00, 0x00,
|
||||
0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x61, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f,
|
||||
0x6e, 0x00, 0x61, 0x54, 0x65, 0x78, 0x63, 0x6f,
|
||||
0x6f, 0x72, 0x64, 0x00, 0x77, 0x76, 0x70, 0x00,
|
||||
};
|
||||
|
||||
|
||||
static const SceGxmProgram *const clearVertexProgramGxp = (const SceGxmProgram*)gxm_shader_clear_v;
|
||||
static const SceGxmProgram *const clearFragmentProgramGxp = (const SceGxmProgram *)gxm_shader_clear_f;
|
||||
static const SceGxmProgram *const colorVertexProgramGxp = (const SceGxmProgram *)gxm_shader_color_v;
|
||||
static const SceGxmProgram *const colorFragmentProgramGxp = (const SceGxmProgram *)gxm_shader_color_f;
|
||||
static const SceGxmProgram *const textureVertexProgramGxp = (const SceGxmProgram *)gxm_shader_texture_v;
|
||||
static const SceGxmProgram *const textureFragmentProgramGxp = (const SceGxmProgram *)gxm_shader_texture_f;
|
||||
static const SceGxmProgram *const textureTintFragmentProgramGxp = (const SceGxmProgram *)gxm_shader_texture_tint_f;
|
||||
|
||||
#endif // SDL_RENDER_VITA_GXM_SHADERS_H
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
1269
externals/SDL/src/render/vitagxm/SDL_render_vita_gxm_tools.c
vendored
Executable file
1269
externals/SDL/src/render/vitagxm/SDL_render_vita_gxm_tools.c
vendored
Executable file
File diff suppressed because it is too large
Load Diff
70
externals/SDL/src/render/vitagxm/SDL_render_vita_gxm_tools.h
vendored
Executable file
70
externals/SDL/src/render/vitagxm/SDL_render_vita_gxm_tools.h
vendored
Executable file
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef SDL_RENDER_VITA_GXM_TOOLS_H
|
||||
#define SDL_RENDER_VITA_GXM_TOOLS_H
|
||||
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#include "SDL_hints.h"
|
||||
#include "../SDL_sysrender.h"
|
||||
|
||||
#include <psp2/kernel/processmgr.h>
|
||||
#include <psp2/appmgr.h>
|
||||
#include <psp2/display.h>
|
||||
#include <psp2/gxm.h>
|
||||
#include <psp2/types.h>
|
||||
#include <psp2/kernel/sysmem.h>
|
||||
|
||||
#include "SDL_render_vita_gxm_types.h"
|
||||
|
||||
void
|
||||
init_orthographic_matrix(float *m, float left, float right, float bottom, float top, float near, float far);
|
||||
|
||||
void *pool_malloc(VITA_GXM_RenderData *data, unsigned int size);
|
||||
void *pool_memalign(VITA_GXM_RenderData *data, unsigned int size, unsigned int alignment);
|
||||
|
||||
void set_clip_rectangle(VITA_GXM_RenderData *data, int x_min, int y_min, int x_max, int y_max);
|
||||
void unset_clip_rectangle(VITA_GXM_RenderData *data);
|
||||
|
||||
int gxm_init(SDL_Renderer *renderer);
|
||||
void gxm_finish(SDL_Renderer *renderer);
|
||||
|
||||
gxm_texture *create_gxm_texture(VITA_GXM_RenderData *data, unsigned int w, unsigned int h, SceGxmTextureFormat format, unsigned int isRenderTarget);
|
||||
void free_gxm_texture(gxm_texture *texture);
|
||||
|
||||
void gxm_texture_set_filters(gxm_texture *texture, SceGxmTextureFilter min_filter, SceGxmTextureFilter mag_filter);
|
||||
SceGxmTextureFormat gxm_texture_get_format(const gxm_texture *texture);
|
||||
|
||||
unsigned int gxm_texture_get_width(const gxm_texture *texture);
|
||||
unsigned int gxm_texture_get_height(const gxm_texture *texture);
|
||||
unsigned int gxm_texture_get_stride(const gxm_texture *texture);
|
||||
void *gxm_texture_get_datap(const gxm_texture *texture);
|
||||
|
||||
void gxm_minimal_init_for_common_dialog(void);
|
||||
void gxm_minimal_term_for_common_dialog(void);
|
||||
void gxm_init_for_common_dialog(void);
|
||||
void gxm_swap_for_common_dialog(void);
|
||||
void gxm_term_for_common_dialog(void);
|
||||
|
||||
#endif /* SDL_RENDER_VITA_GXM_TOOLS_H */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
208
externals/SDL/src/render/vitagxm/SDL_render_vita_gxm_types.h
vendored
Executable file
208
externals/SDL/src/render/vitagxm/SDL_render_vita_gxm_types.h
vendored
Executable file
@@ -0,0 +1,208 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef SDL_RENDER_VITA_GXM_TYPES_H
|
||||
#define SDL_RENDER_VITA_GXM_TYPES_H
|
||||
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#include "SDL_hints.h"
|
||||
#include "../SDL_sysrender.h"
|
||||
|
||||
#include <psp2/kernel/processmgr.h>
|
||||
#include <psp2/appmgr.h>
|
||||
#include <psp2/display.h>
|
||||
#include <psp2/gxm.h>
|
||||
#include <psp2/types.h>
|
||||
#include <psp2/kernel/sysmem.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#define VITA_GXM_SCREEN_WIDTH 960
|
||||
#define VITA_GXM_SCREEN_HEIGHT 544
|
||||
#define VITA_GXM_SCREEN_STRIDE 960
|
||||
|
||||
#define VITA_GXM_COLOR_FORMAT SCE_GXM_COLOR_FORMAT_A8B8G8R8
|
||||
#define VITA_GXM_PIXEL_FORMAT SCE_DISPLAY_PIXELFORMAT_A8B8G8R8
|
||||
|
||||
#define VITA_GXM_BUFFERS 3
|
||||
#define VITA_GXM_PENDING_SWAPS 2
|
||||
#define VITA_GXM_POOL_SIZE 2 * 1024 * 1024
|
||||
|
||||
typedef struct
|
||||
{
|
||||
void *address;
|
||||
Uint8 wait_vblank;
|
||||
} VITA_GXM_DisplayData;
|
||||
|
||||
typedef struct clear_vertex {
|
||||
float x;
|
||||
float y;
|
||||
} clear_vertex;
|
||||
|
||||
typedef struct color_vertex {
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
unsigned int color;
|
||||
} color_vertex;
|
||||
|
||||
typedef struct texture_vertex {
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
float u;
|
||||
float v;
|
||||
} texture_vertex;
|
||||
|
||||
typedef struct gxm_texture {
|
||||
SceGxmTexture gxm_tex;
|
||||
SceUID data_UID;
|
||||
SceUID palette_UID;
|
||||
SceGxmRenderTarget *gxm_rendertarget;
|
||||
SceGxmColorSurface gxm_colorsurface;
|
||||
SceGxmDepthStencilSurface gxm_depthstencil;
|
||||
SceUID depth_UID;
|
||||
} gxm_texture;
|
||||
|
||||
typedef struct fragment_programs {
|
||||
SceGxmFragmentProgram *color;
|
||||
SceGxmFragmentProgram *texture;
|
||||
SceGxmFragmentProgram *textureTint;
|
||||
} fragment_programs;
|
||||
|
||||
typedef struct blend_fragment_programs {
|
||||
fragment_programs blend_mode_none;
|
||||
fragment_programs blend_mode_blend;
|
||||
fragment_programs blend_mode_add;
|
||||
fragment_programs blend_mode_mod;
|
||||
fragment_programs blend_mode_mul;
|
||||
} blend_fragment_programs;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
SDL_Rect viewport;
|
||||
SDL_bool viewport_dirty;
|
||||
SDL_Texture *texture;
|
||||
SDL_Texture *target;
|
||||
Uint32 color;
|
||||
Uint32 texture_color;
|
||||
SceGxmFragmentProgram *fragment_program;
|
||||
SceGxmVertexProgram *vertex_program;
|
||||
int last_command;
|
||||
|
||||
SDL_bool cliprect_enabled_dirty;
|
||||
SDL_bool cliprect_enabled;
|
||||
SDL_bool cliprect_dirty;
|
||||
SDL_Rect cliprect;
|
||||
SDL_bool texturing;
|
||||
Uint32 clear_color;
|
||||
int drawablew;
|
||||
int drawableh;
|
||||
} gxm_drawstate_cache;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
SDL_bool initialized;
|
||||
SDL_bool drawing;
|
||||
|
||||
unsigned int psm;
|
||||
unsigned int bpp;
|
||||
|
||||
int currentBlendMode;
|
||||
|
||||
VITA_GXM_DisplayData displayData;
|
||||
|
||||
SceUID vdmRingBufferUid;
|
||||
SceUID vertexRingBufferUid;
|
||||
SceUID fragmentRingBufferUid;
|
||||
SceUID fragmentUsseRingBufferUid;
|
||||
SceGxmContextParams contextParams;
|
||||
SceGxmContext *gxm_context;
|
||||
SceGxmRenderTarget *renderTarget;
|
||||
SceUID displayBufferUid[VITA_GXM_BUFFERS];
|
||||
void *displayBufferData[VITA_GXM_BUFFERS];
|
||||
SceGxmColorSurface displaySurface[VITA_GXM_BUFFERS];
|
||||
SceGxmSyncObject *displayBufferSync[VITA_GXM_BUFFERS];
|
||||
|
||||
SceUID depthBufferUid;
|
||||
SceUID stencilBufferUid;
|
||||
SceGxmDepthStencilSurface depthSurface;
|
||||
void *depthBufferData;
|
||||
void *stencilBufferData;
|
||||
|
||||
unsigned int backBufferIndex;
|
||||
unsigned int frontBufferIndex;
|
||||
|
||||
void* pool_addr[2];
|
||||
SceUID poolUid[2];
|
||||
unsigned int pool_index;
|
||||
unsigned int current_pool;
|
||||
|
||||
float ortho_matrix[4*4];
|
||||
|
||||
SceGxmVertexProgram *colorVertexProgram;
|
||||
SceGxmFragmentProgram *colorFragmentProgram;
|
||||
SceGxmVertexProgram *textureVertexProgram;
|
||||
SceGxmFragmentProgram *textureFragmentProgram;
|
||||
SceGxmFragmentProgram *textureTintFragmentProgram;
|
||||
SceGxmProgramParameter *clearClearColorParam;
|
||||
SceGxmProgramParameter *colorWvpParam;
|
||||
SceGxmProgramParameter *textureWvpParam;
|
||||
SceGxmProgramParameter *textureTintColorParam;
|
||||
|
||||
SceGxmShaderPatcher *shaderPatcher;
|
||||
SceGxmVertexProgram *clearVertexProgram;
|
||||
SceGxmFragmentProgram *clearFragmentProgram;
|
||||
|
||||
SceGxmShaderPatcherId clearVertexProgramId;
|
||||
SceGxmShaderPatcherId clearFragmentProgramId;
|
||||
SceGxmShaderPatcherId colorVertexProgramId;
|
||||
SceGxmShaderPatcherId colorFragmentProgramId;
|
||||
SceGxmShaderPatcherId textureVertexProgramId;
|
||||
SceGxmShaderPatcherId textureFragmentProgramId;
|
||||
SceGxmShaderPatcherId textureTintFragmentProgramId;
|
||||
|
||||
SceUID patcherBufferUid;
|
||||
SceUID patcherVertexUsseUid;
|
||||
SceUID patcherFragmentUsseUid;
|
||||
|
||||
SceUID clearVerticesUid;
|
||||
SceUID linearIndicesUid;
|
||||
clear_vertex *clearVertices;
|
||||
uint16_t *linearIndices;
|
||||
|
||||
blend_fragment_programs blendFragmentPrograms;
|
||||
|
||||
gxm_drawstate_cache drawstate;
|
||||
} VITA_GXM_RenderData;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
gxm_texture *tex;
|
||||
unsigned int pitch;
|
||||
unsigned int w;
|
||||
unsigned int h;
|
||||
} VITA_GXM_TextureData;
|
||||
|
||||
#endif /* SDL_RENDER_VITA_GXM_TYPES_H */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
4
externals/SDL/src/render/vitagxm/shader_src/clear_f.cg
vendored
Executable file
4
externals/SDL/src/render/vitagxm/shader_src/clear_f.cg
vendored
Executable file
@@ -0,0 +1,4 @@
|
||||
float4 main( uniform float4 uClearColor) : COLOR
|
||||
{
|
||||
return uClearColor;
|
||||
}
|
4
externals/SDL/src/render/vitagxm/shader_src/clear_v.cg
vendored
Executable file
4
externals/SDL/src/render/vitagxm/shader_src/clear_v.cg
vendored
Executable file
@@ -0,0 +1,4 @@
|
||||
float4 main(float2 aPosition) : POSITION
|
||||
{
|
||||
return float4(aPosition, 1.f, 1.f);
|
||||
}
|
4
externals/SDL/src/render/vitagxm/shader_src/color_f.cg
vendored
Executable file
4
externals/SDL/src/render/vitagxm/shader_src/color_f.cg
vendored
Executable file
@@ -0,0 +1,4 @@
|
||||
float4 main(float4 vColor : COLOR)
|
||||
{
|
||||
return vColor;
|
||||
}
|
11
externals/SDL/src/render/vitagxm/shader_src/color_v.cg
vendored
Executable file
11
externals/SDL/src/render/vitagxm/shader_src/color_v.cg
vendored
Executable file
@@ -0,0 +1,11 @@
|
||||
void main(
|
||||
float3 aPosition,
|
||||
float4 aColor,
|
||||
uniform float4x4 wvp,
|
||||
float4 out vPosition : POSITION,
|
||||
float4 out vColor : COLOR
|
||||
)
|
||||
{
|
||||
vPosition = mul(float4(aPosition, 1.f), wvp);
|
||||
vColor = aColor;
|
||||
}
|
4
externals/SDL/src/render/vitagxm/shader_src/texture_f.cg
vendored
Executable file
4
externals/SDL/src/render/vitagxm/shader_src/texture_f.cg
vendored
Executable file
@@ -0,0 +1,4 @@
|
||||
float4 main(float2 vTexcoord : TEXCOORD0, uniform sampler2D tex)
|
||||
{
|
||||
return tex2D(tex, vTexcoord);
|
||||
}
|
4
externals/SDL/src/render/vitagxm/shader_src/texture_tint_f.cg
vendored
Executable file
4
externals/SDL/src/render/vitagxm/shader_src/texture_tint_f.cg
vendored
Executable file
@@ -0,0 +1,4 @@
|
||||
float4 main( float2 vTexcoord : TEXCOORD0, uniform sampler2D tex, uniform float4 uTintColor)
|
||||
{
|
||||
return tex2D(tex, vTexcoord) * uTintColor;
|
||||
}
|
11
externals/SDL/src/render/vitagxm/shader_src/texture_v.cg
vendored
Executable file
11
externals/SDL/src/render/vitagxm/shader_src/texture_v.cg
vendored
Executable file
@@ -0,0 +1,11 @@
|
||||
void main(
|
||||
float3 aPosition,
|
||||
float2 aTexcoord,
|
||||
uniform float4x4 wvp,
|
||||
float4 out vPosition : POSITION,
|
||||
float2 out vTexcoord : TEXCOORD0
|
||||
)
|
||||
{
|
||||
vPosition = mul(float4(aPosition, 1.f), wvp);
|
||||
vTexcoord = aTexcoord;
|
||||
}
|
Reference in New Issue
Block a user