Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
This commit is contained in:
1 parent
658fc3db0f
commit
6501e90018
743 files changed
+11882
-11882
No files matched your search
@@ -24,7 +24,7 @@
|
||||
|
||||
#include "SDL_d3dmath.h"
|
||||
|
||||
/* Direct3D matrix math functions */
|
||||
// Direct3D matrix math functions
|
||||
|
||||
Float4X4 MatrixIdentity(void)
|
||||
{
|
||||
@@ -129,4 +129,4 @@ Float4X4 MatrixRotationZ(float r)
|
||||
return m;
|
||||
}
|
||||
|
||||
#endif /* (SDL_VIDEO_RENDER_D3D || SDL_VIDEO_RENDER_D3D11 || SDL_VIDEO_RENDER_D3D12) */
|
||||
#endif // (SDL_VIDEO_RENDER_D3D || SDL_VIDEO_RENDER_D3D11 || SDL_VIDEO_RENDER_D3D12)
|
||||
@@ -22,12 +22,12 @@
|
||||
|
||||
#if (SDL_VIDEO_RENDER_D3D || SDL_VIDEO_RENDER_D3D11 || SDL_VIDEO_RENDER_D3D12 || SDL_VIDEO_RENDER_VULKAN)
|
||||
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
// Set up for C function definitions, even when using C++
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Direct3D matrix math functions */
|
||||
// Direct3D matrix math functions
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@@ -73,9 +73,9 @@ extern Float4X4 MatrixRotationX(float r);
|
||||
extern Float4X4 MatrixRotationY(float r);
|
||||
extern Float4X4 MatrixRotationZ(float r);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
// Ends C function definitions when using C++
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* (SDL_VIDEO_RENDER_D3D || SDL_VIDEO_RENDER_D3D11 || SDL_VIDEO_RENDER_D3D12 || SDL_VIDEO_RENDER_VULKAN)*/
|
||||
#endif // (SDL_VIDEO_RENDER_D3D || SDL_VIDEO_RENDER_D3D11 || SDL_VIDEO_RENDER_D3D12 || SDL_VIDEO_RENDER_VULKAN)
|
||||
+147
-147
File diff suppressed because it is too large.
Load diff
+25
-25
@@ -25,7 +25,7 @@
|
||||
|
||||
#include "SDL_yuv_sw_c.h"
|
||||
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
// Set up for C function definitions, even when using C++
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@@ -48,11 +48,11 @@ typedef struct SDL_DRect
|
||||
double h;
|
||||
} SDL_DRect;
|
||||
|
||||
/* The SDL 2D rendering system */
|
||||
// The SDL 2D rendering system
|
||||
|
||||
typedef struct SDL_RenderDriver SDL_RenderDriver;
|
||||
|
||||
/* Rendering view state */
|
||||
// Rendering view state
|
||||
typedef struct SDL_RenderViewState
|
||||
{
|
||||
int pixel_w;
|
||||
@@ -66,7 +66,7 @@ typedef struct SDL_RenderViewState
|
||||
|
||||
} SDL_RenderViewState;
|
||||
|
||||
/* Define the SDL texture structure */
|
||||
// Define the SDL texture structure
|
||||
struct SDL_Texture
|
||||
{
|
||||
SDL_Colorspace colorspace; /**< The colorspace of the texture */
|
||||
@@ -83,7 +83,7 @@ struct SDL_Texture
|
||||
|
||||
SDL_Renderer *renderer;
|
||||
|
||||
/* Support for formats not supported directly by the renderer */
|
||||
// Support for formats not supported directly by the renderer
|
||||
SDL_Texture *native;
|
||||
SDL_SW_YUVTexture *yuv;
|
||||
void *pixels;
|
||||
@@ -91,7 +91,7 @@ struct SDL_Texture
|
||||
SDL_Rect locked_rect;
|
||||
SDL_Surface *locked_surface; /**< Locked region exposed as a SDL surface */
|
||||
|
||||
Uint32 last_command_generation; /* last command queue generation this texture was in. */
|
||||
Uint32 last_command_generation; // last command queue generation this texture was in.
|
||||
|
||||
SDL_PropertiesID props;
|
||||
|
||||
@@ -164,7 +164,7 @@ typedef enum
|
||||
SDL_RENDERLINEMETHOD_GEOMETRY,
|
||||
} SDL_RenderLineMethod;
|
||||
|
||||
/* Define the SDL renderer structure */
|
||||
// Define the SDL renderer structure
|
||||
struct SDL_Renderer
|
||||
{
|
||||
void (*WindowEvent)(SDL_Renderer *renderer, const SDL_WindowEvent *event);
|
||||
@@ -223,23 +223,23 @@ struct SDL_Renderer
|
||||
|
||||
int (*AddVulkanRenderSemaphores)(SDL_Renderer *renderer, Uint32 wait_stage_mask, Sint64 wait_semaphore, Sint64 signal_semaphore);
|
||||
|
||||
/* The current renderer info */
|
||||
// The current renderer info
|
||||
const char *name;
|
||||
SDL_PixelFormat *texture_formats;
|
||||
int num_texture_formats;
|
||||
SDL_bool software;
|
||||
|
||||
/* The window associated with the renderer */
|
||||
// The window associated with the renderer
|
||||
SDL_Window *window;
|
||||
SDL_bool hidden;
|
||||
|
||||
/* Whether we should simulate vsync */
|
||||
// Whether we should simulate vsync
|
||||
SDL_bool wanted_vsync;
|
||||
SDL_bool simulate_vsync;
|
||||
Uint64 simulate_vsync_interval_ns;
|
||||
Uint64 last_present;
|
||||
|
||||
/* Support for logical output coordinates */
|
||||
// Support for logical output coordinates
|
||||
SDL_Texture *logical_target;
|
||||
SDL_RendererLogicalPresentation logical_presentation_mode;
|
||||
SDL_ScaleMode logical_scale_mode;
|
||||
@@ -249,16 +249,16 @@ struct SDL_Renderer
|
||||
SDL_RenderViewState *view;
|
||||
SDL_RenderViewState main_view;
|
||||
|
||||
/* The window pixel to point coordinate scale */
|
||||
// The window pixel to point coordinate scale
|
||||
SDL_FPoint dpi_scale;
|
||||
|
||||
/* The method of drawing lines */
|
||||
// The method of drawing lines
|
||||
SDL_RenderLineMethod line_method;
|
||||
|
||||
/* List of triangle indices to draw rects */
|
||||
// List of triangle indices to draw rects
|
||||
int rect_index_order[6];
|
||||
|
||||
/* The list of textures */
|
||||
// The list of textures
|
||||
SDL_Texture *textures;
|
||||
SDL_Texture *target;
|
||||
SDL_Mutex *target_mutex;
|
||||
@@ -290,7 +290,7 @@ struct SDL_Renderer
|
||||
size_t vertex_data_used;
|
||||
size_t vertex_data_allocation;
|
||||
|
||||
/* Shaped window support */
|
||||
// Shaped window support
|
||||
SDL_bool transparent_window;
|
||||
SDL_Surface *shape_surface;
|
||||
SDL_Texture *shape_texture;
|
||||
@@ -304,7 +304,7 @@ struct SDL_Renderer
|
||||
SDL_Renderer *next;
|
||||
};
|
||||
|
||||
/* Define the SDL render driver structure */
|
||||
// Define the SDL render driver structure
|
||||
struct SDL_RenderDriver
|
||||
{
|
||||
int (*CreateRenderer)(SDL_Renderer *renderer, SDL_Window *window, SDL_PropertiesID props);
|
||||
@@ -312,7 +312,7 @@ struct SDL_RenderDriver
|
||||
const char *name;
|
||||
};
|
||||
|
||||
/* Not all of these are available in a given build. Use #ifdefs, etc. */
|
||||
// Not all of these are available in a given build. Use #ifdefs, etc.
|
||||
extern SDL_RenderDriver D3D_RenderDriver;
|
||||
extern SDL_RenderDriver D3D11_RenderDriver;
|
||||
extern SDL_RenderDriver D3D12_RenderDriver;
|
||||
@@ -325,21 +325,21 @@ extern SDL_RenderDriver PSP_RenderDriver;
|
||||
extern SDL_RenderDriver SW_RenderDriver;
|
||||
extern SDL_RenderDriver VITA_GXM_RenderDriver;
|
||||
|
||||
/* Clean up any renderers at shutdown */
|
||||
// Clean up any renderers at shutdown
|
||||
extern void SDL_QuitRender(void);
|
||||
|
||||
/* Add a supported texture format to a renderer */
|
||||
// Add a supported texture format to a renderer
|
||||
extern int SDL_AddSupportedTextureFormat(SDL_Renderer *renderer, SDL_PixelFormat format);
|
||||
|
||||
/* Setup colorspace conversion */
|
||||
// Setup colorspace conversion
|
||||
extern void SDL_SetupRendererColorspace(SDL_Renderer *renderer, SDL_PropertiesID props);
|
||||
|
||||
/* Colorspace conversion functions */
|
||||
// Colorspace conversion functions
|
||||
extern SDL_bool SDL_RenderingLinearSpace(SDL_Renderer *renderer);
|
||||
extern void SDL_ConvertToLinear(SDL_FColor *color);
|
||||
extern void SDL_ConvertFromLinear(SDL_FColor *color);
|
||||
|
||||
/* Blend mode functions */
|
||||
// Blend mode functions
|
||||
extern SDL_BlendFactor SDL_GetBlendModeSrcColorFactor(SDL_BlendMode blendMode);
|
||||
extern SDL_BlendFactor SDL_GetBlendModeDstColorFactor(SDL_BlendMode blendMode);
|
||||
extern SDL_BlendOperation SDL_GetBlendModeColorOperation(SDL_BlendMode blendMode);
|
||||
@@ -355,9 +355,9 @@ extern void *SDL_AllocateRenderVertices(SDL_Renderer *renderer, const size_t num
|
||||
// Let the video subsystem destroy a renderer without making its pointer invalid.
|
||||
extern void SDL_DestroyRendererWithoutFreeing(SDL_Renderer *renderer);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
// Ends C function definitions when using C++
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* SDL_sysrender_h_ */
|
||||
#endif // SDL_sysrender_h_
|
||||
+15
-15
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
#include "SDL_internal.h"
|
||||
|
||||
/* This is the software implementation of the YUV texture support */
|
||||
// This is the software implementation of the YUV texture support
|
||||
|
||||
#if SDL_HAVE_YUV
|
||||
|
||||
@@ -68,7 +68,7 @@ SDL_SW_YUVTexture *SDL_SW_CreateYUVTexture(SDL_PixelFormat format, int w, int h)
|
||||
}
|
||||
}
|
||||
|
||||
/* Find the pitch and offset values for the texture */
|
||||
// Find the pitch and offset values for the texture
|
||||
switch (format) {
|
||||
case SDL_PIXELFORMAT_YV12:
|
||||
case SDL_PIXELFORMAT_IYUV:
|
||||
@@ -99,7 +99,7 @@ SDL_SW_YUVTexture *SDL_SW_CreateYUVTexture(SDL_PixelFormat format, int w, int h)
|
||||
break;
|
||||
}
|
||||
|
||||
/* We're all done.. */
|
||||
// We're all done..
|
||||
return swdata;
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ int SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect,
|
||||
int row;
|
||||
size_t length;
|
||||
|
||||
/* Copy the Y plane */
|
||||
// Copy the Y plane
|
||||
src = (Uint8 *)pixels;
|
||||
dst = swdata->pixels + rect->y * swdata->w + rect->x;
|
||||
length = rect->w;
|
||||
@@ -136,7 +136,7 @@ int SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect,
|
||||
dst += swdata->w;
|
||||
}
|
||||
|
||||
/* Copy the next plane */
|
||||
// Copy the next plane
|
||||
src = (Uint8 *)pixels + rect->h * pitch;
|
||||
dst = swdata->pixels + swdata->h * swdata->w;
|
||||
dst += rect->y / 2 * ((swdata->w + 1) / 2) + rect->x / 2;
|
||||
@@ -147,7 +147,7 @@ int SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect,
|
||||
dst += (swdata->w + 1) / 2;
|
||||
}
|
||||
|
||||
/* Copy the next plane */
|
||||
// Copy the next plane
|
||||
src = (Uint8 *)pixels + rect->h * pitch + ((rect->h + 1) / 2) * ((pitch + 1) / 2);
|
||||
dst = swdata->pixels + swdata->h * swdata->w +
|
||||
((swdata->h + 1) / 2) * ((swdata->w + 1) / 2);
|
||||
@@ -191,7 +191,7 @@ int SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect,
|
||||
int row;
|
||||
size_t length;
|
||||
|
||||
/* Copy the Y plane */
|
||||
// Copy the Y plane
|
||||
src = (Uint8 *)pixels;
|
||||
dst = swdata->pixels + rect->y * swdata->w + rect->x;
|
||||
length = rect->w;
|
||||
@@ -201,7 +201,7 @@ int SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect,
|
||||
dst += swdata->w;
|
||||
}
|
||||
|
||||
/* Copy the next plane */
|
||||
// Copy the next plane
|
||||
src = (Uint8 *)pixels + rect->h * pitch;
|
||||
dst = swdata->pixels + swdata->h * swdata->w;
|
||||
dst += 2 * ((rect->y + 1) / 2) * ((swdata->w + 1) / 2) + 2 * (rect->x / 2);
|
||||
@@ -229,7 +229,7 @@ int SDL_SW_UpdateYUVTexturePlanar(SDL_SW_YUVTexture *swdata, const SDL_Rect *rec
|
||||
int row;
|
||||
size_t length;
|
||||
|
||||
/* Copy the Y plane */
|
||||
// Copy the Y plane
|
||||
src = Yplane;
|
||||
dst = swdata->pixels + rect->y * swdata->w + rect->x;
|
||||
length = rect->w;
|
||||
@@ -239,7 +239,7 @@ int SDL_SW_UpdateYUVTexturePlanar(SDL_SW_YUVTexture *swdata, const SDL_Rect *rec
|
||||
dst += swdata->w;
|
||||
}
|
||||
|
||||
/* Copy the U plane */
|
||||
// Copy the U plane
|
||||
src = Uplane;
|
||||
if (swdata->format == SDL_PIXELFORMAT_IYUV) {
|
||||
dst = swdata->pixels + swdata->h * swdata->w;
|
||||
@@ -255,7 +255,7 @@ int SDL_SW_UpdateYUVTexturePlanar(SDL_SW_YUVTexture *swdata, const SDL_Rect *rec
|
||||
dst += (swdata->w + 1) / 2;
|
||||
}
|
||||
|
||||
/* Copy the V plane */
|
||||
// Copy the V plane
|
||||
src = Vplane;
|
||||
if (swdata->format == SDL_PIXELFORMAT_YV12) {
|
||||
dst = swdata->pixels + swdata->h * swdata->w;
|
||||
@@ -282,7 +282,7 @@ int SDL_SW_UpdateNVTexturePlanar(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect
|
||||
int row;
|
||||
size_t length;
|
||||
|
||||
/* Copy the Y plane */
|
||||
// Copy the Y plane
|
||||
src = Yplane;
|
||||
dst = swdata->pixels + rect->y * swdata->w + rect->x;
|
||||
length = rect->w;
|
||||
@@ -292,7 +292,7 @@ int SDL_SW_UpdateNVTexturePlanar(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect
|
||||
dst += swdata->w;
|
||||
}
|
||||
|
||||
/* Copy the UV or VU plane */
|
||||
// Copy the UV or VU plane
|
||||
src = UVplane;
|
||||
dst = swdata->pixels + swdata->h * swdata->w;
|
||||
dst += rect->y * ((swdata->w + 1) / 2) + rect->x;
|
||||
@@ -342,7 +342,7 @@ int SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture *swdata, const SDL_Rect *srcrect,
|
||||
{
|
||||
int stretch;
|
||||
|
||||
/* Make sure we're set up to display in the desired format */
|
||||
// Make sure we're set up to display in the desired format
|
||||
if (target_format != swdata->target_format && swdata->display) {
|
||||
SDL_DestroySurface(swdata->display);
|
||||
swdata->display = NULL;
|
||||
@@ -402,4 +402,4 @@ void SDL_SW_DestroyYUVTexture(SDL_SW_YUVTexture *swdata)
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* SDL_HAVE_YUV */
|
||||
#endif // SDL_HAVE_YUV
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
#include "SDL_internal.h"
|
||||
|
||||
/* This is the software implementation of the YUV texture support */
|
||||
// This is the software implementation of the YUV texture support
|
||||
|
||||
struct SDL_SW_YUVTexture
|
||||
{
|
||||
@@ -33,11 +33,11 @@ struct SDL_SW_YUVTexture
|
||||
int w, h;
|
||||
Uint8 *pixels;
|
||||
|
||||
/* These are just so we don't have to allocate them separately */
|
||||
// These are just so we don't have to allocate them separately
|
||||
int pitches[3];
|
||||
Uint8 *planes[3];
|
||||
|
||||
/* This is a temporary surface in case we have to stretch copy */
|
||||
// This is a temporary surface in case we have to stretch copy
|
||||
SDL_Surface *stretch;
|
||||
SDL_Surface *display;
|
||||
};
|
||||
@@ -64,4 +64,4 @@ int SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture *swdata, const SDL_Rect *srcrect,
|
||||
int pitch);
|
||||
void SDL_SW_DestroyYUVTexture(SDL_SW_YUVTexture *swdata);
|
||||
|
||||
#endif /* SDL_yuv_sw_c_h_ */
|
||||
#endif // SDL_yuv_sw_c_h_
|
||||
@@ -50,7 +50,7 @@ typedef struct
|
||||
const float *shader_params;
|
||||
} D3D_DrawStateCache;
|
||||
|
||||
/* Direct3D renderer implementation */
|
||||
// Direct3D renderer implementation
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@@ -96,7 +96,7 @@ typedef struct
|
||||
const float *shader_params;
|
||||
|
||||
#if SDL_HAVE_YUV
|
||||
/* YV12 texture support */
|
||||
// YV12 texture support
|
||||
SDL_bool yuv;
|
||||
D3D_TextureRep utexture;
|
||||
D3D_TextureRep vtexture;
|
||||
@@ -239,7 +239,7 @@ static void D3D_InitRenderState(D3D_RenderData *data)
|
||||
IDirect3DDevice9_SetRenderState(device, D3DRS_CULLMODE, D3DCULL_NONE);
|
||||
IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
|
||||
|
||||
/* Enable color modulation by diffuse color */
|
||||
// Enable color modulation by diffuse color
|
||||
IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLOROP,
|
||||
D3DTOP_MODULATE);
|
||||
IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG1,
|
||||
@@ -247,7 +247,7 @@ static void D3D_InitRenderState(D3D_RenderData *data)
|
||||
IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG2,
|
||||
D3DTA_DIFFUSE);
|
||||
|
||||
/* Enable alpha modulation by diffuse alpha */
|
||||
// Enable alpha modulation by diffuse alpha
|
||||
IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_ALPHAOP,
|
||||
D3DTOP_MODULATE);
|
||||
IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_ALPHAARG1,
|
||||
@@ -255,18 +255,18 @@ static void D3D_InitRenderState(D3D_RenderData *data)
|
||||
IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_ALPHAARG2,
|
||||
D3DTA_DIFFUSE);
|
||||
|
||||
/* Enable separate alpha blend function, if possible */
|
||||
// Enable separate alpha blend function, if possible
|
||||
if (data->enableSeparateAlphaBlend) {
|
||||
IDirect3DDevice9_SetRenderState(device, D3DRS_SEPARATEALPHABLENDENABLE, TRUE);
|
||||
}
|
||||
|
||||
/* Disable second texture stage, since we're done */
|
||||
// Disable second texture stage, since we're done
|
||||
IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_COLOROP,
|
||||
D3DTOP_DISABLE);
|
||||
IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_ALPHAOP,
|
||||
D3DTOP_DISABLE);
|
||||
|
||||
/* Set an identity world and view matrix */
|
||||
// Set an identity world and view matrix
|
||||
SDL_zero(matrix);
|
||||
matrix.m[0][0] = 1.0f;
|
||||
matrix.m[1][1] = 1.0f;
|
||||
@@ -275,13 +275,13 @@ static void D3D_InitRenderState(D3D_RenderData *data)
|
||||
IDirect3DDevice9_SetTransform(device, D3DTS_WORLD, &matrix);
|
||||
IDirect3DDevice9_SetTransform(device, D3DTS_VIEW, &matrix);
|
||||
|
||||
/* Reset our current scale mode */
|
||||
// Reset our current scale mode
|
||||
SDL_memset(data->scaleMode, 0xFF, sizeof(data->scaleMode));
|
||||
|
||||
/* Reset our current address mode */
|
||||
// Reset our current address mode
|
||||
SDL_zeroa(data->addressMode);
|
||||
|
||||
/* Start the render with beginScene */
|
||||
// Start the render with beginScene
|
||||
data->beginScene = SDL_TRUE;
|
||||
}
|
||||
|
||||
@@ -612,14 +612,14 @@ static int D3D_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
}
|
||||
#if SDL_HAVE_YUV
|
||||
if (texturedata->yuv) {
|
||||
/* Skip to the correct offset into the next texture */
|
||||
// Skip to the correct offset into the next texture
|
||||
pixels = (const void *)((const Uint8 *)pixels + rect->h * pitch);
|
||||
|
||||
if (D3D_UpdateTextureRep(data->device, texture->format == SDL_PIXELFORMAT_YV12 ? &texturedata->vtexture : &texturedata->utexture, rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2, pixels, (pitch + 1) / 2) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Skip to the correct offset into the next texture */
|
||||
// Skip to the correct offset into the next texture
|
||||
pixels = (const void *)((const Uint8 *)pixels + ((rect->h + 1) / 2) * ((pitch + 1) / 2));
|
||||
if (D3D_UpdateTextureRep(data->device, texture->format == SDL_PIXELFORMAT_YV12 ? &texturedata->utexture : &texturedata->vtexture, rect->x / 2, (rect->y + 1) / 2, (rect->w + 1) / 2, (rect->h + 1) / 2, pixels, (pitch + 1) / 2) < 0) {
|
||||
return -1;
|
||||
@@ -670,7 +670,7 @@ static int D3D_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
texturedata->locked_rect = *rect;
|
||||
|
||||
if (texturedata->yuv) {
|
||||
/* It's more efficient to upload directly... */
|
||||
// It's more efficient to upload directly...
|
||||
if (!texturedata->pixels) {
|
||||
texturedata->pitch = texture->w;
|
||||
texturedata->pixels = (Uint8 *)SDL_malloc((texture->h * texturedata->pitch * 3) / 2);
|
||||
@@ -757,7 +757,7 @@ static int D3D_SetRenderTargetInternal(SDL_Renderer *renderer, SDL_Texture *text
|
||||
HRESULT result;
|
||||
IDirect3DDevice9 *device = data->device;
|
||||
|
||||
/* Release the previous render target if it wasn't the default one */
|
||||
// Release the previous render target if it wasn't the default one
|
||||
if (data->currentRenderTarget) {
|
||||
IDirect3DSurface9_Release(data->currentRenderTarget);
|
||||
data->currentRenderTarget = NULL;
|
||||
@@ -773,7 +773,7 @@ static int D3D_SetRenderTargetInternal(SDL_Renderer *renderer, SDL_Texture *text
|
||||
return SDL_SetError("Texture is not currently available");
|
||||
}
|
||||
|
||||
/* Make sure the render target is updated if it was locked and written to */
|
||||
// Make sure the render target is updated if it was locked and written to
|
||||
texturerep = &texturedata->texture;
|
||||
if (texturerep->dirty && texturerep->staging) {
|
||||
if (!texturerep->texture) {
|
||||
@@ -814,7 +814,7 @@ static int D3D_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
|
||||
static int D3D_QueueNoOp(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
{
|
||||
return 0; /* nothing to do in this backend. */
|
||||
return 0; // nothing to do in this backend.
|
||||
}
|
||||
|
||||
static int D3D_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count)
|
||||
@@ -1004,7 +1004,7 @@ static int SetDrawState(D3D_RenderData *data, const SDL_RenderCommand *cmd)
|
||||
D3D9_Shader shader = SHADER_NONE;
|
||||
const float *shader_params = NULL;
|
||||
|
||||
/* disable any enabled textures we aren't going to use, let SetupTextureState() do the rest. */
|
||||
// disable any enabled textures we aren't going to use, let SetupTextureState() do the rest.
|
||||
if (!texture) {
|
||||
IDirect3DDevice9_SetTexture(data->device, 0, NULL);
|
||||
}
|
||||
@@ -1029,7 +1029,7 @@ static int SetDrawState(D3D_RenderData *data, const SDL_RenderCommand *cmd)
|
||||
|
||||
if (shader_params != data->drawstate.shader_params) {
|
||||
if (shader_params) {
|
||||
const UINT shader_params_length = 4; /* The YUV shader takes 4 float4 parameters */
|
||||
const UINT shader_params_length = 4; // The YUV shader takes 4 float4 parameters
|
||||
const HRESULT result = IDirect3DDevice9_SetPixelShaderConstantF(data->device, 0, shader_params, shader_params_length);
|
||||
if (FAILED(result)) {
|
||||
return D3D_SetError("IDirect3DDevice9_SetPixelShaderConstantF()", result);
|
||||
@@ -1037,7 +1037,7 @@ static int SetDrawState(D3D_RenderData *data, const SDL_RenderCommand *cmd)
|
||||
}
|
||||
data->drawstate.shader_params = shader_params;
|
||||
}
|
||||
#endif /* SDL_HAVE_YUV */
|
||||
#endif // SDL_HAVE_YUV
|
||||
|
||||
data->drawstate.texture = texture;
|
||||
} else if (texture) {
|
||||
@@ -1086,7 +1086,7 @@ static int SetDrawState(D3D_RenderData *data, const SDL_RenderCommand *cmd)
|
||||
d3dviewport.MaxZ = 1.0f;
|
||||
IDirect3DDevice9_SetViewport(data->device, &d3dviewport);
|
||||
|
||||
/* Set an orthographic projection matrix */
|
||||
// Set an orthographic projection matrix
|
||||
if (viewport->w && viewport->h) {
|
||||
D3DMATRIX d3dmatrix;
|
||||
SDL_zero(d3dmatrix);
|
||||
@@ -1146,7 +1146,7 @@ static int D3D_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, v
|
||||
}
|
||||
|
||||
if (vertsize > 0) {
|
||||
/* upload the new VBO data for this set of commands. */
|
||||
// upload the new VBO data for this set of commands.
|
||||
vbo = data->vertexBuffers[vboidx];
|
||||
if (data->vertexBufferSize[vboidx] < vertsize) {
|
||||
const DWORD usage = D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY;
|
||||
@@ -1165,16 +1165,16 @@ static int D3D_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, v
|
||||
if (vbo) {
|
||||
void *ptr;
|
||||
if (FAILED(IDirect3DVertexBuffer9_Lock(vbo, 0, (UINT)vertsize, &ptr, D3DLOCK_DISCARD))) {
|
||||
vbo = NULL; /* oh well, we'll do immediate mode drawing. :( */
|
||||
vbo = NULL; // oh well, we'll do immediate mode drawing. :(
|
||||
} else {
|
||||
SDL_memcpy(ptr, vertices, vertsize);
|
||||
if (FAILED(IDirect3DVertexBuffer9_Unlock(vbo))) {
|
||||
vbo = NULL; /* oh well, we'll do immediate mode drawing. :( */
|
||||
vbo = NULL; // oh well, we'll do immediate mode drawing. :(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* cycle through a few VBOs so D3D has some time with the data before we replace it. */
|
||||
// cycle through a few VBOs so D3D has some time with the data before we replace it.
|
||||
if (vbo) {
|
||||
data->currentVertexBuffer++;
|
||||
if (data->currentVertexBuffer >= SDL_arraysize(data->vertexBuffers)) {
|
||||
@@ -1243,16 +1243,16 @@ static int D3D_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, v
|
||||
data->drawstate.cliprect_enabled_dirty = data->drawstate.cliprect_enabled;
|
||||
}
|
||||
|
||||
/* Don't reset the viewport if we don't have to! */
|
||||
// Don't reset the viewport if we don't have to!
|
||||
if (!data->drawstate.viewport_dirty && viewport_equal) {
|
||||
IDirect3DDevice9_Clear(data->device, 0, NULL, D3DCLEAR_TARGET, color, 0.0f, 0);
|
||||
} else {
|
||||
/* Clear is defined to clear the entire render target */
|
||||
// Clear is defined to clear the entire render target
|
||||
D3DVIEWPORT9 wholeviewport = { 0, 0, 0, 0, 0.0f, 1.0f };
|
||||
wholeviewport.Width = backw;
|
||||
wholeviewport.Height = backh;
|
||||
IDirect3DDevice9_SetViewport(data->device, &wholeviewport);
|
||||
data->drawstate.viewport_dirty = SDL_TRUE; /* we still need to (re)set orthographic projection, so always mark it dirty. */
|
||||
data->drawstate.viewport_dirty = SDL_TRUE; // we still need to (re)set orthographic projection, so always mark it dirty.
|
||||
IDirect3DDevice9_Clear(data->device, 0, NULL, D3DCLEAR_TARGET, color, 0.0f, 0);
|
||||
}
|
||||
|
||||
@@ -1300,13 +1300,13 @@ static int D3D_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, v
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_FILL_RECTS: /* unused */
|
||||
case SDL_RENDERCMD_FILL_RECTS: // unused
|
||||
break;
|
||||
|
||||
case SDL_RENDERCMD_COPY: /* unused */
|
||||
case SDL_RENDERCMD_COPY: // unused
|
||||
break;
|
||||
|
||||
case SDL_RENDERCMD_COPY_EX: /* unused */
|
||||
case SDL_RENDERCMD_COPY_EX: // unused
|
||||
break;
|
||||
|
||||
case SDL_RENDERCMD_GEOMETRY:
|
||||
@@ -1402,7 +1402,7 @@ static int D3D_RenderPresent(SDL_Renderer *renderer)
|
||||
|
||||
result = IDirect3DDevice9_TestCooperativeLevel(data->device);
|
||||
if (result == D3DERR_DEVICELOST) {
|
||||
/* We'll reset later */
|
||||
// We'll reset later
|
||||
return -1;
|
||||
}
|
||||
if (result == D3DERR_DEVICENOTRESET) {
|
||||
@@ -1455,7 +1455,7 @@ static void D3D_DestroyRenderer(SDL_Renderer *renderer)
|
||||
if (data) {
|
||||
int i;
|
||||
|
||||
/* Release the render target */
|
||||
// Release the render target
|
||||
if (data->defaultRenderTarget) {
|
||||
IDirect3DSurface9_Release(data->defaultRenderTarget);
|
||||
data->defaultRenderTarget = NULL;
|
||||
@@ -1472,7 +1472,7 @@ static void D3D_DestroyRenderer(SDL_Renderer *renderer)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
/* Release all vertex buffers */
|
||||
// Release all vertex buffers
|
||||
for (i = 0; i < SDL_arraysize(data->vertexBuffers); ++i) {
|
||||
if (data->vertexBuffers[i]) {
|
||||
IDirect3DVertexBuffer9_Release(data->vertexBuffers[i]);
|
||||
@@ -1499,13 +1499,13 @@ static int D3D_Reset(SDL_Renderer *renderer)
|
||||
SDL_Texture *texture;
|
||||
int i;
|
||||
|
||||
/* Cancel any scene that we've started */
|
||||
// Cancel any scene that we've started
|
||||
if (!data->beginScene) {
|
||||
IDirect3DDevice9_EndScene(data->device);
|
||||
data->beginScene = SDL_TRUE;
|
||||
}
|
||||
|
||||
/* Release the default render target before reset */
|
||||
// Release the default render target before reset
|
||||
if (data->defaultRenderTarget) {
|
||||
IDirect3DSurface9_Release(data->defaultRenderTarget);
|
||||
data->defaultRenderTarget = NULL;
|
||||
@@ -1515,7 +1515,7 @@ static int D3D_Reset(SDL_Renderer *renderer)
|
||||
data->currentRenderTarget = NULL;
|
||||
}
|
||||
|
||||
/* Release application render targets */
|
||||
// Release application render targets
|
||||
for (texture = renderer->textures; texture; texture = texture->next) {
|
||||
if (texture->access == SDL_TEXTUREACCESS_TARGET) {
|
||||
D3D_DestroyTexture(renderer, texture);
|
||||
@@ -1524,7 +1524,7 @@ static int D3D_Reset(SDL_Renderer *renderer)
|
||||
}
|
||||
}
|
||||
|
||||
/* Release all vertex buffers */
|
||||
// Release all vertex buffers
|
||||
for (i = 0; i < SDL_arraysize(data->vertexBuffers); ++i) {
|
||||
if (data->vertexBuffers[i]) {
|
||||
IDirect3DVertexBuffer9_Release(data->vertexBuffers[i]);
|
||||
@@ -1536,14 +1536,14 @@ static int D3D_Reset(SDL_Renderer *renderer)
|
||||
result = IDirect3DDevice9_Reset(data->device, &data->pparams);
|
||||
if (FAILED(result)) {
|
||||
if (result == D3DERR_DEVICELOST) {
|
||||
/* Don't worry about it, we'll reset later... */
|
||||
// Don't worry about it, we'll reset later...
|
||||
return 0;
|
||||
} else {
|
||||
return D3D_SetError("Reset()", result);
|
||||
}
|
||||
}
|
||||
|
||||
/* Allocate application render targets */
|
||||
// Allocate application render targets
|
||||
for (texture = renderer->textures; texture; texture = texture->next) {
|
||||
if (texture->access == SDL_TEXTUREACCESS_TARGET) {
|
||||
D3D_CreateTexture(renderer, texture, 0);
|
||||
@@ -1558,7 +1558,7 @@ static int D3D_Reset(SDL_Renderer *renderer)
|
||||
|
||||
IDirect3DDevice9_SetTransform(data->device, D3DTS_VIEW, (D3DMATRIX *)&d3dmatrix);
|
||||
|
||||
/* Let the application know that render targets were reset */
|
||||
// Let the application know that render targets were reset
|
||||
{
|
||||
SDL_Event event;
|
||||
event.type = SDL_EVENT_RENDER_TARGETS_RESET;
|
||||
@@ -1605,7 +1605,7 @@ static int D3D_SetVSync(SDL_Renderer *renderer, const int vsync)
|
||||
data->pparams.PresentationInterval = PresentationInterval;
|
||||
|
||||
if (D3D_Reset(renderer) < 0) {
|
||||
/* D3D_Reset will call SDL_SetError() */
|
||||
// D3D_Reset will call SDL_SetError()
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -1659,7 +1659,7 @@ int D3D_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Propertie
|
||||
renderer->QueueSetViewport = D3D_QueueNoOp;
|
||||
renderer->QueueSetDrawColor = D3D_QueueNoOp;
|
||||
renderer->QueueDrawPoints = D3D_QueueDrawPoints;
|
||||
renderer->QueueDrawLines = D3D_QueueDrawPoints; /* lines and points queue vertices the same way. */
|
||||
renderer->QueueDrawLines = D3D_QueueDrawPoints; // lines and points queue vertices the same way.
|
||||
renderer->QueueGeometry = D3D_QueueGeometry;
|
||||
renderer->InvalidateCachedState = D3D_InvalidateCachedState;
|
||||
renderer->RunCommandQueue = D3D_RunCommandQueue;
|
||||
@@ -1697,7 +1697,7 @@ int D3D_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Propertie
|
||||
}
|
||||
pparams.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
|
||||
|
||||
/* Get the adapter for the display that the window is on */
|
||||
// Get the adapter for the display that the window is on
|
||||
displayID = SDL_GetDisplayForWindow(window);
|
||||
data->adapter = SDL_GetDirect3D9AdapterIndex(displayID);
|
||||
|
||||
@@ -1726,7 +1726,7 @@ int D3D_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Propertie
|
||||
return D3D_SetError("CreateDevice()", result);
|
||||
}
|
||||
|
||||
/* Get presentation parameters to fill info */
|
||||
// Get presentation parameters to fill info
|
||||
result = IDirect3DDevice9_GetSwapChain(data->device, 0, &chain);
|
||||
if (FAILED(result)) {
|
||||
return D3D_SetError("GetSwapChain()", result);
|
||||
@@ -1746,11 +1746,11 @@ int D3D_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Propertie
|
||||
data->enableSeparateAlphaBlend = SDL_TRUE;
|
||||
}
|
||||
|
||||
/* Store the default render target */
|
||||
// Store the default render target
|
||||
IDirect3DDevice9_GetRenderTarget(data->device, 0, &data->defaultRenderTarget);
|
||||
data->currentRenderTarget = NULL;
|
||||
|
||||
/* Set up parameters for rendering */
|
||||
// Set up parameters for rendering
|
||||
D3D_InitRenderState(data);
|
||||
#if SDL_HAVE_YUV
|
||||
if (caps.MaxSimultaneousTextures >= 3) {
|
||||
@@ -1776,4 +1776,4 @@ int D3D_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Propertie
|
||||
SDL_RenderDriver D3D_RenderDriver = {
|
||||
D3D_CreateRenderer, "direct3d"
|
||||
};
|
||||
#endif /* SDL_VIDEO_RENDER_D3D && !SDL_RENDER_DISABLED */
|
||||
#endif // SDL_VIDEO_RENDER_D3D && !SDL_RENDER_DISABLED
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
#include "SDL_shaders_d3d.h"
|
||||
|
||||
/* The shaders here were compiled with compile_shaders.bat */
|
||||
// The shaders here were compiled with compile_shaders.bat
|
||||
|
||||
#define g_ps20_main D3D9_PixelShader_YUV
|
||||
#include "D3D9_PixelShader_YUV.h"
|
||||
@@ -45,4 +45,4 @@ HRESULT D3D9_CreatePixelShader(IDirect3DDevice9 *d3dDevice, D3D9_Shader shader,
|
||||
return IDirect3DDevice9_CreatePixelShader(d3dDevice, (const DWORD *)D3D9_shaders[shader], pixelShader);
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_D3D */
|
||||
#endif // SDL_VIDEO_RENDER_D3D
|
||||
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
#include "SDL_internal.h"
|
||||
|
||||
/* D3D9 shader implementation */
|
||||
// D3D9 shader implementation
|
||||
|
||||
typedef enum
|
||||
{
|
||||
|
||||
@@ -47,11 +47,11 @@
|
||||
|
||||
#if WINAPI_FAMILY == WINAPI_FAMILY_APP
|
||||
#include <windows.ui.xaml.media.dxinterop.h>
|
||||
/* TODO, WinRT, XAML: get the ISwapChainBackgroundPanelNative from something other than a global var */
|
||||
// TODO, WinRT, XAML: get the ISwapChainBackgroundPanelNative from something other than a global var
|
||||
extern ISwapChainBackgroundPanelNative *WINRT_GlobalSwapChainBackgroundPanelNative;
|
||||
#endif /* WINAPI_FAMILY == WINAPI_FAMILY_APP */
|
||||
#endif // WINAPI_FAMILY == WINAPI_FAMILY_APP
|
||||
|
||||
#endif /* SDL_PLATFORM_WINRT */
|
||||
#endif // SDL_PLATFORM_WINRT
|
||||
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
#define SDL_COMPOSE_ERROR(str) __FUNCTION__ ", " str
|
||||
@@ -68,7 +68,7 @@ extern ISwapChainBackgroundPanelNative *WINRT_GlobalSwapChainBackgroundPanelNati
|
||||
/* !!! FIXME: vertex buffer bandwidth could be lower; only use UV coords when
|
||||
!!! FIXME: textures are needed. */
|
||||
|
||||
/* Sampler types */
|
||||
// Sampler types
|
||||
typedef enum
|
||||
{
|
||||
SDL_D3D11_SAMPLER_NEAREST_CLAMP,
|
||||
@@ -78,14 +78,14 @@ typedef enum
|
||||
SDL_NUM_D3D11_SAMPLERS
|
||||
} SDL_D3D11_sampler_type;
|
||||
|
||||
/* Vertex shader, common values */
|
||||
// Vertex shader, common values
|
||||
typedef struct
|
||||
{
|
||||
Float4X4 model;
|
||||
Float4X4 projectionAndView;
|
||||
} VertexShaderConstants;
|
||||
|
||||
/* These should mirror the definitions in D3D11_PixelShader_Common.hlsli */
|
||||
// These should mirror the definitions in D3D11_PixelShader_Common.hlsli
|
||||
//static const float TONEMAP_NONE = 0;
|
||||
//static const float TONEMAP_LINEAR = 1;
|
||||
static const float TONEMAP_CHROME = 2;
|
||||
@@ -122,7 +122,7 @@ typedef struct
|
||||
PixelShaderConstants shader_constants;
|
||||
} PixelShaderState;
|
||||
|
||||
/* Per-vertex data */
|
||||
// Per-vertex data
|
||||
typedef struct
|
||||
{
|
||||
Float2 pos;
|
||||
@@ -130,7 +130,7 @@ typedef struct
|
||||
SDL_FColor color;
|
||||
} VertexPositionColor;
|
||||
|
||||
/* Per-texture data */
|
||||
// Per-texture data
|
||||
typedef struct
|
||||
{
|
||||
int w, h;
|
||||
@@ -144,14 +144,14 @@ typedef struct
|
||||
D3D11_Shader shader;
|
||||
const float *YCbCr_matrix;
|
||||
#if SDL_HAVE_YUV
|
||||
/* YV12 texture support */
|
||||
// YV12 texture support
|
||||
SDL_bool yuv;
|
||||
ID3D11Texture2D *mainTextureU;
|
||||
ID3D11ShaderResourceView *mainTextureResourceViewU;
|
||||
ID3D11Texture2D *mainTextureV;
|
||||
ID3D11ShaderResourceView *mainTextureResourceViewV;
|
||||
|
||||
/* NV12 texture support */
|
||||
// NV12 texture support
|
||||
SDL_bool nv12;
|
||||
ID3D11ShaderResourceView *mainTextureResourceViewNV;
|
||||
|
||||
@@ -161,14 +161,14 @@ typedef struct
|
||||
#endif
|
||||
} D3D11_TextureData;
|
||||
|
||||
/* Blend mode data */
|
||||
// Blend mode data
|
||||
typedef struct
|
||||
{
|
||||
SDL_BlendMode blendMode;
|
||||
ID3D11BlendState *blendState;
|
||||
} D3D11_BlendMode;
|
||||
|
||||
/* Private renderer data */
|
||||
// Private renderer data
|
||||
typedef struct
|
||||
{
|
||||
void *hDXGIMod;
|
||||
@@ -195,15 +195,15 @@ typedef struct
|
||||
D3D_FEATURE_LEVEL featureLevel;
|
||||
SDL_bool pixelSizeChanged;
|
||||
|
||||
/* Rasterizers */
|
||||
// Rasterizers
|
||||
ID3D11RasterizerState *mainRasterizer;
|
||||
ID3D11RasterizerState *clippedRasterizer;
|
||||
|
||||
/* Vertex buffer constants */
|
||||
// Vertex buffer constants
|
||||
VertexShaderConstants vertexShaderConstantsData;
|
||||
ID3D11Buffer *vertexShaderConstants;
|
||||
|
||||
/* Cached renderer properties */
|
||||
// Cached renderer properties
|
||||
DXGI_MODE_ROTATION rotation;
|
||||
ID3D11RenderTargetView *currentRenderTargetView;
|
||||
ID3D11RasterizerState *currentRasterizerState;
|
||||
@@ -320,10 +320,10 @@ static DXGI_FORMAT SDLPixelFormatToDXGIMainResourceViewFormat(Uint32 format, Uin
|
||||
return DXGI_FORMAT_B8G8R8X8_UNORM;
|
||||
case SDL_PIXELFORMAT_YV12:
|
||||
case SDL_PIXELFORMAT_IYUV:
|
||||
case SDL_PIXELFORMAT_NV12: /* For the Y texture */
|
||||
case SDL_PIXELFORMAT_NV21: /* For the Y texture */
|
||||
case SDL_PIXELFORMAT_NV12: // For the Y texture
|
||||
case SDL_PIXELFORMAT_NV21: // For the Y texture
|
||||
return DXGI_FORMAT_R8_UNORM;
|
||||
case SDL_PIXELFORMAT_P010: /* For the Y texture */
|
||||
case SDL_PIXELFORMAT_P010: // For the Y texture
|
||||
return DXGI_FORMAT_R16_UNORM;
|
||||
default:
|
||||
return DXGI_FORMAT_UNKNOWN;
|
||||
@@ -337,16 +337,16 @@ static void D3D11_ReleaseAll(SDL_Renderer *renderer)
|
||||
D3D11_RenderData *data = (D3D11_RenderData *)renderer->internal;
|
||||
SDL_Texture *texture = NULL;
|
||||
|
||||
/* Release all textures */
|
||||
// Release all textures
|
||||
for (texture = renderer->textures; texture; texture = texture->next) {
|
||||
D3D11_DestroyTexture(renderer, texture);
|
||||
}
|
||||
|
||||
/* Release/reset everything else */
|
||||
// Release/reset everything else
|
||||
if (data) {
|
||||
int i;
|
||||
|
||||
/* Make sure the swap chain is fully released */
|
||||
// Make sure the swap chain is fully released
|
||||
if (data->d3dContext) {
|
||||
ID3D11DeviceContext_ClearState(data->d3dContext);
|
||||
ID3D11DeviceContext_Flush(data->d3dContext);
|
||||
@@ -397,7 +397,7 @@ static void D3D11_ReleaseAll(SDL_Renderer *renderer)
|
||||
data->currentShaderResource = NULL;
|
||||
data->currentSampler = NULL;
|
||||
|
||||
/* Check for any leaks if in debug mode */
|
||||
// Check for any leaks if in debug mode
|
||||
if (data->dxgiDebug) {
|
||||
DXGI_DEBUG_RLO_FLAGS rloFlags = (DXGI_DEBUG_RLO_FLAGS)(DXGI_DEBUG_RLO_DETAIL | DXGI_DEBUG_RLO_IGNORE_INTERNAL);
|
||||
IDXGIDebug_ReportLiveObjects(data->dxgiDebug, SDL_DXGI_DEBUG_ALL, rloFlags);
|
||||
@@ -517,7 +517,7 @@ static ID3D11BlendState *D3D11_CreateBlendState(SDL_Renderer *renderer, SDL_Blen
|
||||
return blendState;
|
||||
}
|
||||
|
||||
/* Create resources that depend on the device. */
|
||||
// Create resources that depend on the device.
|
||||
static HRESULT D3D11_CreateDeviceResources(SDL_Renderer *renderer)
|
||||
{
|
||||
typedef HRESULT(WINAPI * PFN_CREATE_DXGI_FACTORY)(REFIID riid, void **ppFactory);
|
||||
@@ -552,7 +552,7 @@ static HRESULT D3D11_CreateDeviceResources(SDL_Renderer *renderer)
|
||||
D3D11_SAMPLER_DESC samplerDesc;
|
||||
D3D11_RASTERIZER_DESC rasterDesc;
|
||||
|
||||
/* See if we need debug interfaces */
|
||||
// See if we need debug interfaces
|
||||
createDebug = SDL_GetHintBoolean(SDL_HINT_RENDER_DIRECT3D11_DEBUG, SDL_FALSE);
|
||||
|
||||
#ifdef SDL_PLATFORM_WINRT
|
||||
@@ -585,14 +585,14 @@ static HRESULT D3D11_CreateDeviceResources(SDL_Renderer *renderer)
|
||||
result = E_FAIL;
|
||||
goto done;
|
||||
}
|
||||
#endif /* SDL_PLATFORM_WINRT */
|
||||
#endif // SDL_PLATFORM_WINRT
|
||||
|
||||
if (createDebug) {
|
||||
#ifdef __IDXGIInfoQueue_INTERFACE_DEFINED__
|
||||
IDXGIInfoQueue *dxgiInfoQueue = NULL;
|
||||
PFN_CREATE_DXGI_FACTORY2 DXGIGetDebugInterfaceFunc;
|
||||
|
||||
/* If the debug hint is set, also create the DXGI factory in debug mode */
|
||||
// If the debug hint is set, also create the DXGI factory in debug mode
|
||||
DXGIGetDebugInterfaceFunc = (PFN_CREATE_DXGI_FACTORY2)SDL_LoadFunction(data->hDXGIMod, "DXGIGetDebugInterface1");
|
||||
if (!DXGIGetDebugInterfaceFunc) {
|
||||
result = E_FAIL;
|
||||
@@ -614,7 +614,7 @@ static HRESULT D3D11_CreateDeviceResources(SDL_Renderer *renderer)
|
||||
IDXGIInfoQueue_SetBreakOnSeverity(dxgiInfoQueue, SDL_DXGI_DEBUG_ALL, DXGI_INFO_QUEUE_MESSAGE_SEVERITY_ERROR, TRUE);
|
||||
IDXGIInfoQueue_SetBreakOnSeverity(dxgiInfoQueue, SDL_DXGI_DEBUG_ALL, DXGI_INFO_QUEUE_MESSAGE_SEVERITY_CORRUPTION, TRUE);
|
||||
SAFE_RELEASE(dxgiInfoQueue);
|
||||
#endif /* __IDXGIInfoQueue_INTERFACE_DEFINED__ */
|
||||
#endif // __IDXGIInfoQueue_INTERFACE_DEFINED__
|
||||
creationFlags = DXGI_CREATE_FACTORY_DEBUG;
|
||||
}
|
||||
|
||||
@@ -628,7 +628,7 @@ static HRESULT D3D11_CreateDeviceResources(SDL_Renderer *renderer)
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* FIXME: Should we use the default adapter? */
|
||||
// FIXME: Should we use the default adapter?
|
||||
result = IDXGIFactory2_EnumAdapters(data->dxgiFactory, 0, &data->dxgiAdapter);
|
||||
if (FAILED(result)) {
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("D3D11CreateDevice"), result);
|
||||
@@ -640,28 +640,28 @@ static HRESULT D3D11_CreateDeviceResources(SDL_Renderer *renderer)
|
||||
*/
|
||||
creationFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT;
|
||||
|
||||
/* Make sure Direct3D's debugging feature gets used, if the app requests it. */
|
||||
// Make sure Direct3D's debugging feature gets used, if the app requests it.
|
||||
if (createDebug) {
|
||||
creationFlags |= D3D11_CREATE_DEVICE_DEBUG;
|
||||
}
|
||||
|
||||
/* Create a single-threaded device unless the app requests otherwise. */
|
||||
// Create a single-threaded device unless the app requests otherwise.
|
||||
if (!SDL_GetHintBoolean(SDL_HINT_RENDER_DIRECT3D_THREADSAFE, SDL_FALSE)) {
|
||||
creationFlags |= D3D11_CREATE_DEVICE_SINGLETHREADED;
|
||||
}
|
||||
|
||||
/* Create the Direct3D 11 API device object and a corresponding context. */
|
||||
// Create the Direct3D 11 API device object and a corresponding context.
|
||||
result = D3D11CreateDeviceFunc(
|
||||
data->dxgiAdapter,
|
||||
D3D_DRIVER_TYPE_UNKNOWN,
|
||||
NULL,
|
||||
creationFlags, /* Set set debug and Direct2D compatibility flags. */
|
||||
featureLevels, /* List of feature levels this app can support. */
|
||||
creationFlags, // Set set debug and Direct2D compatibility flags.
|
||||
featureLevels, // List of feature levels this app can support.
|
||||
SDL_arraysize(featureLevels),
|
||||
D3D11_SDK_VERSION, /* Always set this to D3D11_SDK_VERSION for Windows Store apps. */
|
||||
&d3dDevice, /* Returns the Direct3D device created. */
|
||||
&data->featureLevel, /* Returns feature level of device created. */
|
||||
&d3dContext /* Returns the device immediate context. */
|
||||
D3D11_SDK_VERSION, // Always set this to D3D11_SDK_VERSION for Windows Store apps.
|
||||
&d3dDevice, // Returns the Direct3D device created.
|
||||
&data->featureLevel, // Returns feature level of device created.
|
||||
&d3dContext // Returns the device immediate context.
|
||||
);
|
||||
if (FAILED(result)) {
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("D3D11CreateDevice"), result);
|
||||
@@ -729,7 +729,7 @@ static HRESULT D3D11_CreateDeviceResources(SDL_Renderer *renderer)
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* Setup space to hold vertex shader constants: */
|
||||
// Setup space to hold vertex shader constants:
|
||||
SDL_zero(constantBufferDesc);
|
||||
constantBufferDesc.ByteWidth = sizeof(VertexShaderConstants);
|
||||
constantBufferDesc.Usage = D3D11_USAGE_DEFAULT;
|
||||
@@ -743,7 +743,7 @@ static HRESULT D3D11_CreateDeviceResources(SDL_Renderer *renderer)
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* Create samplers to use when drawing textures: */
|
||||
// Create samplers to use when drawing textures:
|
||||
static struct
|
||||
{
|
||||
D3D11_FILTER filter;
|
||||
@@ -775,7 +775,7 @@ static HRESULT D3D11_CreateDeviceResources(SDL_Renderer *renderer)
|
||||
}
|
||||
}
|
||||
|
||||
/* Setup Direct3D rasterizer states */
|
||||
// Setup Direct3D rasterizer states
|
||||
SDL_zero(rasterDesc);
|
||||
rasterDesc.AntialiasedLineEnable = FALSE;
|
||||
rasterDesc.CullMode = D3D11_CULL_NONE;
|
||||
@@ -800,13 +800,13 @@ static HRESULT D3D11_CreateDeviceResources(SDL_Renderer *renderer)
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* Create blending states: */
|
||||
// Create blending states:
|
||||
if (!D3D11_CreateBlendState(renderer, SDL_BLENDMODE_BLEND)) {
|
||||
/* D3D11_CreateBlendState will set the SDL error, if it fails */
|
||||
// D3D11_CreateBlendState will set the SDL error, if it fails
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* Setup render state that doesn't change */
|
||||
// Setup render state that doesn't change
|
||||
ID3D11DeviceContext_IASetInputLayout(data->d3dContext, data->inputLayout);
|
||||
ID3D11DeviceContext_VSSetShader(data->d3dContext, data->vertexShader, NULL, 0);
|
||||
ID3D11DeviceContext_VSSetConstantBuffers(data->d3dContext, 0, 1, &data->vertexShaderConstants);
|
||||
@@ -824,11 +824,11 @@ done:
|
||||
|
||||
static DXGI_MODE_ROTATION D3D11_GetCurrentRotation(void)
|
||||
{
|
||||
/* FIXME */
|
||||
// FIXME
|
||||
return DXGI_MODE_ROTATION_IDENTITY;
|
||||
}
|
||||
|
||||
#endif /* defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) */
|
||||
#endif // defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK)
|
||||
|
||||
static BOOL D3D11_IsDisplayRotated90Degrees(DXGI_MODE_ROTATION rotation)
|
||||
{
|
||||
@@ -907,7 +907,7 @@ static HRESULT D3D11_CreateSwapChain(SDL_Renderer *renderer, int w, int h)
|
||||
IDXGISwapChain3 *swapChain3 = NULL;
|
||||
HRESULT result = S_OK;
|
||||
|
||||
/* Create a swap chain using the same adapter as the existing Direct3D device. */
|
||||
// Create a swap chain using the same adapter as the existing Direct3D device.
|
||||
DXGI_SWAP_CHAIN_DESC1 swapChainDesc;
|
||||
SDL_zero(swapChainDesc);
|
||||
swapChainDesc.Width = w;
|
||||
@@ -920,18 +920,18 @@ static HRESULT D3D11_CreateSwapChain(SDL_Renderer *renderer, int w, int h)
|
||||
swapChainDesc.Format = DXGI_FORMAT_R10G10B10A2_UNORM;
|
||||
break;
|
||||
default:
|
||||
swapChainDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM; /* This is the most common swap chain format. */
|
||||
swapChainDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM; // This is the most common swap chain format.
|
||||
break;
|
||||
}
|
||||
swapChainDesc.Stereo = FALSE;
|
||||
swapChainDesc.SampleDesc.Count = 1; /* Don't use multi-sampling. */
|
||||
swapChainDesc.SampleDesc.Count = 1; // Don't use multi-sampling.
|
||||
swapChainDesc.SampleDesc.Quality = 0;
|
||||
swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
|
||||
swapChainDesc.BufferCount = 2; /* Use double-buffering to minimize latency. */
|
||||
swapChainDesc.BufferCount = 2; // Use double-buffering to minimize latency.
|
||||
#if SDL_WINAPI_FAMILY_PHONE
|
||||
swapChainDesc.Scaling = DXGI_SCALING_STRETCH; /* On phone, only stretch and aspect-ratio stretch scaling are allowed. */
|
||||
swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; /* On phone, no swap effects are supported. */
|
||||
/* TODO, WinRT: see if Win 8.x DXGI_SWAP_CHAIN_DESC1 settings are available on Windows Phone 8.1, and if there's any advantage to having them on */
|
||||
swapChainDesc.Scaling = DXGI_SCALING_STRETCH; // On phone, only stretch and aspect-ratio stretch scaling are allowed.
|
||||
swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; // On phone, no swap effects are supported.
|
||||
// TODO, WinRT: see if Win 8.x DXGI_SWAP_CHAIN_DESC1 settings are available on Windows Phone 8.1, and if there's any advantage to having them on
|
||||
#else
|
||||
if (usingXAML) {
|
||||
swapChainDesc.Scaling = DXGI_SCALING_STRETCH;
|
||||
@@ -946,7 +946,7 @@ static HRESULT D3D11_CreateSwapChain(SDL_Renderer *renderer, int w, int h)
|
||||
swapChainDesc.Scaling = DXGI_SCALING_STRETCH;
|
||||
swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
|
||||
} else {
|
||||
swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL; /* All Windows Store apps must use this SwapEffect. */
|
||||
swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL; // All Windows Store apps must use this SwapEffect.
|
||||
}
|
||||
#endif
|
||||
swapChainDesc.Flags = 0;
|
||||
@@ -956,7 +956,7 @@ static HRESULT D3D11_CreateSwapChain(SDL_Renderer *renderer, int w, int h)
|
||||
(IUnknown *)data->d3dDevice,
|
||||
coreWindow,
|
||||
&swapChainDesc,
|
||||
NULL, /* Allow on all displays. */
|
||||
NULL, // Allow on all displays.
|
||||
&data->swapChain);
|
||||
if (FAILED(result)) {
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGIFactory2::CreateSwapChainForCoreWindow"), result);
|
||||
@@ -998,7 +998,7 @@ static HRESULT D3D11_CreateSwapChain(SDL_Renderer *renderer, int w, int h)
|
||||
hwnd,
|
||||
&swapChainDesc,
|
||||
NULL,
|
||||
NULL, /* Allow on all displays. */
|
||||
NULL, // Allow on all displays.
|
||||
&data->swapChain);
|
||||
if (FAILED(result)) {
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGIFactory2::CreateSwapChainForHwnd"), result);
|
||||
@@ -1009,7 +1009,7 @@ static HRESULT D3D11_CreateSwapChain(SDL_Renderer *renderer, int w, int h)
|
||||
#else
|
||||
SDL_SetError(__FUNCTION__ ", Unable to find something to attach a swap chain to");
|
||||
goto done;
|
||||
#endif /* defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) / else */
|
||||
#endif // defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) / else
|
||||
}
|
||||
data->swapEffect = swapChainDesc.SwapEffect;
|
||||
|
||||
@@ -1024,7 +1024,7 @@ static HRESULT D3D11_CreateSwapChain(SDL_Renderer *renderer, int w, int h)
|
||||
colorspace = DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020;
|
||||
break;
|
||||
default:
|
||||
/* sRGB */
|
||||
// sRGB
|
||||
colorspace = DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709;
|
||||
break;
|
||||
}
|
||||
@@ -1036,7 +1036,7 @@ static HRESULT D3D11_CreateSwapChain(SDL_Renderer *renderer, int w, int h)
|
||||
goto done;
|
||||
}
|
||||
} else if (colorspace != DXGI_COLOR_SPACE_RGB_FULL_G10_NONE_P709) {
|
||||
/* Not the default, we're not going to be able to present in this colorspace */
|
||||
// Not the default, we're not going to be able to present in this colorspace
|
||||
SDL_SetError("Unsupported output colorspace");
|
||||
result = DXGI_ERROR_UNSUPPORTED;
|
||||
}
|
||||
@@ -1067,17 +1067,17 @@ static HRESULT D3D11_HandleDeviceLost(SDL_Renderer *renderer)
|
||||
|
||||
result = D3D11_CreateDeviceResources(renderer);
|
||||
if (FAILED(result)) {
|
||||
/* D3D11_CreateDeviceResources will set the SDL error */
|
||||
// D3D11_CreateDeviceResources will set the SDL error
|
||||
return result;
|
||||
}
|
||||
|
||||
result = D3D11_UpdateForWindowSizeChange(renderer);
|
||||
if (FAILED(result)) {
|
||||
/* D3D11_UpdateForWindowSizeChange will set the SDL error */
|
||||
// D3D11_UpdateForWindowSizeChange will set the SDL error
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Let the application know that the device has been reset */
|
||||
// Let the application know that the device has been reset
|
||||
{
|
||||
SDL_Event event;
|
||||
event.type = SDL_EVENT_RENDER_DEVICE_RESET;
|
||||
@@ -1088,7 +1088,7 @@ static HRESULT D3D11_HandleDeviceLost(SDL_Renderer *renderer)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
/* Initialize all resources that change when the window's size changes. */
|
||||
// Initialize all resources that change when the window's size changes.
|
||||
static HRESULT D3D11_CreateWindowSizeDependentResources(SDL_Renderer *renderer)
|
||||
{
|
||||
D3D11_RenderData *data = (D3D11_RenderData *)renderer->internal;
|
||||
@@ -1096,7 +1096,7 @@ static HRESULT D3D11_CreateWindowSizeDependentResources(SDL_Renderer *renderer)
|
||||
HRESULT result = S_OK;
|
||||
int w, h;
|
||||
|
||||
/* Release the previous render target view */
|
||||
// Release the previous render target view
|
||||
D3D11_ReleaseMainRenderTargetView(renderer);
|
||||
|
||||
/* The width and height of the swap chain must be based on the display's
|
||||
@@ -1108,7 +1108,7 @@ static HRESULT D3D11_CreateWindowSizeDependentResources(SDL_Renderer *renderer)
|
||||
SDL_GetWindowSizeInPixels(renderer->window, &w, &h);
|
||||
#endif
|
||||
data->rotation = D3D11_GetCurrentRotation();
|
||||
/* SDL_Log("%s: windowSize={%d,%d}, orientation=%d\n", __FUNCTION__, w, h, (int)data->rotation); */
|
||||
// SDL_Log("%s: windowSize={%d,%d}, orientation=%d\n", __FUNCTION__, w, h, (int)data->rotation);
|
||||
if (D3D11_IsDisplayRotated90Degrees(data->rotation)) {
|
||||
int tmp = w;
|
||||
w = h;
|
||||
@@ -1116,16 +1116,16 @@ static HRESULT D3D11_CreateWindowSizeDependentResources(SDL_Renderer *renderer)
|
||||
}
|
||||
|
||||
if (data->swapChain) {
|
||||
/* IDXGISwapChain::ResizeBuffers is not available on Windows Phone 8. */
|
||||
// IDXGISwapChain::ResizeBuffers is not available on Windows Phone 8.
|
||||
#if !defined(SDL_PLATFORM_WINRT) || !SDL_WINAPI_FAMILY_PHONE
|
||||
/* If the swap chain already exists, resize it. */
|
||||
// If the swap chain already exists, resize it.
|
||||
result = IDXGISwapChain_ResizeBuffers(data->swapChain,
|
||||
0,
|
||||
w, h,
|
||||
DXGI_FORMAT_UNKNOWN,
|
||||
0);
|
||||
if (result == DXGI_ERROR_DEVICE_REMOVED) {
|
||||
/* If the device was removed for any reason, a new device and swap chain will need to be created. */
|
||||
// If the device was removed for any reason, a new device and swap chain will need to be created.
|
||||
D3D11_HandleDeviceLost(renderer);
|
||||
|
||||
/* Everything is set up now. Do not continue execution of this method. HandleDeviceLost will reenter this method
|
||||
@@ -1181,7 +1181,7 @@ static HRESULT D3D11_CreateWindowSizeDependentResources(SDL_Renderer *renderer)
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* Create a render target view of the swap chain back buffer. */
|
||||
// Create a render target view of the swap chain back buffer.
|
||||
result = ID3D11Device_CreateRenderTargetView(data->d3dDevice,
|
||||
(ID3D11Resource *)backBuffer,
|
||||
NULL,
|
||||
@@ -1207,7 +1207,7 @@ done:
|
||||
return result;
|
||||
}
|
||||
|
||||
/* This method is called when the window's size changes. */
|
||||
// This method is called when the window's size changes.
|
||||
static HRESULT D3D11_UpdateForWindowSizeChange(SDL_Renderer *renderer)
|
||||
{
|
||||
return D3D11_CreateWindowSizeDependentResources(renderer);
|
||||
@@ -1304,7 +1304,7 @@ static int D3D11_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL
|
||||
textureDesc.SampleDesc.Quality = 0;
|
||||
textureDesc.MiscFlags = 0;
|
||||
|
||||
/* NV12 textures must have even width and height */
|
||||
// NV12 textures must have even width and height
|
||||
if (texture->format == SDL_PIXELFORMAT_NV12 ||
|
||||
texture->format == SDL_PIXELFORMAT_NV21 ||
|
||||
texture->format == SDL_PIXELFORMAT_P010) {
|
||||
@@ -1407,7 +1407,7 @@ static int D3D11_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL
|
||||
return SDL_SetError("Unsupported YUV colorspace");
|
||||
}
|
||||
}
|
||||
#endif /* SDL_HAVE_YUV */
|
||||
#endif // SDL_HAVE_YUV
|
||||
SDL_zero(resourceViewDesc);
|
||||
resourceViewDesc.Format = SDLPixelFormatToDXGIMainResourceViewFormat(texture->format, renderer->output_colorspace);
|
||||
resourceViewDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
|
||||
@@ -1455,7 +1455,7 @@ static int D3D11_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL
|
||||
return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateShaderResourceView"), result);
|
||||
}
|
||||
}
|
||||
#endif /* SDL_HAVE_YUV */
|
||||
#endif // SDL_HAVE_YUV
|
||||
|
||||
if (texture->access & SDL_TEXTUREACCESS_TARGET) {
|
||||
D3D11_RENDER_TARGET_VIEW_DESC renderTargetViewDesc;
|
||||
@@ -1512,7 +1512,7 @@ static int D3D11_UpdateTextureInternal(D3D11_RenderData *rendererData, ID3D11Tex
|
||||
D3D11_TEXTURE2D_DESC stagingTextureDesc;
|
||||
D3D11_MAPPED_SUBRESOURCE textureMemory;
|
||||
|
||||
/* Create a 'staging' texture, which will be used to write to a portion of the main texture. */
|
||||
// Create a 'staging' texture, which will be used to write to a portion of the main texture.
|
||||
ID3D11Texture2D_GetDesc(texture, &stagingTextureDesc);
|
||||
stagingTextureDesc.Width = w;
|
||||
stagingTextureDesc.Height = h;
|
||||
@@ -1533,7 +1533,7 @@ static int D3D11_UpdateTextureInternal(D3D11_RenderData *rendererData, ID3D11Tex
|
||||
return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D [create staging texture]"), result);
|
||||
}
|
||||
|
||||
/* Get a write-only pointer to data in the staging texture: */
|
||||
// Get a write-only pointer to data in the staging texture:
|
||||
result = ID3D11DeviceContext_Map(rendererData->d3dContext,
|
||||
(ID3D11Resource *)stagingTexture,
|
||||
0,
|
||||
@@ -1566,7 +1566,7 @@ static int D3D11_UpdateTextureInternal(D3D11_RenderData *rendererData, ID3D11Tex
|
||||
|
||||
if (stagingTextureDesc.Format == DXGI_FORMAT_NV12 ||
|
||||
stagingTextureDesc.Format == DXGI_FORMAT_P010) {
|
||||
/* Copy the UV plane as well */
|
||||
// Copy the UV plane as well
|
||||
h = (h + 1) / 2;
|
||||
if (stagingTextureDesc.Format == DXGI_FORMAT_P010) {
|
||||
length = (length + 3) & ~3;
|
||||
@@ -1583,12 +1583,12 @@ static int D3D11_UpdateTextureInternal(D3D11_RenderData *rendererData, ID3D11Tex
|
||||
}
|
||||
}
|
||||
|
||||
/* Commit the pixel buffer's changes back to the staging texture: */
|
||||
// Commit the pixel buffer's changes back to the staging texture:
|
||||
ID3D11DeviceContext_Unmap(rendererData->d3dContext,
|
||||
(ID3D11Resource *)stagingTexture,
|
||||
0);
|
||||
|
||||
/* Copy the staging texture's contents back to the texture: */
|
||||
// Copy the staging texture's contents back to the texture:
|
||||
ID3D11DeviceContext_CopySubresourceRegion(rendererData->d3dContext,
|
||||
(ID3D11Resource *)texture,
|
||||
0,
|
||||
@@ -1705,7 +1705,7 @@ static int D3D11_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
w = rect->w;
|
||||
h = rect->h;
|
||||
|
||||
/* Create a 'staging' texture, which will be used to write to a portion of the main texture. */
|
||||
// Create a 'staging' texture, which will be used to write to a portion of the main texture.
|
||||
ID3D11Texture2D_GetDesc(textureData->mainTexture, &stagingTextureDesc);
|
||||
stagingTextureDesc.Width = w;
|
||||
stagingTextureDesc.Height = h;
|
||||
@@ -1726,7 +1726,7 @@ static int D3D11_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D [create staging texture]"), result);
|
||||
}
|
||||
|
||||
/* Get a write-only pointer to data in the staging texture: */
|
||||
// Get a write-only pointer to data in the staging texture:
|
||||
result = ID3D11DeviceContext_Map(rendererData->d3dContext,
|
||||
(ID3D11Resource *)stagingTexture,
|
||||
0,
|
||||
@@ -1774,12 +1774,12 @@ static int D3D11_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
dst += textureMemory.RowPitch;
|
||||
}
|
||||
|
||||
/* Commit the pixel buffer's changes back to the staging texture: */
|
||||
// Commit the pixel buffer's changes back to the staging texture:
|
||||
ID3D11DeviceContext_Unmap(rendererData->d3dContext,
|
||||
(ID3D11Resource *)stagingTexture,
|
||||
0);
|
||||
|
||||
/* Copy the staging texture's contents back to the texture: */
|
||||
// Copy the staging texture's contents back to the texture:
|
||||
ID3D11DeviceContext_CopySubresourceRegion(rendererData->d3dContext,
|
||||
(ID3D11Resource *)textureData->mainTexture,
|
||||
0,
|
||||
@@ -1810,7 +1810,7 @@ static int D3D11_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
}
|
||||
#if SDL_HAVE_YUV
|
||||
if (textureData->yuv || textureData->nv12) {
|
||||
/* It's more efficient to upload directly... */
|
||||
// It's more efficient to upload directly...
|
||||
if (!textureData->pixels) {
|
||||
textureData->pitch = texture->w;
|
||||
textureData->pixels = (Uint8 *)SDL_malloc((texture->h * textureData->pitch * 3) / 2);
|
||||
@@ -1853,7 +1853,7 @@ static int D3D11_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D [create staging texture]"), result);
|
||||
}
|
||||
|
||||
/* Get a write-only pointer to data in the staging texture: */
|
||||
// Get a write-only pointer to data in the staging texture:
|
||||
result = ID3D11DeviceContext_Map(rendererData->d3dContext,
|
||||
(ID3D11Resource *)textureData->stagingTexture,
|
||||
0,
|
||||
@@ -1897,12 +1897,12 @@ static void D3D11_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
/* Commit the pixel buffer's changes back to the staging texture: */
|
||||
// Commit the pixel buffer's changes back to the staging texture:
|
||||
ID3D11DeviceContext_Unmap(rendererData->d3dContext,
|
||||
(ID3D11Resource *)textureData->stagingTexture,
|
||||
0);
|
||||
|
||||
/* Copy the staging texture's contents back to the main texture: */
|
||||
// Copy the staging texture's contents back to the main texture:
|
||||
ID3D11DeviceContext_CopySubresourceRegion(rendererData->d3dContext,
|
||||
(ID3D11Resource *)textureData->mainTexture,
|
||||
0,
|
||||
@@ -1950,7 +1950,7 @@ static int D3D11_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
|
||||
static int D3D11_QueueNoOp(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
{
|
||||
return 0; /* nothing to do in this backend. */
|
||||
return 0; // nothing to do in this backend.
|
||||
}
|
||||
|
||||
static int D3D11_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count)
|
||||
@@ -2048,7 +2048,7 @@ static int D3D11_UpdateVertexBuffer(SDL_Renderer *renderer,
|
||||
const UINT offset = 0;
|
||||
|
||||
if (dataSizeInBytes == 0) {
|
||||
return 0; /* nothing to do. */
|
||||
return 0; // nothing to do.
|
||||
}
|
||||
|
||||
if (rendererData->vertexBuffers[vbidx] && rendererData->vertexBufferSizes[vbidx] >= dataSizeInBytes) {
|
||||
@@ -2123,7 +2123,7 @@ static int D3D11_UpdateViewport(SDL_Renderer *renderer)
|
||||
* SDL_CreateRenderer is calling it, and will call it again later
|
||||
* with a non-empty viewport.
|
||||
*/
|
||||
/* SDL_Log("%s, no viewport was set!\n", __FUNCTION__); */
|
||||
// SDL_Log("%s, no viewport was set!\n", __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -2149,7 +2149,7 @@ static int D3D11_UpdateViewport(SDL_Renderer *renderer)
|
||||
return SDL_SetError("An unknown DisplayOrientation is being used");
|
||||
}
|
||||
|
||||
/* Update the view matrix */
|
||||
// Update the view matrix
|
||||
SDL_zero(view);
|
||||
view.m[0][0] = 2.0f / viewport->w;
|
||||
view.m[1][1] = -2.0f / viewport->h;
|
||||
@@ -2183,7 +2183,7 @@ static int D3D11_UpdateViewport(SDL_Renderer *renderer)
|
||||
orientationAlignedViewport.w = (float)viewport->w;
|
||||
orientationAlignedViewport.h = (float)viewport->h;
|
||||
}
|
||||
/* TODO, WinRT: get custom viewports working with non-Landscape modes (Portrait, PortraitFlipped, and LandscapeFlipped) */
|
||||
// TODO, WinRT: get custom viewports working with non-Landscape modes (Portrait, PortraitFlipped, and LandscapeFlipped)
|
||||
|
||||
d3dviewport.TopLeftX = orientationAlignedViewport.x;
|
||||
d3dviewport.TopLeftY = orientationAlignedViewport.y;
|
||||
@@ -2191,7 +2191,7 @@ static int D3D11_UpdateViewport(SDL_Renderer *renderer)
|
||||
d3dviewport.Height = orientationAlignedViewport.h;
|
||||
d3dviewport.MinDepth = 0.0f;
|
||||
d3dviewport.MaxDepth = 1.0f;
|
||||
/* SDL_Log("%s: D3D viewport = {%f,%f,%f,%f}\n", __FUNCTION__, d3dviewport.TopLeftX, d3dviewport.TopLeftY, d3dviewport.Width, d3dviewport.Height); */
|
||||
// SDL_Log("%s: D3D viewport = {%f,%f,%f,%f}\n", __FUNCTION__, d3dviewport.TopLeftX, d3dviewport.TopLeftY, d3dviewport.Width, d3dviewport.Height);
|
||||
ID3D11DeviceContext_RSSetViewports(data->d3dContext, 1, &d3dviewport);
|
||||
|
||||
data->viewportDirty = SDL_FALSE;
|
||||
@@ -2294,7 +2294,7 @@ static int D3D11_SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *c
|
||||
shaderResource = NULL;
|
||||
}
|
||||
|
||||
/* Make sure the render target isn't bound to a shader */
|
||||
// Make sure the render target isn't bound to a shader
|
||||
if (shaderResource != rendererData->currentShaderResource) {
|
||||
ID3D11ShaderResourceView *pNullResource = NULL;
|
||||
ID3D11DeviceContext_PSSetShaderResources(rendererData->d3dContext, 0, 1, &pNullResource);
|
||||
@@ -2311,7 +2311,7 @@ static int D3D11_SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *c
|
||||
|
||||
if (rendererData->viewportDirty) {
|
||||
if (D3D11_UpdateViewport(renderer) == 0) {
|
||||
/* vertexShaderConstantsData.projectionAndView has changed */
|
||||
// vertexShaderConstantsData.projectionAndView has changed
|
||||
updateSubresource = SDL_TRUE;
|
||||
}
|
||||
}
|
||||
@@ -2322,7 +2322,7 @@ static int D3D11_SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *c
|
||||
} else {
|
||||
D3D11_RECT scissorRect;
|
||||
if (D3D11_GetViewportAlignedD3DRect(renderer, &rendererData->currentCliprect, &scissorRect, TRUE) != 0) {
|
||||
/* D3D11_GetViewportAlignedD3DRect will have set the SDL error */
|
||||
// D3D11_GetViewportAlignedD3DRect will have set the SDL error
|
||||
return -1;
|
||||
}
|
||||
ID3D11DeviceContext_RSSetScissorRects(rendererData->d3dContext, 1, &scissorRect);
|
||||
@@ -2386,7 +2386,7 @@ static int D3D11_SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *c
|
||||
}
|
||||
SDL_memcpy(&shader_state->shader_constants, shader_constants, sizeof(*shader_constants));
|
||||
|
||||
/* Force the shader parameters to be re-set */
|
||||
// Force the shader parameters to be re-set
|
||||
rendererData->currentShader = SHADER_NONE;
|
||||
}
|
||||
if (shader != rendererData->currentShader) {
|
||||
@@ -2486,7 +2486,7 @@ static int D3D11_SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *c
|
||||
return D3D11_SetDrawState(renderer, cmd, textureData->shader, &constants,
|
||||
SDL_arraysize(shaderResources), shaderResources, textureSampler, matrix);
|
||||
}
|
||||
#endif /* SDL_HAVE_YUV */
|
||||
#endif // SDL_HAVE_YUV
|
||||
return D3D11_SetDrawState(renderer, cmd, textureData->shader, &constants,
|
||||
1, &textureData->mainTextureResourceView, textureSampler, matrix);
|
||||
}
|
||||
@@ -2534,7 +2534,7 @@ static int D3D11_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
|
||||
switch (cmd->command) {
|
||||
case SDL_RENDERCMD_SETDRAWCOLOR:
|
||||
{
|
||||
break; /* this isn't currently used in this render backend. */
|
||||
break; // this isn't currently used in this render backend.
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_SETVIEWPORT:
|
||||
@@ -2600,13 +2600,13 @@ static int D3D11_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_FILL_RECTS: /* unused */
|
||||
case SDL_RENDERCMD_FILL_RECTS: // unused
|
||||
break;
|
||||
|
||||
case SDL_RENDERCMD_COPY: /* unused */
|
||||
case SDL_RENDERCMD_COPY: // unused
|
||||
break;
|
||||
|
||||
case SDL_RENDERCMD_COPY_EX: /* unused */
|
||||
case SDL_RENDERCMD_COPY_EX: // unused
|
||||
break;
|
||||
|
||||
case SDL_RENDERCMD_GEOMETRY:
|
||||
@@ -2661,7 +2661,7 @@ static SDL_Surface *D3D11_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rec
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* Create a staging texture to copy the screen's data to: */
|
||||
// Create a staging texture to copy the screen's data to:
|
||||
ID3D11Texture2D_GetDesc(backBuffer, &stagingTextureDesc);
|
||||
stagingTextureDesc.Width = rect->w;
|
||||
stagingTextureDesc.Height = rect->h;
|
||||
@@ -2678,9 +2678,9 @@ static SDL_Surface *D3D11_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rec
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* Copy the desired portion of the back buffer to the staging texture: */
|
||||
// Copy the desired portion of the back buffer to the staging texture:
|
||||
if (D3D11_GetViewportAlignedD3DRect(renderer, rect, &srcRect, FALSE) != 0) {
|
||||
/* D3D11_GetViewportAlignedD3DRect will have set the SDL error */
|
||||
// D3D11_GetViewportAlignedD3DRect will have set the SDL error
|
||||
goto done;
|
||||
}
|
||||
|
||||
@@ -2698,7 +2698,7 @@ static SDL_Surface *D3D11_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rec
|
||||
0,
|
||||
&srcBox);
|
||||
|
||||
/* Map the staging texture's data to CPU-accessible memory: */
|
||||
// Map the staging texture's data to CPU-accessible memory:
|
||||
result = ID3D11DeviceContext_Map(data->d3dContext,
|
||||
(ID3D11Resource *)stagingTexture,
|
||||
0,
|
||||
@@ -2717,7 +2717,7 @@ static SDL_Surface *D3D11_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rec
|
||||
textureMemory.pData,
|
||||
textureMemory.RowPitch);
|
||||
|
||||
/* Unmap the texture: */
|
||||
// Unmap the texture:
|
||||
ID3D11DeviceContext_Unmap(data->d3dContext,
|
||||
(ID3D11Resource *)stagingTexture,
|
||||
0);
|
||||
@@ -2752,7 +2752,7 @@ static int D3D11_RenderPresent(SDL_Renderer *renderer)
|
||||
*/
|
||||
ID3D11DeviceContext1_DiscardView(data->d3dContext, (ID3D11View *)data->mainRenderTargetView);
|
||||
|
||||
/* When the present flips, it unbinds the current view, so bind it again on the next draw call */
|
||||
// When the present flips, it unbinds the current view, so bind it again on the next draw call
|
||||
data->currentRenderTargetView = NULL;
|
||||
|
||||
if (FAILED(result) && result != DXGI_ERROR_WAS_STILL_DRAWING) {
|
||||
@@ -2764,7 +2764,7 @@ static int D3D11_RenderPresent(SDL_Renderer *renderer)
|
||||
if (result == DXGI_ERROR_DEVICE_REMOVED) {
|
||||
D3D11_HandleDeviceLost(renderer);
|
||||
} else if (result == DXGI_ERROR_INVALID_CALL) {
|
||||
/* We probably went through a fullscreen <-> windowed transition */
|
||||
// We probably went through a fullscreen <-> windowed transition
|
||||
D3D11_CreateWindowSizeDependentResources(renderer);
|
||||
} else {
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGISwapChain::Present"), result);
|
||||
@@ -2847,7 +2847,7 @@ static int D3D11_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_
|
||||
renderer->QueueSetViewport = D3D11_QueueNoOp;
|
||||
renderer->QueueSetDrawColor = D3D11_QueueNoOp;
|
||||
renderer->QueueDrawPoints = D3D11_QueueDrawPoints;
|
||||
renderer->QueueDrawLines = D3D11_QueueDrawPoints; /* lines and points queue vertices the same way. */
|
||||
renderer->QueueDrawLines = D3D11_QueueDrawPoints; // lines and points queue vertices the same way.
|
||||
renderer->QueueGeometry = D3D11_QueueGeometry;
|
||||
renderer->InvalidateCachedState = D3D11_InvalidateCachedState;
|
||||
renderer->RunCommandQueue = D3D11_RunCommandQueue;
|
||||
@@ -2878,7 +2878,7 @@ static int D3D11_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_
|
||||
*/
|
||||
renderer->window = window;
|
||||
|
||||
/* Initialize Direct3D resources */
|
||||
// Initialize Direct3D resources
|
||||
if (FAILED(D3D11_CreateDeviceResources(renderer))) {
|
||||
return -1;
|
||||
}
|
||||
@@ -2893,4 +2893,4 @@ SDL_RenderDriver D3D11_RenderDriver = {
|
||||
D3D11_CreateRenderer, "direct3d11"
|
||||
};
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED */
|
||||
#endif // SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED
|
||||
@@ -65,7 +65,7 @@ D3D11_GetCurrentRotation()
|
||||
switch (currentOrientation) {
|
||||
|
||||
#if SDL_WINAPI_FAMILY_PHONE
|
||||
/* Windows Phone rotations */
|
||||
// Windows Phone rotations
|
||||
case DisplayOrientations::Landscape:
|
||||
return DXGI_MODE_ROTATION_ROTATE90;
|
||||
case DisplayOrientations::Portrait:
|
||||
@@ -75,7 +75,7 @@ D3D11_GetCurrentRotation()
|
||||
case DisplayOrientations::PortraitFlipped:
|
||||
return DXGI_MODE_ROTATION_ROTATE180;
|
||||
#else
|
||||
/* Non-Windows-Phone rotations (ex: Windows 8, Windows RT) */
|
||||
// Non-Windows-Phone rotations (ex: Windows 8, Windows RT)
|
||||
case DisplayOrientations::Landscape:
|
||||
return DXGI_MODE_ROTATION_IDENTITY;
|
||||
case DisplayOrientations::Portrait:
|
||||
@@ -84,10 +84,10 @@ D3D11_GetCurrentRotation()
|
||||
return DXGI_MODE_ROTATION_ROTATE180;
|
||||
case DisplayOrientations::PortraitFlipped:
|
||||
return DXGI_MODE_ROTATION_ROTATE90;
|
||||
#endif /* SDL_WINAPI_FAMILY_PHONE */
|
||||
#endif // SDL_WINAPI_FAMILY_PHONE
|
||||
}
|
||||
|
||||
return DXGI_MODE_ROTATION_IDENTITY;
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_D3D11 */
|
||||
#endif // SDL_VIDEO_RENDER_D3D11
|
||||
@@ -33,4 +33,4 @@ DXGI_MODE_ROTATION D3D11_GetCurrentRotation();
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_D3D11 */
|
||||
#endif // SDL_VIDEO_RENDER_D3D11
|
||||
@@ -34,7 +34,7 @@
|
||||
#error Need to build shaders with level_9_3
|
||||
#endif
|
||||
|
||||
/* The shaders here were compiled with compile_shaders.bat */
|
||||
// The shaders here were compiled with compile_shaders.bat
|
||||
|
||||
#define g_main D3D11_PixelShader_Colors
|
||||
#include "D3D11_PixelShader_Colors.h"
|
||||
@@ -67,7 +67,7 @@ SDL_COMPILE_TIME_ASSERT(D3D11_shaders, SDL_arraysize(D3D11_shaders) == NUM_SHADE
|
||||
|
||||
int D3D11_CreateVertexShader(ID3D11Device1 *d3dDevice, ID3D11VertexShader **vertexShader, ID3D11InputLayout **inputLayout)
|
||||
{
|
||||
/* Declare how the input layout for SDL's vertex shader will be setup: */
|
||||
// Declare how the input layout for SDL's vertex shader will be setup:
|
||||
const D3D11_INPUT_ELEMENT_DESC vertexDesc[] = {
|
||||
{ "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
||||
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 8, D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
||||
@@ -75,7 +75,7 @@ int D3D11_CreateVertexShader(ID3D11Device1 *d3dDevice, ID3D11VertexShader **vert
|
||||
};
|
||||
HRESULT result;
|
||||
|
||||
/* Load in SDL's one and only vertex shader: */
|
||||
// Load in SDL's one and only vertex shader:
|
||||
result = ID3D11Device_CreateVertexShader(d3dDevice,
|
||||
D3D11_VertexShader,
|
||||
sizeof(D3D11_VertexShader),
|
||||
@@ -85,7 +85,7 @@ int D3D11_CreateVertexShader(ID3D11Device1 *d3dDevice, ID3D11VertexShader **vert
|
||||
return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateVertexShader"), result);
|
||||
}
|
||||
|
||||
/* Create an input layout for SDL's vertex shader: */
|
||||
// Create an input layout for SDL's vertex shader:
|
||||
result = ID3D11Device_CreateInputLayout(d3dDevice,
|
||||
vertexDesc,
|
||||
ARRAYSIZE(vertexDesc),
|
||||
@@ -113,4 +113,4 @@ int D3D11_CreatePixelShader(ID3D11Device1 *d3dDevice, D3D11_Shader shader, ID3D1
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_D3D11 */
|
||||
#endif // SDL_VIDEO_RENDER_D3D11
|
||||
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
#include "SDL_internal.h"
|
||||
|
||||
/* D3D11 shader implementation */
|
||||
// D3D11 shader implementation
|
||||
|
||||
typedef enum
|
||||
{
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -75,7 +75,7 @@ D3D12_XBOX_CreateDevice(ID3D12Device **device, SDL_bool createDebug)
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* Set frame interval */
|
||||
// Set frame interval
|
||||
result = (*device)->SetFrameIntervalX(dxgiOutput, D3D12XBOX_FRAME_INTERVAL_60_HZ, 1, D3D12XBOX_FRAME_INTERVAL_FLAG_NONE);
|
||||
if (FAILED(result)) {
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("[xbox] SetFrameIntervalX"), result);
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include "../../SDL_internal.h"
|
||||
#include "../../video/directx/SDL_d3d12.h"
|
||||
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
// Set up for C function definitions, even when using C++
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@@ -36,7 +36,7 @@ extern HRESULT D3D12_XBOX_StartFrame(ID3D12Device1 *device, UINT64 *outToken);
|
||||
extern HRESULT D3D12_XBOX_PresentFrame(ID3D12CommandQueue *commandQueue, UINT64 token, ID3D12Resource *renderTarget);
|
||||
extern void D3D12_XBOX_GetResolution(Uint32 *width, Uint32 *height);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
// Ends C function definitions when using C++
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
#define SDL_COMPOSE_ERROR(str) SDL_STRINGIFY_ARG(__FUNCTION__) ", " str
|
||||
|
||||
/* The shaders here were compiled with compile_shaders.bat */
|
||||
// The shaders here were compiled with compile_shaders.bat
|
||||
|
||||
#define g_main D3D12_PixelShader_Colors
|
||||
#include "D3D12_PixelShader_Colors.h"
|
||||
@@ -122,4 +122,4 @@ void D3D12_GetRootSignatureData(D3D12_RootSignature rootSig, D3D12_SHADER_BYTECO
|
||||
outBytecode->BytecodeLength = D3D12_rootsigs[rootSig].rs_shader_size;
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_D3D12 && !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) */
|
||||
#endif // SDL_VIDEO_RENDER_D3D12 && !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)
|
||||
@@ -20,9 +20,9 @@
|
||||
*/
|
||||
#include "SDL_internal.h"
|
||||
|
||||
/* D3D12 shader implementation */
|
||||
// D3D12 shader implementation
|
||||
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
// Set up for C function definitions, even when using C++
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@@ -48,7 +48,7 @@ extern void D3D12_GetPixelShader(D3D12_Shader shader, D3D12_SHADER_BYTECODE *out
|
||||
extern D3D12_RootSignature D3D12_GetRootSignatureType(D3D12_Shader shader);
|
||||
extern void D3D12_GetRootSignatureData(D3D12_RootSignature rootSig, D3D12_SHADER_BYTECODE *outBytecode);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
// Ends C function definitions when using C++
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
#define SDL_COMPOSE_ERROR(str) SDL_STRINGIFY_ARG(__FUNCTION__) ", " str
|
||||
|
||||
/* Shader blob headers are generated with a pre-build step using compile_shaders_xbox.bat */
|
||||
// Shader blob headers are generated with a pre-build step using compile_shaders_xbox.bat
|
||||
|
||||
#define g_main D3D12_PixelShader_Colors
|
||||
#include "D3D12_PixelShader_Colors_One.h"
|
||||
@@ -128,6 +128,6 @@ D3D12_GetRootSignatureData(D3D12_RootSignature rootSig, D3D12_SHADER_BYTECODE *o
|
||||
outBytecode->BytecodeLength = D3D12_rootsigs[rootSig].rs_shader_size;
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_D3D12 && defined(SDL_PLATFORM_XBOXONE) */
|
||||
#endif // SDL_VIDEO_RENDER_D3D12 && defined(SDL_PLATFORM_XBOXONE)
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
// vi: set ts=4 sw=4 expandtab:
|
||||
@@ -32,7 +32,7 @@
|
||||
#define SDL_COMPOSE_ERROR(str) SDL_STRINGIFY_ARG(__FUNCTION__) ", " str
|
||||
|
||||
|
||||
/* Shader blob headers are generated with a pre-build step using compile_shaders_xbox.bat */
|
||||
// Shader blob headers are generated with a pre-build step using compile_shaders_xbox.bat
|
||||
|
||||
#define g_main D3D12_PixelShader_Colors
|
||||
#include "D3D12_PixelShader_Colors_Series.h"
|
||||
@@ -129,6 +129,6 @@ D3D12_GetRootSignatureData(D3D12_RootSignature rootSig, D3D12_SHADER_BYTECODE *o
|
||||
outBytecode->BytecodeLength = D3D12_rootsigs[rootSig].rs_shader_size;
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_D3D12 && defined(SDL_PLATFORM_XBOXSERIES) */
|
||||
#endif // SDL_VIDEO_RENDER_D3D12 && defined(SDL_PLATFORM_XBOXSERIES)
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
// vi: set ts=4 sw=4 expandtab:
|
||||
@@ -38,7 +38,7 @@
|
||||
#import <UIKit/UIKit.h>
|
||||
#endif
|
||||
|
||||
/* Regenerate these with build-metal-shaders.sh */
|
||||
// Regenerate these with build-metal-shaders.sh
|
||||
#ifdef SDL_PLATFORM_MACOS
|
||||
#include "SDL_shaders_metal_macos.h"
|
||||
#elif defined(SDL_PLATFORM_TVOS)
|
||||
@@ -55,10 +55,10 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Apple Metal renderer implementation */
|
||||
// Apple Metal renderer implementation
|
||||
|
||||
/* 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 */
|
||||
// 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(SDL_PLATFORM_MACOS) || TARGET_OS_SIMULATOR || TARGET_OS_MACCATALYST
|
||||
#define CONSTANT_ALIGN(x) (256)
|
||||
#else
|
||||
@@ -80,7 +80,7 @@ static const size_t CONSTANTS_OFFSET_DECODE_BT2020_LIMITED = ALIGN_CONSTANTS(16,
|
||||
static const size_t CONSTANTS_OFFSET_DECODE_BT2020_FULL = ALIGN_CONSTANTS(16, CONSTANTS_OFFSET_DECODE_BT2020_LIMITED + sizeof(float) * 4 * 4);
|
||||
static const size_t CONSTANTS_LENGTH = CONSTANTS_OFFSET_DECODE_BT2020_FULL + sizeof(float) * 4 * 4;
|
||||
|
||||
/* Sampler types */
|
||||
// Sampler types
|
||||
typedef enum
|
||||
{
|
||||
SDL_METAL_SAMPLER_NEAREST_CLAMP,
|
||||
@@ -284,7 +284,7 @@ static id<MTLRenderPipelineState> MakePipelineState(SDL3METAL_RenderData *data,
|
||||
|
||||
switch (cache->vertexFunction) {
|
||||
case SDL_METAL_VERTEX_SOLID:
|
||||
/* position (float2), color (float4) */
|
||||
// position (float2), color (float4)
|
||||
vertdesc.layouts[0].stride = sizeof(float) * 2 + sizeof(float) * 4;
|
||||
vertdesc.layouts[0].stepFunction = MTLVertexStepFunctionPerVertex;
|
||||
|
||||
@@ -298,7 +298,7 @@ static id<MTLRenderPipelineState> MakePipelineState(SDL3METAL_RenderData *data,
|
||||
|
||||
break;
|
||||
case SDL_METAL_VERTEX_COPY:
|
||||
/* position (float2), color (float4), texcoord (float2) */
|
||||
// position (float2), color (float4), texcoord (float2)
|
||||
vertdesc.layouts[0].stride = sizeof(float) * 2 + sizeof(float) * 4 + sizeof(float) * 2;
|
||||
vertdesc.layouts[0].stepFunction = MTLVertexStepFunctionPerVertex;
|
||||
|
||||
@@ -692,7 +692,7 @@ static int METAL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL
|
||||
height:(NSUInteger)texture->h
|
||||
mipmapped:NO];
|
||||
|
||||
/* Not available in iOS 8. */
|
||||
// Not available in iOS 8.
|
||||
if ([mtltexdesc respondsToSelector:@selector(usage)]) {
|
||||
if (texture->access == SDL_TEXTUREACCESS_TARGET) {
|
||||
mtltexdesc.usage = MTLTextureUsageShaderRead | MTLTextureUsageRenderTarget;
|
||||
@@ -745,7 +745,7 @@ static int METAL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL
|
||||
return SDL_SetError("Texture allocation failed");
|
||||
}
|
||||
}
|
||||
#endif /* SDL_HAVE_YUV */
|
||||
#endif // SDL_HAVE_YUV
|
||||
texturedata = [[SDL3METAL_TextureData alloc] init];
|
||||
if (SDL_COLORSPACETRANSFER(texture->colorspace) == SDL_TRANSFER_CHARACTERISTICS_SRGB) {
|
||||
texturedata.fragmentFunction = SDL_METAL_FRAGMENT_COPY;
|
||||
@@ -788,7 +788,7 @@ static void METAL_UploadTextureData(id<MTLTexture> texture, SDL_Rect rect, int s
|
||||
|
||||
static MTLStorageMode METAL_GetStorageMode(id<MTLResource> resource)
|
||||
{
|
||||
/* iOS 8 does not have this method. */
|
||||
// iOS 8 does not have this method.
|
||||
if ([resource respondsToSelector:@selector(storageMode)]) {
|
||||
return resource.storageMode;
|
||||
}
|
||||
@@ -879,13 +879,13 @@ static int METAL_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
int UVpitch = (pitch + 1) / 2;
|
||||
SDL_Rect UVrect = { rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2 };
|
||||
|
||||
/* Skip to the correct offset into the next texture */
|
||||
// Skip to the correct offset into the next texture
|
||||
pixels = (const void *)((const Uint8 *)pixels + rect->h * pitch);
|
||||
if (METAL_UpdateTextureInternal(renderer, texturedata, texturedata.mtltextureUv, UVrect, Uslice, pixels, UVpitch) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Skip to the correct offset into the next texture */
|
||||
// Skip to the correct offset into the next texture
|
||||
pixels = (const void *)((const Uint8 *)pixels + UVrect.h * UVpitch);
|
||||
if (METAL_UpdateTextureInternal(renderer, texturedata, texturedata.mtltextureUv, UVrect, Vslice, pixels, UVpitch) < 0) {
|
||||
return -1;
|
||||
@@ -896,7 +896,7 @@ static int METAL_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
SDL_Rect UVrect = { rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2 };
|
||||
int UVpitch = 2 * ((pitch + 1) / 2);
|
||||
|
||||
/* Skip to the correct offset into the next texture */
|
||||
// Skip to the correct offset into the next texture
|
||||
pixels = (const void *)((const Uint8 *)pixels + rect->h * pitch);
|
||||
if (METAL_UpdateTextureInternal(renderer, texturedata, texturedata.mtltextureUv, UVrect, 0, pixels, UVpitch) < 0) {
|
||||
return -1;
|
||||
@@ -922,7 +922,7 @@ static int METAL_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const int Vslice = 1;
|
||||
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 */
|
||||
// Bail out if we're supposed to update an empty rectangle
|
||||
if (rect->w <= 0 || rect->h <= 0) {
|
||||
return 0;
|
||||
}
|
||||
@@ -952,7 +952,7 @@ static int METAL_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
SDL3METAL_TextureData *texturedata = (__bridge SDL3METAL_TextureData *)texture->internal;
|
||||
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 */
|
||||
// Bail out if we're supposed to update an empty rectangle
|
||||
if (rect->w <= 0 || rect->h <= 0) {
|
||||
return 0;
|
||||
}
|
||||
@@ -1090,7 +1090,7 @@ static void METAL_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
[data.mtlcmdbuffer commit];
|
||||
data.mtlcmdbuffer = nil;
|
||||
|
||||
texturedata.lockedbuffer = nil; /* Retained property, so it calls release. */
|
||||
texturedata.lockedbuffer = nil; // Retained property, so it calls release.
|
||||
texturedata.hasdata = YES;
|
||||
}
|
||||
}
|
||||
@@ -1123,7 +1123,7 @@ static int METAL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
|
||||
static int METAL_QueueSetViewport(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
{
|
||||
float projection[4][4]; /* Prepare an orthographic projection */
|
||||
float projection[4][4]; // Prepare an orthographic projection
|
||||
const int w = cmd->data.viewport.rect.w;
|
||||
const int h = cmd->data.viewport.rect.h;
|
||||
const size_t matrixlen = sizeof(projection);
|
||||
@@ -1147,7 +1147,7 @@ static int METAL_QueueSetViewport(SDL_Renderer *renderer, SDL_RenderCommand *cmd
|
||||
|
||||
static int METAL_QueueNoOp(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
{
|
||||
return 0; /* nothing to do in this backend. */
|
||||
return 0; // nothing to do in this backend.
|
||||
}
|
||||
|
||||
static int METAL_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count)
|
||||
@@ -1184,7 +1184,7 @@ static int METAL_QueueDrawLines(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
|
||||
size_t vertlen;
|
||||
float *verts;
|
||||
|
||||
SDL_assert(count >= 2); /* should have been checked at the higher level. */
|
||||
SDL_assert(count >= 2); // should have been checked at the higher level.
|
||||
|
||||
vertlen = (2 * sizeof(float) + 4 * sizeof(float)) * count;
|
||||
verts = (float *)SDL_AllocateRenderVertices(renderer, vertlen, DEVICE_ALIGN(8), &cmd->data.draw.first);
|
||||
@@ -1214,7 +1214,7 @@ static int METAL_QueueDrawLines(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
|
||||
that are missing a pixel that frames something and not arbitrary
|
||||
angles. Maybe !!! FIXME for later, though. */
|
||||
|
||||
points -= 2; /* update the last line. */
|
||||
points -= 2; // update the last line.
|
||||
verts -= 2 + 1;
|
||||
|
||||
{
|
||||
@@ -1223,9 +1223,9 @@ static int METAL_QueueDrawLines(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
|
||||
const float xend = points[1].x;
|
||||
const float yend = points[1].y;
|
||||
|
||||
if (ystart == yend) { /* horizontal line */
|
||||
if (ystart == yend) { // horizontal line
|
||||
verts[0] += (xend > xstart) ? 1.0f : -1.0f;
|
||||
} else if (xstart == xend) { /* vertical line */
|
||||
} else if (xstart == xend) { // vertical line
|
||||
verts[1] += (yend > ystart) ? 1.0f : -1.0f;
|
||||
}
|
||||
}
|
||||
@@ -1289,7 +1289,7 @@ static int METAL_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, S
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* These should mirror the definitions in SDL_shaders_metal.metal */
|
||||
// These should mirror the definitions in SDL_shaders_metal.metal
|
||||
//static const float TONEMAP_NONE = 0;
|
||||
//static const float TONEMAP_LINEAR = 1;
|
||||
static const float TONEMAP_CHROME = 2;
|
||||
@@ -1426,7 +1426,7 @@ static SDL_bool SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *cm
|
||||
clip = statecache->viewport;
|
||||
}
|
||||
|
||||
/* Set Scissor Rect Validation: w/h must be <= render pass */
|
||||
// Set Scissor Rect Validation: w/h must be <= render pass
|
||||
SDL_zero(output);
|
||||
|
||||
if (renderer->target) {
|
||||
@@ -1477,7 +1477,7 @@ static SDL_bool SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *cm
|
||||
statecache->constants_offset = constants_offset;
|
||||
}
|
||||
|
||||
[data.mtlcmdencoder setVertexBufferOffset:first atIndex:0]; /* position/texcoords */
|
||||
[data.mtlcmdencoder setVertexBufferOffset:first atIndex:0]; // position/texcoords
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
@@ -1653,13 +1653,13 @@ static int METAL_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_FILL_RECTS: /* unused */
|
||||
case SDL_RENDERCMD_FILL_RECTS: // unused
|
||||
break;
|
||||
|
||||
case SDL_RENDERCMD_COPY: /* unused */
|
||||
case SDL_RENDERCMD_COPY: // unused
|
||||
break;
|
||||
|
||||
case SDL_RENDERCMD_COPY_EX: /* unused */
|
||||
case SDL_RENDERCMD_COPY_EX: // unused
|
||||
break;
|
||||
|
||||
case SDL_RENDERCMD_GEOMETRY:
|
||||
@@ -1817,7 +1817,7 @@ static void METAL_DestroyRenderer(SDL_Renderer *renderer)
|
||||
/* Release the metal view instead of destroying it,
|
||||
in case we want to use it later (recreating the renderer)
|
||||
*/
|
||||
/* SDL_Metal_DestroyView(data.mtlview); */
|
||||
// SDL_Metal_DestroyView(data.mtlview);
|
||||
CFBridgingRelease(data.mtlview);
|
||||
}
|
||||
}
|
||||
@@ -1921,7 +1921,7 @@ static int METAL_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_
|
||||
id<MTLBlitCommandEncoder> blitcmd;
|
||||
SDL_bool scRGB_supported = SDL_FALSE;
|
||||
|
||||
/* Note: matrices are column major. */
|
||||
// Note: matrices are column major.
|
||||
float identitytransform[16] = {
|
||||
1.0f,
|
||||
0.0f,
|
||||
@@ -1975,7 +1975,7 @@ static int METAL_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_
|
||||
#endif
|
||||
if (renderer->output_colorspace != SDL_COLORSPACE_SRGB) {
|
||||
if (renderer->output_colorspace == SDL_COLORSPACE_SRGB_LINEAR && scRGB_supported) {
|
||||
/* This colorspace is supported */
|
||||
// This colorspace is supported
|
||||
} else {
|
||||
return SDL_SetError("Unsupported output colorspace");
|
||||
}
|
||||
@@ -2018,7 +2018,7 @@ static int METAL_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_
|
||||
/* Release the metal view instead of destroying it,
|
||||
in case we want to use it later (recreating the renderer)
|
||||
*/
|
||||
/* SDL_Metal_DestroyView(view); */
|
||||
// SDL_Metal_DestroyView(view);
|
||||
CFBridgingRelease(view);
|
||||
return SDL_SetError("SDL3METAL_RenderData alloc/init failed");
|
||||
}
|
||||
@@ -2049,11 +2049,11 @@ static int METAL_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_
|
||||
layer.colorspace = colorspace;
|
||||
CGColorSpaceRelease(colorspace);
|
||||
}
|
||||
#endif /* !SDL_PLATFORM_TVOS */
|
||||
#endif // !SDL_PLATFORM_TVOS
|
||||
|
||||
layer.device = mtldevice;
|
||||
|
||||
/* Necessary for RenderReadPixels. */
|
||||
// Necessary for RenderReadPixels.
|
||||
layer.framebufferOnly = NO;
|
||||
|
||||
data.mtldevice = layer.device;
|
||||
@@ -2072,7 +2072,7 @@ static int METAL_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_
|
||||
SDL_assert(err == nil);
|
||||
data.mtllibrary.label = @"SDL Metal renderer shader library";
|
||||
|
||||
/* Do some shader pipeline state loading up-front rather than on demand. */
|
||||
// Do some shader pipeline state loading up-front rather than on demand.
|
||||
data.pipelinescount = 0;
|
||||
data.allpipelines = NULL;
|
||||
ChooseShaderPipelines(data, MTLPixelFormatBGRA8Unorm);
|
||||
@@ -2196,7 +2196,7 @@ static int METAL_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_
|
||||
}
|
||||
#endif
|
||||
|
||||
/* https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf */
|
||||
// https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf
|
||||
maxtexsize = 4096;
|
||||
#if defined(SDL_PLATFORM_MACOS) || TARGET_OS_MACCATALYST
|
||||
maxtexsize = 16384;
|
||||
@@ -2240,4 +2240,4 @@ SDL_RenderDriver METAL_RenderDriver = {
|
||||
METAL_CreateRenderer, "metal"
|
||||
};
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_METAL */
|
||||
#endif // SDL_VIDEO_RENDER_METAL
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "SDL_internal.h"
|
||||
|
||||
#if SDL_VIDEO_RENDER_OGL
|
||||
#include "../../video/SDL_sysvideo.h" /* For SDL_RecreateWindow */
|
||||
#include "../../video/SDL_sysvideo.h" // For SDL_RecreateWindow
|
||||
#include <SDL3/SDL_opengl.h>
|
||||
#include "../SDL_sysrender.h"
|
||||
#include "SDL_shaders_gl.h"
|
||||
@@ -43,7 +43,7 @@
|
||||
#define RENDERER_CONTEXT_MAJOR 2
|
||||
#define RENDERER_CONTEXT_MINOR 1
|
||||
|
||||
/* OpenGL renderer implementation */
|
||||
// OpenGL renderer implementation
|
||||
|
||||
/* Details on optimizing the texture path on macOS:
|
||||
http://developer.apple.com/library/mac/#documentation/GraphicsImaging/Conceptual/OpenGL-MacProgGuide/opengl_texturedata/opengl_texturedata.html
|
||||
@@ -102,12 +102,12 @@ typedef struct
|
||||
SDL_bool GL_EXT_framebuffer_object_supported;
|
||||
GL_FBOList *framebuffers;
|
||||
|
||||
/* OpenGL functions */
|
||||
// OpenGL functions
|
||||
#define SDL_PROC(ret, func, params) ret (APIENTRY *func) params;
|
||||
#include "SDL_glfuncs.h"
|
||||
#undef SDL_PROC
|
||||
|
||||
/* Multitexture support */
|
||||
// Multitexture support
|
||||
SDL_bool GL_ARB_multitexture_supported;
|
||||
PFNGLACTIVETEXTUREARBPROC glActiveTextureARB;
|
||||
GLint num_texture_units;
|
||||
@@ -118,7 +118,7 @@ typedef struct
|
||||
PFNGLBINDFRAMEBUFFEREXTPROC glBindFramebufferEXT;
|
||||
PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC glCheckFramebufferStatusEXT;
|
||||
|
||||
/* Shader support */
|
||||
// Shader support
|
||||
GL_ShaderContext *shaders;
|
||||
|
||||
GL_DrawStateCache drawstate;
|
||||
@@ -139,7 +139,7 @@ typedef struct
|
||||
SDL_Rect locked_rect;
|
||||
|
||||
#if SDL_HAVE_YUV
|
||||
/* YUV texture support */
|
||||
// YUV texture support
|
||||
SDL_bool yuv;
|
||||
SDL_bool nv12;
|
||||
GLuint utexture;
|
||||
@@ -191,7 +191,7 @@ static void GL_ClearErrors(SDL_Renderer *renderer)
|
||||
}
|
||||
} else if (data->glGetError) {
|
||||
while (data->glGetError() != GL_NO_ERROR) {
|
||||
/* continue; */
|
||||
// continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -214,7 +214,7 @@ static int GL_CheckAllErrors(const char *prefix, SDL_Renderer *renderer, const c
|
||||
GL_ClearErrors(renderer);
|
||||
}
|
||||
} else {
|
||||
/* check gl errors (can return multiple errors) */
|
||||
// check gl errors (can return multiple errors)
|
||||
for (;;) {
|
||||
GLenum error = data->glGetError();
|
||||
if (error != GL_NO_ERROR) {
|
||||
@@ -250,7 +250,7 @@ static int GL_LoadFunctions(GL_RenderData *data)
|
||||
retval = SDL_SetError("Couldn't load GL function %s: %s", #func, SDL_GetError()); \
|
||||
} \
|
||||
} while (0);
|
||||
#endif /* __SDL_NOGETPROCADDR__ */
|
||||
#endif // __SDL_NOGETPROCADDR__
|
||||
|
||||
#include "SDL_glfuncs.h"
|
||||
#undef SDL_PROC
|
||||
@@ -278,7 +278,7 @@ static void APIENTRY GL_HandleDebugMessage(GLenum source, GLenum type, GLuint id
|
||||
GL_RenderData *data = (GL_RenderData *)renderer->internal;
|
||||
|
||||
if (type == GL_DEBUG_TYPE_ERROR_ARB) {
|
||||
/* Record this error */
|
||||
// Record this error
|
||||
int errors = data->errors + 1;
|
||||
char **error_messages = (char **)SDL_realloc(data->error_messages, errors * sizeof(*data->error_messages));
|
||||
if (error_messages) {
|
||||
@@ -288,7 +288,7 @@ static void APIENTRY GL_HandleDebugMessage(GLenum source, GLenum type, GLuint id
|
||||
}
|
||||
}
|
||||
|
||||
/* If there's another error callback, pass it along, otherwise log it */
|
||||
// If there's another error callback, pass it along, otherwise log it
|
||||
if (data->next_error_callback) {
|
||||
data->next_error_callback(source, type, id, severity, length, message, data->next_error_userparam);
|
||||
} else {
|
||||
@@ -451,8 +451,8 @@ static int GL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_Pr
|
||||
|
||||
GL_ActivateRenderer(renderer);
|
||||
|
||||
renderdata->drawstate.texture = NULL; /* we trash this state. */
|
||||
renderdata->drawstate.texturing_dirty = SDL_TRUE; /* we trash this state. */
|
||||
renderdata->drawstate.texture = NULL; // we trash this state.
|
||||
renderdata->drawstate.texturing_dirty = SDL_TRUE; // we trash this state.
|
||||
|
||||
if (texture->access == SDL_TEXTUREACCESS_TARGET &&
|
||||
!renderdata->GL_EXT_framebuffer_object_supported) {
|
||||
@@ -475,12 +475,12 @@ static int GL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_Pr
|
||||
size = (size_t)texture->h * data->pitch;
|
||||
if (texture->format == SDL_PIXELFORMAT_YV12 ||
|
||||
texture->format == SDL_PIXELFORMAT_IYUV) {
|
||||
/* Need to add size for the U and V planes */
|
||||
// Need to add size for the U and V planes
|
||||
size += 2 * ((texture->h + 1) / 2) * ((data->pitch + 1) / 2);
|
||||
}
|
||||
if (texture->format == SDL_PIXELFORMAT_NV12 ||
|
||||
texture->format == SDL_PIXELFORMAT_NV21) {
|
||||
/* Need to add size for the U/V plane */
|
||||
// Need to add size for the U/V plane
|
||||
size += 2 * ((texture->h + 1) / 2) * ((data->pitch + 1) / 2);
|
||||
}
|
||||
data->pixels = SDL_calloc(1, size);
|
||||
@@ -663,7 +663,7 @@ static int GL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_Pr
|
||||
return SDL_SetError("Unsupported YUV colorspace");
|
||||
}
|
||||
}
|
||||
#endif /* SDL_HAVE_YUV */
|
||||
#endif // SDL_HAVE_YUV
|
||||
|
||||
return GL_CheckError("", renderer);
|
||||
}
|
||||
@@ -676,11 +676,11 @@ static int GL_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
GL_TextureData *data = (GL_TextureData *)texture->internal;
|
||||
const int texturebpp = SDL_BYTESPERPIXEL(texture->format);
|
||||
|
||||
SDL_assert_release(texturebpp != 0); /* otherwise, division by zero later. */
|
||||
SDL_assert_release(texturebpp != 0); // otherwise, division by zero later.
|
||||
|
||||
GL_ActivateRenderer(renderer);
|
||||
|
||||
renderdata->drawstate.texture = NULL; /* we trash this state. */
|
||||
renderdata->drawstate.texture = NULL; // we trash this state.
|
||||
|
||||
renderdata->glBindTexture(textype, data->texture);
|
||||
renderdata->glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
@@ -692,7 +692,7 @@ static int GL_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
if (data->yuv) {
|
||||
renderdata->glPixelStorei(GL_UNPACK_ROW_LENGTH, ((pitch + 1) / 2));
|
||||
|
||||
/* Skip to the correct offset into the next texture */
|
||||
// Skip to the correct offset into the next texture
|
||||
pixels = (const void *)((const Uint8 *)pixels + rect->h * pitch);
|
||||
if (texture->format == SDL_PIXELFORMAT_YV12) {
|
||||
renderdata->glBindTexture(textype, data->vtexture);
|
||||
@@ -703,7 +703,7 @@ static int GL_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
(rect->w + 1) / 2, (rect->h + 1) / 2,
|
||||
data->format, data->formattype, pixels);
|
||||
|
||||
/* Skip to the correct offset into the next texture */
|
||||
// Skip to the correct offset into the next texture
|
||||
pixels = (const void *)((const Uint8 *)pixels + ((rect->h + 1) / 2) * ((pitch + 1) / 2));
|
||||
if (texture->format == SDL_PIXELFORMAT_YV12) {
|
||||
renderdata->glBindTexture(textype, data->utexture);
|
||||
@@ -718,7 +718,7 @@ static int GL_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
if (data->nv12) {
|
||||
renderdata->glPixelStorei(GL_UNPACK_ROW_LENGTH, ((pitch + 1) / 2));
|
||||
|
||||
/* Skip to the correct offset into the next texture */
|
||||
// Skip to the correct offset into the next texture
|
||||
pixels = (const void *)((const Uint8 *)pixels + rect->h * pitch);
|
||||
renderdata->glBindTexture(textype, data->utexture);
|
||||
renderdata->glTexSubImage2D(textype, 0, rect->x / 2, rect->y / 2,
|
||||
@@ -742,7 +742,7 @@ static int GL_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
|
||||
GL_ActivateRenderer(renderer);
|
||||
|
||||
renderdata->drawstate.texture = NULL; /* we trash this state. */
|
||||
renderdata->drawstate.texture = NULL; // we trash this state.
|
||||
|
||||
renderdata->glBindTexture(textype, data->texture);
|
||||
renderdata->glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
@@ -777,7 +777,7 @@ static int GL_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
|
||||
GL_ActivateRenderer(renderer);
|
||||
|
||||
renderdata->drawstate.texture = NULL; /* we trash this state. */
|
||||
renderdata->drawstate.texture = NULL; // we trash this state.
|
||||
|
||||
renderdata->glBindTexture(textype, data->texture);
|
||||
renderdata->glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
@@ -875,9 +875,9 @@ static int GL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
|
||||
texturedata = (GL_TextureData *)texture->internal;
|
||||
data->glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, texturedata->fbo->FBO);
|
||||
/* TODO: check if texture pixel format allows this operation */
|
||||
// TODO: check if texture pixel format allows this operation
|
||||
data->glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, data->textype, texturedata->texture, 0);
|
||||
/* Check FBO status */
|
||||
// Check FBO status
|
||||
status = data->glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
|
||||
if (status != GL_FRAMEBUFFER_COMPLETE_EXT) {
|
||||
return SDL_SetError("glFramebufferTexture2DEXT() failed");
|
||||
@@ -890,7 +890,7 @@ static int GL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
!!! FIXME: VBOs at some point. */
|
||||
static int GL_QueueNoOp(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
{
|
||||
return 0; /* nothing to do in this backend. */
|
||||
return 0; // nothing to do in this backend.
|
||||
}
|
||||
|
||||
static int GL_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count)
|
||||
@@ -923,7 +923,7 @@ static int GL_QueueDrawLines(SDL_Renderer *renderer, SDL_RenderCommand *cmd, con
|
||||
}
|
||||
cmd->data.draw.count = count;
|
||||
|
||||
/* 0.5f offset to hit the center of the pixel. */
|
||||
// 0.5f offset to hit the center of the pixel.
|
||||
prevx = 0.5f + points->x;
|
||||
prevy = 0.5f + points->y;
|
||||
*(verts++) = prevx;
|
||||
@@ -936,9 +936,9 @@ static int GL_QueueDrawLines(SDL_Renderer *renderer, SDL_RenderCommand *cmd, con
|
||||
for (i = 1; i < count; i++) {
|
||||
const GLfloat xstart = prevx;
|
||||
const GLfloat ystart = prevy;
|
||||
const GLfloat xend = points[i].x + 0.5f; /* 0.5f to hit pixel center. */
|
||||
const GLfloat xend = points[i].x + 0.5f; // 0.5f to hit pixel center.
|
||||
const GLfloat yend = points[i].y + 0.5f;
|
||||
/* bump a little in the direction we are moving in. */
|
||||
// bump a little in the direction we are moving in.
|
||||
const GLfloat deltax = xend - xstart;
|
||||
const GLfloat deltay = yend - ystart;
|
||||
const GLfloat angle = SDL_atan2f(deltay, deltax);
|
||||
@@ -1204,16 +1204,16 @@ static void GL_InvalidateCachedState(SDL_Renderer *renderer)
|
||||
cache->cliprect_enabled_dirty = SDL_TRUE;
|
||||
cache->cliprect_dirty = SDL_TRUE;
|
||||
cache->texturing_dirty = SDL_TRUE;
|
||||
cache->vertex_array = SDL_FALSE; /* !!! FIXME: this resets to false at the end of GL_RunCommandQueue, but we could cache this more aggressively. */
|
||||
cache->color_array = SDL_FALSE; /* !!! FIXME: this resets to false at the end of GL_RunCommandQueue, but we could cache this more aggressively. */
|
||||
cache->texture_array = SDL_FALSE; /* !!! FIXME: this resets to false at the end of GL_RunCommandQueue, but we could cache this more aggressively. */
|
||||
cache->vertex_array = SDL_FALSE; // !!! FIXME: this resets to false at the end of GL_RunCommandQueue, but we could cache this more aggressively.
|
||||
cache->color_array = SDL_FALSE; // !!! FIXME: this resets to false at the end of GL_RunCommandQueue, but we could cache this more aggressively.
|
||||
cache->texture_array = SDL_FALSE; // !!! FIXME: this resets to false at the end of GL_RunCommandQueue, but we could cache this more aggressively.
|
||||
cache->color_dirty = SDL_TRUE;
|
||||
cache->clear_color_dirty = SDL_TRUE;
|
||||
}
|
||||
|
||||
static int GL_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize)
|
||||
{
|
||||
/* !!! FIXME: it'd be nice to use a vertex buffer instead of immediate mode... */
|
||||
// !!! FIXME: it'd be nice to use a vertex buffer instead of immediate mode...
|
||||
GL_RenderData *data = (GL_RenderData *)renderer->internal;
|
||||
|
||||
if (GL_ActivateRenderer(renderer) < 0) {
|
||||
@@ -1316,13 +1316,13 @@ static int GL_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_FILL_RECTS: /* unused */
|
||||
case SDL_RENDERCMD_FILL_RECTS: // unused
|
||||
break;
|
||||
|
||||
case SDL_RENDERCMD_COPY: /* unused */
|
||||
case SDL_RENDERCMD_COPY: // unused
|
||||
break;
|
||||
|
||||
case SDL_RENDERCMD_COPY_EX: /* unused */
|
||||
case SDL_RENDERCMD_COPY_EX: // unused
|
||||
break;
|
||||
|
||||
case SDL_RENDERCMD_DRAW_LINES:
|
||||
@@ -1331,14 +1331,14 @@ static int GL_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
|
||||
size_t count = cmd->data.draw.count;
|
||||
const GLfloat *verts = (GLfloat *)(((Uint8 *)vertices) + cmd->data.draw.first);
|
||||
|
||||
/* SetDrawState handles glEnableClientState. */
|
||||
// SetDrawState handles glEnableClientState.
|
||||
data->glVertexPointer(2, GL_FLOAT, sizeof(float) * 2, verts);
|
||||
|
||||
if (count > 2) {
|
||||
/* joined lines cannot be grouped */
|
||||
// joined lines cannot be grouped
|
||||
data->glDrawArrays(GL_LINE_STRIP, 0, (GLsizei)count);
|
||||
} else {
|
||||
/* let's group non joined lines */
|
||||
// let's group non joined lines
|
||||
SDL_RenderCommand *finalcmd = cmd;
|
||||
SDL_RenderCommand *nextcmd = cmd->next;
|
||||
SDL_BlendMode thisblend = cmd->data.draw.blend;
|
||||
@@ -1346,20 +1346,20 @@ static int GL_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
|
||||
while (nextcmd) {
|
||||
const SDL_RenderCommandType nextcmdtype = nextcmd->command;
|
||||
if (nextcmdtype != SDL_RENDERCMD_DRAW_LINES) {
|
||||
break; /* can't go any further on this draw call, different render command up next. */
|
||||
break; // can't go any further on this draw call, different render command up next.
|
||||
} else if (nextcmd->data.draw.count != 2) {
|
||||
break; /* can't go any further on this draw call, those are joined lines */
|
||||
break; // can't go any further on this draw call, those are joined lines
|
||||
} else if (nextcmd->data.draw.blend != thisblend) {
|
||||
break; /* can't go any further on this draw call, different blendmode copy up next. */
|
||||
break; // can't go any further on this draw call, different blendmode copy up next.
|
||||
} else {
|
||||
finalcmd = nextcmd; /* we can combine copy operations here. Mark this one as the furthest okay command. */
|
||||
finalcmd = nextcmd; // we can combine copy operations here. Mark this one as the furthest okay command.
|
||||
count += nextcmd->data.draw.count;
|
||||
}
|
||||
nextcmd = nextcmd->next;
|
||||
}
|
||||
|
||||
data->glDrawArrays(GL_LINES, 0, (GLsizei)count);
|
||||
cmd = finalcmd; /* skip any copy commands we just combined in here. */
|
||||
cmd = finalcmd; // skip any copy commands we just combined in here.
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -1380,11 +1380,11 @@ static int GL_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
|
||||
while (nextcmd) {
|
||||
const SDL_RenderCommandType nextcmdtype = nextcmd->command;
|
||||
if (nextcmdtype != thiscmdtype) {
|
||||
break; /* can't go any further on this draw call, different render command up next. */
|
||||
break; // can't go any further on this draw call, different render command up next.
|
||||
} else if (nextcmd->data.draw.texture != thistexture || nextcmd->data.draw.blend != thisblend) {
|
||||
break; /* can't go any further on this draw call, different texture/blendmode copy up next. */
|
||||
break; // can't go any further on this draw call, different texture/blendmode copy up next.
|
||||
} else {
|
||||
finalcmd = nextcmd; /* we can combine copy operations here. Mark this one as the furthest okay command. */
|
||||
finalcmd = nextcmd; // we can combine copy operations here. Mark this one as the furthest okay command.
|
||||
count += nextcmd->data.draw.count;
|
||||
}
|
||||
nextcmd = nextcmd->next;
|
||||
@@ -1398,16 +1398,16 @@ static int GL_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
|
||||
|
||||
if (ret == 0) {
|
||||
const GLfloat *verts = (GLfloat *)(((Uint8 *)vertices) + cmd->data.draw.first);
|
||||
int op = GL_TRIANGLES; /* SDL_RENDERCMD_GEOMETRY */
|
||||
int op = GL_TRIANGLES; // SDL_RENDERCMD_GEOMETRY
|
||||
if (thiscmdtype == SDL_RENDERCMD_DRAW_POINTS) {
|
||||
op = GL_POINTS;
|
||||
}
|
||||
|
||||
if (thiscmdtype == SDL_RENDERCMD_DRAW_POINTS) {
|
||||
/* SetDrawState handles glEnableClientState. */
|
||||
// SetDrawState handles glEnableClientState.
|
||||
data->glVertexPointer(2, GL_FLOAT, sizeof(float) * 2, verts);
|
||||
} else {
|
||||
/* SetDrawState handles glEnableClientState. */
|
||||
// SetDrawState handles glEnableClientState.
|
||||
if (thistexture) {
|
||||
data->glVertexPointer(2, GL_FLOAT, sizeof(float) * 8, verts + 0);
|
||||
data->glColorPointer(4, GL_FLOAT, sizeof(float) * 8, verts + 2);
|
||||
@@ -1420,7 +1420,7 @@ static int GL_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
|
||||
|
||||
data->glDrawArrays(op, 0, (GLsizei)count);
|
||||
|
||||
/* Restore previously set color when we're done. */
|
||||
// Restore previously set color when we're done.
|
||||
if (thiscmdtype != SDL_RENDERCMD_DRAW_POINTS) {
|
||||
const float r = data->drawstate.color.r;
|
||||
const float g = data->drawstate.color.g;
|
||||
@@ -1430,7 +1430,7 @@ static int GL_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
|
||||
}
|
||||
}
|
||||
|
||||
cmd = finalcmd; /* skip any copy commands we just combined in here. */
|
||||
cmd = finalcmd; // skip any copy commands we just combined in here.
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1493,7 +1493,7 @@ static SDL_Surface *GL_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Flip the rows to be top-down if necessary */
|
||||
// Flip the rows to be top-down if necessary
|
||||
if (!renderer->target) {
|
||||
SDL_bool isstack;
|
||||
int length = rect->w * SDL_BYTESPERPIXEL(format);
|
||||
@@ -1566,7 +1566,7 @@ static void GL_DestroyRenderer(SDL_Renderer *renderer)
|
||||
|
||||
if (data) {
|
||||
if (data->context) {
|
||||
/* make sure we delete the right resources! */
|
||||
// make sure we delete the right resources!
|
||||
GL_ActivateRenderer(renderer);
|
||||
}
|
||||
|
||||
@@ -1574,8 +1574,8 @@ static void GL_DestroyRenderer(SDL_Renderer *renderer)
|
||||
if (data->GL_ARB_debug_output_supported) {
|
||||
PFNGLDEBUGMESSAGECALLBACKARBPROC glDebugMessageCallbackARBFunc = (PFNGLDEBUGMESSAGECALLBACKARBPROC)SDL_GL_GetProcAddress("glDebugMessageCallbackARB");
|
||||
|
||||
/* Uh oh, we don't have a safe way of removing ourselves from the callback chain, if it changed after we set our callback. */
|
||||
/* For now, just always replace the callback with the original one */
|
||||
// Uh oh, we don't have a safe way of removing ourselves from the callback chain, if it changed after we set our callback.
|
||||
// For now, just always replace the callback with the original one
|
||||
glDebugMessageCallbackARBFunc(data->next_error_callback, data->next_error_userparam);
|
||||
}
|
||||
if (data->shaders) {
|
||||
@@ -1584,7 +1584,7 @@ static void GL_DestroyRenderer(SDL_Renderer *renderer)
|
||||
if (data->context) {
|
||||
while (data->framebuffers) {
|
||||
GL_FBOList *nextnode = data->framebuffers->next;
|
||||
/* delete the framebuffer object */
|
||||
// delete the framebuffer object
|
||||
data->glDeleteFramebuffersEXT(1, &data->framebuffers->FBO);
|
||||
GL_CheckError("", renderer);
|
||||
SDL_free(data->framebuffers);
|
||||
@@ -1706,13 +1706,13 @@ static int GL_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Pro
|
||||
}
|
||||
|
||||
#ifdef SDL_PLATFORM_MACOS
|
||||
/* Enable multi-threaded rendering */
|
||||
// Enable multi-threaded rendering
|
||||
/* Disabled until Ryan finishes his VBO/PBO code...
|
||||
CGLEnable(CGLGetCurrentContext(), kCGLCEMPEngine);
|
||||
*/
|
||||
#endif
|
||||
|
||||
/* Check for debug output support */
|
||||
// Check for debug output support
|
||||
if (SDL_GL_GetAttribute(SDL_GL_CONTEXT_FLAGS, &value) == 0 &&
|
||||
(value & SDL_GL_CONTEXT_DEBUG_FLAG)) {
|
||||
data->debug_enabled = SDL_TRUE;
|
||||
@@ -1725,7 +1725,7 @@ static int GL_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Pro
|
||||
data->glGetPointerv(GL_DEBUG_CALLBACK_USER_PARAM_ARB, &data->next_error_userparam);
|
||||
glDebugMessageCallbackARBFunc(GL_HandleDebugMessage, renderer);
|
||||
|
||||
/* Make sure our callback is called when errors actually happen */
|
||||
// Make sure our callback is called when errors actually happen
|
||||
data->glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
|
||||
}
|
||||
|
||||
@@ -1766,7 +1766,7 @@ static int GL_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Pro
|
||||
SDL_SetNumberProperty(SDL_GetRendererProperties(renderer), SDL_PROP_RENDERER_MAX_TEXTURE_SIZE_NUMBER, value);
|
||||
}
|
||||
|
||||
/* Check for multitexture support */
|
||||
// Check for multitexture support
|
||||
if (SDL_GL_ExtensionSupported("GL_ARB_multitexture")) {
|
||||
data->glActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC)SDL_GL_GetProcAddress("glActiveTextureARB");
|
||||
if (data->glActiveTextureARB) {
|
||||
@@ -1775,18 +1775,18 @@ static int GL_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Pro
|
||||
}
|
||||
}
|
||||
|
||||
/* Check for shader support */
|
||||
// Check for shader support
|
||||
data->shaders = GL_CreateShaderContext();
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_RENDER, "OpenGL shaders: %s",
|
||||
data->shaders ? "ENABLED" : "DISABLED");
|
||||
#if SDL_HAVE_YUV
|
||||
/* We support YV12 textures using 3 textures and a shader */
|
||||
// We support YV12 textures using 3 textures and a shader
|
||||
if (data->shaders && data->num_texture_units >= 3) {
|
||||
SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_YV12);
|
||||
SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_IYUV);
|
||||
}
|
||||
|
||||
/* We support NV12 textures using 2 textures and a shader */
|
||||
// We support NV12 textures using 2 textures and a shader
|
||||
if (data->shaders && data->num_texture_units >= 2) {
|
||||
SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_NV12);
|
||||
SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_NV21);
|
||||
@@ -1820,7 +1820,7 @@ static int GL_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Pro
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* Set up parameters for rendering */
|
||||
// Set up parameters for rendering
|
||||
data->glMatrixMode(GL_MODELVIEW);
|
||||
data->glLoadIdentity();
|
||||
data->glDisable(GL_DEPTH_TEST);
|
||||
@@ -1829,8 +1829,8 @@ static int GL_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Pro
|
||||
data->glDisable(data->textype);
|
||||
data->glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
data->glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
/* This ended up causing video discrepancies between OpenGL and Direct3D */
|
||||
/* data->glEnable(GL_LINE_SMOOTH); */
|
||||
// This ended up causing video discrepancies between OpenGL and Direct3D
|
||||
// data->glEnable(GL_LINE_SMOOTH);
|
||||
|
||||
data->drawstate.color.r = 1.0f;
|
||||
data->drawstate.color.g = 1.0f;
|
||||
@@ -1845,7 +1845,7 @@ static int GL_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Pro
|
||||
|
||||
error:
|
||||
if (changed_window) {
|
||||
/* Uh oh, better try to put it back... */
|
||||
// Uh oh, better try to put it back...
|
||||
char *error = SDL_strdup(SDL_GetError());
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, profile_mask);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, major);
|
||||
@@ -1861,4 +1861,4 @@ SDL_RenderDriver GL_RenderDriver = {
|
||||
GL_CreateRenderer, "opengl"
|
||||
};
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_OGL */
|
||||
#endif // SDL_VIDEO_RENDER_OGL
|
||||
@@ -25,9 +25,9 @@
|
||||
#include <SDL3/SDL_opengl.h>
|
||||
#include "SDL_shaders_gl.h"
|
||||
|
||||
/* OpenGL shader implementation */
|
||||
// OpenGL shader implementation
|
||||
|
||||
/* #define DEBUG_SHADERS */
|
||||
// #define DEBUG_SHADERS
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@@ -61,7 +61,7 @@ struct GL_ShaderContext
|
||||
const float *shader_params[NUM_SHADERS];
|
||||
};
|
||||
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */ // clang-format off
|
||||
|
||||
#define COLOR_VERTEX_SHADER \
|
||||
"varying vec4 v_color;\n" \
|
||||
@@ -237,14 +237,14 @@ struct GL_ShaderContext
|
||||
* texture_rectangle versions if we choose to use that extension.
|
||||
*/
|
||||
static const char *shader_source[NUM_SHADERS][2] = {
|
||||
/* SHADER_NONE */
|
||||
// SHADER_NONE
|
||||
{ NULL, NULL },
|
||||
|
||||
/* SHADER_SOLID */
|
||||
// SHADER_SOLID
|
||||
{
|
||||
/* vertex shader */
|
||||
// vertex shader
|
||||
COLOR_VERTEX_SHADER,
|
||||
/* fragment shader */
|
||||
// fragment shader
|
||||
"varying vec4 v_color;\n"
|
||||
"\n"
|
||||
"void main()\n"
|
||||
@@ -253,11 +253,11 @@ static const char *shader_source[NUM_SHADERS][2] = {
|
||||
"}"
|
||||
},
|
||||
|
||||
/* SHADER_RGB */
|
||||
// SHADER_RGB
|
||||
{
|
||||
/* vertex shader */
|
||||
// vertex shader
|
||||
TEXTURE_VERTEX_SHADER,
|
||||
/* fragment shader */
|
||||
// fragment shader
|
||||
"varying vec4 v_color;\n"
|
||||
"varying vec2 v_texCoord;\n"
|
||||
"uniform sampler2D tex0;\n"
|
||||
@@ -270,11 +270,11 @@ static const char *shader_source[NUM_SHADERS][2] = {
|
||||
"}"
|
||||
},
|
||||
|
||||
/* SHADER_RGBA */
|
||||
// SHADER_RGBA
|
||||
{
|
||||
/* vertex shader */
|
||||
// vertex shader
|
||||
TEXTURE_VERTEX_SHADER,
|
||||
/* fragment shader */
|
||||
// fragment shader
|
||||
"varying vec4 v_color;\n"
|
||||
"varying vec2 v_texCoord;\n"
|
||||
"uniform sampler2D tex0;\n"
|
||||
@@ -285,50 +285,50 @@ static const char *shader_source[NUM_SHADERS][2] = {
|
||||
"}"
|
||||
},
|
||||
#if SDL_HAVE_YUV
|
||||
/* SHADER_YUV */
|
||||
// SHADER_YUV
|
||||
{
|
||||
/* vertex shader */
|
||||
// vertex shader
|
||||
TEXTURE_VERTEX_SHADER,
|
||||
/* fragment shader */
|
||||
// fragment shader
|
||||
YUV_SHADER_PROLOGUE
|
||||
YUV_SHADER_BODY
|
||||
},
|
||||
/* SHADER_NV12_RA */
|
||||
// SHADER_NV12_RA
|
||||
{
|
||||
/* vertex shader */
|
||||
// vertex shader
|
||||
TEXTURE_VERTEX_SHADER,
|
||||
/* fragment shader */
|
||||
// fragment shader
|
||||
NV12_SHADER_PROLOGUE
|
||||
NV12_RA_SHADER_BODY
|
||||
},
|
||||
/* SHADER_NV12_RG */
|
||||
// SHADER_NV12_RG
|
||||
{
|
||||
/* vertex shader */
|
||||
// vertex shader
|
||||
TEXTURE_VERTEX_SHADER,
|
||||
/* fragment shader */
|
||||
// fragment shader
|
||||
NV12_SHADER_PROLOGUE
|
||||
NV12_RG_SHADER_BODY
|
||||
},
|
||||
/* SHADER_NV21_RA */
|
||||
// SHADER_NV21_RA
|
||||
{
|
||||
/* vertex shader */
|
||||
// vertex shader
|
||||
TEXTURE_VERTEX_SHADER,
|
||||
/* fragment shader */
|
||||
// fragment shader
|
||||
NV12_SHADER_PROLOGUE
|
||||
NV21_RA_SHADER_BODY
|
||||
},
|
||||
/* SHADER_NV21_RG */
|
||||
// SHADER_NV21_RG
|
||||
{
|
||||
/* vertex shader */
|
||||
// vertex shader
|
||||
TEXTURE_VERTEX_SHADER,
|
||||
/* fragment shader */
|
||||
// fragment shader
|
||||
NV12_SHADER_PROLOGUE
|
||||
NV21_RG_SHADER_BODY
|
||||
},
|
||||
#endif /* SDL_HAVE_YUV */
|
||||
#endif // SDL_HAVE_YUV
|
||||
};
|
||||
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */ // clang-format on
|
||||
|
||||
static SDL_bool CompileShader(GL_ShaderContext *ctx, GLhandleARB shader, const char *defines, const char *source)
|
||||
{
|
||||
@@ -377,7 +377,7 @@ static SDL_bool CompileShaderProgram(GL_ShaderContext *ctx, int index, GL_Shader
|
||||
|
||||
ctx->glGetError();
|
||||
|
||||
/* Make sure we use the correct sampler type for our texture type */
|
||||
// Make sure we use the correct sampler type for our texture type
|
||||
if (ctx->GL_ARB_texture_rectangle_supported) {
|
||||
frag_defines =
|
||||
"#define sampler2D sampler2DRect\n"
|
||||
@@ -388,27 +388,27 @@ static SDL_bool CompileShaderProgram(GL_ShaderContext *ctx, int index, GL_Shader
|
||||
"#define UVCoordScale 1.0\n";
|
||||
}
|
||||
|
||||
/* Create one program object to rule them all */
|
||||
// Create one program object to rule them all
|
||||
data->program = ctx->glCreateProgramObjectARB();
|
||||
|
||||
/* Create the vertex shader */
|
||||
// Create the vertex shader
|
||||
data->vert_shader = ctx->glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);
|
||||
if (!CompileShader(ctx, data->vert_shader, vert_defines, shader_source[index][0])) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
/* Create the fragment shader */
|
||||
// Create the fragment shader
|
||||
data->frag_shader = ctx->glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);
|
||||
if (!CompileShader(ctx, data->frag_shader, frag_defines, shader_source[index][1])) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
/* ... and in the darkness bind them */
|
||||
// ... and in the darkness bind them
|
||||
ctx->glAttachObjectARB(data->program, data->vert_shader);
|
||||
ctx->glAttachObjectARB(data->program, data->frag_shader);
|
||||
ctx->glLinkProgramARB(data->program);
|
||||
|
||||
/* Set up some uniform variables */
|
||||
// Set up some uniform variables
|
||||
ctx->glUseProgramObjectARB(data->program);
|
||||
for (i = 0; i < num_tmus_bound; ++i) {
|
||||
char tex_name[10];
|
||||
@@ -447,7 +447,7 @@ GL_ShaderContext *GL_CreateShaderContext(void)
|
||||
ctx->GL_ARB_texture_rectangle_supported = SDL_TRUE;
|
||||
}
|
||||
|
||||
/* Check for shader support */
|
||||
// Check for shader support
|
||||
shaders_supported = SDL_FALSE;
|
||||
if (SDL_GL_ExtensionSupported("GL_ARB_shader_objects") &&
|
||||
SDL_GL_ExtensionSupported("GL_ARB_shading_language_100") &&
|
||||
@@ -492,7 +492,7 @@ GL_ShaderContext *GL_CreateShaderContext(void)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Compile all the shaders */
|
||||
// Compile all the shaders
|
||||
for (i = 0; i < NUM_SHADERS; ++i) {
|
||||
if (!CompileShaderProgram(ctx, i, &ctx->shaders[i])) {
|
||||
GL_DestroyShaderContext(ctx);
|
||||
@@ -500,7 +500,7 @@ GL_ShaderContext *GL_CreateShaderContext(void)
|
||||
}
|
||||
}
|
||||
|
||||
/* We're done! */
|
||||
// We're done!
|
||||
return ctx;
|
||||
}
|
||||
|
||||
@@ -512,7 +512,7 @@ void GL_SelectShader(GL_ShaderContext *ctx, GL_Shader shader, const float *shade
|
||||
ctx->glUseProgramObjectARB(program);
|
||||
|
||||
if (shader_params && shader_params != ctx->shader_params[shader]) {
|
||||
/* YUV shader params are Yoffset, 0, Rcoeff, 0, Gcoeff, 0, Bcoeff, 0 */
|
||||
// YUV shader params are Yoffset, 0, Rcoeff, 0, Gcoeff, 0, Bcoeff, 0
|
||||
location = ctx->glGetUniformLocationARB(program, "Yoffset");
|
||||
if (location >= 0) {
|
||||
ctx->glUniform3fARB(location, shader_params[0], shader_params[1], shader_params[2]);
|
||||
@@ -543,4 +543,4 @@ void GL_DestroyShaderContext(GL_ShaderContext *ctx)
|
||||
SDL_free(ctx);
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_OGL */
|
||||
#endif // SDL_VIDEO_RENDER_OGL
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
#include "SDL_internal.h"
|
||||
|
||||
/* OpenGL shader implementation */
|
||||
// OpenGL shader implementation
|
||||
|
||||
typedef enum
|
||||
{
|
||||
@@ -49,4 +49,4 @@ extern GL_ShaderContext *GL_CreateShaderContext(void);
|
||||
extern void GL_SelectShader(GL_ShaderContext *ctx, GL_Shader shader, const float *shader_params);
|
||||
extern void GL_DestroyShaderContext(GL_ShaderContext *ctx);
|
||||
|
||||
#endif /* SDL_shaders_gl_h_ */
|
||||
#endif // SDL_shaders_gl_h_
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
#if SDL_VIDEO_RENDER_OGL_ES2
|
||||
|
||||
#include "../../video/SDL_sysvideo.h" /* For SDL_RecreateWindow */
|
||||
#include "../../video/SDL_sysvideo.h" // For SDL_RecreateWindow
|
||||
#include <SDL3/SDL_opengles2.h>
|
||||
#include "../SDL_sysrender.h"
|
||||
#include "../../video/SDL_blit.h"
|
||||
@@ -69,7 +69,7 @@ typedef struct GLES2_TextureData
|
||||
void *pixel_data;
|
||||
int pitch;
|
||||
#if SDL_HAVE_YUV
|
||||
/* YUV texture support */
|
||||
// YUV texture support
|
||||
SDL_bool yuv;
|
||||
SDL_bool nv12;
|
||||
GLuint texture_v;
|
||||
@@ -219,7 +219,7 @@ static void GL_ClearErrors(SDL_Renderer *renderer)
|
||||
return;
|
||||
}
|
||||
while (data->glGetError() != GL_NO_ERROR) {
|
||||
/* continue; */
|
||||
// continue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -231,7 +231,7 @@ static int GL_CheckAllErrors(const char *prefix, SDL_Renderer *renderer, const c
|
||||
if (!data->debug_enabled) {
|
||||
return 0;
|
||||
}
|
||||
/* check gl errors (can return multiple errors) */
|
||||
// check gl errors (can return multiple errors)
|
||||
for (;;) {
|
||||
GLenum error = data->glGetError();
|
||||
if (error != GL_NO_ERROR) {
|
||||
@@ -275,7 +275,7 @@ static int GLES2_LoadFunctions(GLES2_RenderData *data)
|
||||
return SDL_SetError("Couldn't load GLES2 function %s: %s", #func, SDL_GetError()); \
|
||||
} \
|
||||
} while (0);
|
||||
#endif /* __SDL_NOGETPROCADDR__ */
|
||||
#endif // __SDL_NOGETPROCADDR__
|
||||
|
||||
#include "SDL_gles2funcs.h"
|
||||
#undef SDL_PROC
|
||||
@@ -304,7 +304,7 @@ static int GLES2_ActivateRenderer(SDL_Renderer *renderer)
|
||||
GLES2_RenderData *data = (GLES2_RenderData *)renderer->internal;
|
||||
|
||||
if (SDL_GL_GetCurrentContext() != data->context) {
|
||||
/* Null out the current program to ensure we set it again */
|
||||
// Null out the current program to ensure we set it again
|
||||
data->drawstate.program = NULL;
|
||||
|
||||
if (SDL_GL_MakeCurrent(renderer->window, data->context) < 0) {
|
||||
@@ -322,7 +322,7 @@ static void GLES2_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *eve
|
||||
GLES2_RenderData *data = (GLES2_RenderData *)renderer->internal;
|
||||
|
||||
if (event->type == SDL_EVENT_WINDOW_MINIMIZED) {
|
||||
/* According to Apple documentation, we need to finish drawing NOW! */
|
||||
// According to Apple documentation, we need to finish drawing NOW!
|
||||
data->glFinish();
|
||||
}
|
||||
}
|
||||
@@ -409,7 +409,7 @@ static GLES2_ProgramCacheEntry *GLES2_CacheProgram(GLES2_RenderData *data, GLuin
|
||||
GLint linkSuccessful;
|
||||
int i;
|
||||
|
||||
/* Check if we've already cached this program */
|
||||
// Check if we've already cached this program
|
||||
entry = data->program_cache.head;
|
||||
while (entry) {
|
||||
if (entry->vertex_shader == vertex && entry->fragment_shader == fragment) {
|
||||
@@ -433,7 +433,7 @@ static GLES2_ProgramCacheEntry *GLES2_CacheProgram(GLES2_RenderData *data, GLuin
|
||||
return entry;
|
||||
}
|
||||
|
||||
/* Create a program cache entry */
|
||||
// Create a program cache entry
|
||||
entry = (GLES2_ProgramCacheEntry *)SDL_calloc(1, sizeof(GLES2_ProgramCacheEntry));
|
||||
if (!entry) {
|
||||
return NULL;
|
||||
@@ -441,7 +441,7 @@ static GLES2_ProgramCacheEntry *GLES2_CacheProgram(GLES2_RenderData *data, GLuin
|
||||
entry->vertex_shader = vertex;
|
||||
entry->fragment_shader = fragment;
|
||||
|
||||
/* Create the program and link it */
|
||||
// Create the program and link it
|
||||
entry->id = data->glCreateProgram();
|
||||
data->glAttachShader(entry->id, vertex);
|
||||
data->glAttachShader(entry->id, fragment);
|
||||
@@ -457,26 +457,26 @@ static GLES2_ProgramCacheEntry *GLES2_CacheProgram(GLES2_RenderData *data, GLuin
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Predetermine locations of uniform variables */
|
||||
// Predetermine locations of uniform variables
|
||||
for (i = 0; i < NUM_GLES2_UNIFORMS; ++i) {
|
||||
entry->uniform_locations[i] = data->glGetUniformLocation(entry->id, GLES2_UniformNames[i]);
|
||||
}
|
||||
|
||||
data->glUseProgram(entry->id);
|
||||
if (entry->uniform_locations[GLES2_UNIFORM_TEXTURE_V] != -1) {
|
||||
data->glUniform1i(entry->uniform_locations[GLES2_UNIFORM_TEXTURE_V], 2); /* always texture unit 2. */
|
||||
data->glUniform1i(entry->uniform_locations[GLES2_UNIFORM_TEXTURE_V], 2); // always texture unit 2.
|
||||
}
|
||||
if (entry->uniform_locations[GLES2_UNIFORM_TEXTURE_U] != -1) {
|
||||
data->glUniform1i(entry->uniform_locations[GLES2_UNIFORM_TEXTURE_U], 1); /* always texture unit 1. */
|
||||
data->glUniform1i(entry->uniform_locations[GLES2_UNIFORM_TEXTURE_U], 1); // always texture unit 1.
|
||||
}
|
||||
if (entry->uniform_locations[GLES2_UNIFORM_TEXTURE] != -1) {
|
||||
data->glUniform1i(entry->uniform_locations[GLES2_UNIFORM_TEXTURE], 0); /* always texture unit 0. */
|
||||
data->glUniform1i(entry->uniform_locations[GLES2_UNIFORM_TEXTURE], 0); // always texture unit 0.
|
||||
}
|
||||
if (entry->uniform_locations[GLES2_UNIFORM_PROJECTION] != -1) {
|
||||
data->glUniformMatrix4fv(entry->uniform_locations[GLES2_UNIFORM_PROJECTION], 1, GL_FALSE, (GLfloat *)entry->projection);
|
||||
}
|
||||
|
||||
/* Cache the linked program */
|
||||
// Cache the linked program
|
||||
if (data->program_cache.head) {
|
||||
entry->next = data->program_cache.head;
|
||||
data->program_cache.head->prev = entry;
|
||||
@@ -486,7 +486,7 @@ static GLES2_ProgramCacheEntry *GLES2_CacheProgram(GLES2_RenderData *data, GLuin
|
||||
data->program_cache.head = entry;
|
||||
++data->program_cache.count;
|
||||
|
||||
/* Evict the last entry from the cache if we exceed the limit */
|
||||
// Evict the last entry from the cache if we exceed the limit
|
||||
if (data->program_cache.count > GLES2_MAX_CACHED_PROGRAMS) {
|
||||
data->glDeleteProgram(data->program_cache.tail->id);
|
||||
data->program_cache.tail = data->program_cache.tail->prev;
|
||||
@@ -545,7 +545,7 @@ static GLuint GLES2_CacheShader(GLES2_RenderData *data, GLES2_ShaderType type, G
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Compile */
|
||||
// Compile
|
||||
id = data->glCreateShader(shader_type);
|
||||
data->glShaderSource(id, num_src, shader_src_list, NULL);
|
||||
data->glCompileShader(id);
|
||||
@@ -573,7 +573,7 @@ static GLuint GLES2_CacheShader(GLES2_RenderData *data, GLES2_ShaderType type, G
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Cache */
|
||||
// Cache
|
||||
data->shader_id_cache[(Uint32)type] = id;
|
||||
|
||||
return id;
|
||||
@@ -608,7 +608,7 @@ static int GLES2_SelectProgram(GLES2_RenderData *data, GLES2_ImageSource source,
|
||||
GLES2_ProgramCacheEntry *program;
|
||||
const float *shader_params = NULL;
|
||||
|
||||
/* Select an appropriate shader pair for the specified modes */
|
||||
// Select an appropriate shader pair for the specified modes
|
||||
vtype = GLES2_SHADER_VERTEX_DEFAULT;
|
||||
switch (source) {
|
||||
case GLES2_IMAGESOURCE_SOLID:
|
||||
@@ -659,7 +659,7 @@ static int GLES2_SelectProgram(GLES2_RenderData *data, GLES2_ImageSource source,
|
||||
goto fault;
|
||||
}
|
||||
break;
|
||||
#endif /* SDL_HAVE_YUV */
|
||||
#endif // SDL_HAVE_YUV
|
||||
case GLES2_IMAGESOURCE_TEXTURE_EXTERNAL_OES:
|
||||
ftype = GLES2_SHADER_FRAGMENT_TEXTURE_EXTERNAL_OES;
|
||||
break;
|
||||
@@ -667,7 +667,7 @@ static int GLES2_SelectProgram(GLES2_RenderData *data, GLES2_ImageSource source,
|
||||
goto fault;
|
||||
}
|
||||
|
||||
/* Load the requested shaders */
|
||||
// Load the requested shaders
|
||||
vertex = data->shader_id_cache[(Uint32)vtype];
|
||||
if (!vertex) {
|
||||
vertex = GLES2_CacheShader(data, vtype, GL_VERTEX_SHADER);
|
||||
@@ -684,7 +684,7 @@ static int GLES2_SelectProgram(GLES2_RenderData *data, GLES2_ImageSource source,
|
||||
}
|
||||
}
|
||||
|
||||
/* Check if we need to change programs at all */
|
||||
// Check if we need to change programs at all
|
||||
if (data->drawstate.program &&
|
||||
data->drawstate.program->vertex_shader == vertex &&
|
||||
data->drawstate.program->fragment_shader == fragment &&
|
||||
@@ -692,17 +692,17 @@ static int GLES2_SelectProgram(GLES2_RenderData *data, GLES2_ImageSource source,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Generate a matching program */
|
||||
// Generate a matching program
|
||||
program = GLES2_CacheProgram(data, vertex, fragment);
|
||||
if (!program) {
|
||||
goto fault;
|
||||
}
|
||||
|
||||
/* Select that program in OpenGL */
|
||||
// Select that program in OpenGL
|
||||
data->glUseProgram(program->id);
|
||||
|
||||
if (shader_params && shader_params != program->shader_params) {
|
||||
/* YUV shader params are Yoffset, 0, Rcoeff, 0, Gcoeff, 0, Bcoeff, 0 */
|
||||
// YUV shader params are Yoffset, 0, Rcoeff, 0, Gcoeff, 0, Bcoeff, 0
|
||||
if (program->uniform_locations[GLES2_UNIFORM_OFFSET] != -1) {
|
||||
data->glUniform3f(program->uniform_locations[GLES2_UNIFORM_OFFSET], shader_params[0], shader_params[1], shader_params[2]);
|
||||
}
|
||||
@@ -723,10 +723,10 @@ static int GLES2_SelectProgram(GLES2_RenderData *data, GLES2_ImageSource source,
|
||||
program->shader_params = shader_params;
|
||||
}
|
||||
|
||||
/* Set the current program */
|
||||
// Set the current program
|
||||
data->drawstate.program = program;
|
||||
|
||||
/* Clean up and return */
|
||||
// Clean up and return
|
||||
return 0;
|
||||
fault:
|
||||
data->drawstate.program = NULL;
|
||||
@@ -735,7 +735,7 @@ fault:
|
||||
|
||||
static int GLES2_QueueNoOp(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
{
|
||||
return 0; /* nothing to do in this backend. */
|
||||
return 0; // nothing to do in this backend.
|
||||
}
|
||||
|
||||
static int GLES2_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count)
|
||||
@@ -796,7 +796,7 @@ static int GLES2_QueueDrawLines(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
|
||||
|
||||
cmd->data.draw.count = count;
|
||||
|
||||
/* 0.5f offset to hit the center of the pixel. */
|
||||
// 0.5f offset to hit the center of the pixel.
|
||||
prevx = 0.5f + points->x;
|
||||
prevy = 0.5f + points->y;
|
||||
verts->position.x = prevx;
|
||||
@@ -811,9 +811,9 @@ static int GLES2_QueueDrawLines(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
|
||||
for (i = 1; i < count; i++) {
|
||||
const GLfloat xstart = prevx;
|
||||
const GLfloat ystart = prevy;
|
||||
const GLfloat xend = points[i].x + 0.5f; /* 0.5f to hit pixel center. */
|
||||
const GLfloat xend = points[i].x + 0.5f; // 0.5f to hit pixel center.
|
||||
const GLfloat yend = points[i].y + 0.5f;
|
||||
/* bump a little in the direction we are moving in. */
|
||||
// bump a little in the direction we are moving in.
|
||||
const GLfloat deltax = xend - xstart;
|
||||
const GLfloat deltay = yend - ystart;
|
||||
const GLfloat angle = SDL_atan2f(deltay, deltax);
|
||||
@@ -1020,7 +1020,7 @@ static int SetDrawState(GLES2_RenderData *data, const SDL_RenderCommand *cmd, co
|
||||
data->drawstate.blend = blend;
|
||||
}
|
||||
|
||||
/* all drawing commands use this */
|
||||
// all drawing commands use this
|
||||
{
|
||||
SDL_VertexSolid *verts = (SDL_VertexSolid *)(((Uint8 *)vertices) + cmd->data.draw.first);
|
||||
data->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, stride, (const GLvoid *)&verts->position);
|
||||
@@ -1054,9 +1054,9 @@ static int SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, vo
|
||||
SDL_Texture *texture = cmd->data.draw.texture;
|
||||
int ret;
|
||||
|
||||
/* Pick an appropriate shader */
|
||||
// Pick an appropriate shader
|
||||
if (renderer->target) {
|
||||
/* Check if we need to do color mapping between the source and render target textures */
|
||||
// Check if we need to do color mapping between the source and render target textures
|
||||
if (renderer->target->format != texture->format) {
|
||||
switch (texture->format) {
|
||||
case SDL_PIXELFORMAT_BGRA32:
|
||||
@@ -1134,7 +1134,7 @@ static int SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, vo
|
||||
return SDL_SetError("Unsupported texture format");
|
||||
}
|
||||
} else {
|
||||
sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR; /* Texture formats match, use the non color mapping shader (even if the formats are not ABGR) */
|
||||
sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR; // Texture formats match, use the non color mapping shader (even if the formats are not ABGR)
|
||||
}
|
||||
} else {
|
||||
switch (texture->format) {
|
||||
@@ -1256,7 +1256,7 @@ static int GLES2_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
|
||||
}
|
||||
|
||||
#if USE_VERTEX_BUFFER_OBJECTS
|
||||
/* upload the new VBO data for this set of commands. */
|
||||
// upload the new VBO data for this set of commands.
|
||||
data->glBindBuffer(GL_ARRAY_BUFFER, vbo);
|
||||
if (data->vertex_buffer_size[vboidx] < vertsize) {
|
||||
data->glBufferData(GL_ARRAY_BUFFER, vertsize, vertices, GL_STREAM_DRAW);
|
||||
@@ -1265,12 +1265,12 @@ static int GLES2_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
|
||||
data->glBufferSubData(GL_ARRAY_BUFFER, 0, vertsize, vertices);
|
||||
}
|
||||
|
||||
/* cycle through a few VBOs so the GL has some time with the data before we replace it. */
|
||||
// cycle through a few VBOs so the GL has some time with the data before we replace it.
|
||||
data->current_vertex_buffer++;
|
||||
if (data->current_vertex_buffer >= SDL_arraysize(data->vertex_buffers)) {
|
||||
data->current_vertex_buffer = 0;
|
||||
}
|
||||
vertices = NULL; /* attrib pointers will be offsets into the VBO. */
|
||||
vertices = NULL; // attrib pointers will be offsets into the VBO.
|
||||
#endif
|
||||
|
||||
while (cmd) {
|
||||
@@ -1334,13 +1334,13 @@ static int GLES2_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_FILL_RECTS: /* unused */
|
||||
case SDL_RENDERCMD_FILL_RECTS: // unused
|
||||
break;
|
||||
|
||||
case SDL_RENDERCMD_COPY: /* unused */
|
||||
case SDL_RENDERCMD_COPY: // unused
|
||||
break;
|
||||
|
||||
case SDL_RENDERCMD_COPY_EX: /* unused */
|
||||
case SDL_RENDERCMD_COPY_EX: // unused
|
||||
break;
|
||||
|
||||
case SDL_RENDERCMD_DRAW_LINES:
|
||||
@@ -1348,10 +1348,10 @@ static int GLES2_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
|
||||
if (SetDrawState(data, cmd, GLES2_IMAGESOURCE_SOLID, vertices) == 0) {
|
||||
size_t count = cmd->data.draw.count;
|
||||
if (count > 2) {
|
||||
/* joined lines cannot be grouped */
|
||||
// joined lines cannot be grouped
|
||||
data->glDrawArrays(GL_LINE_STRIP, 0, (GLsizei)count);
|
||||
} else {
|
||||
/* let's group non joined lines */
|
||||
// let's group non joined lines
|
||||
SDL_RenderCommand *finalcmd = cmd;
|
||||
SDL_RenderCommand *nextcmd = cmd->next;
|
||||
SDL_BlendMode thisblend = cmd->data.draw.blend;
|
||||
@@ -1359,20 +1359,20 @@ static int GLES2_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
|
||||
while (nextcmd) {
|
||||
const SDL_RenderCommandType nextcmdtype = nextcmd->command;
|
||||
if (nextcmdtype != SDL_RENDERCMD_DRAW_LINES) {
|
||||
break; /* can't go any further on this draw call, different render command up next. */
|
||||
break; // can't go any further on this draw call, different render command up next.
|
||||
} else if (nextcmd->data.draw.count != 2) {
|
||||
break; /* can't go any further on this draw call, those are joined lines */
|
||||
break; // can't go any further on this draw call, those are joined lines
|
||||
} else if (nextcmd->data.draw.blend != thisblend) {
|
||||
break; /* can't go any further on this draw call, different blendmode copy up next. */
|
||||
break; // can't go any further on this draw call, different blendmode copy up next.
|
||||
} else {
|
||||
finalcmd = nextcmd; /* we can combine copy operations here. Mark this one as the furthest okay command. */
|
||||
finalcmd = nextcmd; // we can combine copy operations here. Mark this one as the furthest okay command.
|
||||
count += nextcmd->data.draw.count;
|
||||
}
|
||||
nextcmd = nextcmd->next;
|
||||
}
|
||||
|
||||
data->glDrawArrays(GL_LINES, 0, (GLsizei)count);
|
||||
cmd = finalcmd; /* skip any copy commands we just combined in here. */
|
||||
cmd = finalcmd; // skip any copy commands we just combined in here.
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -1393,11 +1393,11 @@ static int GLES2_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
|
||||
while (nextcmd) {
|
||||
const SDL_RenderCommandType nextcmdtype = nextcmd->command;
|
||||
if (nextcmdtype != thiscmdtype) {
|
||||
break; /* can't go any further on this draw call, different render command up next. */
|
||||
break; // can't go any further on this draw call, different render command up next.
|
||||
} else if (nextcmd->data.draw.texture != thistexture || nextcmd->data.draw.blend != thisblend) {
|
||||
break; /* can't go any further on this draw call, different texture/blendmode copy up next. */
|
||||
break; // can't go any further on this draw call, different texture/blendmode copy up next.
|
||||
} else {
|
||||
finalcmd = nextcmd; /* we can combine copy operations here. Mark this one as the furthest okay command. */
|
||||
finalcmd = nextcmd; // we can combine copy operations here. Mark this one as the furthest okay command.
|
||||
count += nextcmd->data.draw.count;
|
||||
}
|
||||
nextcmd = nextcmd->next;
|
||||
@@ -1410,14 +1410,14 @@ static int GLES2_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
int op = GL_TRIANGLES; /* SDL_RENDERCMD_GEOMETRY */
|
||||
int op = GL_TRIANGLES; // SDL_RENDERCMD_GEOMETRY
|
||||
if (thiscmdtype == SDL_RENDERCMD_DRAW_POINTS) {
|
||||
op = GL_POINTS;
|
||||
}
|
||||
data->glDrawArrays(op, 0, (GLsizei)count);
|
||||
}
|
||||
|
||||
cmd = finalcmd; /* skip any copy commands we just combined in here. */
|
||||
cmd = finalcmd; // skip any copy commands we just combined in here.
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1435,7 +1435,7 @@ static void GLES2_DestroyRenderer(SDL_Renderer *renderer)
|
||||
{
|
||||
GLES2_RenderData *data = (GLES2_RenderData *)renderer->internal;
|
||||
|
||||
/* Deallocate everything */
|
||||
// Deallocate everything
|
||||
if (data) {
|
||||
GLES2_ActivateRenderer(renderer);
|
||||
|
||||
@@ -1491,9 +1491,9 @@ static int GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL
|
||||
|
||||
GLES2_ActivateRenderer(renderer);
|
||||
|
||||
renderdata->drawstate.texture = NULL; /* we trash this state. */
|
||||
renderdata->drawstate.texture = NULL; // we trash this state.
|
||||
|
||||
/* Determine the corresponding GLES texture format params */
|
||||
// Determine the corresponding GLES texture format params
|
||||
switch (texture->format) {
|
||||
case SDL_PIXELFORMAT_BGRA32:
|
||||
case SDL_PIXELFORMAT_RGBA32:
|
||||
@@ -1526,7 +1526,7 @@ static int GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL
|
||||
return SDL_SetError("Unsupported texture access for SDL_PIXELFORMAT_EXTERNAL_OES");
|
||||
}
|
||||
|
||||
/* Allocate a texture struct */
|
||||
// Allocate a texture struct
|
||||
data = (GLES2_TextureData *)SDL_calloc(1, sizeof(GLES2_TextureData));
|
||||
if (!data) {
|
||||
return -1;
|
||||
@@ -1547,17 +1547,17 @@ static int GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL
|
||||
#endif
|
||||
scaleMode = (texture->scaleMode == SDL_SCALEMODE_NEAREST) ? GL_NEAREST : GL_LINEAR;
|
||||
|
||||
/* Allocate a blob for image renderdata */
|
||||
// Allocate a blob for image renderdata
|
||||
if (texture->access == SDL_TEXTUREACCESS_STREAMING) {
|
||||
size_t size;
|
||||
data->pitch = texture->w * SDL_BYTESPERPIXEL(texture->format);
|
||||
size = (size_t)texture->h * data->pitch;
|
||||
#if SDL_HAVE_YUV
|
||||
if (data->yuv) {
|
||||
/* Need to add size for the U and V planes */
|
||||
// Need to add size for the U and V planes
|
||||
size += 2 * ((texture->h + 1) / 2) * ((data->pitch + 1) / 2);
|
||||
} else if (data->nv12) {
|
||||
/* Need to add size for the U/V plane */
|
||||
// Need to add size for the U/V plane
|
||||
size += 2 * ((texture->h + 1) / 2) * ((data->pitch + 1) / 2);
|
||||
}
|
||||
#endif
|
||||
@@ -1568,7 +1568,7 @@ static int GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL
|
||||
}
|
||||
}
|
||||
|
||||
/* Allocate the texture */
|
||||
// Allocate the texture
|
||||
GL_CheckError("", renderer);
|
||||
|
||||
#if SDL_HAVE_YUV
|
||||
@@ -1677,10 +1677,10 @@ static int GLES2_TexSubImage2D(GLES2_RenderData *data, GLenum target, GLint xoff
|
||||
int y;
|
||||
|
||||
if ((width == 0) || (height == 0) || (bpp == 0)) {
|
||||
return 0; /* nothing to do */
|
||||
return 0; // nothing to do
|
||||
}
|
||||
|
||||
/* Reformat the texture data into a tightly packed array */
|
||||
// Reformat the texture data into a tightly packed array
|
||||
src_pitch = (size_t)width * bpp;
|
||||
src = (Uint8 *)pixels;
|
||||
if ((size_t)pitch != src_pitch) {
|
||||
@@ -1712,14 +1712,14 @@ static int GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, con
|
||||
|
||||
GLES2_ActivateRenderer(renderer);
|
||||
|
||||
/* Bail out if we're supposed to update an empty rectangle */
|
||||
// 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->drawstate.texture = NULL; // we trash this state.
|
||||
|
||||
/* Create a texture subimage with the supplied data */
|
||||
// Create a texture subimage with the supplied data
|
||||
data->glBindTexture(tdata->texture_type, tdata->texture);
|
||||
GLES2_TexSubImage2D(data, tdata->texture_type,
|
||||
rect->x,
|
||||
@@ -1732,7 +1732,7 @@ static int GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, con
|
||||
|
||||
#if SDL_HAVE_YUV
|
||||
if (tdata->yuv) {
|
||||
/* Skip to the correct offset into the next texture */
|
||||
// Skip to the correct offset into the next texture
|
||||
pixels = (const void *)((const Uint8 *)pixels + rect->h * pitch);
|
||||
if (texture->format == SDL_PIXELFORMAT_YV12) {
|
||||
data->glBindTexture(tdata->texture_type, tdata->texture_v);
|
||||
@@ -1748,7 +1748,7 @@ static int GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, con
|
||||
tdata->pixel_type,
|
||||
pixels, (pitch + 1) / 2, 1);
|
||||
|
||||
/* Skip to the correct offset into the next texture */
|
||||
// Skip to the correct offset into the next texture
|
||||
pixels = (const void *)((const Uint8 *)pixels + ((rect->h + 1) / 2) * ((pitch + 1) / 2));
|
||||
if (texture->format == SDL_PIXELFORMAT_YV12) {
|
||||
data->glBindTexture(tdata->texture_type, tdata->texture_u);
|
||||
@@ -1764,7 +1764,7 @@ static int GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, con
|
||||
tdata->pixel_type,
|
||||
pixels, (pitch + 1) / 2, 1);
|
||||
} else if (tdata->nv12) {
|
||||
/* Skip to the correct offset into the next texture */
|
||||
// Skip to the correct offset into the next texture
|
||||
pixels = (const void *)((const Uint8 *)pixels + rect->h * pitch);
|
||||
data->glBindTexture(tdata->texture_type, tdata->texture_u);
|
||||
GLES2_TexSubImage2D(data, tdata->texture_type,
|
||||
@@ -1793,12 +1793,12 @@ static int GLES2_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
|
||||
GLES2_ActivateRenderer(renderer);
|
||||
|
||||
/* Bail out if we're supposed to update an empty rectangle */
|
||||
// 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->drawstate.texture = NULL; // we trash this state.
|
||||
|
||||
data->glBindTexture(tdata->texture_type, tdata->texture_v);
|
||||
GLES2_TexSubImage2D(data, tdata->texture_type,
|
||||
@@ -1843,12 +1843,12 @@ static int GLES2_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
|
||||
GLES2_ActivateRenderer(renderer);
|
||||
|
||||
/* Bail out if we're supposed to update an empty rectangle */
|
||||
// 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->drawstate.texture = NULL; // we trash this state.
|
||||
|
||||
data->glBindTexture(tdata->texture_type, tdata->texture_u);
|
||||
GLES2_TexSubImage2D(data, tdata->texture_type,
|
||||
@@ -1879,7 +1879,7 @@ static int GLES2_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, const
|
||||
{
|
||||
GLES2_TextureData *tdata = (GLES2_TextureData *)texture->internal;
|
||||
|
||||
/* Retrieve the buffer/pitch for the specified region */
|
||||
// Retrieve the buffer/pitch for the specified region
|
||||
*pixels = (Uint8 *)tdata->pixel_data +
|
||||
(tdata->pitch * rect->y) +
|
||||
(rect->x * SDL_BYTESPERPIXEL(texture->format));
|
||||
@@ -1893,7 +1893,7 @@ static void GLES2_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
GLES2_TextureData *tdata = (GLES2_TextureData *)texture->internal;
|
||||
SDL_Rect rect;
|
||||
|
||||
/* We do whole texture updates, at least for now */
|
||||
// We do whole texture updates, at least for now
|
||||
rect.x = 0;
|
||||
rect.y = 0;
|
||||
rect.w = texture->w;
|
||||
@@ -1945,9 +1945,9 @@ static int GLES2_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
} else {
|
||||
texturedata = (GLES2_TextureData *)texture->internal;
|
||||
data->glBindFramebuffer(GL_FRAMEBUFFER, texturedata->fbo->FBO);
|
||||
/* TODO: check if texture pixel format allows this operation */
|
||||
// TODO: check if texture pixel format allows this operation
|
||||
data->glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, texturedata->texture_type, texturedata->texture, 0);
|
||||
/* Check FBO status */
|
||||
// Check FBO status
|
||||
status = data->glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||
if (status != GL_FRAMEBUFFER_COMPLETE) {
|
||||
return SDL_SetError("glFramebufferTexture2D() failed");
|
||||
@@ -1970,7 +1970,7 @@ static void GLES2_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
data->drawstate.target = NULL;
|
||||
}
|
||||
|
||||
/* Destroy the texture */
|
||||
// Destroy the texture
|
||||
if (tdata) {
|
||||
if (tdata->texture && !tdata->texture_external) {
|
||||
data->glDeleteTextures(1, &tdata->texture);
|
||||
@@ -2010,7 +2010,7 @@ static SDL_Surface *GLES2_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rec
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Flip the rows to be top-down if necessary */
|
||||
// Flip the rows to be top-down if necessary
|
||||
if (!renderer->target) {
|
||||
SDL_bool isstack;
|
||||
int length = rect->w * SDL_BYTESPERPIXEL(format);
|
||||
@@ -2032,7 +2032,7 @@ static SDL_Surface *GLES2_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rec
|
||||
|
||||
static int GLES2_RenderPresent(SDL_Renderer *renderer)
|
||||
{
|
||||
/* Tell the video driver to swap buffers */
|
||||
// Tell the video driver to swap buffers
|
||||
return SDL_GL_SwapWindow(renderer->window);
|
||||
}
|
||||
|
||||
@@ -2073,7 +2073,7 @@ static int GLES2_SetVSync(SDL_Renderer *renderer, const int vsync)
|
||||
static int GLES2_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_PropertiesID create_props)
|
||||
{
|
||||
GLES2_RenderData *data = NULL;
|
||||
SDL_WindowFlags window_flags = 0; /* -Wconditional-uninitialized */
|
||||
SDL_WindowFlags window_flags = 0; // -Wconditional-uninitialized
|
||||
GLint window_framebuffer;
|
||||
GLint value;
|
||||
int profile_mask = 0, major = 0, minor = 0;
|
||||
@@ -2092,7 +2092,7 @@ static int GLES2_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_
|
||||
SDL_SyncWindow(window);
|
||||
window_flags = SDL_GetWindowFlags(window);
|
||||
|
||||
/* OpenGL ES 3.0 is a superset of OpenGL ES 2.0 */
|
||||
// OpenGL ES 3.0 is a superset of OpenGL ES 2.0
|
||||
if (!(window_flags & SDL_WINDOW_OPENGL) ||
|
||||
profile_mask != SDL_GL_CONTEXT_PROFILE_ES || major < RENDERER_CONTEXT_MAJOR) {
|
||||
|
||||
@@ -2127,7 +2127,7 @@ static int GLES2_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_
|
||||
SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_BGRX32);
|
||||
SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_RGBX32);
|
||||
|
||||
/* Create an OpenGL ES 2.0 context */
|
||||
// Create an OpenGL ES 2.0 context
|
||||
data->context = SDL_GL_CreateContext(window);
|
||||
if (!data->context) {
|
||||
goto error;
|
||||
@@ -2144,7 +2144,7 @@ static int GLES2_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* Check for debug output support */
|
||||
// Check for debug output support
|
||||
if (SDL_GL_GetAttribute(SDL_GL_CONTEXT_FLAGS, &value) == 0 &&
|
||||
(value & SDL_GL_CONTEXT_DEBUG_FLAG)) {
|
||||
data->debug_enabled = SDL_TRUE;
|
||||
@@ -2155,7 +2155,7 @@ static int GLES2_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_
|
||||
SDL_SetNumberProperty(SDL_GetRendererProperties(renderer), SDL_PROP_RENDERER_MAX_TEXTURE_SIZE_NUMBER, value);
|
||||
|
||||
#if USE_VERTEX_BUFFER_OBJECTS
|
||||
/* we keep a few of these and cycle through them, so data can live for a few frames. */
|
||||
// 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);
|
||||
#endif
|
||||
|
||||
@@ -2163,7 +2163,7 @@ static int GLES2_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_
|
||||
data->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &window_framebuffer);
|
||||
data->window_framebuffer = (GLuint)window_framebuffer;
|
||||
|
||||
/* Populate the function pointers for the module */
|
||||
// Populate the function pointers for the module
|
||||
renderer->WindowEvent = GLES2_WindowEvent;
|
||||
renderer->SupportsBlendMode = GLES2_SupportsBlendMode;
|
||||
renderer->CreateTexture = GLES2_CreateTexture;
|
||||
@@ -2211,7 +2211,7 @@ static int GLES2_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_
|
||||
data->GL_EXT_blend_minmax_supported = SDL_TRUE;
|
||||
}
|
||||
|
||||
/* Set up parameters for rendering */
|
||||
// Set up parameters for rendering
|
||||
data->glActiveTexture(GL_TEXTURE0);
|
||||
data->glPixelStorei(GL_PACK_ALIGNMENT, 1);
|
||||
data->glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
@@ -2235,7 +2235,7 @@ static int GLES2_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_
|
||||
|
||||
error:
|
||||
if (changed_window) {
|
||||
/* Uh oh, better try to put it back... */
|
||||
// Uh oh, better try to put it back...
|
||||
char *error = SDL_strdup(SDL_GetError());
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, profile_mask);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, major);
|
||||
@@ -2251,4 +2251,4 @@ SDL_RenderDriver GLES2_RenderDriver = {
|
||||
GLES2_CreateRenderer, "opengles2"
|
||||
};
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_OGL_ES2 */
|
||||
#endif // SDL_VIDEO_RENDER_OGL_ES2
|
||||
@@ -25,7 +25,7 @@
|
||||
#include <SDL3/SDL_opengles2.h>
|
||||
#include "SDL_shaders_gles2.h"
|
||||
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */ // clang-format off
|
||||
|
||||
/*************************************************************************************************
|
||||
* Vertex/fragment shader source *
|
||||
@@ -100,7 +100,7 @@ static const char GLES2_Fragment_TextureABGR[] = \
|
||||
"}\n" \
|
||||
;
|
||||
|
||||
/* ARGB to ABGR conversion */
|
||||
// ARGB to ABGR conversion
|
||||
static const char GLES2_Fragment_TextureARGB[] = \
|
||||
"uniform sampler2D u_texture;\n" \
|
||||
"varying mediump vec4 v_color;\n" \
|
||||
@@ -116,7 +116,7 @@ static const char GLES2_Fragment_TextureARGB[] = \
|
||||
"}\n" \
|
||||
;
|
||||
|
||||
/* RGB to ABGR conversion */
|
||||
// RGB to ABGR conversion
|
||||
static const char GLES2_Fragment_TextureRGB[] = \
|
||||
"uniform sampler2D u_texture;\n" \
|
||||
"varying mediump vec4 v_color;\n" \
|
||||
@@ -133,7 +133,7 @@ static const char GLES2_Fragment_TextureRGB[] = \
|
||||
"}\n" \
|
||||
;
|
||||
|
||||
/* BGR to ABGR conversion */
|
||||
// BGR to ABGR conversion
|
||||
static const char GLES2_Fragment_TextureBGR[] = \
|
||||
"uniform sampler2D u_texture;\n" \
|
||||
"varying mediump vec4 v_color;\n" \
|
||||
@@ -256,13 +256,13 @@ static const char GLES2_Fragment_TextureBGR[] = \
|
||||
" gl_FragColor *= v_color;\n" \
|
||||
"}" \
|
||||
|
||||
/* YUV to ABGR conversion */
|
||||
// YUV to ABGR conversion
|
||||
static const char GLES2_Fragment_TextureYUV[] = \
|
||||
YUV_SHADER_PROLOGUE \
|
||||
YUV_SHADER_BODY \
|
||||
;
|
||||
|
||||
/* NV12 to ABGR conversion */
|
||||
// NV12 to ABGR conversion
|
||||
static const char GLES2_Fragment_TextureNV12_RA[] = \
|
||||
YUV_SHADER_PROLOGUE \
|
||||
NV12_RA_SHADER_BODY \
|
||||
@@ -272,7 +272,7 @@ static const char GLES2_Fragment_TextureNV12_RG[] = \
|
||||
NV12_RG_SHADER_BODY \
|
||||
;
|
||||
|
||||
/* NV21 to ABGR conversion */
|
||||
// NV21 to ABGR conversion
|
||||
static const char GLES2_Fragment_TextureNV21_RA[] = \
|
||||
YUV_SHADER_PROLOGUE \
|
||||
NV21_RA_SHADER_BODY \
|
||||
@@ -283,7 +283,7 @@ static const char GLES2_Fragment_TextureNV21_RG[] = \
|
||||
;
|
||||
#endif
|
||||
|
||||
/* Custom Android video format texture */
|
||||
// Custom Android video format texture
|
||||
static const char GLES2_Fragment_TextureExternalOES_Prologue[] = \
|
||||
"#extension GL_OES_EGL_image_external : require\n" \
|
||||
"\n" \
|
||||
@@ -300,7 +300,7 @@ static const char GLES2_Fragment_TextureExternalOES[] = \
|
||||
"}\n" \
|
||||
;
|
||||
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */ // clang-format on
|
||||
|
||||
/*************************************************************************************************
|
||||
* Shader selector *
|
||||
@@ -384,4 +384,4 @@ const char *GLES2_GetShader(GLES2_ShaderType type)
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_OGL_ES2 */
|
||||
#endif // SDL_VIDEO_RENDER_OGL_ES2
|
||||
@@ -50,7 +50,7 @@ typedef enum
|
||||
GLES2_SHADER_FRAGMENT_TEXTURE_NV21_RA,
|
||||
GLES2_SHADER_FRAGMENT_TEXTURE_NV21_RG,
|
||||
#endif
|
||||
/* Shaders beyond this point are optional and not cached at render creation */
|
||||
// Shaders beyond this point are optional and not cached at render creation
|
||||
GLES2_SHADER_FRAGMENT_TEXTURE_EXTERNAL_OES,
|
||||
GLES2_SHADER_COUNT
|
||||
} GLES2_ShaderType;
|
||||
@@ -60,6 +60,6 @@ extern const char *GLES2_GetShaderInclude(GLES2_ShaderIncludeType type);
|
||||
extern const char *GLES2_GetShader(GLES2_ShaderType type);
|
||||
extern GLES2_ShaderIncludeType GLES2_GetTexCoordPrecisionEnumFromHint(void);
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_OGL_ES2 */
|
||||
#endif // SDL_VIDEO_RENDER_OGL_ES2
|
||||
|
||||
#endif /* SDL_shaders_gles2_h_ */
|
||||
#endif // SDL_shaders_gles2_h_
|
||||
@@ -41,9 +41,9 @@
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
/* turn black GS Screen */
|
||||
// turn black GS Screen
|
||||
#define GS_BLACK GS_SETREG_RGBA(0x00, 0x00, 0x00, 0x80)
|
||||
/* Size of Persistent drawbuffer (Single Buffered) */
|
||||
// Size of Persistent drawbuffer (Single Buffered)
|
||||
#define RENDER_QUEUE_PER_POOLSIZE 1024 * 256 // 256K of persistent renderqueue
|
||||
/* Size of Oneshot drawbuffer (Double Buffered, so it uses this size * 2) */
|
||||
#define RENDER_QUEUE_OS_POOLSIZE 1024 * 1024 * 2 // 2048K of oneshot renderqueue
|
||||
@@ -54,12 +54,12 @@ typedef struct
|
||||
uint64_t drawColor;
|
||||
SDL_Rect *viewport;
|
||||
int32_t vsync_callback_id;
|
||||
int vsync; /* 0 (Disabled), 1 (Enabled), -1 (Dynamic) */
|
||||
int vsync; // 0 (Disabled), 1 (Enabled), -1 (Dynamic)
|
||||
} PS2_RenderData;
|
||||
|
||||
static int vsync_sema_id = 0;
|
||||
|
||||
/* PRIVATE METHODS */
|
||||
// PRIVATE METHODS
|
||||
static int vsync_handler(void)
|
||||
{
|
||||
iSignalSema(vsync_sema_id);
|
||||
@@ -68,7 +68,7 @@ static int vsync_handler(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Copy of gsKit_sync_flip, but without the 'flip' */
|
||||
// Copy of gsKit_sync_flip, but without the 'flip'
|
||||
static void gsKit_sync(GSGLOBAL *gsGlobal)
|
||||
{
|
||||
if (!gsGlobal->FirstFrame) {
|
||||
@@ -78,7 +78,7 @@ static void gsKit_sync(GSGLOBAL *gsGlobal)
|
||||
;
|
||||
}
|
||||
|
||||
/* Copy of gsKit_sync_flip, but without the 'sync' */
|
||||
// Copy of gsKit_sync_flip, but without the 'sync'
|
||||
static void gsKit_flip(GSGLOBAL *gsGlobal)
|
||||
{
|
||||
if (!gsGlobal->FirstFrame) {
|
||||
@@ -230,7 +230,7 @@ static int PS2_QueueSetViewport(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
|
||||
static int PS2_QueueNoOp(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
{
|
||||
return 0; /* nothing to do in this backend. */
|
||||
return 0; // nothing to do in this backend.
|
||||
}
|
||||
|
||||
static int PS2_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count)
|
||||
@@ -338,7 +338,7 @@ static int PS2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL
|
||||
|
||||
static int PS2_RenderSetViewPort(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
{
|
||||
return 0; /* nothing to do in this backend. */
|
||||
return 0; // nothing to do in this backend.
|
||||
}
|
||||
|
||||
static int PS2_RenderSetClipRect(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
@@ -349,7 +349,7 @@ static int PS2_RenderSetClipRect(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
const SDL_Rect *rect = &cmd->data.cliprect.rect;
|
||||
|
||||
if (cmd->data.cliprect.enabled) {
|
||||
/* We need to do it relative to saved viewport */
|
||||
// We need to do it relative to saved viewport
|
||||
viewport->x += rect->x;
|
||||
viewport->y += rect->y;
|
||||
viewport->w = SDL_min(viewport->w, rect->w);
|
||||
@@ -375,20 +375,20 @@ static int PS2_RenderClear(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
|
||||
PS2_RenderData *data = (PS2_RenderData *)renderer->internal;
|
||||
|
||||
/* Clear the screen, so let's put default viewport */
|
||||
// Clear the screen, so let's put default viewport
|
||||
gsKit_set_scissor(data->gsGlobal, GS_SCISSOR_RESET);
|
||||
/* Put back original offset */
|
||||
// Put back original offset
|
||||
offsetX = data->gsGlobal->OffsetX;
|
||||
offsetY = data->gsGlobal->OffsetY;
|
||||
data->gsGlobal->OffsetX = (int)(2048.0f * 16.0f);
|
||||
data->gsGlobal->OffsetY = (int)(2048.0f * 16.0f);
|
||||
gsKit_clear(data->gsGlobal, float_GS_SETREG_RGBAQ(&cmd->data.color.color, cmd->data.color.color_scale));
|
||||
|
||||
/* Put back original offset */
|
||||
// Put back original offset
|
||||
data->gsGlobal->OffsetX = offsetX;
|
||||
data->gsGlobal->OffsetY = offsetY;
|
||||
|
||||
// /* Put back view port */
|
||||
// // Put back view port
|
||||
viewport = data->viewport;
|
||||
gsKit_set_scissor(data->gsGlobal, GS_SETREG_SCISSOR(viewport->x, viewport->x + viewport->w, viewport->y, viewport->y + viewport->h));
|
||||
|
||||
@@ -418,7 +418,7 @@ static void PS2_SetBlendMode(PS2_RenderData *data, int blendMode)
|
||||
}
|
||||
case SDL_BLENDMODE_BLEND_PREMULTIPLIED:
|
||||
{
|
||||
/* FIXME: What are the settings for this? */
|
||||
// FIXME: What are the settings for this?
|
||||
gsKit_set_primalpha(data->gsGlobal, GS_SETREG_ALPHA(A_COLOR_SOURCE, A_COLOR_DEST, A_ALPHA_SOURCE, A_COLOR_DEST, 0), 0);
|
||||
data->gsGlobal->PrimAlphaEnable = GS_SETTING_ON;
|
||||
break;
|
||||
@@ -431,7 +431,7 @@ static void PS2_SetBlendMode(PS2_RenderData *data, int blendMode)
|
||||
}
|
||||
case SDL_BLENDMODE_ADD_PREMULTIPLIED:
|
||||
{
|
||||
/* FIXME: What are the settings for this? */
|
||||
// FIXME: What are the settings for this?
|
||||
gsKit_set_primalpha(data->gsGlobal, GS_SETREG_ALPHA(A_COLOR_SOURCE, A_COLOR_NULL, A_ALPHA_FIX, A_COLOR_DEST, 0x80), 0);
|
||||
data->gsGlobal->PrimAlphaEnable = GS_SETTING_ON;
|
||||
break;
|
||||
@@ -439,7 +439,7 @@ static void PS2_SetBlendMode(PS2_RenderData *data, int blendMode)
|
||||
case SDL_BLENDMODE_MUL:
|
||||
case SDL_BLENDMODE_MOD:
|
||||
{
|
||||
/* We don't fully support MOD and MUL, however this is the best we can do */
|
||||
// We don't fully support MOD and MUL, however this is the best we can do
|
||||
gsKit_set_primalpha(data->gsGlobal, GS_SETREG_ALPHA(A_COLOR_DEST, A_COLOR_NULL, A_ALPHA_SOURCE, A_COLOR_SOURCE, 0x80), 0);
|
||||
data->gsGlobal->PrimAlphaEnable = GS_SETTING_ON;
|
||||
break;
|
||||
@@ -477,7 +477,7 @@ int PS2_RenderLines(SDL_Renderer *renderer, void *vertices, SDL_RenderCommand *c
|
||||
PS2_SetBlendMode(data, cmd->data.draw.blend);
|
||||
gsKit_prim_list_line_goraud_3d(data->gsGlobal, count, verts);
|
||||
|
||||
/* We're done! */
|
||||
// We're done!
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -490,13 +490,13 @@ int PS2_RenderPoints(SDL_Renderer *renderer, void *vertices, SDL_RenderCommand *
|
||||
PS2_SetBlendMode(data, cmd->data.draw.blend);
|
||||
gsKit_prim_list_points(data->gsGlobal, count, verts);
|
||||
|
||||
/* We're done! */
|
||||
// We're done!
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void PS2_InvalidateCachedState(SDL_Renderer *renderer)
|
||||
{
|
||||
/* currently this doesn't do anything. If this needs to do something (and someone is mixing their own rendering calls in!), update this. */
|
||||
// currently this doesn't do anything. If this needs to do something (and someone is mixing their own rendering calls in!), update this.
|
||||
}
|
||||
|
||||
static int PS2_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize)
|
||||
@@ -506,7 +506,7 @@ static int PS2_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, v
|
||||
case SDL_RENDERCMD_SETVIEWPORT:
|
||||
{
|
||||
PS2_RenderSetViewPort(renderer, cmd);
|
||||
/* FIXME: We need to update the clip rect too, see https://github.com/libsdl-org/SDL/issues/9094 */
|
||||
// FIXME: We need to update the clip rect too, see https://github.com/libsdl-org/SDL/issues/9094
|
||||
break;
|
||||
}
|
||||
case SDL_RENDERCMD_SETCLIPRECT:
|
||||
@@ -534,11 +534,11 @@ static int PS2_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, v
|
||||
PS2_RenderLines(renderer, vertices, cmd);
|
||||
break;
|
||||
}
|
||||
case SDL_RENDERCMD_FILL_RECTS: /* unused */
|
||||
case SDL_RENDERCMD_FILL_RECTS: // unused
|
||||
break;
|
||||
case SDL_RENDERCMD_COPY: /* unused */
|
||||
case SDL_RENDERCMD_COPY: // unused
|
||||
break;
|
||||
case SDL_RENDERCMD_COPY_EX: /* unused */
|
||||
case SDL_RENDERCMD_COPY_EX: // unused
|
||||
break;
|
||||
case SDL_RENDERCMD_GEOMETRY:
|
||||
{
|
||||
@@ -651,7 +651,7 @@ static int PS2_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Pr
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Specific gsKit init */
|
||||
// Specific gsKit init
|
||||
sema.init_count = 0;
|
||||
sema.max_count = 1;
|
||||
sema.option = 0;
|
||||
@@ -724,4 +724,4 @@ SDL_RenderDriver PS2_RenderDriver = {
|
||||
PS2_CreateRenderer, "PS2 gsKit"
|
||||
};
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_PS2 */
|
||||
#endif // SDL_VIDEO_RENDER_PS2
|
||||
@@ -36,7 +36,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <vram.h>
|
||||
|
||||
/* PSP renderer implementation, based on the PGE */
|
||||
// PSP renderer implementation, based on the PGE
|
||||
|
||||
#define PSP_SCREEN_WIDTH 480
|
||||
#define PSP_SCREEN_HEIGHT 272
|
||||
@@ -170,7 +170,7 @@ static inline int InVram(void *data)
|
||||
return data < (void *)0x04200000;
|
||||
}
|
||||
|
||||
/* Return next power of 2 */
|
||||
// Return next power of 2
|
||||
static int TextureNextPow2(unsigned int w)
|
||||
{
|
||||
unsigned int n = 2;
|
||||
@@ -547,15 +547,15 @@ static void TextureActivate(SDL_Texture *texture)
|
||||
PSP_TextureData *psp_texture = (PSP_TextureData *)texture->internal;
|
||||
int scaleMode = (texture->scaleMode == SDL_SCALEMODE_NEAREST) ? GU_NEAREST : GU_LINEAR;
|
||||
|
||||
/* Swizzling is useless with small textures. */
|
||||
// Swizzling is useless with small textures.
|
||||
if (TextureShouldSwizzle(psp_texture, texture)) {
|
||||
TextureSwizzle(psp_texture, NULL);
|
||||
}
|
||||
|
||||
sceGuTexWrap(GU_REPEAT, GU_REPEAT);
|
||||
sceGuTexMode(psp_texture->format, 0, 0, psp_texture->swizzled);
|
||||
sceGuTexFilter(scaleMode, scaleMode); /* GU_NEAREST good for tile-map */
|
||||
/* GU_LINEAR good for scaling */
|
||||
sceGuTexFilter(scaleMode, scaleMode); // GU_NEAREST good for tile-map
|
||||
// GU_LINEAR good for scaling
|
||||
sceGuTexImage(0, psp_texture->textureWidth, psp_texture->textureHeight, psp_texture->textureWidth, psp_texture->data);
|
||||
}
|
||||
|
||||
@@ -604,7 +604,7 @@ static void PSP_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
PSP_TextureData *psp_texture = (PSP_TextureData *)texture->internal;
|
||||
SDL_Rect rect;
|
||||
|
||||
/* We do whole texture updates, at least for now */
|
||||
// We do whole texture updates, at least for now
|
||||
rect.x = 0;
|
||||
rect.y = 0;
|
||||
rect.w = texture->w;
|
||||
@@ -614,7 +614,7 @@ static void PSP_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
|
||||
static void PSP_SetTextureScaleMode(SDL_Renderer *renderer, SDL_Texture *texture, SDL_ScaleMode scaleMode)
|
||||
{
|
||||
/* Nothing to do because TextureActivate takes care of it */
|
||||
// Nothing to do because TextureActivate takes care of it
|
||||
}
|
||||
|
||||
static int PSP_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
@@ -624,7 +624,7 @@ static int PSP_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
|
||||
static int PSP_QueueNoOp(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
{
|
||||
return 0; /* nothing to do in this backend. */
|
||||
return 0; // nothing to do in this backend.
|
||||
}
|
||||
|
||||
static int PSP_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count)
|
||||
@@ -1012,7 +1012,7 @@ static void PSP_SetBlendState(PSP_RenderData *data, PSP_BlendState *state)
|
||||
break;
|
||||
case SDL_BLENDMODE_MUL:
|
||||
sceGuTexFunc(GU_TFX_MODULATE, GU_TCC_RGBA);
|
||||
/* FIXME SDL_BLENDMODE_MUL is simplified, and dstA is in fact un-changed.*/
|
||||
// FIXME SDL_BLENDMODE_MUL is simplified, and dstA is in fact un-changed.
|
||||
sceGuBlendFunc(GU_ADD, GU_DST_COLOR, GU_ONE_MINUS_SRC_ALPHA, 0, 0);
|
||||
sceGuEnable(GU_BLEND);
|
||||
break;
|
||||
@@ -1043,7 +1043,7 @@ static void PSP_SetBlendState(PSP_RenderData *data, PSP_BlendState *state)
|
||||
|
||||
static void PSP_InvalidateCachedState(SDL_Renderer *renderer)
|
||||
{
|
||||
/* currently this doesn't do anything. If this needs to do something (and someone is mixing their own rendering calls in!), update this. */
|
||||
// currently this doesn't do anything. If this needs to do something (and someone is mixing their own rendering calls in!), update this.
|
||||
}
|
||||
|
||||
static int PSP_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize)
|
||||
@@ -1086,7 +1086,7 @@ static int PSP_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, v
|
||||
sceGuOffset(2048 - (viewport->w >> 1), 2048 - (viewport->h >> 1));
|
||||
sceGuViewport(2048, 2048, viewport->w, viewport->h);
|
||||
sceGuScissor(viewport->x, viewport->y, viewport->w, viewport->h);
|
||||
/* FIXME: We need to update the clip rect too, see https://github.com/libsdl-org/SDL/issues/9094 */
|
||||
// FIXME: We need to update the clip rect too, see https://github.com/libsdl-org/SDL/issues/9094
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1194,7 +1194,7 @@ static int PSP_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, v
|
||||
if (!cmd->data.draw.texture) {
|
||||
const VertCV *verts = (VertCV *)(gpumem + cmd->data.draw.first);
|
||||
sceGuDisable(GU_TEXTURE_2D);
|
||||
/* In GU_SMOOTH mode */
|
||||
// In GU_SMOOTH mode
|
||||
sceGuDrawArray(GU_TRIANGLES, GU_COLOR_8888 | GU_VERTEX_32BITF | GU_TRANSFORM_2D, count, 0, verts);
|
||||
sceGuEnable(GU_TEXTURE_2D);
|
||||
} else {
|
||||
@@ -1319,7 +1319,7 @@ static int PSP_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Pr
|
||||
renderer->QueueSetViewport = PSP_QueueNoOp;
|
||||
renderer->QueueSetDrawColor = PSP_QueueNoOp;
|
||||
renderer->QueueDrawPoints = PSP_QueueDrawPoints;
|
||||
renderer->QueueDrawLines = PSP_QueueDrawPoints; /* lines and points queue vertices the same way. */
|
||||
renderer->QueueDrawLines = PSP_QueueDrawPoints; // lines and points queue vertices the same way.
|
||||
renderer->QueueGeometry = PSP_QueueGeometry;
|
||||
renderer->QueueFillRects = PSP_QueueFillRects;
|
||||
renderer->QueueCopy = PSP_QueueCopy;
|
||||
@@ -1364,7 +1364,7 @@ static int PSP_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Pr
|
||||
data->frontbuffer = ((uint8_t *)doublebuffer) + PSP_FRAME_BUFFER_SIZE * data->bpp;
|
||||
|
||||
sceGuInit();
|
||||
/* setup GU */
|
||||
// setup GU
|
||||
sceGuStart(GU_DIRECT, DisplayList);
|
||||
sceGuDrawBuffer(data->psm, vrelptr(data->frontbuffer), PSP_FRAME_BUFFER_WIDTH);
|
||||
sceGuDispBuffer(PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT, vrelptr(data->backbuffer), PSP_FRAME_BUFFER_WIDTH);
|
||||
@@ -1374,11 +1374,11 @@ static int PSP_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Pr
|
||||
|
||||
sceGuDisable(GU_DEPTH_TEST);
|
||||
|
||||
/* Scissoring */
|
||||
// Scissoring
|
||||
sceGuScissor(0, 0, PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT);
|
||||
sceGuEnable(GU_SCISSOR_TEST);
|
||||
|
||||
/* Backface culling */
|
||||
// Backface culling
|
||||
/*
|
||||
FIXME: Culling probably un-needed ? It can conflict with SDL_RENDERCMD_GEOMETRY
|
||||
sceGuFrontFace(GU_CCW);
|
||||
@@ -1393,7 +1393,7 @@ static int PSP_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Pr
|
||||
sceDisplayWaitVblankStartCB();
|
||||
sceGuDisplay(GU_TRUE);
|
||||
|
||||
/* Improve performance when VSYC is enabled and it is not reaching the 60 FPS */
|
||||
// Improve performance when VSYC is enabled and it is not reaching the 60 FPS
|
||||
data->vblank_not_reached = SDL_TRUE;
|
||||
sceKernelRegisterSubIntrHandler(PSP_VBLANK_INT, 0, psp_on_vblank, data);
|
||||
sceKernelEnableSubIntr(PSP_VBLANK_INT, 0);
|
||||
@@ -1405,4 +1405,4 @@ SDL_RenderDriver PSP_RenderDriver = {
|
||||
PSP_CreateRenderer, "PSP"
|
||||
};
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_PSP */
|
||||
#endif // SDL_VIDEO_RENDER_PSP
|
||||
@@ -243,14 +243,14 @@ int SDL_BlendFillRect(SDL_Surface *dst, const SDL_Rect *rect,
|
||||
return SDL_InvalidParamError("SDL_BlendFillRect(): dst");
|
||||
}
|
||||
|
||||
/* This function doesn't work on surfaces < 8 bpp */
|
||||
// This function doesn't work on surfaces < 8 bpp
|
||||
if (SDL_BITSPERPIXEL(dst->format) < 8) {
|
||||
return SDL_SetError("SDL_BlendFillRect(): Unsupported surface format");
|
||||
}
|
||||
|
||||
/* If 'rect' == NULL, then fill the whole surface */
|
||||
// If 'rect' == NULL, then fill the whole surface
|
||||
if (rect) {
|
||||
/* Perform clipping */
|
||||
// Perform clipping
|
||||
if (!SDL_GetRectIntersection(rect, &dst->internal->clip_rect, &clipped)) {
|
||||
return 0;
|
||||
}
|
||||
@@ -286,7 +286,7 @@ int SDL_BlendFillRect(SDL_Surface *dst, const SDL_Rect *rect,
|
||||
} else {
|
||||
return SDL_BlendFillRect_ARGB8888(dst, rect, blendMode, r, g, b, a);
|
||||
}
|
||||
/* break; -Wunreachable-code-break */
|
||||
// break; -Wunreachable-code-break
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -313,7 +313,7 @@ int SDL_BlendFillRects(SDL_Surface *dst, const SDL_Rect *rects, int count,
|
||||
return SDL_InvalidParamError("SDL_BlendFillRects(): dst");
|
||||
}
|
||||
|
||||
/* This function doesn't work on surfaces < 8 bpp */
|
||||
// This function doesn't work on surfaces < 8 bpp
|
||||
if (dst->internal->format->bits_per_pixel < 8) {
|
||||
return SDL_SetError("SDL_BlendFillRects(): Unsupported surface format");
|
||||
}
|
||||
@@ -324,7 +324,7 @@ int SDL_BlendFillRects(SDL_Surface *dst, const SDL_Rect *rects, int count,
|
||||
b = DRAW_MUL(b, a);
|
||||
}
|
||||
|
||||
/* FIXME: Does this function pointer slow things down significantly? */
|
||||
// FIXME: Does this function pointer slow things down significantly?
|
||||
switch (dst->internal->format->bits_per_pixel) {
|
||||
case 15:
|
||||
switch (dst->internal->format->Rmask) {
|
||||
@@ -362,7 +362,7 @@ int SDL_BlendFillRects(SDL_Surface *dst, const SDL_Rect *rects, int count,
|
||||
}
|
||||
|
||||
for (i = 0; i < count; ++i) {
|
||||
/* Perform clipping */
|
||||
// Perform clipping
|
||||
if (!SDL_GetRectIntersection(&rects[i], &dst->internal->clip_rect, &rect)) {
|
||||
continue;
|
||||
}
|
||||
@@ -371,4 +371,4 @@ int SDL_BlendFillRects(SDL_Surface *dst, const SDL_Rect *rects, int count,
|
||||
return status;
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_SW */
|
||||
#endif // SDL_VIDEO_RENDER_SW
|
||||
@@ -27,4 +27,4 @@
|
||||
extern int SDL_BlendFillRect(SDL_Surface *dst, const SDL_Rect *rect, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
extern int SDL_BlendFillRects(SDL_Surface *dst, const SDL_Rect *rects, int count, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
#endif /* SDL_blendfillrect_h_ */
|
||||
#endif // SDL_blendfillrect_h_
|
||||
@@ -900,7 +900,7 @@ static BlendLineFunc SDL_CalculateBlendLineFunc(const SDL_PixelFormatDetails *fm
|
||||
} else {
|
||||
return SDL_BlendLine_RGB2;
|
||||
}
|
||||
/* break; -Wunreachable-code-break */
|
||||
// break; -Wunreachable-code-break
|
||||
case 4:
|
||||
if (fmt->Rmask == 0x00FF0000) {
|
||||
if (fmt->Amask) {
|
||||
@@ -933,8 +933,8 @@ int SDL_BlendLine(SDL_Surface *dst, int x1, int y1, int x2, int y2,
|
||||
return SDL_SetError("SDL_BlendLine(): Unsupported surface format");
|
||||
}
|
||||
|
||||
/* Perform clipping */
|
||||
/* FIXME: We don't actually want to clip, as it may change line slope */
|
||||
// Perform clipping
|
||||
// FIXME: We don't actually want to clip, as it may change line slope
|
||||
if (!SDL_GetRectAndLineIntersection(&dst->internal->clip_rect, &x1, &y1, &x2, &y2)) {
|
||||
return 0;
|
||||
}
|
||||
@@ -967,13 +967,13 @@ int SDL_BlendLines(SDL_Surface *dst, const SDL_Point *points, int count,
|
||||
x2 = points[i].x;
|
||||
y2 = points[i].y;
|
||||
|
||||
/* Perform clipping */
|
||||
/* FIXME: We don't actually want to clip, as it may change line slope */
|
||||
// Perform clipping
|
||||
// FIXME: We don't actually want to clip, as it may change line slope
|
||||
if (!SDL_GetRectAndLineIntersection(&dst->internal->clip_rect, &x1, &y1, &x2, &y2)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Draw the end if it was clipped */
|
||||
// Draw the end if it was clipped
|
||||
draw_end = (x2 != points[i].x || y2 != points[i].y);
|
||||
|
||||
func(dst, x1, y1, x2, y2, blendMode, r, g, b, a, draw_end);
|
||||
@@ -985,4 +985,4 @@ int SDL_BlendLines(SDL_Surface *dst, const SDL_Point *points, int count,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_SW */
|
||||
#endif // SDL_VIDEO_RENDER_SW
|
||||
@@ -27,4 +27,4 @@
|
||||
extern int SDL_BlendLine(SDL_Surface *dst, int x1, int y1, int x2, int y2, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
extern int SDL_BlendLines(SDL_Surface *dst, const SDL_Point *points, int count, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
#endif /* SDL_blendline_h_ */
|
||||
#endif // SDL_blendline_h_
|
||||
@@ -241,12 +241,12 @@ int SDL_BlendPoint(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint
|
||||
return SDL_InvalidParamError("SDL_BlendPoint(): dst");
|
||||
}
|
||||
|
||||
/* This function doesn't work on surfaces < 8 bpp */
|
||||
// This function doesn't work on surfaces < 8 bpp
|
||||
if (SDL_BITSPERPIXEL(dst->format) < 8) {
|
||||
return SDL_SetError("SDL_BlendPoint(): Unsupported surface format");
|
||||
}
|
||||
|
||||
/* Perform clipping */
|
||||
// Perform clipping
|
||||
if (x < dst->internal->clip_rect.x || y < dst->internal->clip_rect.y ||
|
||||
x >= (dst->internal->clip_rect.x + dst->internal->clip_rect.w) ||
|
||||
y >= (dst->internal->clip_rect.y + dst->internal->clip_rect.h)) {
|
||||
@@ -280,7 +280,7 @@ int SDL_BlendPoint(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint
|
||||
} else {
|
||||
return SDL_BlendPoint_ARGB8888(dst, x, y, blendMode, r, g, b, a);
|
||||
}
|
||||
/* break; -Wunreachable-code-break */
|
||||
// break; -Wunreachable-code-break
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -309,7 +309,7 @@ int SDL_BlendPoints(SDL_Surface *dst, const SDL_Point *points, int count,
|
||||
return SDL_InvalidParamError("SDL_BlendPoints(): dst");
|
||||
}
|
||||
|
||||
/* This function doesn't work on surfaces < 8 bpp */
|
||||
// This function doesn't work on surfaces < 8 bpp
|
||||
if (dst->internal->format->bits_per_pixel < 8) {
|
||||
return SDL_SetError("SDL_BlendPoints(): Unsupported surface format");
|
||||
}
|
||||
@@ -320,7 +320,7 @@ int SDL_BlendPoints(SDL_Surface *dst, const SDL_Point *points, int count,
|
||||
b = DRAW_MUL(b, a);
|
||||
}
|
||||
|
||||
/* FIXME: Does this function pointer slow things down significantly? */
|
||||
// FIXME: Does this function pointer slow things down significantly?
|
||||
switch (dst->internal->format->bits_per_pixel) {
|
||||
case 15:
|
||||
switch (dst->internal->format->Rmask) {
|
||||
@@ -376,4 +376,4 @@ int SDL_BlendPoints(SDL_Surface *dst, const SDL_Point *points, int count,
|
||||
return status;
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_SW */
|
||||
#endif // SDL_VIDEO_RENDER_SW
|
||||
@@ -27,4 +27,4 @@
|
||||
extern int SDL_BlendPoint(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
extern int SDL_BlendPoints(SDL_Surface *dst, const SDL_Point *points, int count, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
#endif /* SDL_blendpoint_h_ */
|
||||
#endif // SDL_blendpoint_h_
|
||||
@@ -424,7 +424,7 @@
|
||||
|
||||
#define ABS(_x) ((_x) < 0 ? -(_x) : (_x))
|
||||
|
||||
/* Horizontal line */
|
||||
// Horizontal line
|
||||
#define HLINE(type, op, draw_end) \
|
||||
{ \
|
||||
int length; \
|
||||
@@ -446,7 +446,7 @@
|
||||
} \
|
||||
}
|
||||
|
||||
/* Vertical line */
|
||||
// Vertical line
|
||||
#define VLINE(type, op, draw_end) \
|
||||
{ \
|
||||
int length; \
|
||||
@@ -468,7 +468,7 @@
|
||||
} \
|
||||
}
|
||||
|
||||
/* Diagonal line */
|
||||
// Diagonal line
|
||||
#define DLINE(type, op, draw_end) \
|
||||
{ \
|
||||
int length; \
|
||||
@@ -503,7 +503,7 @@
|
||||
} \
|
||||
}
|
||||
|
||||
/* Bresenham's line algorithm */
|
||||
// Bresenham's line algorithm
|
||||
#define BLINE(x1, y1, x2, y2, op, draw_end) \
|
||||
{ \
|
||||
int i, deltax, deltay, numpixels; \
|
||||
@@ -563,7 +563,7 @@
|
||||
} \
|
||||
}
|
||||
|
||||
/* Xiaolin Wu's line algorithm, based on Michael Abrash's implementation */
|
||||
// Xiaolin Wu's line algorithm, based on Michael Abrash's implementation
|
||||
#define WULINE(x1, y1, x2, y2, opaque_op, blend_op, draw_end) \
|
||||
{ \
|
||||
Uint16 ErrorAdj, ErrorAcc; \
|
||||
|
||||
@@ -146,8 +146,8 @@ int SDL_DrawLine(SDL_Surface *dst, int x1, int y1, int x2, int y2, Uint32 color)
|
||||
return SDL_SetError("SDL_DrawLine(): Unsupported surface format");
|
||||
}
|
||||
|
||||
/* Perform clipping */
|
||||
/* FIXME: We don't actually want to clip, as it may change line slope */
|
||||
// Perform clipping
|
||||
// FIXME: We don't actually want to clip, as it may change line slope
|
||||
if (!SDL_GetRectAndLineIntersection(&dst->internal->clip_rect, &x1, &y1, &x2, &y2)) {
|
||||
return 0;
|
||||
}
|
||||
@@ -180,13 +180,13 @@ int SDL_DrawLines(SDL_Surface *dst, const SDL_Point *points, int count,
|
||||
x2 = points[i].x;
|
||||
y2 = points[i].y;
|
||||
|
||||
/* Perform clipping */
|
||||
/* FIXME: We don't actually want to clip, as it may change line slope */
|
||||
// Perform clipping
|
||||
// FIXME: We don't actually want to clip, as it may change line slope
|
||||
if (!SDL_GetRectAndLineIntersection(&dst->internal->clip_rect, &x1, &y1, &x2, &y2)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Draw the end if the whole line is a single point or it was clipped */
|
||||
// Draw the end if the whole line is a single point or it was clipped
|
||||
draw_end = ((x1 == x2) && (y1 == y2)) || (x2 != points[i].x || y2 != points[i].y);
|
||||
|
||||
func(dst, x1, y1, x2, y2, color, draw_end);
|
||||
@@ -197,4 +197,4 @@ int SDL_DrawLines(SDL_Surface *dst, const SDL_Point *points, int count,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_SW */
|
||||
#endif // SDL_VIDEO_RENDER_SW
|
||||
@@ -27,4 +27,4 @@
|
||||
extern int SDL_DrawLine(SDL_Surface *dst, int x1, int y1, int x2, int y2, Uint32 color);
|
||||
extern int SDL_DrawLines(SDL_Surface *dst, const SDL_Point *points, int count, Uint32 color);
|
||||
|
||||
#endif /* SDL_drawline_h_ */
|
||||
#endif // SDL_drawline_h_
|
||||
@@ -31,12 +31,12 @@ int SDL_DrawPoint(SDL_Surface *dst, int x, int y, Uint32 color)
|
||||
return SDL_InvalidParamError("SDL_DrawPoint(): dst");
|
||||
}
|
||||
|
||||
/* This function doesn't work on surfaces < 8 bpp */
|
||||
// This function doesn't work on surfaces < 8 bpp
|
||||
if (dst->internal->format->bits_per_pixel < 8) {
|
||||
return SDL_SetError("SDL_DrawPoint(): Unsupported surface format");
|
||||
}
|
||||
|
||||
/* Perform clipping */
|
||||
// Perform clipping
|
||||
if (x < dst->internal->clip_rect.x || y < dst->internal->clip_rect.y ||
|
||||
x >= (dst->internal->clip_rect.x + dst->internal->clip_rect.w) ||
|
||||
y >= (dst->internal->clip_rect.y + dst->internal->clip_rect.h)) {
|
||||
@@ -71,7 +71,7 @@ int SDL_DrawPoints(SDL_Surface *dst, const SDL_Point *points, int count,
|
||||
return SDL_InvalidParamError("SDL_DrawPoints(): dst");
|
||||
}
|
||||
|
||||
/* This function doesn't work on surfaces < 8 bpp */
|
||||
// This function doesn't work on surfaces < 8 bpp
|
||||
if (dst->internal->format->bits_per_pixel < 8) {
|
||||
return SDL_SetError("SDL_DrawPoints(): Unsupported surface format");
|
||||
}
|
||||
@@ -106,4 +106,4 @@ int SDL_DrawPoints(SDL_Surface *dst, const SDL_Point *points, int count,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_SW */
|
||||
#endif // SDL_VIDEO_RENDER_SW
|
||||
@@ -27,4 +27,4 @@
|
||||
extern int SDL_DrawPoint(SDL_Surface *dst, int x, int y, Uint32 color);
|
||||
extern int SDL_DrawPoints(SDL_Surface *dst, const SDL_Point *points, int count, Uint32 color);
|
||||
|
||||
#endif /* SDL_drawpoint_h_ */
|
||||
#endif // SDL_drawpoint_h_
|
||||
@@ -35,7 +35,7 @@
|
||||
#include "SDL_triangle.h"
|
||||
#include "../../video/SDL_pixels_c.h"
|
||||
|
||||
/* SDL surface based renderer implementation */
|
||||
// SDL surface based renderer implementation
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@@ -189,7 +189,7 @@ static int SW_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
|
||||
static int SW_QueueNoOp(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
{
|
||||
return 0; /* nothing to do in this backend. */
|
||||
return 0; // nothing to do in this backend.
|
||||
}
|
||||
|
||||
static int SW_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count)
|
||||
@@ -301,7 +301,7 @@ static int Blit_to_Screen(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *surf
|
||||
float scale_x, float scale_y, SDL_ScaleMode scaleMode)
|
||||
{
|
||||
int retval;
|
||||
/* Renderer scaling, if needed */
|
||||
// Renderer scaling, if needed
|
||||
if (scale_x != 1.0f || scale_y != 1.0f) {
|
||||
SDL_Rect r;
|
||||
r.x = (int)((float)dstrect->x * scale_x);
|
||||
@@ -363,29 +363,29 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex
|
||||
SDL_GetSurfaceAlphaMod(src, &alphaMod);
|
||||
SDL_GetSurfaceColorMod(src, &rMod, &gMod, &bMod);
|
||||
|
||||
/* SDLgfx_rotateSurface only accepts 32-bit surfaces with a 8888 layout. Everything else has to be converted. */
|
||||
// SDLgfx_rotateSurface only accepts 32-bit surfaces with a 8888 layout. Everything else has to be converted.
|
||||
if (src->internal->format->bits_per_pixel != 32 || SDL_PIXELLAYOUT(src->format) != SDL_PACKEDLAYOUT_8888 || !SDL_ISPIXELFORMAT_ALPHA(src->format)) {
|
||||
blitRequired = SDL_TRUE;
|
||||
}
|
||||
|
||||
/* If scaling and cropping is necessary, it has to be taken care of before the rotation. */
|
||||
// If scaling and cropping is necessary, it has to be taken care of before the rotation.
|
||||
if (!(srcrect->w == final_rect->w && srcrect->h == final_rect->h && srcrect->x == 0 && srcrect->y == 0)) {
|
||||
blitRequired = SDL_TRUE;
|
||||
}
|
||||
|
||||
/* srcrect is not selecting the whole src surface, so cropping is needed */
|
||||
// srcrect is not selecting the whole src surface, so cropping is needed
|
||||
if (!(srcrect->w == src->w && srcrect->h == src->h && srcrect->x == 0 && srcrect->y == 0)) {
|
||||
blitRequired = SDL_TRUE;
|
||||
}
|
||||
|
||||
/* The color and alpha modulation has to be applied before the rotation when using the NONE, MOD or MUL blend modes. */
|
||||
// The color and alpha modulation has to be applied before the rotation when using the NONE, MOD or MUL blend modes.
|
||||
if ((blendmode == SDL_BLENDMODE_NONE || blendmode == SDL_BLENDMODE_MOD || blendmode == SDL_BLENDMODE_MUL) && (alphaMod & rMod & gMod & bMod) != 255) {
|
||||
applyModulation = SDL_TRUE;
|
||||
SDL_SetSurfaceAlphaMod(src_clone, alphaMod);
|
||||
SDL_SetSurfaceColorMod(src_clone, rMod, gMod, bMod);
|
||||
}
|
||||
|
||||
/* Opaque surfaces are much easier to handle with the NONE blend mode. */
|
||||
// Opaque surfaces are much easier to handle with the NONE blend mode.
|
||||
if (blendmode == SDL_BLENDMODE_NONE && !SDL_ISPIXELFORMAT_ALPHA(src->format) && alphaMod == 255) {
|
||||
isOpaque = SDL_TRUE;
|
||||
}
|
||||
@@ -419,7 +419,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex
|
||||
}
|
||||
}
|
||||
|
||||
/* SDLgfx_rotateSurface is going to make decisions depending on the blend mode. */
|
||||
// SDLgfx_rotateSurface is going to make decisions depending on the blend mode.
|
||||
SDL_SetSurfaceBlendMode(src_clone, blendmode);
|
||||
|
||||
if (!retval) {
|
||||
@@ -435,7 +435,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex
|
||||
retval = -1;
|
||||
}
|
||||
if (!retval && mask) {
|
||||
/* The mask needed for the NONE blend mode gets rotated with the same parameters. */
|
||||
// The mask needed for the NONE blend mode gets rotated with the same parameters.
|
||||
mask_rotated = SDLgfx_rotateSurface(mask, angle,
|
||||
SDL_FALSE, 0, 0,
|
||||
&rect_dest, cangle, sangle, center);
|
||||
@@ -455,11 +455,11 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex
|
||||
*/
|
||||
if (blendmode != SDL_BLENDMODE_NONE || isOpaque) {
|
||||
if (applyModulation == SDL_FALSE) {
|
||||
/* If the modulation wasn't already applied, make it happen now. */
|
||||
// If the modulation wasn't already applied, make it happen now.
|
||||
SDL_SetSurfaceAlphaMod(src_rotated, alphaMod);
|
||||
SDL_SetSurfaceColorMod(src_rotated, rMod, gMod, bMod);
|
||||
}
|
||||
/* Renderer scaling, if needed */
|
||||
// Renderer scaling, if needed
|
||||
retval = Blit_to_Screen(src_rotated, NULL, surface, &tmp_rect, scale_x, scale_y, texture->scaleMode);
|
||||
} else {
|
||||
/* The NONE blend mode requires three steps to get the pixels onto the destination surface.
|
||||
@@ -469,7 +469,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex
|
||||
*/
|
||||
SDL_Rect mask_rect = tmp_rect;
|
||||
SDL_SetSurfaceBlendMode(mask_rotated, SDL_BLENDMODE_NONE);
|
||||
/* Renderer scaling, if needed */
|
||||
// Renderer scaling, if needed
|
||||
retval = Blit_to_Screen(mask_rotated, NULL, surface, &mask_rect, scale_x, scale_y, texture->scaleMode);
|
||||
if (!retval) {
|
||||
/* The next step copies the alpha value. This is done with the BLEND blend mode and
|
||||
@@ -478,7 +478,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex
|
||||
*/
|
||||
SDL_SetSurfaceColorMod(src_rotated, 0, 0, 0);
|
||||
mask_rect = tmp_rect;
|
||||
/* Renderer scaling, if needed */
|
||||
// Renderer scaling, if needed
|
||||
retval = Blit_to_Screen(src_rotated, NULL, surface, &mask_rect, scale_x, scale_y, texture->scaleMode);
|
||||
if (!retval) {
|
||||
/* The last step gets the color values in place. The ADD blend mode simply adds them to
|
||||
@@ -491,7 +491,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex
|
||||
retval = -1;
|
||||
} else {
|
||||
SDL_SetSurfaceBlendMode(src_rotated_rgb, SDL_BLENDMODE_ADD);
|
||||
/* Renderer scaling, if needed */
|
||||
// Renderer scaling, if needed
|
||||
retval = Blit_to_Screen(src_rotated_rgb, NULL, surface, &tmp_rect, scale_x, scale_y, texture->scaleMode);
|
||||
SDL_DestroySurface(src_rotated_rgb);
|
||||
}
|
||||
@@ -637,7 +637,7 @@ static void PrepTextureForCopy(const SDL_RenderCommand *cmd, SW_DrawStateCache *
|
||||
SDL_SetSurfaceRLE(surface, 0);
|
||||
}
|
||||
|
||||
/* !!! FIXME: we can probably avoid some of these calls. */
|
||||
// !!! FIXME: we can probably avoid some of these calls.
|
||||
SDL_SetSurfaceColorMod(surface, r, g, b);
|
||||
SDL_SetSurfaceAlphaMod(surface, a);
|
||||
SDL_SetSurfaceBlendMode(surface, blend);
|
||||
@@ -648,7 +648,7 @@ static void SetDrawState(SDL_Surface *surface, SW_DrawStateCache *drawstate)
|
||||
if (drawstate->surface_cliprect_dirty) {
|
||||
const SDL_Rect *viewport = drawstate->viewport;
|
||||
const SDL_Rect *cliprect = drawstate->cliprect;
|
||||
SDL_assert_release(viewport != NULL); /* the higher level should have forced a SDL_RENDERCMD_SETVIEWPORT */
|
||||
SDL_assert_release(viewport != NULL); // the higher level should have forced a SDL_RENDERCMD_SETVIEWPORT
|
||||
|
||||
if (cliprect && viewport) {
|
||||
SDL_Rect clip_rect;
|
||||
@@ -667,7 +667,7 @@ static void SetDrawState(SDL_Surface *surface, SW_DrawStateCache *drawstate)
|
||||
|
||||
static void SW_InvalidateCachedState(SDL_Renderer *renderer)
|
||||
{
|
||||
/* SW_DrawStateCache only lives during SW_RunCommandQueue, so nothing to do here! */
|
||||
// SW_DrawStateCache only lives during SW_RunCommandQueue, so nothing to do here!
|
||||
}
|
||||
|
||||
|
||||
@@ -719,7 +719,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
|
||||
const Uint8 g = (Uint8)SDL_roundf(SDL_clamp(cmd->data.color.color.g * cmd->data.color.color_scale, 0.0f, 1.0f) * 255.0f);
|
||||
const Uint8 b = (Uint8)SDL_roundf(SDL_clamp(cmd->data.color.color.b * cmd->data.color.color_scale, 0.0f, 1.0f) * 255.0f);
|
||||
const Uint8 a = (Uint8)SDL_roundf(SDL_clamp(cmd->data.color.color.a, 0.0f, 1.0f) * 255.0f);
|
||||
/* By definition the clear ignores the clip rect */
|
||||
// By definition the clear ignores the clip rect
|
||||
SDL_SetSurfaceClipRect(surface, NULL);
|
||||
SDL_FillSurfaceRect(surface, NULL, SDL_MapSurfaceRGBA(surface, r, g, b, a));
|
||||
drawstate.surface_cliprect_dirty = SDL_TRUE;
|
||||
@@ -737,7 +737,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
|
||||
const SDL_BlendMode blend = cmd->data.draw.blend;
|
||||
SetDrawState(surface, &drawstate);
|
||||
|
||||
/* Apply viewport */
|
||||
// Apply viewport
|
||||
if (drawstate.viewport && (drawstate.viewport->x || drawstate.viewport->y)) {
|
||||
int i;
|
||||
for (i = 0; i < count; i++) {
|
||||
@@ -765,7 +765,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
|
||||
const SDL_BlendMode blend = cmd->data.draw.blend;
|
||||
SetDrawState(surface, &drawstate);
|
||||
|
||||
/* Apply viewport */
|
||||
// Apply viewport
|
||||
if (drawstate.viewport && (drawstate.viewport->x || drawstate.viewport->y)) {
|
||||
int i;
|
||||
for (i = 0; i < count; i++) {
|
||||
@@ -793,7 +793,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
|
||||
const SDL_BlendMode blend = cmd->data.draw.blend;
|
||||
SetDrawState(surface, &drawstate);
|
||||
|
||||
/* Apply viewport */
|
||||
// Apply viewport
|
||||
if (drawstate.viewport && (drawstate.viewport->x || drawstate.viewport->y)) {
|
||||
int i;
|
||||
for (i = 0; i < count; i++) {
|
||||
@@ -822,7 +822,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
|
||||
|
||||
PrepTextureForCopy(cmd, &drawstate);
|
||||
|
||||
/* Apply viewport */
|
||||
// Apply viewport
|
||||
if (drawstate.viewport && (drawstate.viewport->x || drawstate.viewport->y)) {
|
||||
dstrect->x += drawstate.viewport->x;
|
||||
dstrect->y += drawstate.viewport->y;
|
||||
@@ -836,10 +836,10 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
|
||||
*/
|
||||
SDL_SetSurfaceRLE(surface, 0);
|
||||
|
||||
/* Prevent to do scaling + clipping on viewport boundaries as it may lose proportion */
|
||||
// Prevent to do scaling + clipping on viewport boundaries as it may lose proportion
|
||||
if (dstrect->x < 0 || dstrect->y < 0 || dstrect->x + dstrect->w > surface->w || dstrect->y + dstrect->h > surface->h) {
|
||||
SDL_Surface *tmp = SDL_CreateSurface(dstrect->w, dstrect->h, src->format);
|
||||
/* Scale to an intermediate surface, then blit */
|
||||
// Scale to an intermediate surface, then blit
|
||||
if (tmp) {
|
||||
SDL_Rect r;
|
||||
SDL_BlendMode blendmode;
|
||||
@@ -866,7 +866,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
|
||||
|
||||
SDL_BlitSurface(tmp, NULL, surface, dstrect);
|
||||
SDL_DestroySurface(tmp);
|
||||
/* No need to set back r/g/b/a/blendmode to 'src' since it's done in PrepTextureForCopy() */
|
||||
// No need to set back r/g/b/a/blendmode to 'src' since it's done in PrepTextureForCopy()
|
||||
}
|
||||
} else {
|
||||
SDL_BlitSurfaceScaled(src, srcrect, surface, dstrect, texture->scaleMode);
|
||||
@@ -881,7 +881,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
|
||||
SetDrawState(surface, &drawstate);
|
||||
PrepTextureForCopy(cmd, &drawstate);
|
||||
|
||||
/* Apply viewport */
|
||||
// Apply viewport
|
||||
if (drawstate.viewport && (drawstate.viewport->x || drawstate.viewport->y)) {
|
||||
copydata->dstrect.x += drawstate.viewport->x;
|
||||
copydata->dstrect.y += drawstate.viewport->y;
|
||||
@@ -910,7 +910,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
|
||||
|
||||
PrepTextureForCopy(cmd, &drawstate);
|
||||
|
||||
/* Apply viewport */
|
||||
// Apply viewport
|
||||
if (drawstate.viewport && (drawstate.viewport->x || drawstate.viewport->y)) {
|
||||
SDL_Point vp;
|
||||
vp.x = drawstate.viewport->x;
|
||||
@@ -934,7 +934,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
|
||||
} else {
|
||||
GeometryFillData *ptr = (GeometryFillData *)verts;
|
||||
|
||||
/* Apply viewport */
|
||||
// Apply viewport
|
||||
if (drawstate.viewport && (drawstate.viewport->x || drawstate.viewport->y)) {
|
||||
SDL_Point vp;
|
||||
vp.x = drawstate.viewport->x;
|
||||
@@ -1019,7 +1019,7 @@ static void SW_DestroyRenderer(SDL_Renderer *renderer)
|
||||
|
||||
static void SW_SelectBestFormats(SDL_Renderer *renderer, SDL_PixelFormat format)
|
||||
{
|
||||
/* Prefer the format used by the framebuffer by default. */
|
||||
// Prefer the format used by the framebuffer by default.
|
||||
SDL_AddSupportedTextureFormat(renderer, format);
|
||||
|
||||
switch (format) {
|
||||
@@ -1140,7 +1140,7 @@ int SW_CreateRendererForSurface(SDL_Renderer *renderer, SDL_Surface *surface, SD
|
||||
renderer->QueueSetViewport = SW_QueueNoOp;
|
||||
renderer->QueueSetDrawColor = SW_QueueNoOp;
|
||||
renderer->QueueDrawPoints = SW_QueueDrawPoints;
|
||||
renderer->QueueDrawLines = SW_QueueDrawPoints; /* lines and points queue vertices the same way. */
|
||||
renderer->QueueDrawLines = SW_QueueDrawPoints; // lines and points queue vertices the same way.
|
||||
renderer->QueueFillRects = SW_QueueFillRects;
|
||||
renderer->QueueCopy = SW_QueueCopy;
|
||||
renderer->QueueCopyEx = SW_QueueCopyEx;
|
||||
@@ -1169,7 +1169,7 @@ int SW_CreateRendererForSurface(SDL_Renderer *renderer, SDL_Surface *surface, SD
|
||||
|
||||
static int SW_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_PropertiesID create_props)
|
||||
{
|
||||
/* Set the vsync hint based on our flags, if it's not already set */
|
||||
// Set the vsync hint based on our flags, if it's not already set
|
||||
const char *hint = SDL_GetHint(SDL_HINT_RENDER_VSYNC);
|
||||
const SDL_bool no_hint_set = (!hint || !*hint);
|
||||
|
||||
@@ -1183,7 +1183,7 @@ static int SW_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Pro
|
||||
|
||||
SDL_Surface *surface = SDL_GetWindowSurface(window);
|
||||
|
||||
/* Reset the vsync hint if we set it above */
|
||||
// Reset the vsync hint if we set it above
|
||||
if (no_hint_set) {
|
||||
SDL_SetHint(SDL_HINT_RENDER_VSYNC, "");
|
||||
}
|
||||
@@ -1199,4 +1199,4 @@ SDL_RenderDriver SW_RenderDriver = {
|
||||
SW_CreateRenderer, SDL_SOFTWARE_RENDERER
|
||||
};
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_SW */
|
||||
#endif // SDL_VIDEO_RENDER_SW
|
||||
@@ -24,4 +24,4 @@
|
||||
|
||||
extern int SW_CreateRendererForSurface(SDL_Renderer *renderer, SDL_Surface *surface, SDL_PropertiesID create_props);
|
||||
|
||||
#endif /* SDL_render_sw_c_h_ */
|
||||
#endif // SDL_render_sw_c_h_
|
||||
@@ -40,7 +40,7 @@ Andreas Schiffler -- aschiffler at ferzkopp dot net
|
||||
|
||||
#include "../../video/SDL_blit.h"
|
||||
|
||||
/* ---- Internally used structures */
|
||||
// ---- Internally used structures
|
||||
|
||||
/**
|
||||
A 32 bit RGBA pixel.
|
||||
@@ -85,7 +85,7 @@ static Uint32 get_colorkey(SDL_Surface *src)
|
||||
return key;
|
||||
}
|
||||
|
||||
/* rotate (sx, sy) by (angle, center) into (dx, dy) */
|
||||
// rotate (sx, sy) by (angle, center) into (dx, dy)
|
||||
static void rotate(double sx, double sy, double sinangle, double cosangle, const SDL_FPoint *center, double *dx, double *dy)
|
||||
{
|
||||
sx -= center->x;
|
||||
@@ -143,24 +143,24 @@ void SDLgfx_rotozoomSurfaceSizeTrig(int width, int height, double angle, const S
|
||||
rect_dest->x = minx;
|
||||
rect_dest->y = miny;
|
||||
|
||||
/* reverse the angle because our rotations are clockwise */
|
||||
// reverse the angle because our rotations are clockwise
|
||||
*sangle = -sinangle;
|
||||
*cangle = cosangle;
|
||||
|
||||
{
|
||||
/* The trig code below gets the wrong size (due to FP inaccuracy?) when angle is a multiple of 90 degrees */
|
||||
// The trig code below gets the wrong size (due to FP inaccuracy?) when angle is a multiple of 90 degrees
|
||||
int angle90 = (int)(angle / 90);
|
||||
if (angle90 == angle / 90) { /* if the angle is a multiple of 90 degrees */
|
||||
if (angle90 == angle / 90) { // if the angle is a multiple of 90 degrees
|
||||
angle90 %= 4;
|
||||
if (angle90 < 0) {
|
||||
angle90 += 4; /* 0:0 deg, 1:90 deg, 2:180 deg, 3:270 deg */
|
||||
angle90 += 4; // 0:0 deg, 1:90 deg, 2:180 deg, 3:270 deg
|
||||
}
|
||||
|
||||
if (angle90 & 1) {
|
||||
rect_dest->w = height;
|
||||
rect_dest->h = width;
|
||||
*cangle = 0;
|
||||
*sangle = angle90 == 1 ? -1 : 1; /* reversed because our rotations are clockwise */
|
||||
*sangle = angle90 == 1 ? -1 : 1; // reversed because our rotations are clockwise
|
||||
} else {
|
||||
rect_dest->w = width;
|
||||
rect_dest->h = height;
|
||||
@@ -171,7 +171,7 @@ void SDLgfx_rotozoomSurfaceSizeTrig(int width, int height, double angle, const S
|
||||
}
|
||||
}
|
||||
|
||||
/* Computes source pointer X/Y increments for a rotation that's a multiple of 90 degrees. */
|
||||
// Computes source pointer X/Y increments for a rotation that's a multiple of 90 degrees.
|
||||
static void computeSourceIncrements90(SDL_Surface *src, int bpp, int angle, int flipx, int flipy,
|
||||
int *sincx, int *sincy, int *signx, int *signy)
|
||||
{
|
||||
@@ -179,7 +179,7 @@ static void computeSourceIncrements90(SDL_Surface *src, int bpp, int angle, int
|
||||
if (flipx) {
|
||||
bpp = -bpp;
|
||||
}
|
||||
switch (angle) { /* 0:0 deg, 1:90 deg, 2:180 deg, 3:270 deg */
|
||||
switch (angle) { // 0:0 deg, 1:90 deg, 2:180 deg, 3:270 deg
|
||||
case 0:
|
||||
*sincx = bpp;
|
||||
*sincy = pitch - src->w * *sincx;
|
||||
@@ -212,7 +212,7 @@ static void computeSourceIncrements90(SDL_Surface *src, int bpp, int angle, int
|
||||
}
|
||||
}
|
||||
|
||||
/* Performs a relatively fast rotation/flip when the angle is a multiple of 90 degrees. */
|
||||
// Performs a relatively fast rotation/flip when the angle is a multiple of 90 degrees.
|
||||
#define TRANSFORM_SURFACE_90(pixelType) \
|
||||
int dy, dincy = dst->pitch - dst->w * sizeof(pixelType), sincx, sincy, signx, signy; \
|
||||
Uint8 *sp = (Uint8 *)src->pixels, *dp = (Uint8 *)dst->pixels, *de; \
|
||||
@@ -495,7 +495,7 @@ SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, in
|
||||
int colorKeyAvailable = SDL_FALSE;
|
||||
double sangleinv, cangleinv;
|
||||
|
||||
/* Sanity check */
|
||||
// Sanity check
|
||||
if (!SDL_SurfaceValid(src)) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -505,41 +505,41 @@ SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, in
|
||||
colorKeyAvailable = SDL_TRUE;
|
||||
}
|
||||
}
|
||||
/* This function requires a 32-bit surface or 8-bit surface with a colorkey */
|
||||
// This function requires a 32-bit surface or 8-bit surface with a colorkey
|
||||
is8bit = src->internal->format->bits_per_pixel == 8 && colorKeyAvailable;
|
||||
if (!(is8bit || (src->internal->format->bits_per_pixel == 32 && SDL_ISPIXELFORMAT_ALPHA(src->format)))) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Calculate target factors from sine/cosine and zoom */
|
||||
// Calculate target factors from sine/cosine and zoom
|
||||
sangleinv = sangle * 65536.0;
|
||||
cangleinv = cangle * 65536.0;
|
||||
|
||||
/* Alloc space to completely contain the rotated surface */
|
||||
// Alloc space to completely contain the rotated surface
|
||||
rz_dst = NULL;
|
||||
if (is8bit) {
|
||||
/* Target surface is 8 bit */
|
||||
// Target surface is 8 bit
|
||||
rz_dst = SDL_CreateSurface(rect_dest->w, rect_dest->h + GUARD_ROWS, src->format);
|
||||
if (rz_dst) {
|
||||
SDL_SetSurfacePalette(rz_dst, src->internal->palette);
|
||||
}
|
||||
} else {
|
||||
/* Target surface is 32 bit with source RGBA ordering */
|
||||
// Target surface is 32 bit with source RGBA ordering
|
||||
rz_dst = SDL_CreateSurface(rect_dest->w, rect_dest->h + GUARD_ROWS, src->format);
|
||||
}
|
||||
|
||||
/* Check target */
|
||||
// Check target
|
||||
if (!rz_dst) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Adjust for guard rows */
|
||||
// Adjust for guard rows
|
||||
rz_dst->h = rect_dest->h;
|
||||
|
||||
SDL_GetSurfaceBlendMode(src, &blendmode);
|
||||
|
||||
if (colorKeyAvailable == SDL_TRUE) {
|
||||
/* If available, the colorkey will be used to discard the pixels that are outside of the rotated area. */
|
||||
// If available, the colorkey will be used to discard the pixels that are outside of the rotated area.
|
||||
SDL_SetSurfaceColorKey(rz_dst, SDL_TRUE, colorkey);
|
||||
SDL_FillSurfaceRect(rz_dst, NULL, colorkey);
|
||||
} else if (blendmode == SDL_BLENDMODE_NONE) {
|
||||
@@ -559,7 +559,7 @@ SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, in
|
||||
|
||||
SDL_SetSurfaceBlendMode(rz_dst, blendmode);
|
||||
|
||||
/* Lock source surface */
|
||||
// Lock source surface
|
||||
if (SDL_MUSTLOCK(src)) {
|
||||
if (SDL_LockSurface(src) < 0) {
|
||||
SDL_DestroySurface(rz_dst);
|
||||
@@ -575,7 +575,7 @@ SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, in
|
||||
if (angle90 == angle / 90) {
|
||||
angle90 %= 4;
|
||||
if (angle90 < 0) {
|
||||
angle90 += 4; /* 0:0 deg, 1:90 deg, 2:180 deg, 3:270 deg */
|
||||
angle90 += 4; // 0:0 deg, 1:90 deg, 2:180 deg, 3:270 deg
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -583,7 +583,7 @@ SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, in
|
||||
}
|
||||
|
||||
if (is8bit) {
|
||||
/* Call the 8-bit transformation routine to do the rotation */
|
||||
// Call the 8-bit transformation routine to do the rotation
|
||||
if (angle90 >= 0) {
|
||||
transformSurfaceY90(src, rz_dst, angle90, flipx, flipy);
|
||||
} else {
|
||||
@@ -591,7 +591,7 @@ SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, in
|
||||
flipx, flipy, rect_dest, center);
|
||||
}
|
||||
} else {
|
||||
/* Call the 32-bit transformation routine to do the rotation */
|
||||
// Call the 32-bit transformation routine to do the rotation
|
||||
if (angle90 >= 0) {
|
||||
transformSurfaceRGBA90(src, rz_dst, angle90, flipx, flipy);
|
||||
} else {
|
||||
@@ -600,13 +600,13 @@ SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, in
|
||||
}
|
||||
}
|
||||
|
||||
/* Unlock source surface */
|
||||
// Unlock source surface
|
||||
if (SDL_MUSTLOCK(src)) {
|
||||
SDL_UnlockSurface(src);
|
||||
}
|
||||
|
||||
/* Return rotated surface */
|
||||
// Return rotated surface
|
||||
return rz_dst;
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_SW */
|
||||
#endif // SDL_VIDEO_RENDER_SW
|
||||
@@ -27,4 +27,4 @@ extern SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smo
|
||||
extern void SDLgfx_rotozoomSurfaceSizeTrig(int width, int height, double angle, const SDL_FPoint *center,
|
||||
SDL_Rect *rect_dest, double *cangle, double *sangle);
|
||||
|
||||
#endif /* SDL_rotate_h_ */
|
||||
#endif // SDL_rotate_h_
|
||||
@@ -87,13 +87,13 @@ int SDL_FillTriangle(SDL_Surface *dst, const SDL_Point points[3], Uint32 color)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* cross product AB x AC */
|
||||
// cross product AB x AC
|
||||
static Sint64 cross_product(const SDL_Point *a, const SDL_Point *b, int c_x, int c_y)
|
||||
{
|
||||
return ((Sint64)(b->x - a->x)) * ((Sint64)(c_y - a->y)) - ((Sint64)(b->y - a->y)) * ((Sint64)(c_x - a->x));
|
||||
}
|
||||
|
||||
/* check for top left rules */
|
||||
// check for top left rules
|
||||
static int is_top_left(const SDL_Point *a, const SDL_Point *b, int is_clockwise)
|
||||
{
|
||||
if (is_clockwise) {
|
||||
@@ -114,8 +114,8 @@ static int is_top_left(const SDL_Point *a, const SDL_Point *b, int is_clockwise)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* x = (y << FP_BITS) */
|
||||
/* prevent runtime error: left shift of negative value */
|
||||
// x = (y << FP_BITS)
|
||||
// prevent runtime error: left shift of negative value
|
||||
#define PRECOMP(x, y) \
|
||||
val = y; \
|
||||
if (val >= 0) { \
|
||||
@@ -133,21 +133,21 @@ void trianglepoint_2_fixedpoint(SDL_Point *a)
|
||||
PRECOMP(a->y, a->y);
|
||||
}
|
||||
|
||||
/* bounding rect of three points (in fixed point) */
|
||||
// bounding rect of three points (in fixed point)
|
||||
static void bounding_rect_fixedpoint(const SDL_Point *a, const SDL_Point *b, const SDL_Point *c, SDL_Rect *r)
|
||||
{
|
||||
int min_x = SDL_min(a->x, SDL_min(b->x, c->x));
|
||||
int max_x = SDL_max(a->x, SDL_max(b->x, c->x));
|
||||
int min_y = SDL_min(a->y, SDL_min(b->y, c->y));
|
||||
int max_y = SDL_max(a->y, SDL_max(b->y, c->y));
|
||||
/* points are in fixed point, shift back */
|
||||
// points are in fixed point, shift back
|
||||
r->x = min_x >> FP_BITS;
|
||||
r->y = min_y >> FP_BITS;
|
||||
r->w = (max_x - min_x) >> FP_BITS;
|
||||
r->h = (max_y - min_y) >> FP_BITS;
|
||||
}
|
||||
|
||||
/* bounding rect of three points */
|
||||
// bounding rect of three points
|
||||
static void bounding_rect(const SDL_Point *a, const SDL_Point *b, const SDL_Point *c, SDL_Rect *r)
|
||||
{
|
||||
int min_x = SDL_min(a->x, SDL_min(b->x, c->x));
|
||||
@@ -180,7 +180,7 @@ static void bounding_rect(const SDL_Point *a, const SDL_Point *b, const SDL_Poin
|
||||
if (w0 + bias_w0 >= 0 && w1 + bias_w1 >= 0 && w2 + bias_w2 >= 0) { \
|
||||
Uint8 *dptr = (Uint8 *)dst_ptr + x * dstbpp;
|
||||
|
||||
/* Use 64 bits precision to prevent overflow when interpolating color / texture with wide triangles */
|
||||
// Use 64 bits precision to prevent overflow when interpolating color / texture with wide triangles
|
||||
#define TRIANGLE_GET_TEXTCOORD \
|
||||
int srcx = (int)(((Sint64)w0 * s2s0_x + (Sint64)w1 * s2s1_x + s2_x_area.x) / area); \
|
||||
int srcy = (int)(((Sint64)w0 * s2s0_y + (Sint64)w1 * s2s1_y + s2_x_area.y) / area); \
|
||||
@@ -253,12 +253,12 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin
|
||||
|
||||
is_uniform = COLOR_EQ(c0, c1) && COLOR_EQ(c1, c2);
|
||||
|
||||
/* Flat triangle */
|
||||
// Flat triangle
|
||||
if (area == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Lock the destination, if needed */
|
||||
// Lock the destination, if needed
|
||||
if (SDL_MUSTLOCK(dst)) {
|
||||
if (SDL_LockSurface(dst) < 0) {
|
||||
ret = -1;
|
||||
@@ -271,7 +271,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin
|
||||
bounding_rect_fixedpoint(d0, d1, d2, &dstrect);
|
||||
|
||||
{
|
||||
/* Clip triangle rect with surface rect */
|
||||
// Clip triangle rect with surface rect
|
||||
SDL_Rect rect;
|
||||
rect.x = 0;
|
||||
rect.y = 0;
|
||||
@@ -281,7 +281,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin
|
||||
}
|
||||
|
||||
{
|
||||
/* Clip triangle with surface clip rect */
|
||||
// Clip triangle with surface clip rect
|
||||
SDL_Rect rect;
|
||||
SDL_GetSurfaceClipRect(dst, &rect);
|
||||
SDL_GetRectIntersection(&dstrect, &rect, &dstrect);
|
||||
@@ -290,12 +290,12 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin
|
||||
if (blend != SDL_BLENDMODE_NONE) {
|
||||
SDL_PixelFormat format = dst->format;
|
||||
|
||||
/* need an alpha format */
|
||||
// need an alpha format
|
||||
if (!SDL_ISPIXELFORMAT_ALPHA(format)) {
|
||||
format = SDL_PIXELFORMAT_ARGB8888;
|
||||
}
|
||||
|
||||
/* Use an intermediate surface */
|
||||
// Use an intermediate surface
|
||||
tmp = SDL_CreateSurface(dstrect.w, dstrect.h, format);
|
||||
if (!tmp) {
|
||||
ret = -1;
|
||||
@@ -314,7 +314,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin
|
||||
dst_pitch = tmp->pitch;
|
||||
|
||||
} else {
|
||||
/* Write directly to destination surface */
|
||||
// Write directly to destination surface
|
||||
dstbpp = dst->internal->format->bytes_per_pixel;
|
||||
dst_ptr = (Uint8 *)dst->pixels + dstrect.x * dstbpp + dstrect.y * dst->pitch;
|
||||
dst_pitch = dst->pitch;
|
||||
@@ -335,7 +335,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin
|
||||
PRECOMP(d0d1_x, d1->x - d0->x)
|
||||
}
|
||||
|
||||
/* Starting point for rendering, at the middle of a pixel */
|
||||
// Starting point for rendering, at the middle of a pixel
|
||||
{
|
||||
SDL_Point p;
|
||||
p.x = dstrect.x;
|
||||
@@ -348,7 +348,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin
|
||||
w2_row = cross_product(d0, d1, p.x, p.y);
|
||||
}
|
||||
|
||||
/* Handle anti-clockwise triangles */
|
||||
// Handle anti-clockwise triangles
|
||||
if (!is_clockwise) {
|
||||
d2d1_y *= -1;
|
||||
d0d2_y *= -1;
|
||||
@@ -361,7 +361,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin
|
||||
w2_row *= -1;
|
||||
}
|
||||
|
||||
/* Add a bias to respect top-left rasterization rule */
|
||||
// Add a bias to respect top-left rasterization rule
|
||||
bias_w0 = (is_top_left(d1, d2, is_clockwise) ? 0 : -1);
|
||||
bias_w1 = (is_top_left(d2, d0, is_clockwise) ? 0 : -1);
|
||||
bias_w2 = (is_top_left(d0, d1, is_clockwise) ? 0 : -1);
|
||||
@@ -507,12 +507,12 @@ int SDL_SW_BlitTriangle(
|
||||
|
||||
area = cross_product(d0, d1, d2->x, d2->y);
|
||||
|
||||
/* Flat triangle */
|
||||
// Flat triangle
|
||||
if (area == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Lock the destination, if needed */
|
||||
// Lock the destination, if needed
|
||||
if (SDL_MUSTLOCK(dst)) {
|
||||
if (SDL_LockSurface(dst) < 0) {
|
||||
ret = -1;
|
||||
@@ -522,7 +522,7 @@ int SDL_SW_BlitTriangle(
|
||||
}
|
||||
}
|
||||
|
||||
/* Lock the source, if needed */
|
||||
// Lock the source, if needed
|
||||
if (SDL_MUSTLOCK(src)) {
|
||||
if (SDL_LockSurface(src) < 0) {
|
||||
ret = -1;
|
||||
@@ -538,7 +538,7 @@ int SDL_SW_BlitTriangle(
|
||||
|
||||
SDL_GetSurfaceBlendMode(src, &blend);
|
||||
|
||||
/* TRIANGLE_GET_TEXTCOORD interpolates up to the max values included, so reduce by 1 */
|
||||
// TRIANGLE_GET_TEXTCOORD interpolates up to the max values included, so reduce by 1
|
||||
if (texture_address_mode == SDL_TEXTURE_ADDRESS_CLAMP) {
|
||||
SDL_Rect srcrect;
|
||||
int maxx, maxy;
|
||||
@@ -577,18 +577,18 @@ int SDL_SW_BlitTriangle(
|
||||
}
|
||||
|
||||
{
|
||||
/* Clip triangle with surface clip rect */
|
||||
// Clip triangle with surface clip rect
|
||||
SDL_Rect rect;
|
||||
SDL_GetSurfaceClipRect(dst, &rect);
|
||||
SDL_GetRectIntersection(&dstrect, &rect, &dstrect);
|
||||
}
|
||||
|
||||
/* Set destination pointer */
|
||||
// Set destination pointer
|
||||
dstbpp = dst->internal->format->bytes_per_pixel;
|
||||
dst_ptr = (Uint8 *)dst->pixels + dstrect.x * dstbpp + dstrect.y * dst->pitch;
|
||||
dst_pitch = dst->pitch;
|
||||
|
||||
/* Set source pointer */
|
||||
// Set source pointer
|
||||
src_ptr = (const int *)src->pixels;
|
||||
src_pitch = src->pitch;
|
||||
|
||||
@@ -612,7 +612,7 @@ int SDL_SW_BlitTriangle(
|
||||
s2s0_y = s0->y - s2->y;
|
||||
s2s1_y = s1->y - s2->y;
|
||||
|
||||
/* Starting point for rendering, at the middle of a pixel */
|
||||
// Starting point for rendering, at the middle of a pixel
|
||||
{
|
||||
SDL_Point p;
|
||||
p.x = dstrect.x;
|
||||
@@ -625,7 +625,7 @@ int SDL_SW_BlitTriangle(
|
||||
w2_row = cross_product(d0, d1, p.x, p.y);
|
||||
}
|
||||
|
||||
/* Handle anti-clockwise triangles */
|
||||
// Handle anti-clockwise triangles
|
||||
if (!is_clockwise) {
|
||||
d2d1_y *= -1;
|
||||
d0d2_y *= -1;
|
||||
@@ -638,7 +638,7 @@ int SDL_SW_BlitTriangle(
|
||||
w2_row *= -1;
|
||||
}
|
||||
|
||||
/* Add a bias to respect top-left rasterization rule */
|
||||
// Add a bias to respect top-left rasterization rule
|
||||
bias_w0 = (is_top_left(d1, d2, is_clockwise) ? 0 : -1);
|
||||
bias_w1 = (is_top_left(d2, d0, is_clockwise) ? 0 : -1);
|
||||
bias_w2 = (is_top_left(d0, d1, is_clockwise) ? 0 : -1);
|
||||
@@ -660,7 +660,7 @@ int SDL_SW_BlitTriangle(
|
||||
}
|
||||
|
||||
if (blend != SDL_BLENDMODE_NONE || src->format != dst->format || has_modulation || !is_uniform) {
|
||||
/* Use SDL_BlitTriangle_Slow */
|
||||
// Use SDL_BlitTriangle_Slow
|
||||
|
||||
SDL_BlitInfo *info = &src->internal->map.info;
|
||||
SDL_BlitInfo tmp_info;
|
||||
@@ -695,12 +695,12 @@ int SDL_SW_BlitTriangle(
|
||||
|
||||
tmp_info.colorkey = info->colorkey;
|
||||
|
||||
/* src */
|
||||
// src
|
||||
tmp_info.src_surface = src_surface;
|
||||
tmp_info.src = (Uint8 *)src_ptr;
|
||||
tmp_info.src_pitch = src_pitch;
|
||||
|
||||
/* dst */
|
||||
// dst
|
||||
tmp_info.dst = dst_ptr;
|
||||
tmp_info.dst_pitch = dst_pitch;
|
||||
|
||||
@@ -827,12 +827,12 @@ static void SDL_BlitTriangle_Slow(SDL_BlitInfo *info,
|
||||
DISEMBLE_RGB(src, srcbpp, src_fmt, srcpixel, srcR, srcG, srcB);
|
||||
srcA = 0xFF;
|
||||
} else {
|
||||
/* SDL_PIXELFORMAT_ARGB2101010 */
|
||||
// SDL_PIXELFORMAT_ARGB2101010
|
||||
srcpixel = *((Uint32 *)(src));
|
||||
RGBA_FROM_ARGB2101010(srcpixel, srcR, srcG, srcB, srcA);
|
||||
}
|
||||
if (flags & SDL_COPY_COLORKEY) {
|
||||
/* srcpixel isn't set for 24 bpp */
|
||||
// srcpixel isn't set for 24 bpp
|
||||
if (srcbpp == 3) {
|
||||
srcpixel = (srcR << src_fmt->Rshift) |
|
||||
(srcG << src_fmt->Gshift) | (srcB << src_fmt->Bshift);
|
||||
@@ -848,12 +848,12 @@ static void SDL_BlitTriangle_Slow(SDL_BlitInfo *info,
|
||||
DISEMBLE_RGB(dst, dstbpp, dst_fmt, dstpixel, dstR, dstG, dstB);
|
||||
dstA = 0xFF;
|
||||
} else {
|
||||
/* SDL_PIXELFORMAT_ARGB2101010 */
|
||||
// SDL_PIXELFORMAT_ARGB2101010
|
||||
dstpixel = *((Uint32 *) (dst));
|
||||
RGBA_FROM_ARGB2101010(dstpixel, dstR, dstG, dstB, dstA);
|
||||
}
|
||||
} else {
|
||||
/* don't care */
|
||||
// don't care
|
||||
dstR = dstG = dstB = dstA = 0;
|
||||
}
|
||||
|
||||
@@ -874,7 +874,7 @@ static void SDL_BlitTriangle_Slow(SDL_BlitInfo *info,
|
||||
srcA = (srcA * modulateA) / 255;
|
||||
}
|
||||
if (flags & (SDL_COPY_BLEND | SDL_COPY_ADD)) {
|
||||
/* This goes away if we ever use premultiplied alpha */
|
||||
// This goes away if we ever use premultiplied alpha
|
||||
if (srcA < 255) {
|
||||
srcR = (srcR * srcA) / 255;
|
||||
srcG = (srcG * srcA) / 255;
|
||||
@@ -933,7 +933,7 @@ static void SDL_BlitTriangle_Slow(SDL_BlitInfo *info,
|
||||
} else if (FORMAT_HAS_NO_ALPHA(dstfmt_val)) {
|
||||
ASSEMBLE_RGB(dst, dstbpp, dst_fmt, dstR, dstG, dstB);
|
||||
} else {
|
||||
/* SDL_PIXELFORMAT_ARGB2101010 */
|
||||
// SDL_PIXELFORMAT_ARGB2101010
|
||||
Uint32 pixel;
|
||||
ARGB2101010_FROM_RGBA(pixel, dstR, dstG, dstB, dstA);
|
||||
*(Uint32 *)dst = pixel;
|
||||
@@ -942,4 +942,4 @@ static void SDL_BlitTriangle_Slow(SDL_BlitInfo *info,
|
||||
TRIANGLE_END_LOOP
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_SW */
|
||||
#endif // SDL_VIDEO_RENDER_SW
|
||||
@@ -40,4 +40,4 @@ extern int SDL_SW_BlitTriangle(
|
||||
|
||||
extern void trianglepoint_2_fixedpoint(SDL_Point *a);
|
||||
|
||||
#endif /* SDL_triangle_h_ */
|
||||
#endif // SDL_triangle_h_
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
#include <psp2/common_dialog.h>
|
||||
|
||||
/* #define DEBUG_RAZOR */
|
||||
// #define DEBUG_RAZOR
|
||||
|
||||
#ifdef DEBUG_RAZOR
|
||||
#include <psp2/sysmodule.h>
|
||||
@@ -915,7 +915,7 @@ static int SetDrawState(VITA_GXM_RenderData *data, const SDL_RenderCommand *cmd)
|
||||
data->drawstate.texture = texture;
|
||||
}
|
||||
|
||||
/* all drawing commands use this */
|
||||
// all drawing commands use this
|
||||
sceGxmSetVertexStream(data->gxm_context, 0, (const void *)cmd->data.draw.first);
|
||||
|
||||
return 0;
|
||||
@@ -923,7 +923,7 @@ static int SetDrawState(VITA_GXM_RenderData *data, const SDL_RenderCommand *cmd)
|
||||
|
||||
static void VITA_GXM_InvalidateCachedState(SDL_Renderer *renderer)
|
||||
{
|
||||
/* currently this doesn't do anything. If this needs to do something (and someone is mixing their own rendering calls in!), update this. */
|
||||
// currently this doesn't do anything. If this needs to do something (and someone is mixing their own rendering calls in!), update this.
|
||||
}
|
||||
|
||||
static int VITA_GXM_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize)
|
||||
@@ -983,13 +983,13 @@ static int VITA_GXM_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *c
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_FILL_RECTS: /* unused */
|
||||
case SDL_RENDERCMD_FILL_RECTS: // unused
|
||||
break;
|
||||
|
||||
case SDL_RENDERCMD_COPY: /* unused */
|
||||
case SDL_RENDERCMD_COPY: // unused
|
||||
break;
|
||||
|
||||
case SDL_RENDERCMD_COPY_EX: /* unused */
|
||||
case SDL_RENDERCMD_COPY_EX: // unused
|
||||
break;
|
||||
|
||||
case SDL_RENDERCMD_DRAW_POINTS:
|
||||
@@ -1006,11 +1006,11 @@ static int VITA_GXM_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *c
|
||||
while (nextcmd) {
|
||||
const SDL_RenderCommandType nextcmdtype = nextcmd->command;
|
||||
if (nextcmdtype != thiscmdtype) {
|
||||
break; /* can't go any further on this draw call, different render command up next. */
|
||||
break; // can't go any further on this draw call, different render command up next.
|
||||
} else if (nextcmd->data.draw.texture != thistexture || nextcmd->data.draw.blend != thisblend) {
|
||||
break; /* can't go any further on this draw call, different texture/blendmode copy up next. */
|
||||
break; // can't go any further on this draw call, different texture/blendmode copy up next.
|
||||
} else {
|
||||
finalcmd = nextcmd; /* we can combine copy operations here. Mark this one as the furthest okay command. */
|
||||
finalcmd = nextcmd; // we can combine copy operations here. Mark this one as the furthest okay command.
|
||||
count += nextcmd->data.draw.count;
|
||||
}
|
||||
nextcmd = nextcmd->next;
|
||||
@@ -1036,7 +1036,7 @@ static int VITA_GXM_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *c
|
||||
}
|
||||
}
|
||||
|
||||
cmd = finalcmd; /* skip any copy commands we just combined in here. */
|
||||
cmd = finalcmd; // skip any copy commands we just combined in here.
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1099,7 +1099,7 @@ static SDL_Surface *VITA_GXM_RenderReadPixels(SDL_Renderer *renderer, const SDL_
|
||||
read_pixels(rect->x, renderer->target ? rect->y : (h - rect->y) - rect->h,
|
||||
rect->w, rect->h, surface->pixels);
|
||||
|
||||
/* Flip the rows to be top-down if necessary */
|
||||
// Flip the rows to be top-down if necessary
|
||||
|
||||
if (!renderer->target) {
|
||||
SDL_bool isstack;
|
||||
@@ -1204,4 +1204,4 @@ static void VITA_GXM_DestroyRenderer(SDL_Renderer *renderer)
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_VITA_GXM */
|
||||
#endif // SDL_VIDEO_RENDER_VITA_GXM
|
||||
@@ -174,4 +174,4 @@ void vita_mem_fragment_usse_free(SceUID uid)
|
||||
sceKernelFreeMemBlock(uid);
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_VITA_GXM */
|
||||
#endif // SDL_VIDEO_RENDER_VITA_GXM
|
||||
@@ -39,4 +39,4 @@ void vita_mem_vertex_usse_free(SceUID uid);
|
||||
void *vita_mem_fragment_usse_alloc(unsigned int size, SceUID *uid, unsigned int *usse_offset);
|
||||
void vita_mem_fragment_usse_free(SceUID uid);
|
||||
|
||||
#endif /* SDL_RENDER_VITA_GXM_MEMORY_H */
|
||||
#endif // SDL_RENDER_VITA_GXM_MEMORY_H
|
||||
@@ -734,13 +734,13 @@ int gxm_init(SDL_Renderer *renderer)
|
||||
// create color vertex format
|
||||
SceGxmVertexAttribute colorVertexAttributes[2];
|
||||
SceGxmVertexStream colorVertexStreams[1];
|
||||
/* x,y: 2 float 32 bits */
|
||||
// x,y: 2 float 32 bits
|
||||
colorVertexAttributes[0].streamIndex = 0;
|
||||
colorVertexAttributes[0].offset = 0;
|
||||
colorVertexAttributes[0].format = SCE_GXM_ATTRIBUTE_FORMAT_F32;
|
||||
colorVertexAttributes[0].componentCount = 2; // (x, y)
|
||||
colorVertexAttributes[0].regIndex = sceGxmProgramParameterGetResourceIndex(paramColorPositionAttribute);
|
||||
/* color: 4 unsigned char = 32 bits */
|
||||
// color: 4 unsigned char = 32 bits
|
||||
colorVertexAttributes[1].streamIndex = 0;
|
||||
colorVertexAttributes[1].offset = 8; // (x, y) * 4 = 8 bytes
|
||||
colorVertexAttributes[1].format = SCE_GXM_ATTRIBUTE_FORMAT_U8N;
|
||||
@@ -773,19 +773,19 @@ int gxm_init(SDL_Renderer *renderer)
|
||||
// create texture vertex format
|
||||
SceGxmVertexAttribute textureVertexAttributes[3];
|
||||
SceGxmVertexStream textureVertexStreams[1];
|
||||
/* x,y: 2 float 32 bits */
|
||||
// x,y: 2 float 32 bits
|
||||
textureVertexAttributes[0].streamIndex = 0;
|
||||
textureVertexAttributes[0].offset = 0;
|
||||
textureVertexAttributes[0].format = SCE_GXM_ATTRIBUTE_FORMAT_F32;
|
||||
textureVertexAttributes[0].componentCount = 2; // (x, y)
|
||||
textureVertexAttributes[0].regIndex = sceGxmProgramParameterGetResourceIndex(paramTexturePositionAttribute);
|
||||
/* u,v: 2 floats 32 bits */
|
||||
// u,v: 2 floats 32 bits
|
||||
textureVertexAttributes[1].streamIndex = 0;
|
||||
textureVertexAttributes[1].offset = 8; // (x, y) * 4 = 8 bytes
|
||||
textureVertexAttributes[1].format = SCE_GXM_ATTRIBUTE_FORMAT_F32;
|
||||
textureVertexAttributes[1].componentCount = 2; // (u, v)
|
||||
textureVertexAttributes[1].regIndex = sceGxmProgramParameterGetResourceIndex(paramTextureTexcoordAttribute);
|
||||
/* r,g,b,a: 4 unsigned chars 32 bits */
|
||||
// r,g,b,a: 4 unsigned chars 32 bits
|
||||
textureVertexAttributes[2].streamIndex = 0;
|
||||
textureVertexAttributes[2].offset = 16; // (x, y, u, v) * 4 = 16 bytes
|
||||
textureVertexAttributes[2].format = SCE_GXM_ATTRIBUTE_FORMAT_U8N;
|
||||
@@ -1009,12 +1009,12 @@ gxm_texture *create_gxm_texture(VITA_GXM_RenderData *data, unsigned int w, unsig
|
||||
*return_h = h;
|
||||
*return_pitch = aligned_w * tex_format_to_bytespp(format);
|
||||
|
||||
/* Allocate a GPU buffer for the texture */
|
||||
// Allocate a GPU buffer for the texture
|
||||
texture_data = vita_gpu_mem_alloc(
|
||||
data,
|
||||
tex_size);
|
||||
|
||||
/* Try SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE in case we're out of VRAM */
|
||||
// Try SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE in case we're out of VRAM
|
||||
if (!texture_data) {
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_RENDER, "CDRAM texture allocation failed\n");
|
||||
texture_data = vita_mem_alloc(
|
||||
@@ -1033,10 +1033,10 @@ gxm_texture *create_gxm_texture(VITA_GXM_RenderData *data, unsigned int w, unsig
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Clear the texture */
|
||||
// Clear the texture
|
||||
SDL_memset(texture_data, 0, tex_size);
|
||||
|
||||
/* Create the gxm texture */
|
||||
// Create the gxm texture
|
||||
ret = sceGxmTextureInitLinear(&texture->gxm_tex, texture_data, format, texture_w, h, 0);
|
||||
if (ret < 0) {
|
||||
free_gxm_texture(data, texture);
|
||||
@@ -1210,4 +1210,4 @@ void gxm_term_for_common_dialog(void)
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_VITA_GXM */
|
||||
#endif // SDL_VIDEO_RENDER_VITA_GXM
|
||||
@@ -60,4 +60,4 @@ 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 */
|
||||
#endif // SDL_RENDER_VITA_GXM_TOOLS_H
|
||||
@@ -207,4 +207,4 @@ typedef struct
|
||||
SDL_bool nv12;
|
||||
} VITA_GXM_TextureData;
|
||||
|
||||
#endif /* SDL_RENDER_VITA_GXM_TYPES_H */
|
||||
#endif // SDL_RENDER_VITA_GXM_TYPES_H
|
||||
@@ -150,14 +150,14 @@ VULKAN_FUNCTIONS()
|
||||
#undef VULKAN_OPTIONAL_INSTANCE_FUNCTION
|
||||
#undef VULKAN_OPTIONAL_DEVICE_FUNCTION
|
||||
|
||||
/* Renderpass types */
|
||||
// Renderpass types
|
||||
typedef enum {
|
||||
SDL_VULKAN_RENDERPASS_LOAD = 0,
|
||||
SDL_VULKAN_RENDERPASS_CLEAR = 1,
|
||||
SDL_VULKAN_NUM_RENDERPASSES
|
||||
} SDL_vulkan_renderpass_type;
|
||||
|
||||
/* Sampler types */
|
||||
// Sampler types
|
||||
typedef enum
|
||||
{
|
||||
SDL_VULKAN_SAMPLER_NEAREST_CLAMP,
|
||||
@@ -167,14 +167,14 @@ typedef enum
|
||||
SDL_VULKAN_NUM_SAMPLERS
|
||||
} SDL_vulkan_sampler_type;
|
||||
|
||||
/* Vertex shader, common values */
|
||||
// Vertex shader, common values
|
||||
typedef struct
|
||||
{
|
||||
Float4X4 model;
|
||||
Float4X4 projectionAndView;
|
||||
} VertexShaderConstants;
|
||||
|
||||
/* These should mirror the definitions in VULKAN_PixelShader_Common.hlsli */
|
||||
// These should mirror the definitions in VULKAN_PixelShader_Common.hlsli
|
||||
//static const float TONEMAP_NONE = 0;
|
||||
//static const float TONEMAP_LINEAR = 1;
|
||||
static const float TONEMAP_CHROME = 2;
|
||||
@@ -193,7 +193,7 @@ typedef enum
|
||||
NUM_SAMPLERS
|
||||
} Sampler;
|
||||
|
||||
/* Pixel shader constants, common values */
|
||||
// Pixel shader constants, common values
|
||||
typedef struct
|
||||
{
|
||||
float scRGB_output;
|
||||
@@ -207,7 +207,7 @@ typedef struct
|
||||
float sdr_white_point;
|
||||
} PixelShaderConstants;
|
||||
|
||||
/* Per-vertex data */
|
||||
// Per-vertex data
|
||||
typedef struct
|
||||
{
|
||||
float pos[2];
|
||||
@@ -215,7 +215,7 @@ typedef struct
|
||||
SDL_FColor color;
|
||||
} VertexPositionColor;
|
||||
|
||||
/* Vulkan Buffer */
|
||||
// Vulkan Buffer
|
||||
typedef struct
|
||||
{
|
||||
VkDeviceMemory deviceMemory;
|
||||
@@ -225,7 +225,7 @@ typedef struct
|
||||
|
||||
} VULKAN_Buffer;
|
||||
|
||||
/* Vulkan image */
|
||||
// Vulkan image
|
||||
typedef struct
|
||||
{
|
||||
SDL_bool allocatedImage;
|
||||
@@ -236,7 +236,7 @@ typedef struct
|
||||
VkFormat format;
|
||||
} VULKAN_Image;
|
||||
|
||||
/* Per-texture data */
|
||||
// Per-texture data
|
||||
typedef struct
|
||||
{
|
||||
VULKAN_Image mainImage;
|
||||
@@ -249,18 +249,18 @@ typedef struct
|
||||
int height;
|
||||
VULKAN_Shader shader;
|
||||
|
||||
/* Object passed to VkImageView and VkSampler for doing Ycbcr -> RGB conversion */
|
||||
// Object passed to VkImageView and VkSampler for doing Ycbcr -> RGB conversion
|
||||
VkSamplerYcbcrConversion samplerYcbcrConversion;
|
||||
/* Sampler created with samplerYcbcrConversion, passed to PSO as immutable sampler */
|
||||
// Sampler created with samplerYcbcrConversion, passed to PSO as immutable sampler
|
||||
VkSampler samplerYcbcr;
|
||||
/* Descriptor set layout with samplerYcbcr baked as immutable sampler */
|
||||
// Descriptor set layout with samplerYcbcr baked as immutable sampler
|
||||
VkDescriptorSetLayout descriptorSetLayoutYcbcr;
|
||||
/* Pipeline layout with immutable sampler descriptor set layout */
|
||||
// Pipeline layout with immutable sampler descriptor set layout
|
||||
VkPipelineLayout pipelineLayoutYcbcr;
|
||||
|
||||
} VULKAN_TextureData;
|
||||
|
||||
/* Pipeline State Object data */
|
||||
// Pipeline State Object data
|
||||
typedef struct
|
||||
{
|
||||
VULKAN_Shader shader;
|
||||
@@ -278,7 +278,7 @@ typedef struct
|
||||
VkBuffer vertexBuffer;
|
||||
} VULKAN_DrawStateCache;
|
||||
|
||||
/* Private renderer data */
|
||||
// Private renderer data
|
||||
typedef struct
|
||||
{
|
||||
PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr;
|
||||
@@ -316,15 +316,15 @@ typedef struct
|
||||
VkDescriptorSetLayout descriptorSetLayout;
|
||||
VkPipelineLayout pipelineLayout;
|
||||
|
||||
/* Vertex buffer data */
|
||||
// Vertex buffer data
|
||||
VULKAN_Buffer vertexBuffers[SDL_VULKAN_NUM_VERTEX_BUFFERS];
|
||||
VertexShaderConstants vertexShaderConstantsData;
|
||||
|
||||
/* Data for staging/allocating textures */
|
||||
// Data for staging/allocating textures
|
||||
VULKAN_Buffer **uploadBuffers;
|
||||
int *currentUploadBuffer;
|
||||
|
||||
/* Data for updating constants */
|
||||
// Data for updating constants
|
||||
VULKAN_Buffer **constantBuffers;
|
||||
uint32_t *numConstantBuffers;
|
||||
uint32_t currentConstantBufferIndex;
|
||||
@@ -365,7 +365,7 @@ typedef struct
|
||||
uint32_t signalRenderSemaphoreCount;
|
||||
uint32_t signalRenderSemaphoreMax;
|
||||
|
||||
/* Cached renderer properties */
|
||||
// Cached renderer properties
|
||||
VULKAN_TextureData *textureRenderTarget;
|
||||
SDL_bool cliprectDirty;
|
||||
SDL_bool currentCliprectEnabled;
|
||||
@@ -823,7 +823,7 @@ static VkResult VULKAN_AllocateImage(VULKAN_RenderData *rendererData, SDL_Proper
|
||||
imageViewCreateInfo.subresourceRange.baseArrayLayer = 0;
|
||||
imageViewCreateInfo.subresourceRange.layerCount = 1;
|
||||
|
||||
/* If it's a YCbCr image, we need to pass the conversion info to the VkImageView (and the VkSampler) */
|
||||
// If it's a YCbCr image, we need to pass the conversion info to the VkImageView (and the VkSampler)
|
||||
if (samplerYcbcrConversion != VK_NULL_HANDLE) {
|
||||
samplerYcbcrConversionInfo.sType = VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_INFO_KHR;
|
||||
samplerYcbcrConversionInfo.conversion = samplerYcbcrConversion;
|
||||
@@ -844,7 +844,7 @@ static VkResult VULKAN_AllocateImage(VULKAN_RenderData *rendererData, SDL_Proper
|
||||
static void VULKAN_RecordPipelineImageBarrier(VULKAN_RenderData *rendererData, VkAccessFlags sourceAccessMask, VkAccessFlags destAccessMask,
|
||||
VkPipelineStageFlags srcStageFlags, VkPipelineStageFlags dstStageFlags, VkImageLayout destLayout, VkImage image, VkImageLayout *imageLayout)
|
||||
{
|
||||
/* Stop any outstanding renderpass if open */
|
||||
// Stop any outstanding renderpass if open
|
||||
if (rendererData->currentRenderPass != VK_NULL_HANDLE) {
|
||||
vkCmdEndRenderPass(rendererData->currentCommandBuffer);
|
||||
rendererData->currentRenderPass = VK_NULL_HANDLE;
|
||||
@@ -881,7 +881,7 @@ static VkResult VULKAN_AcquireNextSwapchainImage(SDL_Renderer *renderer)
|
||||
result = VULKAN_CreateWindowSizeDependentResources(renderer);
|
||||
return result;
|
||||
} else if(result == VK_SUBOPTIMAL_KHR) {
|
||||
/* Suboptimal, but we can contiue */
|
||||
// Suboptimal, but we can contiue
|
||||
}
|
||||
else if (result != VK_SUCCESS) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_RENDER, "vkAcquireNextImageKHR(): %s\n", SDL_Vulkan_GetResultString(result));
|
||||
@@ -942,7 +942,7 @@ static void VULKAN_EnsureCommandBuffer(VULKAN_RenderData *rendererData)
|
||||
rendererData->currentCommandBuffer = rendererData->commandBuffers[rendererData->currentCommandBufferIndex];
|
||||
VULKAN_ResetCommandList(rendererData);
|
||||
|
||||
/* Ensure the swapchain is in the correct layout */
|
||||
// Ensure the swapchain is in the correct layout
|
||||
if (rendererData->swapchainImageLayouts[rendererData->currentSwapchainImageIndex] == VK_IMAGE_LAYOUT_UNDEFINED) {
|
||||
VULKAN_RecordPipelineImageBarrier(rendererData,
|
||||
0,
|
||||
@@ -1016,7 +1016,7 @@ static void VULKAN_ResetCommandList(VULKAN_RenderData *rendererData)
|
||||
rendererData->currentConstantBufferOffset = -1;
|
||||
rendererData->currentConstantBufferIndex = 0;
|
||||
|
||||
/* Release any upload buffers that were inflight */
|
||||
// Release any upload buffers that were inflight
|
||||
for (int i = 0; i < rendererData->currentUploadBuffer[rendererData->currentCommandBufferIndex]; ++i) {
|
||||
VULKAN_DestroyBuffer(rendererData, &rendererData->uploadBuffers[rendererData->currentCommandBufferIndex][i]);
|
||||
}
|
||||
@@ -1162,7 +1162,7 @@ static VULKAN_PipelineState *VULKAN_CreatePipelineState(SDL_Renderer *renderer,
|
||||
pipelineCreateInfo.pColorBlendState = &colorBlendStateCreateInfo;
|
||||
pipelineCreateInfo.pDynamicState = &dynamicStateCreateInfo;
|
||||
|
||||
/* Shaders */
|
||||
// Shaders
|
||||
const char *name = "main";
|
||||
for (uint32_t i = 0; i < 2; i++) {
|
||||
SDL_memset(&shaderStageCreateInfo[i], 0, sizeof(shaderStageCreateInfo[i]));
|
||||
@@ -1175,7 +1175,7 @@ static VULKAN_PipelineState *VULKAN_CreatePipelineState(SDL_Renderer *renderer,
|
||||
pipelineCreateInfo.pStages = &shaderStageCreateInfo[0];
|
||||
|
||||
|
||||
/* Vertex input */
|
||||
// Vertex input
|
||||
vertexInputCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
|
||||
vertexInputCreateInfo.vertexAttributeDescriptionCount = 3;
|
||||
vertexInputCreateInfo.pVertexAttributeDescriptions = &attributeDescriptions[0];
|
||||
@@ -1199,7 +1199,7 @@ static VULKAN_PipelineState *VULKAN_CreatePipelineState(SDL_Renderer *renderer,
|
||||
bindingDescriptions[ 0 ].inputRate = VK_VERTEX_INPUT_RATE_VERTEX;
|
||||
bindingDescriptions[ 0 ].stride = 32;
|
||||
|
||||
/* Input assembly */
|
||||
// Input assembly
|
||||
inputAssemblyStateCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;
|
||||
inputAssemblyStateCreateInfo.topology = ( VkPrimitiveTopology ) topology;
|
||||
inputAssemblyStateCreateInfo.primitiveRestartEnable = VK_FALSE;
|
||||
@@ -1208,7 +1208,7 @@ static VULKAN_PipelineState *VULKAN_CreatePipelineState(SDL_Renderer *renderer,
|
||||
viewportStateCreateInfo.scissorCount = 1;
|
||||
viewportStateCreateInfo.viewportCount = 1;
|
||||
|
||||
/* Dynamic states */
|
||||
// Dynamic states
|
||||
dynamicStateCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO;
|
||||
VkDynamicState dynamicStates[2] = {
|
||||
VK_DYNAMIC_STATE_VIEWPORT,
|
||||
@@ -1217,7 +1217,7 @@ static VULKAN_PipelineState *VULKAN_CreatePipelineState(SDL_Renderer *renderer,
|
||||
dynamicStateCreateInfo.dynamicStateCount = SDL_arraysize(dynamicStates);
|
||||
dynamicStateCreateInfo.pDynamicStates = dynamicStates;
|
||||
|
||||
/* Rasterization state */
|
||||
// Rasterization state
|
||||
rasterizationStateCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO;
|
||||
rasterizationStateCreateInfo.depthClampEnable = VK_FALSE;
|
||||
rasterizationStateCreateInfo.rasterizerDiscardEnable = VK_FALSE;
|
||||
@@ -1230,16 +1230,16 @@ static VULKAN_PipelineState *VULKAN_CreatePipelineState(SDL_Renderer *renderer,
|
||||
rasterizationStateCreateInfo.depthBiasSlopeFactor = 0.0f;
|
||||
rasterizationStateCreateInfo.lineWidth = 1.0f;
|
||||
|
||||
/* MSAA state */
|
||||
// MSAA state
|
||||
multisampleStateCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
|
||||
VkSampleMask multiSampleMask = 0xFFFFFFFF;
|
||||
multisampleStateCreateInfo.pSampleMask = &multiSampleMask;
|
||||
multisampleStateCreateInfo.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT;
|
||||
|
||||
/* Depth Stencil */
|
||||
// Depth Stencil
|
||||
depthStencilStateCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO;
|
||||
|
||||
/* Color blend */
|
||||
// Color blend
|
||||
VkPipelineColorBlendAttachmentState colorBlendAttachment = { 0 };
|
||||
colorBlendStateCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
|
||||
colorBlendStateCreateInfo.attachmentCount = 1;
|
||||
@@ -1253,7 +1253,7 @@ static VULKAN_PipelineState *VULKAN_CreatePipelineState(SDL_Renderer *renderer,
|
||||
colorBlendAttachment.alphaBlendOp = GetBlendOp(SDL_GetBlendModeAlphaOperation(blendMode));
|
||||
colorBlendAttachment.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT;
|
||||
|
||||
/* Renderpass / layout */
|
||||
// Renderpass / layout
|
||||
pipelineCreateInfo.renderPass = rendererData->currentRenderPass;
|
||||
pipelineCreateInfo.subpass = 0;
|
||||
pipelineCreateInfo.layout = pipelineLayout;
|
||||
@@ -1283,7 +1283,7 @@ static SDL_bool VULKAN_FindMemoryTypeIndex(VULKAN_RenderData *rendererData, uint
|
||||
uint32_t memoryTypeIndex = 0;
|
||||
SDL_bool foundExactMatch = SDL_FALSE;
|
||||
|
||||
/* Desired flags must be a superset of required flags. */
|
||||
// Desired flags must be a superset of required flags.
|
||||
desiredFlags |= requiredFlags;
|
||||
|
||||
for (memoryTypeIndex = 0; memoryTypeIndex < rendererData->physicalDeviceMemoryProperties.memoryTypeCount; memoryTypeIndex++) {
|
||||
@@ -1673,7 +1673,7 @@ static SDL_bool VULKAN_ValidationLayersFound(void)
|
||||
return foundValidation;
|
||||
}
|
||||
|
||||
/* Create resources that depend on the device. */
|
||||
// Create resources that depend on the device.
|
||||
static VkResult VULKAN_CreateDeviceResources(SDL_Renderer *renderer, SDL_PropertiesID create_props)
|
||||
{
|
||||
static const char *const deviceExtensionNames[] = {
|
||||
@@ -1704,13 +1704,13 @@ static VkResult VULKAN_CreateDeviceResources(SDL_Renderer *renderer, SDL_Propert
|
||||
return VK_ERROR_UNKNOWN;
|
||||
}
|
||||
|
||||
/* Load global Vulkan functions */
|
||||
// Load global Vulkan functions
|
||||
rendererData->vkGetInstanceProcAddr = vkGetInstanceProcAddr;
|
||||
if (VULKAN_LoadGlobalFunctions(rendererData) != 0) {
|
||||
return VK_ERROR_UNKNOWN;
|
||||
}
|
||||
|
||||
/* Check for colorspace extension */
|
||||
// Check for colorspace extension
|
||||
rendererData->supportsEXTSwapchainColorspace = VK_FALSE;
|
||||
if (renderer->output_colorspace == SDL_COLORSPACE_SRGB_LINEAR ||
|
||||
renderer->output_colorspace == SDL_COLORSPACE_HDR10) {
|
||||
@@ -1721,10 +1721,10 @@ static VkResult VULKAN_CreateDeviceResources(SDL_Renderer *renderer, SDL_Propert
|
||||
}
|
||||
}
|
||||
|
||||
/* Check for VK_KHR_get_physical_device_properties2 */
|
||||
// Check for VK_KHR_get_physical_device_properties2
|
||||
rendererData->supportsKHRGetPhysicalDeviceProperties2 = VULKAN_InstanceExtensionFound(rendererData, VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
|
||||
|
||||
/* Create VkInstance */
|
||||
// Create VkInstance
|
||||
rendererData->instance = (VkInstance)SDL_GetPointerProperty(create_props, SDL_PROP_RENDERER_CREATE_VULKAN_INSTANCE_POINTER, NULL);
|
||||
if (rendererData->instance) {
|
||||
rendererData->instance_external = SDL_TRUE;
|
||||
@@ -1762,13 +1762,13 @@ static VkResult VULKAN_CreateDeviceResources(SDL_Renderer *renderer, SDL_Propert
|
||||
}
|
||||
}
|
||||
|
||||
/* Load instance Vulkan functions */
|
||||
// Load instance Vulkan functions
|
||||
if (VULKAN_LoadInstanceFunctions(rendererData) != 0) {
|
||||
VULKAN_DestroyAll(renderer);
|
||||
return VK_ERROR_UNKNOWN;
|
||||
}
|
||||
|
||||
/* Create Vulkan surface */
|
||||
// Create Vulkan surface
|
||||
rendererData->surface = (VkSurfaceKHR)SDL_GetNumberProperty(create_props, SDL_PROP_RENDERER_CREATE_VULKAN_SURFACE_NUMBER, 0);
|
||||
if (rendererData->surface) {
|
||||
rendererData->surface_external = SDL_TRUE;
|
||||
@@ -1780,7 +1780,7 @@ static VkResult VULKAN_CreateDeviceResources(SDL_Renderer *renderer, SDL_Propert
|
||||
}
|
||||
}
|
||||
|
||||
/* Choose Vulkan physical device */
|
||||
// Choose Vulkan physical device
|
||||
rendererData->physicalDevice = (VkPhysicalDevice)SDL_GetPointerProperty(create_props, SDL_PROP_RENDERER_CREATE_VULKAN_PHYSICAL_DEVICE_POINTER, NULL);
|
||||
if (rendererData->physicalDevice) {
|
||||
vkGetPhysicalDeviceMemoryProperties(rendererData->physicalDevice, &rendererData->physicalDeviceMemoryProperties);
|
||||
@@ -1804,7 +1804,7 @@ static VkResult VULKAN_CreateDeviceResources(SDL_Renderer *renderer, SDL_Propert
|
||||
rendererData->supportsKHRSamplerYCbCrConversion = SDL_TRUE;
|
||||
}
|
||||
|
||||
/* Create Vulkan device */
|
||||
// Create Vulkan device
|
||||
rendererData->device = (VkDevice)SDL_GetPointerProperty(create_props, SDL_PROP_RENDERER_CREATE_VULKAN_DEVICE_POINTER, NULL);
|
||||
if (rendererData->device) {
|
||||
rendererData->device_external = SDL_TRUE;
|
||||
@@ -1855,7 +1855,7 @@ static VkResult VULKAN_CreateDeviceResources(SDL_Renderer *renderer, SDL_Propert
|
||||
return VK_ERROR_UNKNOWN;
|
||||
}
|
||||
|
||||
/* Get graphics/present queues */
|
||||
// Get graphics/present queues
|
||||
vkGetDeviceQueue(rendererData->device, rendererData->graphicsQueueFamilyIndex, 0, &rendererData->graphicsQueue);
|
||||
if (rendererData->graphicsQueueFamilyIndex != rendererData->presentQueueFamilyIndex) {
|
||||
vkGetDeviceQueue(rendererData->device, rendererData->presentQueueFamilyIndex, 0, &rendererData->presentQueue);
|
||||
@@ -1863,7 +1863,7 @@ static VkResult VULKAN_CreateDeviceResources(SDL_Renderer *renderer, SDL_Propert
|
||||
rendererData->presentQueue = rendererData->graphicsQueue;
|
||||
}
|
||||
|
||||
/* Create command pool/command buffers */
|
||||
// Create command pool/command buffers
|
||||
VkCommandPoolCreateInfo commandPoolCreateInfo = { 0 };
|
||||
commandPoolCreateInfo.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
|
||||
commandPoolCreateInfo.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT;
|
||||
@@ -1880,7 +1880,7 @@ static VkResult VULKAN_CreateDeviceResources(SDL_Renderer *renderer, SDL_Propert
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Create shaders / layouts */
|
||||
// Create shaders / layouts
|
||||
for (uint32_t i = 0; i < NUM_SHADERS; i++) {
|
||||
VULKAN_Shader shader = (VULKAN_Shader)i;
|
||||
VkShaderModuleCreateInfo shaderModuleCreateInfo = { 0 };
|
||||
@@ -1901,7 +1901,7 @@ static VkResult VULKAN_CreateDeviceResources(SDL_Renderer *renderer, SDL_Propert
|
||||
}
|
||||
}
|
||||
|
||||
/* Descriptor set layout / pipeline layout*/
|
||||
// Descriptor set layout / pipeline layout
|
||||
result = VULKAN_CreateDescriptorSetAndPipelineLayout(rendererData, VK_NULL_HANDLE, &rendererData->descriptorSetLayout, &rendererData->pipelineLayout);
|
||||
if (result != VK_SUCCESS) {
|
||||
VULKAN_DestroyAll(renderer);
|
||||
@@ -1909,12 +1909,12 @@ static VkResult VULKAN_CreateDeviceResources(SDL_Renderer *renderer, SDL_Propert
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Create default vertex buffers */
|
||||
// Create default vertex buffers
|
||||
for (uint32_t i = 0; i < SDL_VULKAN_NUM_VERTEX_BUFFERS; ++i) {
|
||||
VULKAN_CreateVertexBuffer(rendererData, i, SDL_VULKAN_VERTEX_BUFFER_DEFAULT_SIZE);
|
||||
}
|
||||
|
||||
/* Create samplers */
|
||||
// Create samplers
|
||||
{
|
||||
static struct
|
||||
{
|
||||
@@ -2101,11 +2101,11 @@ static VkResult VULKAN_CreateSwapChain(SDL_Renderer *renderer, int w, int h)
|
||||
rendererData->surfaceCapabilities.maxImageExtent.height);
|
||||
|
||||
if (rendererData->swapchainSize.width == 0 && rendererData->swapchainSize.height == 0) {
|
||||
/* Don't recreate the swapchain if size is (0,0), just fail and continue attempting creation */
|
||||
// Don't recreate the swapchain if size is (0,0), just fail and continue attempting creation
|
||||
return VK_ERROR_OUT_OF_DATE_KHR;
|
||||
}
|
||||
|
||||
/* Choose a present mode. If vsync is requested, then use VK_PRESENT_MODE_FIFO_KHR which is guaranteed to be supported */
|
||||
// Choose a present mode. If vsync is requested, then use VK_PRESENT_MODE_FIFO_KHR which is guaranteed to be supported
|
||||
VkPresentModeKHR presentMode = VK_PRESENT_MODE_FIFO_KHR;
|
||||
if (rendererData->vsync <= 0) {
|
||||
uint32_t presentModeCount = 0;
|
||||
@@ -2203,7 +2203,7 @@ static VkResult VULKAN_CreateSwapChain(SDL_Renderer *renderer, int w, int h)
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Create VkImageView's for swapchain images */
|
||||
// Create VkImageView's for swapchain images
|
||||
{
|
||||
VkImageViewCreateInfo imageViewCreateInfo = { 0 };
|
||||
imageViewCreateInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
|
||||
@@ -2260,7 +2260,7 @@ static VkResult VULKAN_CreateSwapChain(SDL_Renderer *renderer, int w, int h)
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Create fences */
|
||||
// Create fences
|
||||
if (rendererData->fences) {
|
||||
for (uint32_t i = 0; i < rendererData->swapchainImageCount; i++) {
|
||||
if (rendererData->fences[i] != VK_NULL_HANDLE) {
|
||||
@@ -2282,7 +2282,7 @@ static VkResult VULKAN_CreateSwapChain(SDL_Renderer *renderer, int w, int h)
|
||||
}
|
||||
}
|
||||
|
||||
/* Create renderpasses and framebuffer */
|
||||
// Create renderpasses and framebuffer
|
||||
if (rendererData->framebuffers) {
|
||||
for (uint32_t i = 0; i < rendererData->swapchainImageCount; i++) {
|
||||
if (rendererData->framebuffers[i] != VK_NULL_HANDLE) {
|
||||
@@ -2312,7 +2312,7 @@ static VkResult VULKAN_CreateSwapChain(SDL_Renderer *renderer, int w, int h)
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Create descriptor pools - start by allocating one per swapchain image, let it grow if more are needed */
|
||||
// Create descriptor pools - start by allocating one per swapchain image, let it grow if more are needed
|
||||
if (rendererData->descriptorPools) {
|
||||
SDL_assert(rendererData->numDescriptorPools);
|
||||
for (uint32_t i = 0; i < rendererData->swapchainImageCount; i++) {
|
||||
@@ -2329,7 +2329,7 @@ static VkResult VULKAN_CreateSwapChain(SDL_Renderer *renderer, int w, int h)
|
||||
rendererData->descriptorPools = (VkDescriptorPool **)SDL_calloc(rendererData->swapchainImageCount, sizeof(VkDescriptorPool*));
|
||||
rendererData->numDescriptorPools = (uint32_t *)SDL_calloc(rendererData->swapchainImageCount, sizeof(uint32_t));
|
||||
for (uint32_t i = 0; i < rendererData->swapchainImageCount; i++) {
|
||||
/* Start by just allocating one pool, it will grow if needed */
|
||||
// Start by just allocating one pool, it will grow if needed
|
||||
rendererData->numDescriptorPools[i] = 1;
|
||||
rendererData->descriptorPools[i] = (VkDescriptorPool *)SDL_calloc(1, sizeof(VkDescriptorPool));
|
||||
rendererData->descriptorPools[i][0] = VULKAN_AllocateDescriptorPool(rendererData);
|
||||
@@ -2339,7 +2339,7 @@ static VkResult VULKAN_CreateSwapChain(SDL_Renderer *renderer, int w, int h)
|
||||
}
|
||||
}
|
||||
|
||||
/* Create semaphores */
|
||||
// Create semaphores
|
||||
if (rendererData->imageAvailableSemaphores) {
|
||||
for (uint32_t i = 0; i < rendererData->swapchainImageCount; ++i) {
|
||||
if (rendererData->imageAvailableSemaphores[i] != VK_NULL_HANDLE) {
|
||||
@@ -2371,7 +2371,7 @@ static VkResult VULKAN_CreateSwapChain(SDL_Renderer *renderer, int w, int h)
|
||||
}
|
||||
}
|
||||
|
||||
/* Upload buffers */
|
||||
// Upload buffers
|
||||
if (rendererData->uploadBuffers) {
|
||||
for (uint32_t i = 0; i < rendererData->swapchainImageCount; i++) {
|
||||
for (uint32_t j = 0; j < SDL_VULKAN_NUM_UPLOAD_BUFFERS; j++) {
|
||||
@@ -2388,7 +2388,7 @@ static VkResult VULKAN_CreateSwapChain(SDL_Renderer *renderer, int w, int h)
|
||||
SDL_free(rendererData->currentUploadBuffer);
|
||||
rendererData->currentUploadBuffer = (int *)SDL_calloc(rendererData->swapchainImageCount, sizeof(int));
|
||||
|
||||
/* Constant buffers */
|
||||
// Constant buffers
|
||||
if (rendererData->constantBuffers) {
|
||||
SDL_assert(rendererData->numConstantBuffers);
|
||||
for (uint32_t i = 0; i < rendererData->swapchainImageCount; ++i) {
|
||||
@@ -2404,7 +2404,7 @@ static VkResult VULKAN_CreateSwapChain(SDL_Renderer *renderer, int w, int h)
|
||||
rendererData->constantBuffers = (VULKAN_Buffer **)SDL_calloc(rendererData->swapchainImageCount, sizeof(VULKAN_Buffer*));
|
||||
rendererData->numConstantBuffers = (uint32_t *)SDL_calloc(rendererData->swapchainImageCount, sizeof(uint32_t));
|
||||
for (uint32_t i = 0; i < rendererData->swapchainImageCount; i++) {
|
||||
/* Start with just allocating one, will grow if needed */
|
||||
// Start with just allocating one, will grow if needed
|
||||
rendererData->numConstantBuffers[i] = 1;
|
||||
rendererData->constantBuffers[i] = (VULKAN_Buffer *)SDL_calloc(1, sizeof(VULKAN_Buffer));
|
||||
result = VULKAN_AllocateBuffer(rendererData,
|
||||
@@ -2431,14 +2431,14 @@ static VkResult VULKAN_CreateSwapChain(SDL_Renderer *renderer, int w, int h)
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Initialize all resources that change when the window's size changes. */
|
||||
// Initialize all resources that change when the window's size changes.
|
||||
static VkResult VULKAN_CreateWindowSizeDependentResources(SDL_Renderer *renderer)
|
||||
{
|
||||
VULKAN_RenderData *rendererData = (VULKAN_RenderData *)renderer->internal;
|
||||
VkResult result = VK_SUCCESS;
|
||||
int w, h;
|
||||
|
||||
/* Release resources in the current command list */
|
||||
// Release resources in the current command list
|
||||
VULKAN_IssueBatch(rendererData);
|
||||
VULKAN_WaitForGPU(rendererData);
|
||||
|
||||
@@ -2457,11 +2457,11 @@ static VkResult VULKAN_CreateWindowSizeDependentResources(SDL_Renderer *renderer
|
||||
return result;
|
||||
}
|
||||
|
||||
/* This method is called when the window's size changes. */
|
||||
// This method is called when the window's size changes.
|
||||
static VkResult VULKAN_UpdateForWindowSizeChange(SDL_Renderer *renderer)
|
||||
{
|
||||
VULKAN_RenderData *rendererData = (VULKAN_RenderData *)renderer->internal;
|
||||
/* If the GPU has previous work, wait for it to be done first */
|
||||
// If the GPU has previous work, wait for it to be done first
|
||||
VULKAN_WaitForGPU(rendererData);
|
||||
|
||||
return VULKAN_CreateWindowSizeDependentResources(renderer);
|
||||
@@ -2522,7 +2522,7 @@ static int VULKAN_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SD
|
||||
textureData->scaleMode = (texture->scaleMode == SDL_SCALEMODE_NEAREST) ? VK_FILTER_NEAREST : VK_FILTER_LINEAR;
|
||||
|
||||
#if SDL_HAVE_YUV
|
||||
/* YUV textures must have even width and height. Also create Ycbcr conversion */
|
||||
// YUV textures must have even width and height. Also create Ycbcr conversion
|
||||
if (texture->format == SDL_PIXELFORMAT_YV12 ||
|
||||
texture->format == SDL_PIXELFORMAT_IYUV ||
|
||||
texture->format == SDL_PIXELFORMAT_NV12 ||
|
||||
@@ -2530,7 +2530,7 @@ static int VULKAN_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SD
|
||||
texture->format == SDL_PIXELFORMAT_P010) {
|
||||
const uint32_t YUV_SD_THRESHOLD = 576;
|
||||
|
||||
/* Check that we have VK_KHR_sampler_ycbcr_conversion support */
|
||||
// Check that we have VK_KHR_sampler_ycbcr_conversion support
|
||||
if (!rendererData->supportsKHRSamplerYCbCrConversion) {
|
||||
return SDL_SetError("[Vulkan] YUV textures require a Vulkan device that supports VK_KHR_sampler_ycbcr_conversion");
|
||||
}
|
||||
@@ -2538,11 +2538,11 @@ static int VULKAN_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SD
|
||||
VkSamplerYcbcrConversionCreateInfoKHR samplerYcbcrConversionCreateInfo = { 0 };
|
||||
samplerYcbcrConversionCreateInfo.sType = VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_CREATE_INFO_KHR;
|
||||
|
||||
/* Pad width/height to multiple of 2 */
|
||||
// Pad width/height to multiple of 2
|
||||
width = (width + 1) & ~1;
|
||||
height = (height + 1) & ~1;
|
||||
|
||||
/* Create samplerYcbcrConversion which will be used on the VkImageView and VkSampler */
|
||||
// Create samplerYcbcrConversion which will be used on the VkImageView and VkSampler
|
||||
samplerYcbcrConversionCreateInfo.format = textureFormat;
|
||||
switch (SDL_COLORSPACEMATRIX(texture->colorspace)) {
|
||||
case SDL_MATRIX_COEFFICIENTS_BT470BG:
|
||||
@@ -2611,7 +2611,7 @@ static int VULKAN_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SD
|
||||
return SDL_SetError("[Vulkan] vkCreateSamplerYcbcrConversionKHR %s", SDL_Vulkan_GetResultString(result));
|
||||
}
|
||||
|
||||
/* Also create VkSampler object which we will need to pass to the PSO as an immutable sampler */
|
||||
// Also create VkSampler object which we will need to pass to the PSO as an immutable sampler
|
||||
VkSamplerCreateInfo samplerCreateInfo = { 0 };
|
||||
samplerCreateInfo.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
|
||||
samplerCreateInfo.magFilter = VK_FILTER_NEAREST;
|
||||
@@ -2635,7 +2635,7 @@ static int VULKAN_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SD
|
||||
return SDL_SetError("[Vulkan] vkCreateSampler %s", SDL_Vulkan_GetResultString(result));
|
||||
}
|
||||
|
||||
/* Allocate special descriptor set layout with samplerYcbcr baked as an immutable sampler */
|
||||
// Allocate special descriptor set layout with samplerYcbcr baked as an immutable sampler
|
||||
result = VULKAN_CreateDescriptorSetAndPipelineLayout(rendererData, textureData->samplerYcbcr,
|
||||
&textureData->descriptorSetLayoutYcbcr, &textureData->pipelineLayoutYcbcr);
|
||||
if (result != VK_SUCCESS) {
|
||||
@@ -2769,7 +2769,7 @@ static VkResult VULKAN_UpdateTextureInternal(VULKAN_RenderData *rendererData, Vk
|
||||
}
|
||||
}
|
||||
|
||||
/* Make sure the destination is in the correct resource state */
|
||||
// Make sure the destination is in the correct resource state
|
||||
VULKAN_RecordPipelineImageBarrier(rendererData,
|
||||
VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_TRANSFER_READ_BIT | VK_ACCESS_TRANSFER_WRITE_BIT,
|
||||
VK_ACCESS_TRANSFER_WRITE_BIT,
|
||||
@@ -2801,7 +2801,7 @@ static VkResult VULKAN_UpdateTextureInternal(VULKAN_RenderData *rendererData, Vk
|
||||
|
||||
vkCmdCopyBufferToImage(rendererData->currentCommandBuffer, uploadBuffer->buffer, image, *imageLayout, 1, ®ion);
|
||||
|
||||
/* Transition the texture to be shader accessible */
|
||||
// Transition the texture to be shader accessible
|
||||
VULKAN_RecordPipelineImageBarrier(rendererData,
|
||||
VK_ACCESS_TRANSFER_WRITE_BIT,
|
||||
VK_ACCESS_SHADER_READ_BIT,
|
||||
@@ -2813,7 +2813,7 @@ static VkResult VULKAN_UpdateTextureInternal(VULKAN_RenderData *rendererData, Vk
|
||||
|
||||
rendererData->currentUploadBuffer[rendererData->currentCommandBufferIndex]++;
|
||||
|
||||
/* If we've used up all the upload buffers, we need to issue the batch */
|
||||
// If we've used up all the upload buffers, we need to issue the batch
|
||||
if (rendererData->currentUploadBuffer[rendererData->currentCommandBufferIndex] == SDL_VULKAN_NUM_UPLOAD_BUFFERS) {
|
||||
VULKAN_IssueBatch(rendererData);
|
||||
}
|
||||
@@ -2838,7 +2838,7 @@ static int VULKAN_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
}
|
||||
#if SDL_HAVE_YUV
|
||||
Uint32 numPlanes = VULKAN_VkFormatGetNumPlanes(textureData->mainImage.format);
|
||||
/* Skip to the correct offset into the next texture */
|
||||
// Skip to the correct offset into the next texture
|
||||
srcPixels = (const void *)((const Uint8 *)srcPixels + rect->h * srcPitch);
|
||||
// YUV data
|
||||
if (numPlanes == 3) {
|
||||
@@ -2847,7 +2847,7 @@ static int VULKAN_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Skip to the correct offset into the next texture */
|
||||
// Skip to the correct offset into the next texture
|
||||
srcPixels = (const void *)((const Uint8 *)srcPixels + ((rect->h + 1) / 2) * ((srcPitch + 1) / 2));
|
||||
}
|
||||
}
|
||||
@@ -2970,7 +2970,7 @@ static void VULKAN_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
|
||||
VULKAN_EnsureCommandBuffer(rendererData);
|
||||
|
||||
/* Make sure the destination is in the correct resource state */
|
||||
// Make sure the destination is in the correct resource state
|
||||
VULKAN_RecordPipelineImageBarrier(rendererData,
|
||||
VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_TRANSFER_READ_BIT | VK_ACCESS_TRANSFER_WRITE_BIT,
|
||||
VK_ACCESS_TRANSFER_WRITE_BIT,
|
||||
@@ -2996,7 +2996,7 @@ static void VULKAN_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
region.imageExtent.depth = 1;
|
||||
vkCmdCopyBufferToImage(rendererData->currentCommandBuffer, textureData->stagingBuffer.buffer, textureData->mainImage.image, textureData->mainImage.imageLayout, 1, ®ion);
|
||||
|
||||
/* Transition the texture to be shader accessible */
|
||||
// Transition the texture to be shader accessible
|
||||
VULKAN_RecordPipelineImageBarrier(rendererData,
|
||||
VK_ACCESS_TRANSFER_WRITE_BIT,
|
||||
VK_ACCESS_SHADER_READ_BIT,
|
||||
@@ -3006,7 +3006,7 @@ static void VULKAN_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
textureData->mainImage.image,
|
||||
&textureData->mainImage.imageLayout);
|
||||
|
||||
/* Execute the command list before releasing the staging buffer */
|
||||
// Execute the command list before releasing the staging buffer
|
||||
VULKAN_IssueBatch(rendererData);
|
||||
|
||||
VULKAN_DestroyBuffer(rendererData, &textureData->stagingBuffer);
|
||||
@@ -3067,7 +3067,7 @@ static int VULKAN_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
|
||||
static int VULKAN_QueueNoOp(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
{
|
||||
return 0; /* nothing to do in this backend. */
|
||||
return 0; // nothing to do in this backend.
|
||||
}
|
||||
|
||||
static int VULKAN_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count)
|
||||
@@ -3159,7 +3159,7 @@ static SDL_bool VULKAN_UpdateVertexBuffer(SDL_Renderer *renderer,
|
||||
VULKAN_Buffer *vertexBuffer;
|
||||
|
||||
if (dataSizeInBytes == 0) {
|
||||
return 0; /* nothing to do. */
|
||||
return 0; // nothing to do.
|
||||
}
|
||||
|
||||
if (rendererData->issueBatch) {
|
||||
@@ -3168,7 +3168,7 @@ static SDL_bool VULKAN_UpdateVertexBuffer(SDL_Renderer *renderer,
|
||||
return SDL_FALSE;
|
||||
}
|
||||
}
|
||||
/* If the existing vertex buffer isn't big enough, we need to recreate a big enough one */
|
||||
// If the existing vertex buffer isn't big enough, we need to recreate a big enough one
|
||||
if (dataSizeInBytes > rendererData->vertexBuffers[vbidx].size) {
|
||||
VULKAN_IssueBatch(rendererData);
|
||||
VULKAN_WaitForGPU(rendererData);
|
||||
@@ -3201,13 +3201,13 @@ static int VULKAN_UpdateViewport(SDL_Renderer *renderer)
|
||||
* SDL_CreateRenderer is calling it, and will call it again later
|
||||
* with a non-empty viewport.
|
||||
*/
|
||||
/* SDL_Log("%s, no viewport was set!\n", __FUNCTION__); */
|
||||
// SDL_Log("%s, no viewport was set!\n", __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
projection = MatrixIdentity();
|
||||
|
||||
/* Update the view matrix */
|
||||
// Update the view matrix
|
||||
SDL_zero(view);
|
||||
view.m[0][0] = 2.0f / viewport->w;
|
||||
view.m[1][1] = -2.0f / viewport->h;
|
||||
@@ -3337,19 +3337,19 @@ static VkResult VULKAN_CreateDescriptorSetAndPipelineLayout(VULKAN_RenderData *r
|
||||
{
|
||||
VkResult result;
|
||||
|
||||
/* Descriptor set layout */
|
||||
// Descriptor set layout
|
||||
VkDescriptorSetLayoutCreateInfo descriptorSetLayoutCreateInfo = { 0 };
|
||||
descriptorSetLayoutCreateInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
|
||||
descriptorSetLayoutCreateInfo.flags = 0;
|
||||
VkDescriptorSetLayoutBinding layoutBindings[2];
|
||||
/* PixelShaderConstants */
|
||||
// PixelShaderConstants
|
||||
layoutBindings[0].binding = 1;
|
||||
layoutBindings[0].descriptorCount = 1;
|
||||
layoutBindings[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
|
||||
layoutBindings[0].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT;
|
||||
layoutBindings[0].pImmutableSamplers = NULL;
|
||||
|
||||
/* Combined image/sampler */
|
||||
// Combined image/sampler
|
||||
layoutBindings[1].binding = 0;
|
||||
layoutBindings[1].descriptorCount = 1;
|
||||
layoutBindings[1].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
|
||||
@@ -3364,7 +3364,7 @@ static VkResult VULKAN_CreateDescriptorSetAndPipelineLayout(VULKAN_RenderData *r
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Pipeline layout */
|
||||
// Pipeline layout
|
||||
VkPipelineLayoutCreateInfo pipelineLayoutCreateInfo = { 0 };
|
||||
VkPushConstantRange pushConstantRange;
|
||||
pushConstantRange.size = sizeof( VertexShaderConstants );
|
||||
@@ -3403,14 +3403,14 @@ static VkDescriptorSet VULKAN_AllocateDescriptorSet(SDL_Renderer *renderer, VULK
|
||||
result = vkAllocateDescriptorSets(rendererData->device, &descriptorSetAllocateInfo, &descriptorSet);
|
||||
}
|
||||
if (result != VK_SUCCESS) {
|
||||
/* Out of descriptor sets in this pool - see if we have more pools allocated */
|
||||
// Out of descriptor sets in this pool - see if we have more pools allocated
|
||||
currentDescriptorPoolIndex++;
|
||||
if (currentDescriptorPoolIndex < rendererData->numDescriptorPools[rendererData->currentCommandBufferIndex]) {
|
||||
descriptorPool = rendererData->descriptorPools[rendererData->currentCommandBufferIndex][currentDescriptorPoolIndex];
|
||||
descriptorSetAllocateInfo.descriptorPool = descriptorPool;
|
||||
result = vkAllocateDescriptorSets(rendererData->device, &descriptorSetAllocateInfo, &descriptorSet);
|
||||
if (result != VK_SUCCESS) {
|
||||
/* This should not fail - we are allocating from the front of the descriptor set */
|
||||
// This should not fail - we are allocating from the front of the descriptor set
|
||||
SDL_SetError("[Vulkan] Unable to allocate descriptor set");
|
||||
return VK_NULL_HANDLE;
|
||||
}
|
||||
@@ -3418,11 +3418,11 @@ static VkDescriptorSet VULKAN_AllocateDescriptorSet(SDL_Renderer *renderer, VULK
|
||||
rendererData->currentDescriptorSetIndex = 0;
|
||||
|
||||
}
|
||||
/* We are out of pools, create a new one */
|
||||
// We are out of pools, create a new one
|
||||
else {
|
||||
descriptorPool = VULKAN_AllocateDescriptorPool(rendererData);
|
||||
if (descriptorPool == VK_NULL_HANDLE) {
|
||||
/* SDL_SetError called in VULKAN_AllocateDescriptorPool if we failed to allocate a new pool */
|
||||
// SDL_SetError called in VULKAN_AllocateDescriptorPool if we failed to allocate a new pool
|
||||
return VK_NULL_HANDLE;
|
||||
}
|
||||
rendererData->numDescriptorPools[rendererData->currentCommandBufferIndex]++;
|
||||
@@ -3433,7 +3433,7 @@ static VkDescriptorSet VULKAN_AllocateDescriptorSet(SDL_Renderer *renderer, VULK
|
||||
rendererData->currentDescriptorPoolIndex = currentDescriptorPoolIndex;
|
||||
rendererData->currentDescriptorSetIndex = 0;
|
||||
|
||||
/* Call recursively to allocate from the new pool */
|
||||
// Call recursively to allocate from the new pool
|
||||
return VULKAN_AllocateDescriptorSet(renderer, shader, descriptorSetLayout, sampler, constantBuffer, constantBufferOffset, imageView);
|
||||
}
|
||||
}
|
||||
@@ -3446,7 +3446,7 @@ static VkDescriptorSet VULKAN_AllocateDescriptorSet(SDL_Renderer *renderer, VULK
|
||||
|
||||
VkWriteDescriptorSet descriptorWrites[2];
|
||||
SDL_memset(descriptorWrites, 0, sizeof(descriptorWrites));
|
||||
uint32_t descriptorCount = 1; /* Always have the uniform buffer */
|
||||
uint32_t descriptorCount = 1; // Always have the uniform buffer
|
||||
|
||||
descriptorWrites[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
|
||||
descriptorWrites[0].dstSet = descriptorSet;
|
||||
@@ -3466,7 +3466,7 @@ static VkDescriptorSet VULKAN_AllocateDescriptorSet(SDL_Renderer *renderer, VULK
|
||||
descriptorWrites[1].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
|
||||
descriptorWrites[1].pImageInfo = &combinedImageSamplerDescriptor;
|
||||
|
||||
/* Ignore the sampler if we're using YcBcCr data since it will be baked in the descriptor set layout */
|
||||
// Ignore the sampler if we're using YcBcCr data since it will be baked in the descriptor set layout
|
||||
if (descriptorSetLayout == rendererData->descriptorSetLayout) {
|
||||
combinedImageSamplerDescriptor.sampler = sampler;
|
||||
}
|
||||
@@ -3498,7 +3498,7 @@ static SDL_bool VULKAN_SetDrawState(SDL_Renderer *renderer, const SDL_RenderComm
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
/* See if we need to change the pipeline state */
|
||||
// See if we need to change the pipeline state
|
||||
if (!rendererData->currentPipelineState ||
|
||||
rendererData->currentPipelineState->shader != shader ||
|
||||
rendererData->currentPipelineState->blendMode != blendMode ||
|
||||
@@ -3521,7 +3521,7 @@ static SDL_bool VULKAN_SetDrawState(SDL_Renderer *renderer, const SDL_RenderComm
|
||||
}
|
||||
}
|
||||
|
||||
/* If we didn't find a match, create a new one -- it must mean the blend mode is non-standard */
|
||||
// If we didn't find a match, create a new one -- it must mean the blend mode is non-standard
|
||||
if (!rendererData->currentPipelineState) {
|
||||
rendererData->currentPipelineState = VULKAN_CreatePipelineState(renderer, shader, pipelineLayout, descriptorSetLayout, blendMode, topology, format);
|
||||
}
|
||||
@@ -3536,7 +3536,7 @@ static SDL_bool VULKAN_SetDrawState(SDL_Renderer *renderer, const SDL_RenderComm
|
||||
|
||||
if (rendererData->viewportDirty) {
|
||||
if (VULKAN_UpdateViewport(renderer) == 0) {
|
||||
/* vertexShaderConstantsData.projectionAndView has changed */
|
||||
// vertexShaderConstantsData.projectionAndView has changed
|
||||
updateConstants = SDL_TRUE;
|
||||
}
|
||||
}
|
||||
@@ -3563,22 +3563,22 @@ static SDL_bool VULKAN_SetDrawState(SDL_Renderer *renderer, const SDL_RenderComm
|
||||
SDL_memcmp(shader_constants, &rendererData->currentPipelineState->shader_constants, sizeof(*shader_constants)) != 0) {
|
||||
|
||||
if (rendererData->currentConstantBufferOffset == -1) {
|
||||
/* First time, grab offset 0 */
|
||||
// First time, grab offset 0
|
||||
rendererData->currentConstantBufferOffset = 0;
|
||||
constantBufferOffset = 0;
|
||||
}
|
||||
else {
|
||||
/* Align the next address to the minUniformBufferOffsetAlignment */
|
||||
// Align the next address to the minUniformBufferOffsetAlignment
|
||||
VkDeviceSize alignment = rendererData->physicalDeviceProperties.limits.minUniformBufferOffsetAlignment;
|
||||
SDL_assert(rendererData->currentConstantBufferOffset >= 0 );
|
||||
rendererData->currentConstantBufferOffset += (int32_t)(sizeof(PixelShaderConstants) + alignment - 1) & ~(alignment - 1);
|
||||
constantBufferOffset = rendererData->currentConstantBufferOffset;
|
||||
}
|
||||
|
||||
/* If we have run out of size in this constant buffer, create another if needed */
|
||||
// If we have run out of size in this constant buffer, create another if needed
|
||||
if (rendererData->currentConstantBufferOffset >= SDL_VULKAN_CONSTANT_BUFFER_DEFAULT_SIZE) {
|
||||
uint32_t newConstantBufferIndex = (rendererData->currentConstantBufferIndex + 1);
|
||||
/* We need a new constant buffer */
|
||||
// We need a new constant buffer
|
||||
if (newConstantBufferIndex >= rendererData->numConstantBuffers[rendererData->currentCommandBufferIndex]) {
|
||||
VULKAN_Buffer newConstantBuffer;
|
||||
VkResult result = VULKAN_AllocateBuffer(rendererData,
|
||||
@@ -3608,19 +3608,19 @@ static SDL_bool VULKAN_SetDrawState(SDL_Renderer *renderer, const SDL_RenderComm
|
||||
|
||||
SDL_memcpy(&rendererData->currentPipelineState->shader_constants, shader_constants, sizeof(*shader_constants));
|
||||
|
||||
/* Upload constants to persistently mapped buffer */
|
||||
// Upload constants to persistently mapped buffer
|
||||
uint8_t *dst = (uint8_t *)rendererData->constantBuffers[rendererData->currentCommandBufferIndex][rendererData->currentConstantBufferIndex].mappedBufferPtr;
|
||||
dst += constantBufferOffset;
|
||||
SDL_memcpy(dst, &rendererData->currentPipelineState->shader_constants, sizeof(PixelShaderConstants));
|
||||
}
|
||||
|
||||
/* Allocate/update descriptor set with the bindings */
|
||||
// Allocate/update descriptor set with the bindings
|
||||
descriptorSet = VULKAN_AllocateDescriptorSet(renderer, shader, descriptorSetLayout, sampler, constantBuffer, constantBufferOffset, imageView);
|
||||
if (descriptorSet == VK_NULL_HANDLE) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
/* Bind the descriptor set with the sampler/UBO/image views */
|
||||
// Bind the descriptor set with the sampler/UBO/image views
|
||||
vkCmdBindDescriptorSets(rendererData->currentCommandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, rendererData->currentPipelineState->pipelineLayout,
|
||||
0, 1, &descriptorSet, 0, NULL);
|
||||
|
||||
@@ -3728,7 +3728,7 @@ static int VULKAN_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd
|
||||
switch (cmd->command) {
|
||||
case SDL_RENDERCMD_SETDRAWCOLOR:
|
||||
{
|
||||
break; /* this isn't currently used in this render backend. */
|
||||
break; // this isn't currently used in this render backend.
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_SETVIEWPORT:
|
||||
@@ -3801,13 +3801,13 @@ static int VULKAN_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_FILL_RECTS: /* unused */
|
||||
case SDL_RENDERCMD_FILL_RECTS: // unused
|
||||
break;
|
||||
|
||||
case SDL_RENDERCMD_COPY: /* unused */
|
||||
case SDL_RENDERCMD_COPY: // unused
|
||||
break;
|
||||
|
||||
case SDL_RENDERCMD_COPY_EX: /* unused */
|
||||
case SDL_RENDERCMD_COPY_EX: // unused
|
||||
break;
|
||||
|
||||
case SDL_RENDERCMD_GEOMETRY:
|
||||
@@ -3850,7 +3850,7 @@ static SDL_Surface* VULKAN_RenderReadPixels(SDL_Renderer *renderer, const SDL_Re
|
||||
|
||||
VULKAN_EnsureCommandBuffer(rendererData);
|
||||
|
||||
/* Stop any outstanding renderpass if open */
|
||||
// Stop any outstanding renderpass if open
|
||||
if (rendererData->currentRenderPass != VK_NULL_HANDLE) {
|
||||
vkCmdEndRenderPass(rendererData->currentCommandBuffer);
|
||||
rendererData->currentRenderPass = VK_NULL_HANDLE;
|
||||
@@ -3880,7 +3880,7 @@ static SDL_Surface* VULKAN_RenderReadPixels(SDL_Renderer *renderer, const SDL_Re
|
||||
}
|
||||
|
||||
|
||||
/* Make sure the source is in the correct resource state */
|
||||
// Make sure the source is in the correct resource state
|
||||
VULKAN_RecordPipelineImageBarrier(rendererData,
|
||||
VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_TRANSFER_READ_BIT | VK_ACCESS_TRANSFER_WRITE_BIT,
|
||||
VK_ACCESS_TRANSFER_READ_BIT,
|
||||
@@ -3890,7 +3890,7 @@ static SDL_Surface* VULKAN_RenderReadPixels(SDL_Renderer *renderer, const SDL_Re
|
||||
backBuffer,
|
||||
imageLayout);
|
||||
|
||||
/* Copy the image to the readback buffer */
|
||||
// Copy the image to the readback buffer
|
||||
VkBufferImageCopy region;
|
||||
region.bufferOffset = 0;
|
||||
region.bufferRowLength = 0;
|
||||
@@ -3907,10 +3907,10 @@ static SDL_Surface* VULKAN_RenderReadPixels(SDL_Renderer *renderer, const SDL_Re
|
||||
region.imageExtent.depth = 1;
|
||||
vkCmdCopyImageToBuffer(rendererData->currentCommandBuffer, backBuffer, *imageLayout, readbackBuffer.buffer, 1, ®ion);
|
||||
|
||||
/* We need to issue the command list for the copy to finish */
|
||||
// We need to issue the command list for the copy to finish
|
||||
VULKAN_IssueBatch(rendererData);
|
||||
|
||||
/* Transition the render target back to a render target */
|
||||
// Transition the render target back to a render target
|
||||
VULKAN_RecordPipelineImageBarrier(rendererData,
|
||||
VK_ACCESS_TRANSFER_WRITE_BIT,
|
||||
VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_TRANSFER_READ_BIT | VK_ACCESS_TRANSFER_WRITE_BIT,
|
||||
@@ -3938,7 +3938,7 @@ static int VULKAN_AddVulkanRenderSemaphores(SDL_Renderer *renderer, Uint32 wait_
|
||||
|
||||
if (wait_semaphore) {
|
||||
if (rendererData->waitRenderSemaphoreCount == rendererData->waitRenderSemaphoreMax) {
|
||||
/* Allocate an additional one at the end for the normal present wait */
|
||||
// Allocate an additional one at the end for the normal present wait
|
||||
VkPipelineStageFlags *waitDestStageMasks = (VkPipelineStageFlags *)SDL_realloc(rendererData->waitDestStageMasks, (rendererData->waitRenderSemaphoreMax + 2) * sizeof(*waitDestStageMasks));
|
||||
if (!waitDestStageMasks) {
|
||||
return -1;
|
||||
@@ -3959,7 +3959,7 @@ static int VULKAN_AddVulkanRenderSemaphores(SDL_Renderer *renderer, Uint32 wait_
|
||||
|
||||
if (signal_semaphore) {
|
||||
if (rendererData->signalRenderSemaphoreCount == rendererData->signalRenderSemaphoreMax) {
|
||||
/* Allocate an additional one at the end for the normal present signal */
|
||||
// Allocate an additional one at the end for the normal present signal
|
||||
VkSemaphore *semaphores = (VkSemaphore *)SDL_realloc(rendererData->signalRenderSemaphores, (rendererData->signalRenderSemaphoreMax + 2) * sizeof(*semaphores));
|
||||
if (!semaphores) {
|
||||
return -1;
|
||||
@@ -4053,7 +4053,7 @@ static int VULKAN_RenderPresent(SDL_Renderer *renderer)
|
||||
|
||||
rendererData->currentCommandBufferIndex = ( rendererData->currentCommandBufferIndex + 1 ) % rendererData->swapchainImageCount;
|
||||
|
||||
/* Wait for previous time this command buffer was submitted, will be N frames ago */
|
||||
// Wait for previous time this command buffer was submitted, will be N frames ago
|
||||
result = vkWaitForFences(rendererData->device, 1, &rendererData->fences[rendererData->currentCommandBufferIndex], VK_TRUE, UINT64_MAX);
|
||||
if (result != VK_SUCCESS) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_RENDER, "vkWaitForFences(): %s\n", SDL_Vulkan_GetResultString(result));
|
||||
@@ -4074,7 +4074,7 @@ static int VULKAN_SetVSync(SDL_Renderer *renderer, const int vsync)
|
||||
case -1:
|
||||
case 0:
|
||||
case 1:
|
||||
/* Supported */
|
||||
// Supported
|
||||
break;
|
||||
default:
|
||||
return SDL_Unsupported();
|
||||
@@ -4124,7 +4124,7 @@ static int VULKAN_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL
|
||||
renderer->QueueSetViewport = VULKAN_QueueNoOp;
|
||||
renderer->QueueSetDrawColor = VULKAN_QueueNoOp;
|
||||
renderer->QueueDrawPoints = VULKAN_QueueDrawPoints;
|
||||
renderer->QueueDrawLines = VULKAN_QueueDrawPoints; /* lines and points queue vertices the same way. */
|
||||
renderer->QueueDrawLines = VULKAN_QueueDrawPoints; // lines and points queue vertices the same way.
|
||||
renderer->QueueGeometry = VULKAN_QueueGeometry;
|
||||
renderer->InvalidateCachedState = VULKAN_InvalidateCachedState;
|
||||
renderer->RunCommandQueue = VULKAN_RunCommandQueue;
|
||||
@@ -4149,7 +4149,7 @@ static int VULKAN_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL
|
||||
*/
|
||||
renderer->window = window;
|
||||
|
||||
/* Initialize Vulkan resources */
|
||||
// Initialize Vulkan resources
|
||||
if (VULKAN_CreateDeviceResources(renderer, create_props) != VK_SUCCESS) {
|
||||
return -1;
|
||||
} else if (VULKAN_CreateWindowSizeDependentResources(renderer) != VK_SUCCESS) {
|
||||
@@ -4173,4 +4173,4 @@ SDL_RenderDriver VULKAN_RenderDriver = {
|
||||
VULKAN_CreateRenderer, "vulkan"
|
||||
};
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_VULKAN */
|
||||
#endif // SDL_VIDEO_RENDER_VULKAN
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
#include "SDL_shaders_vulkan.h"
|
||||
|
||||
/* The shaders here were compiled with compile_shaders.bat */
|
||||
// The shaders here were compiled with compile_shaders.bat
|
||||
#include "VULKAN_PixelShader_Colors.h"
|
||||
#include "VULKAN_PixelShader_Textures.h"
|
||||
#include "VULKAN_PixelShader_Advanced.h"
|
||||
@@ -57,4 +57,4 @@ void VULKAN_GetPixelShader(VULKAN_Shader shader, const uint32_t **outBytecode, s
|
||||
*outSize = VULKAN_shaders[shader].ps_shader_size;
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_VULKAN */
|
||||
#endif // SDL_VIDEO_RENDER_VULKAN
|
||||
@@ -20,9 +20,9 @@
|
||||
*/
|
||||
#include "SDL_internal.h"
|
||||
|
||||
/* Vulkan shader implementation */
|
||||
// Vulkan shader implementation
|
||||
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
// Set up for C function definitions, even when using C++
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@@ -38,7 +38,7 @@ typedef enum
|
||||
extern void VULKAN_GetVertexShader(VULKAN_Shader shader, const uint32_t **outBytecode, size_t *outSize);
|
||||
extern void VULKAN_GetPixelShader(VULKAN_Shader shader, const uint32_t **outBytecode, size_t *outSize);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
// Ends C function definitions when using C++
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -5,7 +5,7 @@ struct VertexShaderConstants
|
||||
matrix model;
|
||||
matrix projectionAndView;
|
||||
};
|
||||
[[vk::push_constant]]
|
||||
[[vk::push_constant]]
|
||||
ConstantBuffer<VertexShaderConstants> pushConstants;
|
||||
|
||||
struct VertexShaderInput
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
glslangValidator -D --sep main -e main -S frag --target-env vulkan1.0 --auto-sampled-textures --vn VULKAN_PixelShader_Colors -o VULKAN_PixelShader_Colors.h VULKAN_PixelShader_Colors.hlsl
|
||||
glslangValidator -D --sep main -e main -S frag --target-env vulkan1.0 --auto-sampled-textures --vn VULKAN_PixelShader_Textures -o VULKAN_PixelShader_Textures.h VULKAN_PixelShader_Textures.hlsl
|
||||
glslangValidator -D --sep main -e main -S frag --target-env vulkan1.0 --auto-sampled-textures --vn VULKAN_PixelShader_Advanced -o VULKAN_PixelShader_Advanced.h VULKAN_PixelShader_Advanced.hlsl
|
||||
glslangValidator -D --sep main -e main -S frag --target-env vulkan1.0 --auto-sampled-textures --vn VULKAN_PixelShader_Colors -o VULKAN_PixelShader_Colors.h VULKAN_PixelShader_Colors.hlsl
|
||||
glslangValidator -D --sep main -e main -S frag --target-env vulkan1.0 --auto-sampled-textures --vn VULKAN_PixelShader_Textures -o VULKAN_PixelShader_Textures.h VULKAN_PixelShader_Textures.hlsl
|
||||
glslangValidator -D --sep main -e main -S frag --target-env vulkan1.0 --auto-sampled-textures --vn VULKAN_PixelShader_Advanced -o VULKAN_PixelShader_Advanced.h VULKAN_PixelShader_Advanced.hlsl
|
||||
|
||||
glslangValidator -D --sep mainColor -e main -S vert --iy --target-env vulkan1.0 --vn VULKAN_VertexShader -o VULKAN_VertexShader.h VULKAN_VertexShader.hlsl
|
||||
glslangValidator -D --sep mainColor -e main -S vert --iy --target-env vulkan1.0 --vn VULKAN_VertexShader -o VULKAN_VertexShader.h VULKAN_VertexShader.hlsl
|
||||
Reference in new issue
Block a user