mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-05-14 09:26:57 +00:00
Use SDL_bool instead an int return code in the SDL API
Most SDL functions used to indicate success or failure using an int return code. These functions have been changed to return SDL_bool. Here is a coccinelle patch to change code that previously compared the return value to 0 and changes it to a boolean test: @ bool_return_type @ identifier func =~ "^(SDL_AddEventWatch|SDL_AddHintCallback|SDL_AddSurfaceAlternateImage|SDL_AddVulkanRenderSemaphores|SDL_BindAudioStream|SDL_BindAudioStreams|SDL_BlitSurface|SDL_BlitSurface9Grid|SDL_BlitSurfaceScaled|SDL_BlitSurfaceTiled|SDL_BlitSurfaceTiledWithScale|SDL_BlitSurfaceUnchecked|SDL_BlitSurfaceUncheckedScaled|SDL_CaptureMouse|SDL_ClearAudioStream|SDL_ClearClipboardData|SDL_ClearComposition|SDL_ClearError|SDL_ClearProperty|SDL_ClearSurface|SDL_CloseIO|SDL_CloseStorage|SDL_ConvertAudioSamples|SDL_ConvertEventToRenderCoordinates|SDL_ConvertPixels|SDL_ConvertPixelsAndColorspace|SDL_CopyFile|SDL_CopyProperties|SDL_CopyStorageFile|SDL_CreateDirectory|SDL_CreateStorageDirectory|SDL_CreateWindowAndRenderer|SDL_DateTimeToTime|SDL_DestroyWindowSurface|SDL_DetachVirtualJoystick|SDL_DisableScreenSaver|SDL_EnableScreenSaver|SDL_EnumerateDirectory|SDL_EnumerateProperties|SDL_EnumerateStorageDirectory|SDL_FillSurfaceRect|SDL_FillSurfaceRects|SDL_FlashWindow|SDL_FlipSurface|SDL_FlushAudioStream|SDL_FlushRenderer|SDL_GL_DestroyContext|SDL_GL_GetAttribute|SDL_GL_GetSwapInterval|SDL_GL_LoadLibrary|SDL_GL_MakeCurrent|SDL_GL_SetAttribute|SDL_GL_SetSwapInterval|SDL_GL_SwapWindow|SDL_GetAudioDeviceFormat|SDL_GetAudioStreamFormat|SDL_GetCameraFormat|SDL_GetClosestFullscreenDisplayMode|SDL_GetCurrentRenderOutputSize|SDL_GetCurrentTime|SDL_GetDXGIOutputInfo|SDL_GetDateTimeLocalePreferences|SDL_GetDisplayBounds|SDL_GetDisplayUsableBounds|SDL_GetGDKDefaultUser|SDL_GetGDKTaskQueue|SDL_GetGamepadSensorData|SDL_GetGamepadTouchpadFinger|SDL_GetHapticEffectStatus|SDL_GetJoystickBall|SDL_GetMasksForPixelFormat|SDL_GetPathInfo|SDL_GetRectUnion|SDL_GetRectUnionFloat|SDL_GetRenderClipRect|SDL_GetRenderColorScale|SDL_GetRenderDrawBlendMode|SDL_GetRenderDrawColor|SDL_GetRenderDrawColorFloat|SDL_GetRenderLogicalPresentation|SDL_GetRenderLogicalPresentationRect|SDL_GetRenderOutputSize|SDL_GetRenderSafeArea|SDL_GetRenderScale|SDL_GetRenderVSync|SDL_GetRenderViewport|SDL_GetSensorData|SDL_GetStorageFileSize|SDL_GetStoragePathInfo|SDL_GetSurfaceAlphaMod|SDL_GetSurfaceBlendMode|SDL_GetSurfaceClipRect|SDL_GetSurfaceColorKey|SDL_GetSurfaceColorMod|SDL_GetTextInputArea|SDL_GetTextureAlphaMod|SDL_GetTextureAlphaModFloat|SDL_GetTextureBlendMode|SDL_GetTextureColorMod|SDL_GetTextureColorModFloat|SDL_GetTextureScaleMode|SDL_GetTextureSize|SDL_GetWindowAspectRatio|SDL_GetWindowBordersSize|SDL_GetWindowMaximumSize|SDL_GetWindowMinimumSize|SDL_GetWindowPosition|SDL_GetWindowRelativeMouseMode|SDL_GetWindowSafeArea|SDL_GetWindowSize|SDL_GetWindowSizeInPixels|SDL_GetWindowSurfaceVSync|SDL_HideCursor|SDL_HideWindow|SDL_Init|SDL_InitHapticRumble|SDL_InitSubSystem|SDL_LoadWAV|SDL_LoadWAV_IO|SDL_LockAudioStream|SDL_LockProperties|SDL_LockSurface|SDL_LockTexture|SDL_LockTextureToSurface|SDL_MaximizeWindow|SDL_MinimizeWindow|SDL_MixAudio|SDL_OpenURL|SDL_OutOfMemory|SDL_PauseAudioDevice|SDL_PauseAudioStreamDevice|SDL_PauseHaptic|SDL_PlayHapticRumble|SDL_PremultiplyAlpha|SDL_PremultiplySurfaceAlpha|SDL_PushEvent|SDL_PutAudioStreamData|SDL_RaiseWindow|SDL_ReadStorageFile|SDL_ReadSurfacePixel|SDL_ReadSurfacePixelFloat|SDL_RegisterApp|SDL_ReloadGamepadMappings|SDL_RemovePath|SDL_RemoveStoragePath|SDL_RemoveTimer|SDL_RenamePath|SDL_RenameStoragePath|SDL_RenderClear|SDL_RenderCoordinatesFromWindow|SDL_RenderCoordinatesToWindow|SDL_RenderFillRect|SDL_RenderFillRects|SDL_RenderGeometry|SDL_RenderGeometryRaw|SDL_RenderLine|SDL_RenderLines|SDL_RenderPoint|SDL_RenderPoints|SDL_RenderPresent|SDL_RenderRect|SDL_RenderRects|SDL_RenderTexture|SDL_RenderTexture9Grid|SDL_RenderTextureRotated|SDL_RenderTextureTiled|SDL_RequestAndroidPermission|SDL_RestoreWindow|SDL_ResumeAudioDevice|SDL_ResumeAudioStreamDevice|SDL_ResumeHaptic|SDL_RumbleGamepad|SDL_RumbleGamepadTriggers|SDL_RumbleJoystick|SDL_RumbleJoystickTriggers|SDL_RunHapticEffect|SDL_SaveBMP|SDL_SaveBMP_IO|SDL_SendAndroidMessage|SDL_SendGamepadEffect|SDL_SendJoystickEffect|SDL_SendJoystickVirtualSensorData|SDL_SetAppMetadata|SDL_SetAppMetadataProperty|SDL_SetAudioDeviceGain|SDL_SetAudioPostmixCallback|SDL_SetAudioStreamFormat|SDL_SetAudioStreamFrequencyRatio|SDL_SetAudioStreamGain|SDL_SetAudioStreamGetCallback|SDL_SetAudioStreamInputChannelMap|SDL_SetAudioStreamOutputChannelMap|SDL_SetAudioStreamPutCallback|SDL_SetBooleanProperty|SDL_SetClipboardData|SDL_SetClipboardText|SDL_SetCursor|SDL_SetFloatProperty|SDL_SetGamepadLED|SDL_SetGamepadMapping|SDL_SetGamepadPlayerIndex|SDL_SetGamepadSensorEnabled|SDL_SetHapticAutocenter|SDL_SetHapticGain|SDL_SetJoystickLED|SDL_SetJoystickPlayerIndex|SDL_SetJoystickVirtualAxis|SDL_SetJoystickVirtualBall|SDL_SetJoystickVirtualButton|SDL_SetJoystickVirtualHat|SDL_SetJoystickVirtualTouchpad|SDL_SetLinuxThreadPriority|SDL_SetLinuxThreadPriorityAndPolicy|SDL_SetLogPriorityPrefix|SDL_SetMemoryFunctions|SDL_SetNumberProperty|SDL_SetPaletteColors|SDL_SetPointerProperty|SDL_SetPointerPropertyWithCleanup|SDL_SetPrimarySelectionText|SDL_SetRenderClipRect|SDL_SetRenderColorScale|SDL_SetRenderDrawBlendMode|SDL_SetRenderDrawColor|SDL_SetRenderDrawColorFloat|SDL_SetRenderLogicalPresentation|SDL_SetRenderScale|SDL_SetRenderTarget|SDL_SetRenderVSync|SDL_SetRenderViewport|SDL_SetScancodeName|SDL_SetStringProperty|SDL_SetSurfaceAlphaMod|SDL_SetSurfaceBlendMode|SDL_SetSurfaceColorKey|SDL_SetSurfaceColorMod|SDL_SetSurfaceColorspace|SDL_SetSurfacePalette|SDL_SetSurfaceRLE|SDL_SetTLS|SDL_SetTextInputArea|SDL_SetTextureAlphaMod|SDL_SetTextureAlphaModFloat|SDL_SetTextureBlendMode|SDL_SetTextureColorMod|SDL_SetTextureColorModFloat|SDL_SetTextureScaleMode|SDL_SetThreadPriority|SDL_SetWindowAlwaysOnTop|SDL_SetWindowAspectRatio|SDL_SetWindowBordered|SDL_SetWindowFocusable|SDL_SetWindowFullscreen|SDL_SetWindowFullscreenMode|SDL_SetWindowHitTest|SDL_SetWindowIcon|SDL_SetWindowKeyboardGrab|SDL_SetWindowMaximumSize|SDL_SetWindowMinimumSize|SDL_SetWindowModalFor|SDL_SetWindowMouseGrab|SDL_SetWindowMouseRect|SDL_SetWindowOpacity|SDL_SetWindowPosition|SDL_SetWindowRelativeMouseMode|SDL_SetWindowResizable|SDL_SetWindowShape|SDL_SetWindowSize|SDL_SetWindowSurfaceVSync|SDL_SetWindowTitle|SDL_SetiOSAnimationCallback|SDL_ShowAndroidToast|SDL_ShowCursor|SDL_ShowMessageBox|SDL_ShowSimpleMessageBox|SDL_ShowWindow|SDL_ShowWindowSystemMenu|SDL_StartTextInput|SDL_StartTextInputWithProperties|SDL_StopHapticEffect|SDL_StopHapticEffects|SDL_StopHapticRumble|SDL_StopTextInput|SDL_SyncWindow|SDL_TimeToDateTime|SDL_TryLockMutex|SDL_TryLockRWLockForReading|SDL_TryLockRWLockForWriting|SDL_TryWaitSemaphore|SDL_UnlockAudioStream|SDL_UpdateHapticEffect|SDL_UpdateNVTexture|SDL_UpdateTexture|SDL_UpdateWindowSurface|SDL_UpdateWindowSurfaceRects|SDL_UpdateYUVTexture|SDL_Vulkan_CreateSurface|SDL_Vulkan_LoadLibrary|SDL_WaitConditionTimeout|SDL_WaitSemaphoreTimeout|SDL_WarpMouseGlobal|SDL_WriteStorageFile|SDL_WriteSurfacePixel|SDL_WriteSurfacePixelFloat)$"; @@ ( func( ... ) - == 0 | - func( + !func( ... ) - < 0 | - func( + !func( ... ) - != 0 | - func( + !func( ... ) - == -1 )
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -168,60 +168,60 @@ typedef enum
|
||||
struct SDL_Renderer
|
||||
{
|
||||
void (*WindowEvent)(SDL_Renderer *renderer, const SDL_WindowEvent *event);
|
||||
int (*GetOutputSize)(SDL_Renderer *renderer, int *w, int *h);
|
||||
bool (*GetOutputSize)(SDL_Renderer *renderer, int *w, int *h);
|
||||
bool (*SupportsBlendMode)(SDL_Renderer *renderer, SDL_BlendMode blendMode);
|
||||
int (*CreateTexture)(SDL_Renderer *renderer, SDL_Texture *texture, SDL_PropertiesID create_props);
|
||||
int (*QueueSetViewport)(SDL_Renderer *renderer, SDL_RenderCommand *cmd);
|
||||
int (*QueueSetDrawColor)(SDL_Renderer *renderer, SDL_RenderCommand *cmd);
|
||||
int (*QueueDrawPoints)(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points,
|
||||
bool (*CreateTexture)(SDL_Renderer *renderer, SDL_Texture *texture, SDL_PropertiesID create_props);
|
||||
bool (*QueueSetViewport)(SDL_Renderer *renderer, SDL_RenderCommand *cmd);
|
||||
bool (*QueueSetDrawColor)(SDL_Renderer *renderer, SDL_RenderCommand *cmd);
|
||||
bool (*QueueDrawPoints)(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points,
|
||||
int count);
|
||||
int (*QueueDrawLines)(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points,
|
||||
bool (*QueueDrawLines)(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points,
|
||||
int count);
|
||||
int (*QueueFillRects)(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FRect *rects,
|
||||
bool (*QueueFillRects)(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FRect *rects,
|
||||
int count);
|
||||
int (*QueueCopy)(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
|
||||
bool (*QueueCopy)(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
|
||||
const SDL_FRect *srcrect, const SDL_FRect *dstrect);
|
||||
int (*QueueCopyEx)(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
|
||||
bool (*QueueCopyEx)(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
|
||||
const SDL_FRect *srcquad, const SDL_FRect *dstrect,
|
||||
const double angle, const SDL_FPoint *center, const SDL_FlipMode flip, float scale_x, float scale_y);
|
||||
int (*QueueGeometry)(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
|
||||
bool (*QueueGeometry)(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
|
||||
const float *xy, int xy_stride, const SDL_FColor *color, int color_stride, const float *uv, int uv_stride,
|
||||
int num_vertices, const void *indices, int num_indices, int size_indices,
|
||||
float scale_x, float scale_y);
|
||||
|
||||
void (*InvalidateCachedState)(SDL_Renderer *renderer);
|
||||
int (*RunCommandQueue)(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize);
|
||||
int (*UpdateTexture)(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
bool (*RunCommandQueue)(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize);
|
||||
bool (*UpdateTexture)(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect, const void *pixels,
|
||||
int pitch);
|
||||
#if SDL_HAVE_YUV
|
||||
int (*UpdateTextureYUV)(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
bool (*UpdateTextureYUV)(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *Uplane, int Upitch,
|
||||
const Uint8 *Vplane, int Vpitch);
|
||||
int (*UpdateTextureNV)(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
bool (*UpdateTextureNV)(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *UVplane, int UVpitch);
|
||||
#endif
|
||||
int (*LockTexture)(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
bool (*LockTexture)(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect, void **pixels, int *pitch);
|
||||
void (*UnlockTexture)(SDL_Renderer *renderer, SDL_Texture *texture);
|
||||
void (*SetTextureScaleMode)(SDL_Renderer *renderer, SDL_Texture *texture, SDL_ScaleMode scaleMode);
|
||||
int (*SetRenderTarget)(SDL_Renderer *renderer, SDL_Texture *texture);
|
||||
bool (*SetRenderTarget)(SDL_Renderer *renderer, SDL_Texture *texture);
|
||||
SDL_Surface *(*RenderReadPixels)(SDL_Renderer *renderer, const SDL_Rect *rect);
|
||||
int (*RenderPresent)(SDL_Renderer *renderer);
|
||||
bool (*RenderPresent)(SDL_Renderer *renderer);
|
||||
void (*DestroyTexture)(SDL_Renderer *renderer, SDL_Texture *texture);
|
||||
|
||||
void (*DestroyRenderer)(SDL_Renderer *renderer);
|
||||
|
||||
int (*SetVSync)(SDL_Renderer *renderer, int vsync);
|
||||
bool (*SetVSync)(SDL_Renderer *renderer, int vsync);
|
||||
|
||||
void *(*GetMetalLayer)(SDL_Renderer *renderer);
|
||||
void *(*GetMetalCommandEncoder)(SDL_Renderer *renderer);
|
||||
|
||||
int (*AddVulkanRenderSemaphores)(SDL_Renderer *renderer, Uint32 wait_stage_mask, Sint64 wait_semaphore, Sint64 signal_semaphore);
|
||||
bool (*AddVulkanRenderSemaphores)(SDL_Renderer *renderer, Uint32 wait_stage_mask, Sint64 wait_semaphore, Sint64 signal_semaphore);
|
||||
|
||||
// The current renderer info
|
||||
const char *name;
|
||||
@@ -307,7 +307,7 @@ struct SDL_Renderer
|
||||
// Define the SDL render driver structure
|
||||
struct SDL_RenderDriver
|
||||
{
|
||||
int (*CreateRenderer)(SDL_Renderer *renderer, SDL_Window *window, SDL_PropertiesID props);
|
||||
bool (*CreateRenderer)(SDL_Renderer *renderer, SDL_Window *window, SDL_PropertiesID props);
|
||||
|
||||
const char *name;
|
||||
};
|
||||
@@ -329,7 +329,7 @@ extern SDL_RenderDriver VITA_GXM_RenderDriver;
|
||||
extern void SDL_QuitRender(void);
|
||||
|
||||
// Add a supported texture format to a renderer
|
||||
extern int SDL_AddSupportedTextureFormat(SDL_Renderer *renderer, SDL_PixelFormat format);
|
||||
extern bool SDL_AddSupportedTextureFormat(SDL_Renderer *renderer, SDL_PixelFormat format);
|
||||
|
||||
// Setup colorspace conversion
|
||||
extern void SDL_SetupRendererColorspace(SDL_Renderer *renderer, SDL_PropertiesID props);
|
||||
|
||||
@@ -57,7 +57,7 @@ SDL_SW_YUVTexture *SDL_SW_CreateYUVTexture(SDL_PixelFormat format, int w, int h)
|
||||
swdata->h = h;
|
||||
{
|
||||
size_t dst_size;
|
||||
if (SDL_CalculateYUVSize(format, w, h, &dst_size, NULL) < 0) {
|
||||
if (!SDL_CalculateYUVSize(format, w, h, &dst_size, NULL)) {
|
||||
SDL_SW_DestroyYUVTexture(swdata);
|
||||
return NULL;
|
||||
}
|
||||
@@ -103,15 +103,15 @@ SDL_SW_YUVTexture *SDL_SW_CreateYUVTexture(SDL_PixelFormat format, int w, int h)
|
||||
return swdata;
|
||||
}
|
||||
|
||||
int SDL_SW_QueryYUVTexturePixels(SDL_SW_YUVTexture *swdata, void **pixels,
|
||||
bool SDL_SW_QueryYUVTexturePixels(SDL_SW_YUVTexture *swdata, void **pixels,
|
||||
int *pitch)
|
||||
{
|
||||
*pixels = swdata->planes[0];
|
||||
*pitch = swdata->pitches[0];
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
int SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect,
|
||||
bool SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect,
|
||||
const void *pixels, int pitch)
|
||||
{
|
||||
switch (swdata->format) {
|
||||
@@ -216,10 +216,10 @@ int SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect,
|
||||
default:
|
||||
return SDL_SetError("Unsupported YUV format");
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
int SDL_SW_UpdateYUVTexturePlanar(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect,
|
||||
bool SDL_SW_UpdateYUVTexturePlanar(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *Uplane, int Upitch,
|
||||
const Uint8 *Vplane, int Vpitch)
|
||||
@@ -270,10 +270,10 @@ int SDL_SW_UpdateYUVTexturePlanar(SDL_SW_YUVTexture *swdata, const SDL_Rect *rec
|
||||
src += Vpitch;
|
||||
dst += (swdata->w + 1) / 2;
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
int SDL_SW_UpdateNVTexturePlanar(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect,
|
||||
bool SDL_SW_UpdateNVTexturePlanar(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *UVplane, int UVpitch)
|
||||
{
|
||||
@@ -304,10 +304,10 @@ int SDL_SW_UpdateNVTexturePlanar(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect
|
||||
dst += 2 * ((swdata->w + 1) / 2);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
int SDL_SW_LockYUVTexture(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect,
|
||||
bool SDL_SW_LockYUVTexture(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect,
|
||||
void **pixels, int *pitch)
|
||||
{
|
||||
switch (swdata->format) {
|
||||
@@ -329,16 +329,14 @@ int SDL_SW_LockYUVTexture(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect,
|
||||
*pixels = swdata->planes[0];
|
||||
}
|
||||
*pitch = swdata->pitches[0];
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
void SDL_SW_UnlockYUVTexture(SDL_SW_YUVTexture *swdata)
|
||||
{
|
||||
}
|
||||
|
||||
int SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture *swdata, const SDL_Rect *srcrect,
|
||||
SDL_PixelFormat target_format, int w, int h, void *pixels,
|
||||
int pitch)
|
||||
bool SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture *swdata, const SDL_Rect *srcrect, SDL_PixelFormat target_format, int w, int h, void *pixels, int pitch)
|
||||
{
|
||||
int stretch;
|
||||
|
||||
@@ -368,28 +366,27 @@ int SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture *swdata, const SDL_Rect *srcrect,
|
||||
} else {
|
||||
swdata->display = SDL_CreateSurfaceFrom(w, h, target_format, pixels, pitch);
|
||||
if (!swdata->display) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!swdata->stretch) {
|
||||
swdata->stretch = SDL_CreateSurface(swdata->w, swdata->h, target_format);
|
||||
if (!swdata->stretch) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
pixels = swdata->stretch->pixels;
|
||||
pitch = swdata->stretch->pitch;
|
||||
}
|
||||
if (SDL_ConvertPixels(swdata->w, swdata->h, swdata->format,
|
||||
swdata->planes[0], swdata->pitches[0],
|
||||
target_format, pixels, pitch) < 0) {
|
||||
return -1;
|
||||
if (!SDL_ConvertPixels(swdata->w, swdata->h, swdata->format, swdata->planes[0], swdata->pitches[0], target_format, pixels, pitch)) {
|
||||
return false;
|
||||
}
|
||||
if (stretch) {
|
||||
SDL_Rect rect = *srcrect;
|
||||
SDL_SoftStretch(swdata->stretch, &rect, swdata->display, NULL, SDL_SCALEMODE_NEAREST);
|
||||
return SDL_SoftStretch(swdata->stretch, &rect, swdata->display, NULL, SDL_SCALEMODE_NEAREST);
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SDL_SW_DestroyYUVTexture(SDL_SW_YUVTexture *swdata)
|
||||
|
||||
@@ -44,24 +44,19 @@ struct SDL_SW_YUVTexture
|
||||
|
||||
typedef struct SDL_SW_YUVTexture SDL_SW_YUVTexture;
|
||||
|
||||
SDL_SW_YUVTexture *SDL_SW_CreateYUVTexture(SDL_PixelFormat format, int w, int h);
|
||||
int SDL_SW_QueryYUVTexturePixels(SDL_SW_YUVTexture *swdata, void **pixels,
|
||||
int *pitch);
|
||||
int SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect,
|
||||
const void *pixels, int pitch);
|
||||
int SDL_SW_UpdateYUVTexturePlanar(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *Uplane, int Upitch,
|
||||
const Uint8 *Vplane, int Vpitch);
|
||||
int SDL_SW_UpdateNVTexturePlanar(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *UVplane, int UVpitch);
|
||||
int SDL_SW_LockYUVTexture(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect,
|
||||
void **pixels, int *pitch);
|
||||
void SDL_SW_UnlockYUVTexture(SDL_SW_YUVTexture *swdata);
|
||||
int SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture *swdata, const SDL_Rect *srcrect,
|
||||
SDL_PixelFormat target_format, int w, int h, void *pixels,
|
||||
int pitch);
|
||||
void SDL_SW_DestroyYUVTexture(SDL_SW_YUVTexture *swdata);
|
||||
extern SDL_SW_YUVTexture *SDL_SW_CreateYUVTexture(SDL_PixelFormat format, int w, int h);
|
||||
extern bool SDL_SW_QueryYUVTexturePixels(SDL_SW_YUVTexture *swdata, void **pixels, int *pitch);
|
||||
extern bool SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect, const void *pixels, int pitch);
|
||||
extern bool SDL_SW_UpdateYUVTexturePlanar(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *Uplane, int Upitch,
|
||||
const Uint8 *Vplane, int Vpitch);
|
||||
extern bool SDL_SW_UpdateNVTexturePlanar(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *UVplane, int UVpitch);
|
||||
extern bool SDL_SW_LockYUVTexture(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect, void **pixels, int *pitch);
|
||||
extern void SDL_SW_UnlockYUVTexture(SDL_SW_YUVTexture *swdata);
|
||||
extern bool SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture *swdata, const SDL_Rect *srcrect, SDL_PixelFormat target_format, int w, int h, void *pixels, int pitch);
|
||||
extern void SDL_SW_DestroyYUVTexture(SDL_SW_YUVTexture *swdata);
|
||||
|
||||
#endif // SDL_yuv_sw_c_h_
|
||||
|
||||
@@ -113,7 +113,7 @@ typedef struct
|
||||
float u, v;
|
||||
} Vertex;
|
||||
|
||||
static int D3D_SetError(const char *prefix, HRESULT result)
|
||||
static bool D3D_SetError(const char *prefix, HRESULT result)
|
||||
{
|
||||
const char *error;
|
||||
|
||||
@@ -285,9 +285,9 @@ static void D3D_InitRenderState(D3D_RenderData *data)
|
||||
data->beginScene = true;
|
||||
}
|
||||
|
||||
static int D3D_Reset(SDL_Renderer *renderer);
|
||||
static bool D3D_Reset(SDL_Renderer *renderer);
|
||||
|
||||
static int D3D_ActivateRenderer(SDL_Renderer *renderer)
|
||||
static bool D3D_ActivateRenderer(SDL_Renderer *renderer)
|
||||
{
|
||||
D3D_RenderData *data = (D3D_RenderData *)renderer->internal;
|
||||
HRESULT result;
|
||||
@@ -312,8 +312,8 @@ static int D3D_ActivateRenderer(SDL_Renderer *renderer)
|
||||
data->pparams.BackBufferFormat = D3DFMT_UNKNOWN;
|
||||
data->pparams.FullScreen_RefreshRateInHz = 0;
|
||||
}
|
||||
if (D3D_Reset(renderer) < 0) {
|
||||
return -1;
|
||||
if (!D3D_Reset(renderer)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
data->updateSize = false;
|
||||
@@ -321,8 +321,8 @@ static int D3D_ActivateRenderer(SDL_Renderer *renderer)
|
||||
if (data->beginScene) {
|
||||
result = IDirect3DDevice9_BeginScene(data->device);
|
||||
if (result == D3DERR_DEVICELOST) {
|
||||
if (D3D_Reset(renderer) < 0) {
|
||||
return -1;
|
||||
if (!D3D_Reset(renderer)) {
|
||||
return false;
|
||||
}
|
||||
result = IDirect3DDevice9_BeginScene(data->device);
|
||||
}
|
||||
@@ -331,7 +331,7 @@ static int D3D_ActivateRenderer(SDL_Renderer *renderer)
|
||||
}
|
||||
data->beginScene = false;
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void D3D_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *event)
|
||||
@@ -416,7 +416,7 @@ static bool D3D_SupportsBlendMode(SDL_Renderer *renderer, SDL_BlendMode blendMod
|
||||
return true;
|
||||
}
|
||||
|
||||
static int D3D_CreateTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture, DWORD usage, Uint32 format, D3DFORMAT d3dfmt, int w, int h)
|
||||
static bool D3D_CreateTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture, DWORD usage, Uint32 format, D3DFORMAT d3dfmt, int w, int h)
|
||||
{
|
||||
HRESULT result;
|
||||
|
||||
@@ -433,10 +433,10 @@ static int D3D_CreateTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *textur
|
||||
if (FAILED(result)) {
|
||||
return D3D_SetError("CreateTexture(D3DPOOL_DEFAULT)", result);
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int D3D_CreateStagingTexture(IDirect3DDevice9 *device, D3D_TextureRep *texture)
|
||||
static bool D3D_CreateStagingTexture(IDirect3DDevice9 *device, D3D_TextureRep *texture)
|
||||
{
|
||||
HRESULT result;
|
||||
|
||||
@@ -447,10 +447,10 @@ static int D3D_CreateStagingTexture(IDirect3DDevice9 *device, D3D_TextureRep *te
|
||||
return D3D_SetError("CreateTexture(D3DPOOL_SYSTEMMEM)", result);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int D3D_RecreateTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture)
|
||||
static bool D3D_RecreateTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture)
|
||||
{
|
||||
if (texture->texture) {
|
||||
IDirect3DTexture9_Release(texture->texture);
|
||||
@@ -460,10 +460,10 @@ static int D3D_RecreateTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *text
|
||||
IDirect3DTexture9_AddDirtyRect(texture->staging, NULL);
|
||||
texture->dirty = true;
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int D3D_UpdateTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture, int x, int y, int w, int h, const void *pixels, int pitch)
|
||||
static bool D3D_UpdateTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture, int x, int y, int w, int h, const void *pixels, int pitch)
|
||||
{
|
||||
RECT d3drect;
|
||||
D3DLOCKED_RECT locked;
|
||||
@@ -472,8 +472,8 @@ static int D3D_UpdateTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *textur
|
||||
int row, length;
|
||||
HRESULT result;
|
||||
|
||||
if (D3D_CreateStagingTexture(device, texture) < 0) {
|
||||
return -1;
|
||||
if (!D3D_CreateStagingTexture(device, texture)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
d3drect.left = x;
|
||||
@@ -510,7 +510,7 @@ static int D3D_UpdateTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *textur
|
||||
}
|
||||
texture->dirty = true;
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void D3D_DestroyTextureRep(D3D_TextureRep *texture)
|
||||
@@ -525,7 +525,7 @@ static void D3D_DestroyTextureRep(D3D_TextureRep *texture)
|
||||
}
|
||||
}
|
||||
|
||||
static int D3D_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_PropertiesID create_props)
|
||||
static bool D3D_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_PropertiesID create_props)
|
||||
{
|
||||
D3D_RenderData *data = (D3D_RenderData *)renderer->internal;
|
||||
D3D_TextureData *texturedata;
|
||||
@@ -533,7 +533,7 @@ static int D3D_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_P
|
||||
|
||||
texturedata = (D3D_TextureData *)SDL_calloc(1, sizeof(*texturedata));
|
||||
if (!texturedata) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
texturedata->scaleMode = (texture->scaleMode == SDL_SCALEMODE_NEAREST) ? D3DTEXF_POINT : D3DTEXF_LINEAR;
|
||||
|
||||
@@ -545,20 +545,20 @@ static int D3D_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_P
|
||||
usage = 0;
|
||||
}
|
||||
|
||||
if (D3D_CreateTextureRep(data->device, &texturedata->texture, usage, texture->format, PixelFormatToD3DFMT(texture->format), texture->w, texture->h) < 0) {
|
||||
return -1;
|
||||
if (!D3D_CreateTextureRep(data->device, &texturedata->texture, usage, texture->format, PixelFormatToD3DFMT(texture->format), texture->w, texture->h)) {
|
||||
return false;
|
||||
}
|
||||
#if SDL_HAVE_YUV
|
||||
if (texture->format == SDL_PIXELFORMAT_YV12 ||
|
||||
texture->format == SDL_PIXELFORMAT_IYUV) {
|
||||
texturedata->yuv = true;
|
||||
|
||||
if (D3D_CreateTextureRep(data->device, &texturedata->utexture, usage, texture->format, PixelFormatToD3DFMT(texture->format), (texture->w + 1) / 2, (texture->h + 1) / 2) < 0) {
|
||||
return -1;
|
||||
if (!D3D_CreateTextureRep(data->device, &texturedata->utexture, usage, texture->format, PixelFormatToD3DFMT(texture->format), (texture->w + 1) / 2, (texture->h + 1) / 2)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (D3D_CreateTextureRep(data->device, &texturedata->vtexture, usage, texture->format, PixelFormatToD3DFMT(texture->format), (texture->w + 1) / 2, (texture->h + 1) / 2) < 0) {
|
||||
return -1;
|
||||
if (!D3D_CreateTextureRep(data->device, &texturedata->vtexture, usage, texture->format, PixelFormatToD3DFMT(texture->format), (texture->w + 1) / 2, (texture->h + 1) / 2)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
texturedata->shader = SHADER_YUV;
|
||||
@@ -568,36 +568,36 @@ static int D3D_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_P
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int D3D_RecreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
static bool D3D_RecreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
{
|
||||
D3D_RenderData *data = (D3D_RenderData *)renderer->internal;
|
||||
D3D_TextureData *texturedata = (D3D_TextureData *)texture->internal;
|
||||
|
||||
if (!texturedata) {
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (D3D_RecreateTextureRep(data->device, &texturedata->texture) < 0) {
|
||||
return -1;
|
||||
if (!D3D_RecreateTextureRep(data->device, &texturedata->texture)) {
|
||||
return false;
|
||||
}
|
||||
#if SDL_HAVE_YUV
|
||||
if (texturedata->yuv) {
|
||||
if (D3D_RecreateTextureRep(data->device, &texturedata->utexture) < 0) {
|
||||
return -1;
|
||||
if (!D3D_RecreateTextureRep(data->device, &texturedata->utexture)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (D3D_RecreateTextureRep(data->device, &texturedata->vtexture) < 0) {
|
||||
return -1;
|
||||
if (!D3D_RecreateTextureRep(data->device, &texturedata->vtexture)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int D3D_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
static bool D3D_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect, const void *pixels, int pitch)
|
||||
{
|
||||
D3D_RenderData *data = (D3D_RenderData *)renderer->internal;
|
||||
@@ -607,30 +607,30 @@ static int D3D_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
return SDL_SetError("Texture is not currently available");
|
||||
}
|
||||
|
||||
if (D3D_UpdateTextureRep(data->device, &texturedata->texture, rect->x, rect->y, rect->w, rect->h, pixels, pitch) < 0) {
|
||||
return -1;
|
||||
if (!D3D_UpdateTextureRep(data->device, &texturedata->texture, rect->x, rect->y, rect->w, rect->h, pixels, pitch)) {
|
||||
return false;
|
||||
}
|
||||
#if SDL_HAVE_YUV
|
||||
if (texturedata->yuv) {
|
||||
// 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;
|
||||
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)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 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;
|
||||
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)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
#if SDL_HAVE_YUV
|
||||
static int D3D_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
static bool D3D_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *Uplane, int Upitch,
|
||||
@@ -643,20 +643,20 @@ static int D3D_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
return SDL_SetError("Texture is not currently available");
|
||||
}
|
||||
|
||||
if (D3D_UpdateTextureRep(data->device, &texturedata->texture, rect->x, rect->y, rect->w, rect->h, Yplane, Ypitch) < 0) {
|
||||
return -1;
|
||||
if (!D3D_UpdateTextureRep(data->device, &texturedata->texture, rect->x, rect->y, rect->w, rect->h, Yplane, Ypitch)) {
|
||||
return false;
|
||||
}
|
||||
if (D3D_UpdateTextureRep(data->device, &texturedata->utexture, rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2, Uplane, Upitch) < 0) {
|
||||
return -1;
|
||||
if (!D3D_UpdateTextureRep(data->device, &texturedata->utexture, rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2, Uplane, Upitch)) {
|
||||
return false;
|
||||
}
|
||||
if (D3D_UpdateTextureRep(data->device, &texturedata->vtexture, rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2, Vplane, Vpitch) < 0) {
|
||||
return -1;
|
||||
if (!D3D_UpdateTextureRep(data->device, &texturedata->vtexture, rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2, Vplane, Vpitch)) {
|
||||
return false;
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int D3D_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
static bool D3D_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect, void **pixels, int *pitch)
|
||||
{
|
||||
D3D_RenderData *data = (D3D_RenderData *)renderer->internal;
|
||||
@@ -675,7 +675,7 @@ static int D3D_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
texturedata->pitch = texture->w;
|
||||
texturedata->pixels = (Uint8 *)SDL_malloc((texture->h * texturedata->pitch * 3) / 2);
|
||||
if (!texturedata->pixels) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
*pixels =
|
||||
@@ -689,8 +689,8 @@ static int D3D_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
D3DLOCKED_RECT locked;
|
||||
HRESULT result;
|
||||
|
||||
if (D3D_CreateStagingTexture(device, &texturedata->texture) < 0) {
|
||||
return -1;
|
||||
if (!D3D_CreateStagingTexture(device, &texturedata->texture)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
d3drect.left = rect->x;
|
||||
@@ -705,7 +705,7 @@ static int D3D_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
*pixels = locked.pBits;
|
||||
*pitch = locked.Pitch;
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void D3D_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
@@ -749,7 +749,7 @@ static void D3D_SetTextureScaleMode(SDL_Renderer *renderer, SDL_Texture *texture
|
||||
texturedata->scaleMode = (scaleMode == SDL_SCALEMODE_NEAREST) ? D3DTEXF_POINT : D3DTEXF_LINEAR;
|
||||
}
|
||||
|
||||
static int D3D_SetRenderTargetInternal(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
static bool D3D_SetRenderTargetInternal(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
{
|
||||
D3D_RenderData *data = (D3D_RenderData *)renderer->internal;
|
||||
D3D_TextureData *texturedata;
|
||||
@@ -765,7 +765,7 @@ static int D3D_SetRenderTargetInternal(SDL_Renderer *renderer, SDL_Texture *text
|
||||
|
||||
if (!texture) {
|
||||
IDirect3DDevice9_SetRenderTarget(data->device, 0, data->defaultRenderTarget);
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
texturedata = (D3D_TextureData *)texture->internal;
|
||||
@@ -800,24 +800,24 @@ static int D3D_SetRenderTargetInternal(SDL_Renderer *renderer, SDL_Texture *text
|
||||
return D3D_SetError("SetRenderTarget()", result);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int D3D_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
static bool D3D_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
{
|
||||
if (D3D_ActivateRenderer(renderer) < 0) {
|
||||
return -1;
|
||||
if (!D3D_ActivateRenderer(renderer)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return D3D_SetRenderTargetInternal(renderer, texture);
|
||||
}
|
||||
|
||||
static int D3D_QueueNoOp(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
static bool D3D_QueueNoOp(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
{
|
||||
return 0; // nothing to do in this backend.
|
||||
return true; // nothing to do in this backend.
|
||||
}
|
||||
|
||||
static int D3D_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count)
|
||||
static bool D3D_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count)
|
||||
{
|
||||
const DWORD color = D3DCOLOR_COLORVALUE(cmd->data.draw.color.r * cmd->data.draw.color_scale,
|
||||
cmd->data.draw.color.g * cmd->data.draw.color_scale,
|
||||
@@ -828,7 +828,7 @@ static int D3D_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, c
|
||||
int i;
|
||||
|
||||
if (!verts) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
SDL_memset(verts, '\0', vertslen);
|
||||
@@ -840,10 +840,10 @@ static int D3D_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, c
|
||||
verts->color = color;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int D3D_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
|
||||
static bool D3D_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
|
||||
const float *xy, int xy_stride, const SDL_FColor *color, int color_stride, const float *uv, int uv_stride,
|
||||
int num_vertices, const void *indices, int num_indices, int size_indices,
|
||||
float scale_x, float scale_y)
|
||||
@@ -854,7 +854,7 @@ static int D3D_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL
|
||||
const float color_scale = cmd->data.draw.color_scale;
|
||||
|
||||
if (!verts) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
cmd->data.draw.count = count;
|
||||
@@ -893,10 +893,10 @@ static int D3D_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL
|
||||
|
||||
verts += 1;
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int UpdateDirtyTexture(IDirect3DDevice9 *device, D3D_TextureRep *texture)
|
||||
static bool UpdateDirtyTexture(IDirect3DDevice9 *device, D3D_TextureRep *texture)
|
||||
{
|
||||
if (texture->dirty && texture->staging) {
|
||||
HRESULT result;
|
||||
@@ -914,10 +914,10 @@ static int UpdateDirtyTexture(IDirect3DDevice9 *device, D3D_TextureRep *texture)
|
||||
}
|
||||
texture->dirty = false;
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int BindTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture, DWORD sampler)
|
||||
static bool BindTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture, DWORD sampler)
|
||||
{
|
||||
HRESULT result;
|
||||
UpdateDirtyTexture(device, texture);
|
||||
@@ -925,7 +925,7 @@ static int BindTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture, DWO
|
||||
if (FAILED(result)) {
|
||||
return D3D_SetError("SetTexture()", result);
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void UpdateTextureScaleMode(D3D_RenderData *data, D3D_TextureData *texturedata, unsigned index)
|
||||
@@ -956,7 +956,7 @@ static void UpdateTextureAddressMode(D3D_RenderData *data, SDL_TextureAddressMod
|
||||
}
|
||||
}
|
||||
|
||||
static int SetupTextureState(D3D_RenderData *data, SDL_Texture *texture, SDL_TextureAddressMode addressMode, D3D9_Shader *shader, const float **shader_params)
|
||||
static bool SetupTextureState(D3D_RenderData *data, SDL_Texture *texture, SDL_TextureAddressMode addressMode, D3D9_Shader *shader, const float **shader_params)
|
||||
{
|
||||
D3D_TextureData *texturedata = (D3D_TextureData *)texture->internal;
|
||||
|
||||
@@ -970,8 +970,8 @@ static int SetupTextureState(D3D_RenderData *data, SDL_Texture *texture, SDL_Tex
|
||||
*shader = texturedata->shader;
|
||||
*shader_params = texturedata->shader_params;
|
||||
|
||||
if (BindTextureRep(data->device, &texturedata->texture, 0) < 0) {
|
||||
return -1;
|
||||
if (!BindTextureRep(data->device, &texturedata->texture, 0)) {
|
||||
return false;
|
||||
}
|
||||
#if SDL_HAVE_YUV
|
||||
if (texturedata->yuv) {
|
||||
@@ -980,18 +980,18 @@ static int SetupTextureState(D3D_RenderData *data, SDL_Texture *texture, SDL_Tex
|
||||
UpdateTextureAddressMode(data, addressMode, 1);
|
||||
UpdateTextureAddressMode(data, addressMode, 2);
|
||||
|
||||
if (BindTextureRep(data->device, &texturedata->utexture, 1) < 0) {
|
||||
return -1;
|
||||
if (!BindTextureRep(data->device, &texturedata->utexture, 1)) {
|
||||
return false;
|
||||
}
|
||||
if (BindTextureRep(data->device, &texturedata->vtexture, 2) < 0) {
|
||||
return -1;
|
||||
if (!BindTextureRep(data->device, &texturedata->vtexture, 2)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int SetDrawState(D3D_RenderData *data, const SDL_RenderCommand *cmd)
|
||||
static bool SetDrawState(D3D_RenderData *data, const SDL_RenderCommand *cmd)
|
||||
{
|
||||
SDL_Texture *texture = cmd->data.draw.texture;
|
||||
const SDL_BlendMode blend = cmd->data.draw.blend;
|
||||
@@ -1014,8 +1014,8 @@ static int SetDrawState(D3D_RenderData *data, const SDL_RenderCommand *cmd)
|
||||
IDirect3DDevice9_SetTexture(data->device, 2, NULL);
|
||||
}
|
||||
#endif
|
||||
if (texture && SetupTextureState(data, texture, cmd->data.draw.texture_address_mode, &shader, &shader_params) < 0) {
|
||||
return -1;
|
||||
if (texture && !SetupTextureState(data, texture, cmd->data.draw.texture_address_mode, &shader, &shader_params)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
#if SDL_HAVE_YUV
|
||||
@@ -1119,7 +1119,7 @@ static int SetDrawState(D3D_RenderData *data, const SDL_RenderCommand *cmd)
|
||||
data->drawstate.cliprect_dirty = false;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void D3D_InvalidateCachedState(SDL_Renderer *renderer)
|
||||
@@ -1134,15 +1134,15 @@ static void D3D_InvalidateCachedState(SDL_Renderer *renderer)
|
||||
data->drawstate.shader_params = NULL;
|
||||
}
|
||||
|
||||
static int D3D_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize)
|
||||
static bool D3D_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize)
|
||||
{
|
||||
D3D_RenderData *data = (D3D_RenderData *)renderer->internal;
|
||||
const int vboidx = data->currentVertexBuffer;
|
||||
IDirect3DVertexBuffer9 *vbo = NULL;
|
||||
const bool istarget = renderer->target != NULL;
|
||||
|
||||
if (D3D_ActivateRenderer(renderer) < 0) {
|
||||
return -1;
|
||||
if (!D3D_ActivateRenderer(renderer)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (vertsize > 0) {
|
||||
@@ -1330,7 +1330,7 @@ static int D3D_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, v
|
||||
cmd = cmd->next;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static SDL_Surface *D3D_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect)
|
||||
@@ -1390,7 +1390,7 @@ static SDL_Surface *D3D_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect
|
||||
return output;
|
||||
}
|
||||
|
||||
static int D3D_RenderPresent(SDL_Renderer *renderer)
|
||||
static bool D3D_RenderPresent(SDL_Renderer *renderer)
|
||||
{
|
||||
D3D_RenderData *data = (D3D_RenderData *)renderer->internal;
|
||||
HRESULT result;
|
||||
@@ -1403,7 +1403,7 @@ static int D3D_RenderPresent(SDL_Renderer *renderer)
|
||||
result = IDirect3DDevice9_TestCooperativeLevel(data->device);
|
||||
if (result == D3DERR_DEVICELOST) {
|
||||
// We'll reset later
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
if (result == D3DERR_DEVICENOTRESET) {
|
||||
D3D_Reset(renderer);
|
||||
@@ -1412,7 +1412,7 @@ static int D3D_RenderPresent(SDL_Renderer *renderer)
|
||||
if (FAILED(result)) {
|
||||
return D3D_SetError("Present()", result);
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void D3D_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
@@ -1491,7 +1491,7 @@ static void D3D_DestroyRenderer(SDL_Renderer *renderer)
|
||||
}
|
||||
}
|
||||
|
||||
static int D3D_Reset(SDL_Renderer *renderer)
|
||||
static bool D3D_Reset(SDL_Renderer *renderer)
|
||||
{
|
||||
D3D_RenderData *data = (D3D_RenderData *)renderer->internal;
|
||||
const Float4X4 d3dmatrix = MatrixIdentity();
|
||||
@@ -1537,7 +1537,7 @@ static int D3D_Reset(SDL_Renderer *renderer)
|
||||
if (FAILED(result)) {
|
||||
if (result == D3DERR_DEVICELOST) {
|
||||
// Don't worry about it, we'll reset later...
|
||||
return 0;
|
||||
return true;
|
||||
} else {
|
||||
return D3D_SetError("Reset()", result);
|
||||
}
|
||||
@@ -1566,10 +1566,10 @@ static int D3D_Reset(SDL_Renderer *renderer)
|
||||
SDL_PushEvent(&event);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int D3D_SetVSync(SDL_Renderer *renderer, const int vsync)
|
||||
static bool D3D_SetVSync(SDL_Renderer *renderer, const int vsync)
|
||||
{
|
||||
D3D_RenderData *data = (D3D_RenderData *)renderer->internal;
|
||||
|
||||
@@ -1604,14 +1604,14 @@ static int D3D_SetVSync(SDL_Renderer *renderer, const int vsync)
|
||||
}
|
||||
data->pparams.PresentationInterval = PresentationInterval;
|
||||
|
||||
if (D3D_Reset(renderer) < 0) {
|
||||
if (!D3D_Reset(renderer)) {
|
||||
// D3D_Reset will call SDL_SetError()
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
int D3D_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_PropertiesID create_props)
|
||||
static bool D3D_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_PropertiesID create_props)
|
||||
{
|
||||
D3D_RenderData *data;
|
||||
HRESULT result;
|
||||
@@ -1637,7 +1637,7 @@ int D3D_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Propertie
|
||||
|
||||
data = (D3D_RenderData *)SDL_calloc(1, sizeof(*data));
|
||||
if (!data) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!D3D_LoadDLL(&data->d3dDLL, &data->d3d)) {
|
||||
@@ -1770,7 +1770,7 @@ int D3D_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Propertie
|
||||
|
||||
SDL_SetPointerProperty(SDL_GetRendererProperties(renderer), SDL_PROP_RENDERER_D3D9_DEVICE_POINTER, data->device);
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
SDL_RenderDriver D3D_RenderDriver = {
|
||||
|
||||
@@ -725,7 +725,7 @@ static HRESULT D3D11_CreateDeviceResources(SDL_Renderer *renderer)
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (D3D11_CreateVertexShader(data->d3dDevice, &data->vertexShader, &data->inputLayout) < 0) {
|
||||
if (!D3D11_CreateVertexShader(data->d3dDevice, &data->vertexShader, &data->inputLayout)) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
@@ -851,7 +851,7 @@ static int D3D11_GetRotationForCurrentRenderTarget(SDL_Renderer *renderer)
|
||||
}
|
||||
}
|
||||
|
||||
static int D3D11_GetViewportAlignedD3DRect(SDL_Renderer *renderer, const SDL_Rect *sdlRect, D3D11_RECT *outRect, BOOL includeViewportOffset)
|
||||
static bool D3D11_GetViewportAlignedD3DRect(SDL_Renderer *renderer, const SDL_Rect *sdlRect, D3D11_RECT *outRect, BOOL includeViewportOffset)
|
||||
{
|
||||
D3D11_RenderData *data = (D3D11_RenderData *)renderer->internal;
|
||||
const int rotation = D3D11_GetRotationForCurrentRenderTarget(renderer);
|
||||
@@ -891,7 +891,7 @@ static int D3D11_GetViewportAlignedD3DRect(SDL_Renderer *renderer, const SDL_Rec
|
||||
default:
|
||||
return SDL_SetError("The physical display is in an unknown or unsupported rotation");
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static HRESULT D3D11_CreateSwapChain(SDL_Renderer *renderer, int w, int h)
|
||||
@@ -1260,7 +1260,7 @@ static bool D3D11_SupportsBlendMode(SDL_Renderer *renderer, SDL_BlendMode blendM
|
||||
return true;
|
||||
}
|
||||
|
||||
static int GetTextureProperty(SDL_PropertiesID props, const char *name, ID3D11Texture2D **texture)
|
||||
static bool GetTextureProperty(SDL_PropertiesID props, const char *name, ID3D11Texture2D **texture)
|
||||
{
|
||||
IUnknown *unknown = SDL_GetPointerProperty(props, name, NULL);
|
||||
if (unknown) {
|
||||
@@ -1269,10 +1269,10 @@ static int GetTextureProperty(SDL_PropertiesID props, const char *name, ID3D11Te
|
||||
return WIN_SetErrorFromHRESULT(name, result);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int D3D11_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_PropertiesID create_props)
|
||||
static bool D3D11_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_PropertiesID create_props)
|
||||
{
|
||||
D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->internal;
|
||||
D3D11_TextureData *textureData;
|
||||
@@ -1288,7 +1288,7 @@ static int D3D11_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL
|
||||
|
||||
textureData = (D3D11_TextureData *)SDL_calloc(1, sizeof(*textureData));
|
||||
if (!textureData) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
textureData->scaleMode = (texture->scaleMode == SDL_SCALEMODE_NEAREST) ? D3D11_FILTER_MIN_MAG_MIP_POINT : D3D11_FILTER_MIN_MAG_MIP_LINEAR;
|
||||
|
||||
@@ -1333,8 +1333,8 @@ static int D3D11_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL
|
||||
textureDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
|
||||
}
|
||||
|
||||
if (GetTextureProperty(create_props, SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_POINTER, &textureData->mainTexture) < 0) {
|
||||
return -1;
|
||||
if (!GetTextureProperty(create_props, SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_POINTER, &textureData->mainTexture)) {
|
||||
return false;
|
||||
}
|
||||
if (!textureData->mainTexture) {
|
||||
result = ID3D11Device_CreateTexture2D(rendererData->d3dDevice,
|
||||
@@ -1354,8 +1354,8 @@ static int D3D11_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL
|
||||
textureDesc.Width = (textureDesc.Width + 1) / 2;
|
||||
textureDesc.Height = (textureDesc.Height + 1) / 2;
|
||||
|
||||
if (GetTextureProperty(create_props, SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_U_POINTER, &textureData->mainTextureU) < 0) {
|
||||
return -1;
|
||||
if (!GetTextureProperty(create_props, SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_U_POINTER, &textureData->mainTextureU)) {
|
||||
return false;
|
||||
}
|
||||
if (!textureData->mainTextureU) {
|
||||
result = ID3D11Device_CreateTexture2D(rendererData->d3dDevice,
|
||||
@@ -1368,8 +1368,8 @@ static int D3D11_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL
|
||||
}
|
||||
SDL_SetPointerProperty(SDL_GetTextureProperties(texture), SDL_PROP_TEXTURE_D3D11_TEXTURE_U_POINTER, textureData->mainTextureU);
|
||||
|
||||
if (GetTextureProperty(create_props, SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_V_POINTER, &textureData->mainTextureV) < 0) {
|
||||
return -1;
|
||||
if (!GetTextureProperty(create_props, SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_V_POINTER, &textureData->mainTextureV)) {
|
||||
return false;
|
||||
}
|
||||
if (!textureData->mainTextureV) {
|
||||
result = ID3D11Device_CreateTexture2D(rendererData->d3dDevice,
|
||||
@@ -1473,7 +1473,7 @@ static int D3D11_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void D3D11_DestroyTexture(SDL_Renderer *renderer,
|
||||
@@ -1501,7 +1501,7 @@ static void D3D11_DestroyTexture(SDL_Renderer *renderer,
|
||||
texture->internal = NULL;
|
||||
}
|
||||
|
||||
static int D3D11_UpdateTextureInternal(D3D11_RenderData *rendererData, ID3D11Texture2D *texture, int bpp, int x, int y, int w, int h, const void *pixels, int pitch)
|
||||
static bool D3D11_UpdateTextureInternal(D3D11_RenderData *rendererData, ID3D11Texture2D *texture, int bpp, int x, int y, int w, int h, const void *pixels, int pitch)
|
||||
{
|
||||
ID3D11Texture2D *stagingTexture;
|
||||
const Uint8 *src;
|
||||
@@ -1601,23 +1601,23 @@ static int D3D11_UpdateTextureInternal(D3D11_RenderData *rendererData, ID3D11Tex
|
||||
|
||||
SAFE_RELEASE(stagingTexture);
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
#if SDL_HAVE_YUV
|
||||
static int D3D11_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
static bool D3D11_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *UVplane, int UVpitch);
|
||||
|
||||
static int D3D11_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
static bool D3D11_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *Uplane, int Upitch,
|
||||
const Uint8 *Vplane, int Vpitch);
|
||||
#endif
|
||||
|
||||
static int D3D11_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
static bool D3D11_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect, const void *srcPixels,
|
||||
int srcPitch)
|
||||
{
|
||||
@@ -1650,14 +1650,14 @@ static int D3D11_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
}
|
||||
#endif
|
||||
|
||||
if (D3D11_UpdateTextureInternal(rendererData, textureData->mainTexture, SDL_BYTESPERPIXEL(texture->format), rect->x, rect->y, rect->w, rect->h, srcPixels, srcPitch) < 0) {
|
||||
return -1;
|
||||
if (!D3D11_UpdateTextureInternal(rendererData, textureData->mainTexture, SDL_BYTESPERPIXEL(texture->format), rect->x, rect->y, rect->w, rect->h, srcPixels, srcPitch)) {
|
||||
return false;
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
#if SDL_HAVE_YUV
|
||||
static int D3D11_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
static bool D3D11_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *Uplane, int Upitch,
|
||||
@@ -1670,19 +1670,19 @@ static int D3D11_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
return SDL_SetError("Texture is not currently available");
|
||||
}
|
||||
|
||||
if (D3D11_UpdateTextureInternal(rendererData, textureData->mainTexture, SDL_BYTESPERPIXEL(texture->format), rect->x, rect->y, rect->w, rect->h, Yplane, Ypitch) < 0) {
|
||||
return -1;
|
||||
if (!D3D11_UpdateTextureInternal(rendererData, textureData->mainTexture, SDL_BYTESPERPIXEL(texture->format), rect->x, rect->y, rect->w, rect->h, Yplane, Ypitch)) {
|
||||
return false;
|
||||
}
|
||||
if (D3D11_UpdateTextureInternal(rendererData, textureData->mainTextureU, SDL_BYTESPERPIXEL(texture->format), rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2, Uplane, Upitch) < 0) {
|
||||
return -1;
|
||||
if (!D3D11_UpdateTextureInternal(rendererData, textureData->mainTextureU, SDL_BYTESPERPIXEL(texture->format), rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2, Uplane, Upitch)) {
|
||||
return false;
|
||||
}
|
||||
if (D3D11_UpdateTextureInternal(rendererData, textureData->mainTextureV, SDL_BYTESPERPIXEL(texture->format), rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2, Vplane, Vpitch) < 0) {
|
||||
return -1;
|
||||
if (!D3D11_UpdateTextureInternal(rendererData, textureData->mainTextureV, SDL_BYTESPERPIXEL(texture->format), rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2, Vplane, Vpitch)) {
|
||||
return false;
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int D3D11_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
static bool D3D11_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *UVplane, int UVpitch)
|
||||
@@ -1792,11 +1792,11 @@ static int D3D11_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
|
||||
SAFE_RELEASE(stagingTexture);
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int D3D11_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
static bool D3D11_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect, void **pixels, int *pitch)
|
||||
{
|
||||
D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->internal;
|
||||
@@ -1815,7 +1815,7 @@ static int D3D11_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
textureData->pitch = texture->w;
|
||||
textureData->pixels = (Uint8 *)SDL_malloc((texture->h * textureData->pitch * 3) / 2);
|
||||
if (!textureData->pixels) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
textureData->locked_rect = *rect;
|
||||
@@ -1823,7 +1823,7 @@ static int D3D11_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
(void *)(textureData->pixels + rect->y * textureData->pitch +
|
||||
rect->x * SDL_BYTESPERPIXEL(texture->format));
|
||||
*pitch = textureData->pitch;
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
if (textureData->stagingTexture) {
|
||||
@@ -1876,7 +1876,7 @@ static int D3D11_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
*/
|
||||
*pixels = textureMemory.pData;
|
||||
*pitch = textureMemory.RowPitch;
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void D3D11_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
@@ -1927,14 +1927,14 @@ static void D3D11_SetTextureScaleMode(SDL_Renderer *renderer, SDL_Texture *textu
|
||||
textureData->scaleMode = (scaleMode == SDL_SCALEMODE_NEAREST) ? D3D11_FILTER_MIN_MAG_MIP_POINT : D3D11_FILTER_MIN_MAG_MIP_LINEAR;
|
||||
}
|
||||
|
||||
static int D3D11_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
static bool D3D11_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
{
|
||||
D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->internal;
|
||||
D3D11_TextureData *textureData = NULL;
|
||||
|
||||
if (!texture) {
|
||||
rendererData->currentOffscreenRenderTargetView = NULL;
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
textureData = (D3D11_TextureData *)texture->internal;
|
||||
@@ -1945,15 +1945,15 @@ static int D3D11_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
|
||||
rendererData->currentOffscreenRenderTargetView = textureData->mainTextureRenderTargetView;
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int D3D11_QueueNoOp(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
static bool D3D11_QueueNoOp(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
{
|
||||
return 0; // nothing to do in this backend.
|
||||
return true; // nothing to do in this backend.
|
||||
}
|
||||
|
||||
static int D3D11_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count)
|
||||
static bool D3D11_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count)
|
||||
{
|
||||
VertexPositionColor *verts = (VertexPositionColor *)SDL_AllocateRenderVertices(renderer, count * sizeof(VertexPositionColor), 0, &cmd->data.draw.first);
|
||||
int i;
|
||||
@@ -1961,7 +1961,7 @@ static int D3D11_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
|
||||
bool convert_color = SDL_RenderingLinearSpace(renderer);
|
||||
|
||||
if (!verts) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
cmd->data.draw.count = count;
|
||||
@@ -1979,10 +1979,10 @@ static int D3D11_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
|
||||
verts++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int D3D11_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
|
||||
static bool D3D11_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
|
||||
const float *xy, int xy_stride, const SDL_FColor *color, int color_stride, const float *uv, int uv_stride,
|
||||
int num_vertices, const void *indices, int num_indices, int size_indices,
|
||||
float scale_x, float scale_y)
|
||||
@@ -1996,7 +1996,7 @@ static int D3D11_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, S
|
||||
float v_scale = textureData ? (float)texture->h / textureData->h : 0.0f;
|
||||
|
||||
if (!verts) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
cmd->data.draw.count = count;
|
||||
@@ -2035,10 +2035,10 @@ static int D3D11_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, S
|
||||
|
||||
verts += 1;
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int D3D11_UpdateVertexBuffer(SDL_Renderer *renderer,
|
||||
static bool D3D11_UpdateVertexBuffer(SDL_Renderer *renderer,
|
||||
const void *vertexData, size_t dataSizeInBytes)
|
||||
{
|
||||
D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->internal;
|
||||
@@ -2048,7 +2048,7 @@ static int D3D11_UpdateVertexBuffer(SDL_Renderer *renderer,
|
||||
const UINT offset = 0;
|
||||
|
||||
if (dataSizeInBytes == 0) {
|
||||
return 0; // nothing to do.
|
||||
return true; // nothing to do.
|
||||
}
|
||||
|
||||
if (rendererData->vertexBuffers[vbidx] && rendererData->vertexBufferSizes[vbidx] >= dataSizeInBytes) {
|
||||
@@ -2104,10 +2104,10 @@ static int D3D11_UpdateVertexBuffer(SDL_Renderer *renderer,
|
||||
rendererData->currentVertexBuffer = 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int D3D11_UpdateViewport(SDL_Renderer *renderer)
|
||||
static bool D3D11_UpdateViewport(SDL_Renderer *renderer)
|
||||
{
|
||||
D3D11_RenderData *data = (D3D11_RenderData *)renderer->internal;
|
||||
const SDL_Rect *viewport = &data->currentViewport;
|
||||
@@ -2124,7 +2124,7 @@ static int D3D11_UpdateViewport(SDL_Renderer *renderer)
|
||||
* with a non-empty viewport.
|
||||
*/
|
||||
// SDL_Log("%s, no viewport was set!\n", __FUNCTION__);
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Make sure the SDL viewport gets rotated to that of the physical display's rotation.
|
||||
@@ -2196,7 +2196,7 @@ static int D3D11_UpdateViewport(SDL_Renderer *renderer)
|
||||
|
||||
data->viewportDirty = false;
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static ID3D11RenderTargetView *D3D11_GetCurrentRenderTargetView(SDL_Renderer *renderer)
|
||||
@@ -2271,7 +2271,7 @@ static void D3D11_SetupShaderConstants(SDL_Renderer *renderer, const SDL_RenderC
|
||||
}
|
||||
}
|
||||
|
||||
static int D3D11_SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd,
|
||||
static bool D3D11_SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd,
|
||||
D3D11_Shader shader, const PixelShaderConstants *shader_constants,
|
||||
const int numShaderResources, ID3D11ShaderResourceView **shaderResources,
|
||||
ID3D11SamplerState *sampler, const Float4X4 *matrix)
|
||||
@@ -2310,7 +2310,7 @@ static int D3D11_SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *c
|
||||
}
|
||||
|
||||
if (rendererData->viewportDirty) {
|
||||
if (D3D11_UpdateViewport(renderer) == 0) {
|
||||
if (D3D11_UpdateViewport(renderer)) {
|
||||
// vertexShaderConstantsData.projectionAndView has changed
|
||||
updateSubresource = true;
|
||||
}
|
||||
@@ -2321,9 +2321,9 @@ static int D3D11_SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *c
|
||||
ID3D11DeviceContext_RSSetScissorRects(rendererData->d3dContext, 0, NULL);
|
||||
} else {
|
||||
D3D11_RECT scissorRect;
|
||||
if (D3D11_GetViewportAlignedD3DRect(renderer, &rendererData->currentCliprect, &scissorRect, TRUE) != 0) {
|
||||
if (!D3D11_GetViewportAlignedD3DRect(renderer, &rendererData->currentCliprect, &scissorRect, TRUE)) {
|
||||
// D3D11_GetViewportAlignedD3DRect will have set the SDL error
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
ID3D11DeviceContext_RSSetScissorRects(rendererData->d3dContext, 1, &scissorRect);
|
||||
}
|
||||
@@ -2351,7 +2351,7 @@ static int D3D11_SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *c
|
||||
if (!blendState) {
|
||||
blendState = D3D11_CreateBlendState(renderer, blendMode);
|
||||
if (!blendState) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2382,7 +2382,7 @@ static int D3D11_SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *c
|
||||
HRESULT result = ID3D11Device_CreateBuffer(rendererData->d3dDevice, &desc, &data, &shader_state->constants);
|
||||
if (FAILED(result)) {
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device::CreateBuffer [create shader constants]"), result);
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
SDL_memcpy(&shader_state->shader_constants, shader_constants, sizeof(*shader_constants));
|
||||
|
||||
@@ -2391,8 +2391,8 @@ static int D3D11_SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *c
|
||||
}
|
||||
if (shader != rendererData->currentShader) {
|
||||
if (!rendererData->pixelShaders[shader]) {
|
||||
if (D3D11_CreatePixelShader(rendererData->d3dDevice, shader, &rendererData->pixelShaders[shader]) < 0) {
|
||||
return -1;
|
||||
if (!D3D11_CreatePixelShader(rendererData->d3dDevice, shader, &rendererData->pixelShaders[shader])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
ID3D11DeviceContext_PSSetShader(rendererData->d3dContext, rendererData->pixelShaders[shader], NULL, 0);
|
||||
@@ -2421,10 +2421,10 @@ static int D3D11_SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *c
|
||||
0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int D3D11_SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, const Float4X4 *matrix)
|
||||
static bool D3D11_SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, const Float4X4 *matrix)
|
||||
{
|
||||
SDL_Texture *texture = cmd->data.draw.texture;
|
||||
D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->internal;
|
||||
@@ -2511,7 +2511,7 @@ static void D3D11_InvalidateCachedState(SDL_Renderer *renderer)
|
||||
data->viewportDirty = true;
|
||||
}
|
||||
|
||||
static int D3D11_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize)
|
||||
static bool D3D11_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize)
|
||||
{
|
||||
D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->internal;
|
||||
const int viewportRotation = D3D11_GetRotationForCurrentRenderTarget(renderer);
|
||||
@@ -2526,8 +2526,8 @@ static int D3D11_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
|
||||
rendererData->viewportDirty = true;
|
||||
}
|
||||
|
||||
if (D3D11_UpdateVertexBuffer(renderer, vertices, vertsize) < 0) {
|
||||
return -1;
|
||||
if (!D3D11_UpdateVertexBuffer(renderer, vertices, vertsize)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
while (cmd) {
|
||||
@@ -2633,7 +2633,7 @@ static int D3D11_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
|
||||
cmd = cmd->next;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static SDL_Surface *D3D11_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect)
|
||||
@@ -2679,7 +2679,7 @@ static SDL_Surface *D3D11_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rec
|
||||
}
|
||||
|
||||
// Copy the desired portion of the back buffer to the staging texture:
|
||||
if (D3D11_GetViewportAlignedD3DRect(renderer, rect, &srcRect, FALSE) != 0) {
|
||||
if (!D3D11_GetViewportAlignedD3DRect(renderer, rect, &srcRect, FALSE)) {
|
||||
// D3D11_GetViewportAlignedD3DRect will have set the SDL error
|
||||
goto done;
|
||||
}
|
||||
@@ -2728,7 +2728,7 @@ done:
|
||||
return output;
|
||||
}
|
||||
|
||||
static int D3D11_RenderPresent(SDL_Renderer *renderer)
|
||||
static bool D3D11_RenderPresent(SDL_Renderer *renderer)
|
||||
{
|
||||
D3D11_RenderData *data = (D3D11_RenderData *)renderer->internal;
|
||||
HRESULT result;
|
||||
@@ -2769,12 +2769,12 @@ static int D3D11_RenderPresent(SDL_Renderer *renderer)
|
||||
} else {
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGISwapChain::Present"), result);
|
||||
}
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int D3D11_SetVSync(SDL_Renderer *renderer, const int vsync)
|
||||
static bool D3D11_SetVSync(SDL_Renderer *renderer, const int vsync)
|
||||
{
|
||||
D3D11_RenderData *data = (D3D11_RenderData *)renderer->internal;
|
||||
|
||||
@@ -2805,10 +2805,10 @@ static int D3D11_SetVSync(SDL_Renderer *renderer, const int vsync)
|
||||
data->syncInterval = 0;
|
||||
data->presentFlags = DXGI_PRESENT_DO_NOT_WAIT;
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int D3D11_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_PropertiesID create_props)
|
||||
static bool D3D11_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_PropertiesID create_props)
|
||||
{
|
||||
D3D11_RenderData *data;
|
||||
|
||||
@@ -2827,7 +2827,7 @@ static int D3D11_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_
|
||||
|
||||
data = (D3D11_RenderData *)SDL_calloc(1, sizeof(*data));
|
||||
if (!data) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
data->identity = MatrixIdentity();
|
||||
@@ -2880,13 +2880,13 @@ static int D3D11_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_
|
||||
|
||||
// Initialize Direct3D resources
|
||||
if (FAILED(D3D11_CreateDeviceResources(renderer))) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
if (FAILED(D3D11_CreateWindowSizeDependentResources(renderer))) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
SDL_RenderDriver D3D11_RenderDriver = {
|
||||
|
||||
@@ -65,7 +65,7 @@ static struct
|
||||
};
|
||||
SDL_COMPILE_TIME_ASSERT(D3D11_shaders, SDL_arraysize(D3D11_shaders) == NUM_SHADERS);
|
||||
|
||||
int D3D11_CreateVertexShader(ID3D11Device1 *d3dDevice, ID3D11VertexShader **vertexShader, ID3D11InputLayout **inputLayout)
|
||||
bool D3D11_CreateVertexShader(ID3D11Device1 *d3dDevice, ID3D11VertexShader **vertexShader, ID3D11InputLayout **inputLayout)
|
||||
{
|
||||
// Declare how the input layout for SDL's vertex shader will be setup:
|
||||
const D3D11_INPUT_ELEMENT_DESC vertexDesc[] = {
|
||||
@@ -95,10 +95,10 @@ int D3D11_CreateVertexShader(ID3D11Device1 *d3dDevice, ID3D11VertexShader **vert
|
||||
if (FAILED(result)) {
|
||||
return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateInputLayout"), result);
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
int D3D11_CreatePixelShader(ID3D11Device1 *d3dDevice, D3D11_Shader shader, ID3D11PixelShader **pixelShader)
|
||||
bool D3D11_CreatePixelShader(ID3D11Device1 *d3dDevice, D3D11_Shader shader, ID3D11PixelShader **pixelShader)
|
||||
{
|
||||
HRESULT result;
|
||||
|
||||
@@ -110,7 +110,7 @@ int D3D11_CreatePixelShader(ID3D11Device1 *d3dDevice, D3D11_Shader shader, ID3D1
|
||||
if (FAILED(result)) {
|
||||
return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreatePixelShader"), result);
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif // SDL_VIDEO_RENDER_D3D11
|
||||
|
||||
@@ -31,5 +31,5 @@ typedef enum
|
||||
NUM_SHADERS
|
||||
} D3D11_Shader;
|
||||
|
||||
extern int D3D11_CreateVertexShader(ID3D11Device1 *d3dDevice, ID3D11VertexShader **vertexShader, ID3D11InputLayout **inputLayout);
|
||||
extern int D3D11_CreatePixelShader(ID3D11Device1 *d3dDevice, D3D11_Shader shader, ID3D11PixelShader **pixelShader);
|
||||
extern bool D3D11_CreateVertexShader(ID3D11Device1 *d3dDevice, ID3D11VertexShader **vertexShader, ID3D11InputLayout **inputLayout);
|
||||
extern bool D3D11_CreatePixelShader(ID3D11Device1 *d3dDevice, D3D11_Shader shader, ID3D11PixelShader **pixelShader);
|
||||
|
||||
@@ -544,7 +544,7 @@ static void D3D12_ResetCommandList(D3D12_RenderData *data)
|
||||
ID3D12GraphicsCommandList2_SetDescriptorHeaps(data->commandList, 2, rootDescriptorHeaps);
|
||||
}
|
||||
|
||||
static int D3D12_IssueBatch(D3D12_RenderData *data)
|
||||
static bool D3D12_IssueBatch(D3D12_RenderData *data)
|
||||
{
|
||||
HRESULT result = S_OK;
|
||||
|
||||
@@ -1158,7 +1158,7 @@ static BOOL D3D12_IsDisplayRotated90Degrees(DXGI_MODE_ROTATION rotation)
|
||||
}
|
||||
}
|
||||
|
||||
static int D3D12_GetRotationForCurrentRenderTarget(SDL_Renderer *renderer)
|
||||
static bool D3D12_GetRotationForCurrentRenderTarget(SDL_Renderer *renderer)
|
||||
{
|
||||
D3D12_RenderData *data = (D3D12_RenderData *)renderer->internal;
|
||||
if (data->textureRenderTarget) {
|
||||
@@ -1168,7 +1168,7 @@ static int D3D12_GetRotationForCurrentRenderTarget(SDL_Renderer *renderer)
|
||||
}
|
||||
}
|
||||
|
||||
static int D3D12_GetViewportAlignedD3DRect(SDL_Renderer *renderer, const SDL_Rect *sdlRect, D3D12_RECT *outRect, BOOL includeViewportOffset)
|
||||
static bool D3D12_GetViewportAlignedD3DRect(SDL_Renderer *renderer, const SDL_Rect *sdlRect, D3D12_RECT *outRect, BOOL includeViewportOffset)
|
||||
{
|
||||
D3D12_RenderData *data = (D3D12_RenderData *)renderer->internal;
|
||||
const int rotation = D3D12_GetRotationForCurrentRenderTarget(renderer);
|
||||
@@ -1208,7 +1208,7 @@ static int D3D12_GetViewportAlignedD3DRect(SDL_Renderer *renderer, const SDL_Rec
|
||||
default:
|
||||
return SDL_SetError("The physical display is in an unknown or unsupported rotation");
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)
|
||||
@@ -1539,7 +1539,7 @@ static void D3D12_FreeSRVIndex(SDL_Renderer *renderer, SIZE_T index)
|
||||
rendererData->srvPoolHead = &rendererData->srvPoolNodes[index];
|
||||
}
|
||||
|
||||
static int GetTextureProperty(SDL_PropertiesID props, const char *name, ID3D12Resource **texture)
|
||||
static bool GetTextureProperty(SDL_PropertiesID props, const char *name, ID3D12Resource **texture)
|
||||
{
|
||||
IUnknown *unknown = (IUnknown*)SDL_GetPointerProperty(props, name, NULL);
|
||||
if (unknown) {
|
||||
@@ -1552,10 +1552,10 @@ static int GetTextureProperty(SDL_PropertiesID props, const char *name, ID3D12Re
|
||||
return WIN_SetErrorFromHRESULT(name, result);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int D3D12_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_PropertiesID create_props)
|
||||
static bool D3D12_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_PropertiesID create_props)
|
||||
{
|
||||
D3D12_RenderData *rendererData = (D3D12_RenderData *)renderer->internal;
|
||||
D3D12_TextureData *textureData;
|
||||
@@ -1571,7 +1571,7 @@ static int D3D12_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL
|
||||
|
||||
textureData = (D3D12_TextureData *)SDL_calloc(1, sizeof(*textureData));
|
||||
if (!textureData) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
textureData->scaleMode = (texture->scaleMode == SDL_SCALEMODE_NEAREST) ? D3D12_FILTER_MIN_MAG_MIP_POINT : D3D12_FILTER_MIN_MAG_MIP_LINEAR;
|
||||
|
||||
@@ -1613,8 +1613,8 @@ static int D3D12_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL
|
||||
heapProps.CreationNodeMask = 1;
|
||||
heapProps.VisibleNodeMask = 1;
|
||||
|
||||
if (GetTextureProperty(create_props, SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_POINTER, &textureData->mainTexture) < 0) {
|
||||
return -1;
|
||||
if (!GetTextureProperty(create_props, SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_POINTER, &textureData->mainTexture)) {
|
||||
return false;
|
||||
}
|
||||
if (!textureData->mainTexture) {
|
||||
result = ID3D12Device1_CreateCommittedResource(rendererData->d3dDevice,
|
||||
@@ -1639,8 +1639,8 @@ static int D3D12_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL
|
||||
textureDesc.Width = (textureDesc.Width + 1) / 2;
|
||||
textureDesc.Height = (textureDesc.Height + 1) / 2;
|
||||
|
||||
if (GetTextureProperty(create_props, SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_U_POINTER, &textureData->mainTextureU) < 0) {
|
||||
return -1;
|
||||
if (!GetTextureProperty(create_props, SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_U_POINTER, &textureData->mainTextureU)) {
|
||||
return false;
|
||||
}
|
||||
if (!textureData->mainTextureU) {
|
||||
result = ID3D12Device1_CreateCommittedResource(rendererData->d3dDevice,
|
||||
@@ -1658,8 +1658,8 @@ static int D3D12_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL
|
||||
textureData->mainResourceStateU = D3D12_RESOURCE_STATE_COPY_DEST;
|
||||
SDL_SetPointerProperty(SDL_GetTextureProperties(texture), SDL_PROP_TEXTURE_D3D12_TEXTURE_U_POINTER, textureData->mainTextureU);
|
||||
|
||||
if (GetTextureProperty(create_props, SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_V_POINTER, &textureData->mainTextureV) < 0) {
|
||||
return -1;
|
||||
if (!GetTextureProperty(create_props, SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_V_POINTER, &textureData->mainTextureV)) {
|
||||
return false;
|
||||
}
|
||||
if (!textureData->mainTextureV) {
|
||||
result = ID3D12Device1_CreateCommittedResource(rendererData->d3dDevice,
|
||||
@@ -1773,7 +1773,7 @@ static int D3D12_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL
|
||||
textureData->mainTextureRenderTargetView);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void D3D12_DestroyTexture(SDL_Renderer *renderer,
|
||||
@@ -1809,7 +1809,7 @@ static void D3D12_DestroyTexture(SDL_Renderer *renderer,
|
||||
texture->internal = NULL;
|
||||
}
|
||||
|
||||
static int D3D12_UpdateTextureInternal(D3D12_RenderData *rendererData, ID3D12Resource *texture, int plane, int x, int y, int w, int h, const void *pixels, int pitch, D3D12_RESOURCE_STATES *resourceState)
|
||||
static bool D3D12_UpdateTextureInternal(D3D12_RenderData *rendererData, ID3D12Resource *texture, int plane, int x, int y, int w, int h, const void *pixels, int pitch, D3D12_RESOURCE_STATES *resourceState)
|
||||
{
|
||||
const Uint8 *src;
|
||||
Uint8 *dst;
|
||||
@@ -1944,10 +1944,10 @@ static int D3D12_UpdateTextureInternal(D3D12_RenderData *rendererData, ID3D12Res
|
||||
D3D12_IssueBatch(rendererData);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int D3D12_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
static bool D3D12_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect, const void *srcPixels,
|
||||
int srcPitch)
|
||||
{
|
||||
@@ -1958,22 +1958,22 @@ static int D3D12_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
return SDL_SetError("Texture is not currently available");
|
||||
}
|
||||
|
||||
if (D3D12_UpdateTextureInternal(rendererData, textureData->mainTexture, 0, rect->x, rect->y, rect->w, rect->h, srcPixels, srcPitch, &textureData->mainResourceState) < 0) {
|
||||
return -1;
|
||||
if (!D3D12_UpdateTextureInternal(rendererData, textureData->mainTexture, 0, rect->x, rect->y, rect->w, rect->h, srcPixels, srcPitch, &textureData->mainResourceState)) {
|
||||
return false;
|
||||
}
|
||||
#if SDL_HAVE_YUV
|
||||
if (textureData->yuv) {
|
||||
// Skip to the correct offset into the next texture
|
||||
srcPixels = (const void *)((const Uint8 *)srcPixels + rect->h * srcPitch);
|
||||
|
||||
if (D3D12_UpdateTextureInternal(rendererData, texture->format == SDL_PIXELFORMAT_YV12 ? textureData->mainTextureV : textureData->mainTextureU, 0, rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2, srcPixels, (srcPitch + 1) / 2, texture->format == SDL_PIXELFORMAT_YV12 ? &textureData->mainResourceStateV : &textureData->mainResourceStateU) < 0) {
|
||||
return -1;
|
||||
if (!D3D12_UpdateTextureInternal(rendererData, texture->format == SDL_PIXELFORMAT_YV12 ? textureData->mainTextureV : textureData->mainTextureU, 0, rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2, srcPixels, (srcPitch + 1) / 2, texture->format == SDL_PIXELFORMAT_YV12 ? &textureData->mainResourceStateV : &textureData->mainResourceStateU)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Skip to the correct offset into the next texture
|
||||
srcPixels = (const void *)((const Uint8 *)srcPixels + ((rect->h + 1) / 2) * ((srcPitch + 1) / 2));
|
||||
if (D3D12_UpdateTextureInternal(rendererData, texture->format == SDL_PIXELFORMAT_YV12 ? textureData->mainTextureU : textureData->mainTextureV, 0, rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2, srcPixels, (srcPitch + 1) / 2, texture->format == SDL_PIXELFORMAT_YV12 ? &textureData->mainResourceStateU : &textureData->mainResourceStateV) < 0) {
|
||||
return -1;
|
||||
if (!D3D12_UpdateTextureInternal(rendererData, texture->format == SDL_PIXELFORMAT_YV12 ? textureData->mainTextureU : textureData->mainTextureV, 0, rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2, srcPixels, (srcPitch + 1) / 2, texture->format == SDL_PIXELFORMAT_YV12 ? &textureData->mainResourceStateU : &textureData->mainResourceStateV)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1986,16 +1986,16 @@ static int D3D12_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
} else {
|
||||
srcPitch = (srcPitch + 1) & ~1;
|
||||
}
|
||||
if (D3D12_UpdateTextureInternal(rendererData, textureData->mainTexture, 1, rect->x, rect->y, (rect->w + 1) & ~1, (rect->h + 1) & ~1, srcPixels, srcPitch, &textureData->mainResourceState) < 0) {
|
||||
return -1;
|
||||
if (!D3D12_UpdateTextureInternal(rendererData, textureData->mainTexture, 1, rect->x, rect->y, (rect->w + 1) & ~1, (rect->h + 1) & ~1, srcPixels, srcPitch, &textureData->mainResourceState)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif // SDL_HAVE_YUV
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
#if SDL_HAVE_YUV
|
||||
static int D3D12_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
static bool D3D12_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *Uplane, int Upitch,
|
||||
@@ -2008,19 +2008,19 @@ static int D3D12_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
return SDL_SetError("Texture is not currently available");
|
||||
}
|
||||
|
||||
if (D3D12_UpdateTextureInternal(rendererData, textureData->mainTexture, 0, rect->x, rect->y, rect->w, rect->h, Yplane, Ypitch, &textureData->mainResourceState) < 0) {
|
||||
return -1;
|
||||
if (!D3D12_UpdateTextureInternal(rendererData, textureData->mainTexture, 0, rect->x, rect->y, rect->w, rect->h, Yplane, Ypitch, &textureData->mainResourceState)) {
|
||||
return false;
|
||||
}
|
||||
if (D3D12_UpdateTextureInternal(rendererData, textureData->mainTextureU, 0, rect->x / 2, rect->y / 2, rect->w / 2, rect->h / 2, Uplane, Upitch, &textureData->mainResourceStateU) < 0) {
|
||||
return -1;
|
||||
if (!D3D12_UpdateTextureInternal(rendererData, textureData->mainTextureU, 0, rect->x / 2, rect->y / 2, rect->w / 2, rect->h / 2, Uplane, Upitch, &textureData->mainResourceStateU)) {
|
||||
return false;
|
||||
}
|
||||
if (D3D12_UpdateTextureInternal(rendererData, textureData->mainTextureV, 0, rect->x / 2, rect->y / 2, rect->w / 2, rect->h / 2, Vplane, Vpitch, &textureData->mainResourceStateV) < 0) {
|
||||
return -1;
|
||||
if (!D3D12_UpdateTextureInternal(rendererData, textureData->mainTextureV, 0, rect->x / 2, rect->y / 2, rect->w / 2, rect->h / 2, Vplane, Vpitch, &textureData->mainResourceStateV)) {
|
||||
return false;
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int D3D12_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
static bool D3D12_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *UVplane, int UVpitch)
|
||||
@@ -2032,18 +2032,18 @@ static int D3D12_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
return SDL_SetError("Texture is not currently available");
|
||||
}
|
||||
|
||||
if (D3D12_UpdateTextureInternal(rendererData, textureData->mainTexture, 0, rect->x, rect->y, rect->w, rect->h, Yplane, Ypitch, &textureData->mainResourceState) < 0) {
|
||||
return -1;
|
||||
if (!D3D12_UpdateTextureInternal(rendererData, textureData->mainTexture, 0, rect->x, rect->y, rect->w, rect->h, Yplane, Ypitch, &textureData->mainResourceState)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (D3D12_UpdateTextureInternal(rendererData, textureData->mainTexture, 1, rect->x, rect->y, rect->w, rect->h, UVplane, UVpitch, &textureData->mainResourceState) < 0) {
|
||||
return -1;
|
||||
if (!D3D12_UpdateTextureInternal(rendererData, textureData->mainTexture, 1, rect->x, rect->y, rect->w, rect->h, UVplane, UVpitch, &textureData->mainResourceState)) {
|
||||
return false;
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int D3D12_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
static bool D3D12_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect, void **pixels, int *pitch)
|
||||
{
|
||||
D3D12_RenderData *rendererData = (D3D12_RenderData *)renderer->internal;
|
||||
@@ -2067,7 +2067,7 @@ static int D3D12_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
textureData->pitch = texture->w;
|
||||
textureData->pixels = (Uint8 *)SDL_malloc((texture->h * textureData->pitch * 3) / 2);
|
||||
if (!textureData->pixels) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
textureData->lockedRect = *rect;
|
||||
@@ -2075,7 +2075,7 @@ static int D3D12_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
(void *)(textureData->pixels + rect->y * textureData->pitch +
|
||||
rect->x * SDL_BYTESPERPIXEL(texture->format));
|
||||
*pitch = textureData->pitch;
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
if (textureData->stagingBuffer) {
|
||||
@@ -2161,7 +2161,7 @@ static int D3D12_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
*/
|
||||
*pixels = textureMemory;
|
||||
*pitch = pitchedDesc.RowPitch;
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void D3D12_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
@@ -2254,7 +2254,7 @@ static void D3D12_SetTextureScaleMode(SDL_Renderer *renderer, SDL_Texture *textu
|
||||
textureData->scaleMode = (scaleMode == SDL_SCALEMODE_NEAREST) ? D3D12_FILTER_MIN_MAG_MIP_POINT : D3D12_FILTER_MIN_MAG_MIP_LINEAR;
|
||||
}
|
||||
|
||||
static int D3D12_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
static bool D3D12_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
{
|
||||
D3D12_RenderData *rendererData = (D3D12_RenderData *)renderer->internal;
|
||||
D3D12_TextureData *textureData = NULL;
|
||||
@@ -2268,7 +2268,7 @@ static int D3D12_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
rendererData->textureRenderTarget->mainResourceState = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE;
|
||||
}
|
||||
rendererData->textureRenderTarget = NULL;
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
textureData = (D3D12_TextureData *)texture->internal;
|
||||
@@ -2284,15 +2284,15 @@ static int D3D12_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
D3D12_RESOURCE_STATE_RENDER_TARGET);
|
||||
rendererData->textureRenderTarget->mainResourceState = D3D12_RESOURCE_STATE_RENDER_TARGET;
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int D3D12_QueueNoOp(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
static bool D3D12_QueueNoOp(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
{
|
||||
return 0; // nothing to do in this backend.
|
||||
return true; // nothing to do in this backend.
|
||||
}
|
||||
|
||||
static int D3D12_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count)
|
||||
static bool D3D12_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count)
|
||||
{
|
||||
VertexPositionColor *verts = (VertexPositionColor *)SDL_AllocateRenderVertices(renderer, count * sizeof(VertexPositionColor), 0, &cmd->data.draw.first);
|
||||
int i;
|
||||
@@ -2300,7 +2300,7 @@ static int D3D12_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
|
||||
bool convert_color = SDL_RenderingLinearSpace(renderer);
|
||||
|
||||
if (!verts) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
cmd->data.draw.count = count;
|
||||
@@ -2318,10 +2318,10 @@ static int D3D12_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
|
||||
verts++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int D3D12_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
|
||||
static bool D3D12_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
|
||||
const float *xy, int xy_stride, const SDL_FColor *color, int color_stride, const float *uv, int uv_stride,
|
||||
int num_vertices, const void *indices, int num_indices, int size_indices,
|
||||
float scale_x, float scale_y)
|
||||
@@ -2335,7 +2335,7 @@ static int D3D12_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, S
|
||||
float v_scale = textureData ? (float)texture->h / textureData->h : 0.0f;
|
||||
|
||||
if (!verts) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
cmd->data.draw.count = count;
|
||||
@@ -2374,10 +2374,10 @@ static int D3D12_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, S
|
||||
|
||||
verts += 1;
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int D3D12_UpdateVertexBuffer(SDL_Renderer *renderer,
|
||||
static bool D3D12_UpdateVertexBuffer(SDL_Renderer *renderer,
|
||||
const void *vertexData, size_t dataSizeInBytes)
|
||||
{
|
||||
D3D12_RenderData *rendererData = (D3D12_RenderData *)renderer->internal;
|
||||
@@ -2391,7 +2391,7 @@ static int D3D12_UpdateVertexBuffer(SDL_Renderer *renderer,
|
||||
range.End = 0;
|
||||
|
||||
if (dataSizeInBytes == 0) {
|
||||
return 0; // nothing to do.
|
||||
return true; // nothing to do.
|
||||
}
|
||||
|
||||
if (rendererData->issueBatch) {
|
||||
@@ -2427,7 +2427,7 @@ static int D3D12_UpdateVertexBuffer(SDL_Renderer *renderer,
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static int D3D12_UpdateViewport(SDL_Renderer *renderer)
|
||||
static bool D3D12_UpdateViewport(SDL_Renderer *renderer)
|
||||
{
|
||||
D3D12_RenderData *data = (D3D12_RenderData *)renderer->internal;
|
||||
const SDL_Rect *viewport = &data->currentViewport;
|
||||
@@ -2444,7 +2444,7 @@ static int D3D12_UpdateViewport(SDL_Renderer *renderer)
|
||||
* with a non-empty viewport.
|
||||
*/
|
||||
// SDL_Log("%s, no viewport was set!\n", __FUNCTION__);
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Make sure the SDL viewport gets rotated to that of the physical display's rotation.
|
||||
@@ -2515,7 +2515,7 @@ static int D3D12_UpdateViewport(SDL_Renderer *renderer)
|
||||
|
||||
data->viewportDirty = false;
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void D3D12_SetupShaderConstants(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, const SDL_Texture *texture, PixelShaderConstants *constants)
|
||||
@@ -2580,7 +2580,7 @@ static void D3D12_SetupShaderConstants(SDL_Renderer *renderer, const SDL_RenderC
|
||||
}
|
||||
}
|
||||
|
||||
static int D3D12_SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, D3D12_Shader shader, const PixelShaderConstants *shader_constants,
|
||||
static bool D3D12_SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, D3D12_Shader shader, const PixelShaderConstants *shader_constants,
|
||||
D3D12_PRIMITIVE_TOPOLOGY_TYPE topology,
|
||||
const int numShaderResources, D3D12_CPU_DESCRIPTOR_HANDLE *shaderResources,
|
||||
D3D12_CPU_DESCRIPTOR_HANDLE *sampler, const Float4X4 *matrix)
|
||||
@@ -2633,7 +2633,7 @@ static int D3D12_SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *c
|
||||
|
||||
if (!currentPipelineState) {
|
||||
// The error has been set inside D3D12_CreatePipelineState()
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
ID3D12GraphicsCommandList2_SetPipelineState(rendererData->commandList, currentPipelineState->pipelineState);
|
||||
@@ -2652,7 +2652,7 @@ static int D3D12_SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *c
|
||||
}
|
||||
|
||||
if (rendererData->viewportDirty) {
|
||||
if (D3D12_UpdateViewport(renderer) == 0) {
|
||||
if (D3D12_UpdateViewport(renderer)) {
|
||||
// vertexShaderConstantsData.projectionAndView has changed
|
||||
updateSubresource = true;
|
||||
}
|
||||
@@ -2660,9 +2660,9 @@ static int D3D12_SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *c
|
||||
|
||||
if (rendererData->cliprectDirty) {
|
||||
D3D12_RECT scissorRect;
|
||||
if (D3D12_GetViewportAlignedD3DRect(renderer, &rendererData->currentCliprect, &scissorRect, TRUE) != 0) {
|
||||
if (!D3D12_GetViewportAlignedD3DRect(renderer, &rendererData->currentCliprect, &scissorRect, TRUE)) {
|
||||
// D3D12_GetViewportAlignedD3DRect will have set the SDL error
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
ID3D12GraphicsCommandList2_RSSetScissorRects(rendererData->commandList, 1, &scissorRect);
|
||||
rendererData->cliprectDirty = false;
|
||||
@@ -2727,10 +2727,10 @@ static int D3D12_SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *c
|
||||
SDL_memcpy(¤tPipelineState->shader_constants, shader_constants, sizeof(*shader_constants));
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int D3D12_SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, const Float4X4 *matrix)
|
||||
static bool D3D12_SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, const Float4X4 *matrix)
|
||||
{
|
||||
SDL_Texture *texture = cmd->data.draw.texture;
|
||||
D3D12_RenderData *rendererData = (D3D12_RenderData *)renderer->internal;
|
||||
@@ -2820,7 +2820,7 @@ static void D3D12_InvalidateCachedState(SDL_Renderer *renderer)
|
||||
data->viewportDirty = true;
|
||||
}
|
||||
|
||||
static int D3D12_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize)
|
||||
static bool D3D12_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize)
|
||||
{
|
||||
D3D12_RenderData *rendererData = (D3D12_RenderData *)renderer->internal;
|
||||
const int viewportRotation = D3D12_GetRotationForCurrentRenderTarget(renderer);
|
||||
@@ -2835,8 +2835,8 @@ static int D3D12_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
|
||||
rendererData->viewportDirty = true;
|
||||
}
|
||||
|
||||
if (D3D12_UpdateVertexBuffer(renderer, vertices, vertsize) < 0) {
|
||||
return -1;
|
||||
if (!D3D12_UpdateVertexBuffer(renderer, vertices, vertsize)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
while (cmd) {
|
||||
@@ -2953,7 +2953,7 @@ static int D3D12_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
|
||||
cmd = cmd->next;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static SDL_Surface *D3D12_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect)
|
||||
@@ -3032,7 +3032,7 @@ static SDL_Surface *D3D12_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rec
|
||||
D3D12_TransitionResource(data, backBuffer, D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE);
|
||||
|
||||
// Copy the desired portion of the back buffer to the staging texture:
|
||||
if (D3D12_GetViewportAlignedD3DRect(renderer, rect, &srcRect, FALSE) != 0) {
|
||||
if (!D3D12_GetViewportAlignedD3DRect(renderer, rect, &srcRect, FALSE)) {
|
||||
// D3D12_GetViewportAlignedD3DRect will have set the SDL error
|
||||
goto done;
|
||||
}
|
||||
@@ -3103,7 +3103,7 @@ done:
|
||||
return output;
|
||||
}
|
||||
|
||||
static int D3D12_RenderPresent(SDL_Renderer *renderer)
|
||||
static bool D3D12_RenderPresent(SDL_Renderer *renderer)
|
||||
{
|
||||
D3D12_RenderData *data = (D3D12_RenderData *)renderer->internal;
|
||||
HRESULT result;
|
||||
@@ -3139,7 +3139,7 @@ static int D3D12_RenderPresent(SDL_Renderer *renderer)
|
||||
} else {
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGISwapChain::Present"), result);
|
||||
}
|
||||
return -1;
|
||||
return false;
|
||||
} else {
|
||||
// Wait for the GPU and move to the next frame
|
||||
result = ID3D12CommandQueue_Signal(data->commandQueue, data->fence, data->fenceValue);
|
||||
@@ -3169,11 +3169,11 @@ static int D3D12_RenderPresent(SDL_Renderer *renderer)
|
||||
#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)
|
||||
D3D12_XBOX_StartFrame(data->d3dDevice, &data->frameToken);
|
||||
#endif
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
static int D3D12_SetVSync(SDL_Renderer *renderer, const int vsync)
|
||||
static bool D3D12_SetVSync(SDL_Renderer *renderer, const int vsync)
|
||||
{
|
||||
D3D12_RenderData *data = (D3D12_RenderData *)renderer->internal;
|
||||
|
||||
@@ -3188,10 +3188,10 @@ static int D3D12_SetVSync(SDL_Renderer *renderer, const int vsync)
|
||||
data->syncInterval = 0;
|
||||
data->presentFlags = DXGI_PRESENT_ALLOW_TEARING;
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
int D3D12_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_PropertiesID create_props)
|
||||
bool D3D12_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_PropertiesID create_props)
|
||||
{
|
||||
D3D12_RenderData *data;
|
||||
|
||||
@@ -3215,7 +3215,7 @@ int D3D12_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Propert
|
||||
|
||||
data = (D3D12_RenderData *)SDL_calloc(1, sizeof(*data));
|
||||
if (!data) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
data->identity = MatrixIdentity();
|
||||
@@ -3269,13 +3269,13 @@ int D3D12_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Propert
|
||||
|
||||
// Initialize Direct3D resources
|
||||
if (FAILED(D3D12_CreateDeviceResources(renderer))) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
if (FAILED(D3D12_CreateWindowSizeDependentResources(renderer))) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
SDL_RenderDriver D3D12_RenderDriver = {
|
||||
|
||||
@@ -35,8 +35,8 @@ static const GUID SDL_IID_ID3D12Device1 = { 0x77acce80, 0x638e, 0x4e65, { 0x88,
|
||||
static const GUID SDL_IID_ID3D12Resource = { 0x696442be, 0xa72e, 0x4059, { 0xbc, 0x79, 0x5b, 0x5c, 0x98, 0x04, 0x0f, 0xad } };
|
||||
static const GUID SDL_IID_IDXGIDevice1 = { 0x77db970f, 0x6276, 0x48ba, { 0xba, 0x28, 0x07, 0x01, 0x43, 0xb4, 0x39, 0x2c } };
|
||||
|
||||
extern "C" HRESULT
|
||||
D3D12_XBOX_CreateDevice(ID3D12Device **device, bool createDebug)
|
||||
extern "C"
|
||||
HRESULT D3D12_XBOX_CreateDevice(ID3D12Device **device, bool createDebug)
|
||||
{
|
||||
HRESULT result;
|
||||
D3D12XBOX_CREATE_DEVICE_PARAMETERS params;
|
||||
@@ -92,8 +92,8 @@ done:
|
||||
return result;
|
||||
}
|
||||
|
||||
extern "C" HRESULT
|
||||
D3D12_XBOX_CreateBackBufferTarget(ID3D12Device1 *device, int width, int height, void **resource)
|
||||
extern "C"
|
||||
HRESULT D3D12_XBOX_CreateBackBufferTarget(ID3D12Device1 *device, int width, int height, void **resource)
|
||||
{
|
||||
|
||||
D3D12_HEAP_PROPERTIES heapProps;
|
||||
@@ -129,15 +129,15 @@ D3D12_XBOX_CreateBackBufferTarget(ID3D12Device1 *device, int width, int height,
|
||||
);
|
||||
}
|
||||
|
||||
extern "C" HRESULT
|
||||
D3D12_XBOX_StartFrame(ID3D12Device1 *device, UINT64 *outToken)
|
||||
extern "C"
|
||||
HRESULT D3D12_XBOX_StartFrame(ID3D12Device1 *device, UINT64 *outToken)
|
||||
{
|
||||
*outToken = D3D12XBOX_FRAME_PIPELINE_TOKEN_NULL;
|
||||
return device->WaitFrameEventX(D3D12XBOX_FRAME_EVENT_ORIGIN, INFINITE, NULL, D3D12XBOX_WAIT_FRAME_EVENT_FLAG_NONE, outToken);
|
||||
}
|
||||
|
||||
extern "C" HRESULT
|
||||
D3D12_XBOX_PresentFrame(ID3D12CommandQueue *commandQueue, UINT64 token, ID3D12Resource *renderTarget)
|
||||
extern "C"
|
||||
HRESULT D3D12_XBOX_PresentFrame(ID3D12CommandQueue *commandQueue, UINT64 token, ID3D12Resource *renderTarget)
|
||||
{
|
||||
D3D12XBOX_PRESENT_PLANE_PARAMETERS planeParameters;
|
||||
SDL_zero(planeParameters);
|
||||
@@ -147,8 +147,8 @@ D3D12_XBOX_PresentFrame(ID3D12CommandQueue *commandQueue, UINT64 token, ID3D12Re
|
||||
return commandQueue->PresentX(1, &planeParameters, NULL);
|
||||
}
|
||||
|
||||
extern "C" void
|
||||
D3D12_XBOX_GetResolution(Uint32 *width, Uint32 *height)
|
||||
extern "C"
|
||||
void D3D12_XBOX_GetResolution(Uint32 *width, Uint32 *height)
|
||||
{
|
||||
switch (XSystemGetDeviceType()) {
|
||||
case XSystemDeviceType::XboxScarlettLockhart:
|
||||
|
||||
@@ -101,28 +101,28 @@ static struct
|
||||
{ D3D12_RootSig_Advanced, sizeof(D3D12_RootSig_Advanced) },
|
||||
};
|
||||
|
||||
extern "C" void
|
||||
D3D12_GetVertexShader(D3D12_Shader shader, D3D12_SHADER_BYTECODE *outBytecode)
|
||||
extern "C"
|
||||
void D3D12_GetVertexShader(D3D12_Shader shader, D3D12_SHADER_BYTECODE *outBytecode)
|
||||
{
|
||||
outBytecode->pShaderBytecode = D3D12_shaders[shader].vs_shader_data;
|
||||
outBytecode->BytecodeLength = D3D12_shaders[shader].vs_shader_size;
|
||||
}
|
||||
|
||||
extern "C" void
|
||||
D3D12_GetPixelShader(D3D12_Shader shader, D3D12_SHADER_BYTECODE *outBytecode)
|
||||
extern "C"
|
||||
void D3D12_GetPixelShader(D3D12_Shader shader, D3D12_SHADER_BYTECODE *outBytecode)
|
||||
{
|
||||
outBytecode->pShaderBytecode = D3D12_shaders[shader].ps_shader_data;
|
||||
outBytecode->BytecodeLength = D3D12_shaders[shader].ps_shader_size;
|
||||
}
|
||||
|
||||
extern "C" D3D12_RootSignature
|
||||
D3D12_GetRootSignatureType(D3D12_Shader shader)
|
||||
extern "C"
|
||||
D3D12_RootSignature D3D12_GetRootSignatureType(D3D12_Shader shader)
|
||||
{
|
||||
return D3D12_shaders[shader].root_sig;
|
||||
}
|
||||
|
||||
extern "C" void
|
||||
D3D12_GetRootSignatureData(D3D12_RootSignature rootSig, D3D12_SHADER_BYTECODE *outBytecode)
|
||||
extern "C"
|
||||
void D3D12_GetRootSignatureData(D3D12_RootSignature rootSig, D3D12_SHADER_BYTECODE *outBytecode)
|
||||
{
|
||||
outBytecode->pShaderBytecode = D3D12_rootsigs[rootSig].rs_shader_data;
|
||||
outBytecode->BytecodeLength = D3D12_rootsigs[rootSig].rs_shader_size;
|
||||
|
||||
@@ -102,28 +102,28 @@ static struct
|
||||
{ D3D12_RootSig_Advanced, sizeof(D3D12_RootSig_Advanced) },
|
||||
};
|
||||
|
||||
extern "C" void
|
||||
D3D12_GetVertexShader(D3D12_Shader shader, D3D12_SHADER_BYTECODE *outBytecode)
|
||||
extern "C"
|
||||
void D3D12_GetVertexShader(D3D12_Shader shader, D3D12_SHADER_BYTECODE *outBytecode)
|
||||
{
|
||||
outBytecode->pShaderBytecode = D3D12_shaders[shader].vs_shader_data;
|
||||
outBytecode->BytecodeLength = D3D12_shaders[shader].vs_shader_size;
|
||||
}
|
||||
|
||||
extern "C" void
|
||||
D3D12_GetPixelShader(D3D12_Shader shader, D3D12_SHADER_BYTECODE *outBytecode)
|
||||
extern "C"
|
||||
void D3D12_GetPixelShader(D3D12_Shader shader, D3D12_SHADER_BYTECODE *outBytecode)
|
||||
{
|
||||
outBytecode->pShaderBytecode = D3D12_shaders[shader].ps_shader_data;
|
||||
outBytecode->BytecodeLength = D3D12_shaders[shader].ps_shader_size;
|
||||
}
|
||||
|
||||
extern "C" D3D12_RootSignature
|
||||
D3D12_GetRootSignatureType(D3D12_Shader shader)
|
||||
extern "C"
|
||||
D3D12_RootSignature D3D12_GetRootSignatureType(D3D12_Shader shader)
|
||||
{
|
||||
return D3D12_shaders[shader].root_sig;
|
||||
}
|
||||
|
||||
extern "C" void
|
||||
D3D12_GetRootSignatureData(D3D12_RootSignature rootSig, D3D12_SHADER_BYTECODE *outBytecode)
|
||||
extern "C"
|
||||
void D3D12_GetRootSignatureData(D3D12_RootSignature rootSig, D3D12_SHADER_BYTECODE *outBytecode)
|
||||
{
|
||||
outBytecode->pShaderBytecode = D3D12_rootsigs[rootSig].rs_shader_data;
|
||||
outBytecode->BytecodeLength = D3D12_rootsigs[rootSig].rs_shader_size;
|
||||
|
||||
@@ -517,7 +517,7 @@ static void METAL_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *eve
|
||||
{
|
||||
}
|
||||
|
||||
static int METAL_GetOutputSize(SDL_Renderer *renderer, int *w, int *h)
|
||||
static bool METAL_GetOutputSize(SDL_Renderer *renderer, int *w, int *h)
|
||||
{
|
||||
@autoreleasepool {
|
||||
SDL3METAL_RenderData *data = (__bridge SDL3METAL_RenderData *)renderer->internal;
|
||||
@@ -527,7 +527,7 @@ static int METAL_GetOutputSize(SDL_Renderer *renderer, int *w, int *h)
|
||||
if (h) {
|
||||
*h = (int)data.mtllayer.drawableSize.height;
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -629,7 +629,7 @@ size_t GetYCbCRtoRGBConversionMatrix(SDL_Colorspace colorspace, int w, int h, in
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int METAL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_PropertiesID create_props)
|
||||
static bool METAL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_PropertiesID create_props)
|
||||
{
|
||||
@autoreleasepool {
|
||||
SDL3METAL_RenderData *data = (__bridge SDL3METAL_RenderData *)renderer->internal;
|
||||
@@ -771,7 +771,7 @@ static int METAL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL
|
||||
#endif
|
||||
texture->internal = (void *)CFBridgingRetain(texturedata);
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -795,7 +795,7 @@ static MTLStorageMode METAL_GetStorageMode(id<MTLResource> resource)
|
||||
return MTLStorageModeShared;
|
||||
}
|
||||
|
||||
static int METAL_UpdateTextureInternal(SDL_Renderer *renderer, SDL3METAL_TextureData *texturedata,
|
||||
static bool METAL_UpdateTextureInternal(SDL_Renderer *renderer, SDL3METAL_TextureData *texturedata,
|
||||
id<MTLTexture> texture, SDL_Rect rect, int slice,
|
||||
const void *pixels, int pitch)
|
||||
{
|
||||
@@ -810,7 +810,7 @@ static int METAL_UpdateTextureInternal(SDL_Renderer *renderer, SDL3METAL_Texture
|
||||
* to a staging texture and copy that over. */
|
||||
if (!texturedata.hasdata && METAL_GetStorageMode(texture) != MTLStorageModePrivate) {
|
||||
METAL_UploadTextureData(texture, rect, slice, pixels, pitch);
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
desc = [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:texture.pixelFormat
|
||||
@@ -860,17 +860,17 @@ static int METAL_UpdateTextureInternal(SDL_Renderer *renderer, SDL3METAL_Texture
|
||||
[data.mtlcmdbuffer commit];
|
||||
data.mtlcmdbuffer = nil;
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int METAL_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
static bool METAL_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect, const void *pixels, int pitch)
|
||||
{
|
||||
@autoreleasepool {
|
||||
SDL3METAL_TextureData *texturedata = (__bridge SDL3METAL_TextureData *)texture->internal;
|
||||
|
||||
if (METAL_UpdateTextureInternal(renderer, texturedata, texturedata.mtltexture, *rect, 0, pixels, pitch) < 0) {
|
||||
return -1;
|
||||
if (!METAL_UpdateTextureInternal(renderer, texturedata, texturedata.mtltexture, *rect, 0, pixels, pitch)) {
|
||||
return false;
|
||||
}
|
||||
#if SDL_HAVE_YUV
|
||||
if (texturedata.yuv) {
|
||||
@@ -881,14 +881,14 @@ static int METAL_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *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;
|
||||
if (!METAL_UpdateTextureInternal(renderer, texturedata, texturedata.mtltextureUv, UVrect, Uslice, pixels, UVpitch)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 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;
|
||||
if (!METAL_UpdateTextureInternal(renderer, texturedata, texturedata.mtltextureUv, UVrect, Vslice, pixels, UVpitch)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -898,19 +898,19 @@ static int METAL_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *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;
|
||||
if (!METAL_UpdateTextureInternal(renderer, texturedata, texturedata.mtltextureUv, UVrect, 0, pixels, UVpitch)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
texturedata.hasdata = YES;
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
#if SDL_HAVE_YUV
|
||||
static int METAL_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
static bool METAL_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *Uplane, int Upitch,
|
||||
@@ -924,26 +924,26 @@ static int METAL_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
|
||||
// Bail out if we're supposed to update an empty rectangle
|
||||
if (rect->w <= 0 || rect->h <= 0) {
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (METAL_UpdateTextureInternal(renderer, texturedata, texturedata.mtltexture, *rect, 0, Yplane, Ypitch) < 0) {
|
||||
return -1;
|
||||
if (!METAL_UpdateTextureInternal(renderer, texturedata, texturedata.mtltexture, *rect, 0, Yplane, Ypitch)) {
|
||||
return false;
|
||||
}
|
||||
if (METAL_UpdateTextureInternal(renderer, texturedata, texturedata.mtltextureUv, UVrect, Uslice, Uplane, Upitch)) {
|
||||
return -1;
|
||||
if (!METAL_UpdateTextureInternal(renderer, texturedata, texturedata.mtltextureUv, UVrect, Uslice, Uplane, Upitch)) {
|
||||
return false;
|
||||
}
|
||||
if (METAL_UpdateTextureInternal(renderer, texturedata, texturedata.mtltextureUv, UVrect, Vslice, Vplane, Vpitch)) {
|
||||
return -1;
|
||||
if (!METAL_UpdateTextureInternal(renderer, texturedata, texturedata.mtltextureUv, UVrect, Vslice, Vplane, Vpitch)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
texturedata.hasdata = YES;
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
static int METAL_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
static bool METAL_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *UVplane, int UVpitch)
|
||||
@@ -954,25 +954,25 @@ static int METAL_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
|
||||
// Bail out if we're supposed to update an empty rectangle
|
||||
if (rect->w <= 0 || rect->h <= 0) {
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (METAL_UpdateTextureInternal(renderer, texturedata, texturedata.mtltexture, *rect, 0, Yplane, Ypitch) < 0) {
|
||||
return -1;
|
||||
if (!METAL_UpdateTextureInternal(renderer, texturedata, texturedata.mtltexture, *rect, 0, Yplane, Ypitch)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (METAL_UpdateTextureInternal(renderer, texturedata, texturedata.mtltextureUv, UVrect, 0, UVplane, UVpitch) < 0) {
|
||||
return -1;
|
||||
if (!METAL_UpdateTextureInternal(renderer, texturedata, texturedata.mtltextureUv, UVrect, 0, UVplane, UVpitch)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
texturedata.hasdata = YES;
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static int METAL_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
static bool METAL_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect, void **pixels, int *pitch)
|
||||
{
|
||||
@autoreleasepool {
|
||||
@@ -1004,7 +1004,7 @@ static int METAL_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
texturedata.lockedbuffer = lockedbuffer;
|
||||
*pixels = [lockedbuffer contents];
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1099,7 +1099,7 @@ static void METAL_SetTextureScaleMode(SDL_Renderer *renderer, SDL_Texture *textu
|
||||
{
|
||||
}
|
||||
|
||||
static int METAL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
static bool METAL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
{
|
||||
@autoreleasepool {
|
||||
SDL3METAL_RenderData *data = (__bridge SDL3METAL_RenderData *)renderer->internal;
|
||||
@@ -1117,11 +1117,11 @@ static int METAL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
/* We don't begin a new render pass right away - we delay it until an actual
|
||||
* draw or clear happens. That way we can use hardware clears when possible,
|
||||
* which are only available when beginning a new render pass. */
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
static int METAL_QueueSetViewport(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
static bool METAL_QueueSetViewport(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
{
|
||||
float projection[4][4]; // Prepare an orthographic projection
|
||||
const int w = cmd->data.viewport.rect.w;
|
||||
@@ -1129,7 +1129,7 @@ static int METAL_QueueSetViewport(SDL_Renderer *renderer, SDL_RenderCommand *cmd
|
||||
const size_t matrixlen = sizeof(projection);
|
||||
float *matrix = (float *)SDL_AllocateRenderVertices(renderer, matrixlen, CONSTANT_ALIGN(16), &cmd->data.viewport.first);
|
||||
if (!matrix) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
SDL_memset(projection, '\0', matrixlen);
|
||||
@@ -1142,15 +1142,15 @@ static int METAL_QueueSetViewport(SDL_Renderer *renderer, SDL_RenderCommand *cmd
|
||||
}
|
||||
SDL_memcpy(matrix, projection, matrixlen);
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int METAL_QueueNoOp(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
static bool METAL_QueueNoOp(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
{
|
||||
return 0; // nothing to do in this backend.
|
||||
return true; // nothing to do in this backend.
|
||||
}
|
||||
|
||||
static int METAL_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count)
|
||||
static bool METAL_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count)
|
||||
{
|
||||
SDL_FColor color = cmd->data.draw.color;
|
||||
bool convert_color = SDL_RenderingLinearSpace(renderer);
|
||||
@@ -1158,7 +1158,7 @@ static int METAL_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
|
||||
const size_t vertlen = (2 * sizeof(float) + 4 * sizeof(float)) * count;
|
||||
float *verts = (float *)SDL_AllocateRenderVertices(renderer, vertlen, DEVICE_ALIGN(8), &cmd->data.draw.first);
|
||||
if (!verts) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
cmd->data.draw.count = count;
|
||||
|
||||
@@ -1174,10 +1174,10 @@ static int METAL_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
|
||||
*(verts++) = color.b;
|
||||
*(verts++) = color.a;
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int METAL_QueueDrawLines(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count)
|
||||
static bool METAL_QueueDrawLines(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count)
|
||||
{
|
||||
SDL_FColor color = cmd->data.draw.color;
|
||||
bool convert_color = SDL_RenderingLinearSpace(renderer);
|
||||
@@ -1189,7 +1189,7 @@ static int METAL_QueueDrawLines(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
|
||||
vertlen = (2 * sizeof(float) + 4 * sizeof(float)) * count;
|
||||
verts = (float *)SDL_AllocateRenderVertices(renderer, vertlen, DEVICE_ALIGN(8), &cmd->data.draw.first);
|
||||
if (!verts) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
cmd->data.draw.count = count;
|
||||
|
||||
@@ -1230,10 +1230,10 @@ static int METAL_QueueDrawLines(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int METAL_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
|
||||
static bool METAL_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
|
||||
const float *xy, int xy_stride, const SDL_FColor *color, int color_stride, const float *uv, int uv_stride,
|
||||
int num_vertices, const void *indices, int num_indices, int size_indices,
|
||||
float scale_x, float scale_y)
|
||||
@@ -1243,7 +1243,7 @@ static int METAL_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, S
|
||||
const size_t vertlen = (2 * sizeof(float) + 4 * sizeof(float) + (texture ? 2 : 0) * sizeof(float)) * count;
|
||||
float *verts = (float *)SDL_AllocateRenderVertices(renderer, vertlen, DEVICE_ALIGN(8), &cmd->data.draw.first);
|
||||
if (!verts) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
cmd->data.draw.count = count;
|
||||
@@ -1286,7 +1286,7 @@ static int METAL_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, S
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
// These should mirror the definitions in SDL_shaders_metal.metal
|
||||
@@ -1540,7 +1540,7 @@ static void METAL_InvalidateCachedState(SDL_Renderer *renderer)
|
||||
// METAL_DrawStateCache only exists during a run of METAL_RunCommandQueue, so there's nothing to invalidate!
|
||||
}
|
||||
|
||||
static int METAL_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize)
|
||||
static bool METAL_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize)
|
||||
{
|
||||
@autoreleasepool {
|
||||
SDL3METAL_RenderData *data = (__bridge SDL3METAL_RenderData *)renderer->internal;
|
||||
@@ -1685,7 +1685,7 @@ static int METAL_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
|
||||
cmd = cmd->next;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1754,7 +1754,7 @@ static SDL_Surface *METAL_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rec
|
||||
}
|
||||
}
|
||||
|
||||
static int METAL_RenderPresent(SDL_Renderer *renderer)
|
||||
static bool METAL_RenderPresent(SDL_Renderer *renderer)
|
||||
{
|
||||
@autoreleasepool {
|
||||
SDL3METAL_RenderData *data = (__bridge SDL3METAL_RenderData *)renderer->internal;
|
||||
@@ -1788,9 +1788,9 @@ static int METAL_RenderPresent(SDL_Renderer *renderer)
|
||||
data.mtlbackbuffer = nil;
|
||||
|
||||
if (renderer->hidden || !ready) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1844,7 +1844,7 @@ static void *METAL_GetMetalCommandEncoder(SDL_Renderer *renderer)
|
||||
}
|
||||
}
|
||||
|
||||
static int METAL_SetVSync(SDL_Renderer *renderer, const int vsync)
|
||||
static bool METAL_SetVSync(SDL_Renderer *renderer, const int vsync)
|
||||
{
|
||||
#if (defined(SDL_PLATFORM_MACOS) && defined(MAC_OS_X_VERSION_10_13)) || TARGET_OS_MACCATALYST
|
||||
if (@available(macOS 10.13, *)) {
|
||||
@@ -1859,12 +1859,12 @@ static int METAL_SetVSync(SDL_Renderer *renderer, const int vsync)
|
||||
default:
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
switch (vsync) {
|
||||
case 1:
|
||||
return 0;
|
||||
return true;
|
||||
default:
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
@@ -1900,7 +1900,7 @@ static SDL_MetalView GetWindowView(SDL_Window *window)
|
||||
return nil;
|
||||
}
|
||||
|
||||
static int METAL_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_PropertiesID create_props)
|
||||
static bool METAL_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_PropertiesID create_props)
|
||||
{
|
||||
@autoreleasepool {
|
||||
SDL3METAL_RenderData *data = NULL;
|
||||
@@ -1963,7 +1963,7 @@ static int METAL_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_
|
||||
const size_t YCbCr_shader_matrix_size = 4 * 4 * sizeof(float);
|
||||
|
||||
if (!IsMetalAvailable()) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
SDL_SetupRendererColorspace(renderer, create_props);
|
||||
@@ -2008,7 +2008,7 @@ static int METAL_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_
|
||||
}
|
||||
|
||||
if (view == NULL) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
// !!! FIXME: error checking on all of this.
|
||||
@@ -2232,7 +2232,7 @@ static int METAL_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_
|
||||
|
||||
SDL_SetNumberProperty(SDL_GetRendererProperties(renderer), SDL_PROP_RENDERER_MAX_TEXTURE_SIZE_NUMBER, maxtexsize);
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -196,20 +196,20 @@ static void GL_ClearErrors(SDL_Renderer *renderer)
|
||||
}
|
||||
}
|
||||
|
||||
static int GL_CheckAllErrors(const char *prefix, SDL_Renderer *renderer, const char *file, int line, const char *function)
|
||||
static bool GL_CheckAllErrors(const char *prefix, SDL_Renderer *renderer, const char *file, int line, const char *function)
|
||||
{
|
||||
GL_RenderData *data = (GL_RenderData *)renderer->internal;
|
||||
int ret = 0;
|
||||
bool result = true;
|
||||
|
||||
if (!data->debug_enabled) {
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
if (data->GL_ARB_debug_output_supported) {
|
||||
if (data->errors) {
|
||||
int i;
|
||||
for (i = 0; i < data->errors; ++i) {
|
||||
SDL_SetError("%s: %s (%d): %s %s", prefix, file, line, function, data->error_messages[i]);
|
||||
ret = -1;
|
||||
result = false;
|
||||
}
|
||||
GL_ClearErrors(renderer);
|
||||
}
|
||||
@@ -222,13 +222,13 @@ static int GL_CheckAllErrors(const char *prefix, SDL_Renderer *renderer, const c
|
||||
prefix = "generic";
|
||||
}
|
||||
SDL_SetError("%s: %s (%d): %s %s (0x%X)", prefix, file, line, function, GL_TranslateError(error), error);
|
||||
ret = -1;
|
||||
result = false;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
return result;
|
||||
}
|
||||
|
||||
#if 0
|
||||
@@ -237,39 +237,39 @@ static int GL_CheckAllErrors(const char *prefix, SDL_Renderer *renderer, const c
|
||||
#define GL_CheckError(prefix, renderer) GL_CheckAllErrors(prefix, renderer, SDL_FILE, SDL_LINE, SDL_FUNCTION)
|
||||
#endif
|
||||
|
||||
static int GL_LoadFunctions(GL_RenderData *data)
|
||||
static bool GL_LoadFunctions(GL_RenderData *data)
|
||||
{
|
||||
#ifdef __SDL_NOGETPROCADDR__
|
||||
#define SDL_PROC(ret, func, params) data->func = func;
|
||||
#else
|
||||
int retval = 0;
|
||||
bool result = true;
|
||||
#define SDL_PROC(ret, func, params) \
|
||||
do { \
|
||||
data->func = (ret (APIENTRY *) params)SDL_GL_GetProcAddress(#func); \
|
||||
if (!data->func) { \
|
||||
retval = SDL_SetError("Couldn't load GL function %s: %s", #func, SDL_GetError()); \
|
||||
result = SDL_SetError("Couldn't load GL function %s: %s", #func, SDL_GetError()); \
|
||||
} \
|
||||
} while (0);
|
||||
#endif // __SDL_NOGETPROCADDR__
|
||||
|
||||
#include "SDL_glfuncs.h"
|
||||
#undef SDL_PROC
|
||||
return retval;
|
||||
return result;
|
||||
}
|
||||
|
||||
static int GL_ActivateRenderer(SDL_Renderer *renderer)
|
||||
static bool GL_ActivateRenderer(SDL_Renderer *renderer)
|
||||
{
|
||||
GL_RenderData *data = (GL_RenderData *)renderer->internal;
|
||||
|
||||
if (SDL_GL_GetCurrentContext() != data->context) {
|
||||
if (SDL_GL_MakeCurrent(renderer->window, data->context) < 0) {
|
||||
return -1;
|
||||
if (!SDL_GL_MakeCurrent(renderer->window, data->context)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
GL_ClearErrors(renderer);
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void APIENTRY GL_HandleDebugMessage(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const char *message, const void *userParam)
|
||||
@@ -439,7 +439,7 @@ static bool convert_format(Uint32 pixel_format, GLint *internalFormat, GLenum *f
|
||||
return true;
|
||||
}
|
||||
|
||||
static int GL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_PropertiesID create_props)
|
||||
static bool GL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_PropertiesID create_props)
|
||||
{
|
||||
GL_RenderData *renderdata = (GL_RenderData *)renderer->internal;
|
||||
const GLenum textype = renderdata->textype;
|
||||
@@ -466,7 +466,7 @@ static int GL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_Pr
|
||||
|
||||
data = (GL_TextureData *)SDL_calloc(1, sizeof(*data));
|
||||
if (!data) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (texture->access == SDL_TEXTUREACCESS_STREAMING) {
|
||||
@@ -486,7 +486,7 @@ static int GL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_Pr
|
||||
data->pixels = SDL_calloc(1, size);
|
||||
if (!data->pixels) {
|
||||
SDL_free(data);
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -502,12 +502,12 @@ static int GL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_Pr
|
||||
} else {
|
||||
GL_CheckError("", renderer);
|
||||
renderdata->glGenTextures(1, &data->texture);
|
||||
if (GL_CheckError("glGenTextures()", renderer) < 0) {
|
||||
if (!GL_CheckError("glGenTextures()", renderer)) {
|
||||
if (data->pixels) {
|
||||
SDL_free(data->pixels);
|
||||
}
|
||||
SDL_free(data);
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
texture->internal = data;
|
||||
@@ -573,8 +573,8 @@ static int GL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_Pr
|
||||
texture_h, 0, format, type, NULL);
|
||||
}
|
||||
renderdata->glDisable(textype);
|
||||
if (GL_CheckError("glTexImage2D()", renderer) < 0) {
|
||||
return -1;
|
||||
if (!GL_CheckError("glTexImage2D()", renderer)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
#if SDL_HAVE_YUV
|
||||
@@ -668,7 +668,7 @@ static int GL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_Pr
|
||||
return GL_CheckError("", renderer);
|
||||
}
|
||||
|
||||
static int GL_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
static bool GL_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect, const void *pixels, int pitch)
|
||||
{
|
||||
GL_RenderData *renderdata = (GL_RenderData *)renderer->internal;
|
||||
@@ -730,7 +730,7 @@ static int GL_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
}
|
||||
|
||||
#if SDL_HAVE_YUV
|
||||
static int GL_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
static bool GL_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *Uplane, int Upitch,
|
||||
@@ -766,7 +766,7 @@ static int GL_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
return GL_CheckError("glTexSubImage2D()", renderer);
|
||||
}
|
||||
|
||||
static int GL_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
static bool GL_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *UVplane, int UVpitch)
|
||||
@@ -796,7 +796,7 @@ static int GL_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
}
|
||||
#endif
|
||||
|
||||
static int GL_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
static bool GL_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect, void **pixels, int *pitch)
|
||||
{
|
||||
GL_TextureData *data = (GL_TextureData *)texture->internal;
|
||||
@@ -806,7 +806,7 @@ static int GL_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
(void *)((Uint8 *)data->pixels + rect->y * data->pitch +
|
||||
rect->x * SDL_BYTESPERPIXEL(texture->format));
|
||||
*pitch = data->pitch;
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void GL_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
@@ -854,7 +854,7 @@ static void GL_SetTextureScaleMode(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
#endif
|
||||
}
|
||||
|
||||
static int GL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
static bool GL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
{
|
||||
GL_RenderData *data = (GL_RenderData *)renderer->internal;
|
||||
GL_TextureData *texturedata;
|
||||
@@ -870,7 +870,7 @@ static int GL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
|
||||
if (!texture) {
|
||||
data->glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
texturedata = (GL_TextureData *)texture->internal;
|
||||
@@ -882,24 +882,24 @@ static int GL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
if (status != GL_FRAMEBUFFER_COMPLETE_EXT) {
|
||||
return SDL_SetError("glFramebufferTexture2DEXT() failed");
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* !!! FIXME: all these Queue* calls set up the vertex buffer the way the immediate mode
|
||||
!!! FIXME: renderer wants it, but this might want to operate differently if we move to
|
||||
!!! FIXME: VBOs at some point. */
|
||||
static int GL_QueueNoOp(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
static bool GL_QueueNoOp(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
{
|
||||
return 0; // nothing to do in this backend.
|
||||
return true; // nothing to do in this backend.
|
||||
}
|
||||
|
||||
static int GL_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count)
|
||||
static bool GL_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count)
|
||||
{
|
||||
GLfloat *verts = (GLfloat *)SDL_AllocateRenderVertices(renderer, count * 2 * sizeof(GLfloat), 0, &cmd->data.draw.first);
|
||||
int i;
|
||||
|
||||
if (!verts) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
cmd->data.draw.count = count;
|
||||
@@ -908,10 +908,10 @@ static int GL_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, co
|
||||
*(verts++) = 0.5f + points[i].y;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int GL_QueueDrawLines(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count)
|
||||
static bool GL_QueueDrawLines(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count)
|
||||
{
|
||||
int i;
|
||||
GLfloat prevx, prevy;
|
||||
@@ -919,7 +919,7 @@ static int GL_QueueDrawLines(SDL_Renderer *renderer, SDL_RenderCommand *cmd, con
|
||||
GLfloat *verts = (GLfloat *)SDL_AllocateRenderVertices(renderer, vertlen, 0, &cmd->data.draw.first);
|
||||
|
||||
if (!verts) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
cmd->data.draw.count = count;
|
||||
|
||||
@@ -948,10 +948,10 @@ static int GL_QueueDrawLines(SDL_Renderer *renderer, SDL_RenderCommand *cmd, con
|
||||
*(verts++) = prevy;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int GL_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
|
||||
static bool GL_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
|
||||
const float *xy, int xy_stride, const SDL_FColor *color, int color_stride, const float *uv, int uv_stride,
|
||||
int num_vertices, const void *indices, int num_indices, int size_indices,
|
||||
float scale_x, float scale_y)
|
||||
@@ -965,7 +965,7 @@ static int GL_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_
|
||||
|
||||
verts = (GLfloat *)SDL_AllocateRenderVertices(renderer, count * sz, 0, &cmd->data.draw.first);
|
||||
if (!verts) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (texture) {
|
||||
@@ -1006,10 +1006,10 @@ static int GL_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_
|
||||
*(verts++) = uv_[1] * texturedata->texh;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int SetDrawState(GL_RenderData *data, const SDL_RenderCommand *cmd, const GL_Shader shader, const float *shader_params)
|
||||
static bool SetDrawState(GL_RenderData *data, const SDL_RenderCommand *cmd, const GL_Shader shader, const float *shader_params)
|
||||
{
|
||||
const SDL_BlendMode blend = cmd->data.draw.blend;
|
||||
bool vertex_array;
|
||||
@@ -1117,10 +1117,10 @@ static int SetDrawState(GL_RenderData *data, const SDL_RenderCommand *cmd, const
|
||||
data->drawstate.texture_array = texture_array;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int SetTextureAddressMode(GL_RenderData *data, GLenum textype, SDL_TextureAddressMode addressMode)
|
||||
static bool SetTextureAddressMode(GL_RenderData *data, GLenum textype, SDL_TextureAddressMode addressMode)
|
||||
{
|
||||
switch (addressMode) {
|
||||
case SDL_TEXTURE_ADDRESS_CLAMP:
|
||||
@@ -1134,10 +1134,10 @@ static int SetTextureAddressMode(GL_RenderData *data, GLenum textype, SDL_Textur
|
||||
default:
|
||||
return SDL_SetError("Unknown texture address mode: %d\n", addressMode);
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int SetCopyState(GL_RenderData *data, const SDL_RenderCommand *cmd)
|
||||
static bool SetCopyState(GL_RenderData *data, const SDL_RenderCommand *cmd)
|
||||
{
|
||||
SDL_Texture *texture = cmd->data.draw.texture;
|
||||
const GL_TextureData *texturedata = (GL_TextureData *)texture->internal;
|
||||
@@ -1153,8 +1153,8 @@ static int SetCopyState(GL_RenderData *data, const SDL_RenderCommand *cmd)
|
||||
}
|
||||
data->glBindTexture(textype, texturedata->vtexture);
|
||||
|
||||
if (SetTextureAddressMode(data, textype, cmd->data.draw.texture_address_mode) < 0) {
|
||||
return -1;
|
||||
if (!SetTextureAddressMode(data, textype, cmd->data.draw.texture_address_mode)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (data->GL_ARB_multitexture_supported) {
|
||||
@@ -1162,8 +1162,8 @@ static int SetCopyState(GL_RenderData *data, const SDL_RenderCommand *cmd)
|
||||
}
|
||||
data->glBindTexture(textype, texturedata->utexture);
|
||||
|
||||
if (SetTextureAddressMode(data, textype, cmd->data.draw.texture_address_mode) < 0) {
|
||||
return -1;
|
||||
if (!SetTextureAddressMode(data, textype, cmd->data.draw.texture_address_mode)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (texturedata->nv12) {
|
||||
@@ -1172,8 +1172,8 @@ static int SetCopyState(GL_RenderData *data, const SDL_RenderCommand *cmd)
|
||||
}
|
||||
data->glBindTexture(textype, texturedata->utexture);
|
||||
|
||||
if (SetTextureAddressMode(data, textype, cmd->data.draw.texture_address_mode) < 0) {
|
||||
return -1;
|
||||
if (!SetTextureAddressMode(data, textype, cmd->data.draw.texture_address_mode)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1182,14 +1182,14 @@ static int SetCopyState(GL_RenderData *data, const SDL_RenderCommand *cmd)
|
||||
}
|
||||
data->glBindTexture(textype, texturedata->texture);
|
||||
|
||||
if (SetTextureAddressMode(data, textype, cmd->data.draw.texture_address_mode) < 0) {
|
||||
return -1;
|
||||
if (!SetTextureAddressMode(data, textype, cmd->data.draw.texture_address_mode)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
data->drawstate.texture = texture;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void GL_InvalidateCachedState(SDL_Renderer *renderer)
|
||||
@@ -1211,13 +1211,13 @@ static void GL_InvalidateCachedState(SDL_Renderer *renderer)
|
||||
cache->clear_color_dirty = true;
|
||||
}
|
||||
|
||||
static int GL_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize)
|
||||
static bool 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...
|
||||
GL_RenderData *data = (GL_RenderData *)renderer->internal;
|
||||
|
||||
if (GL_ActivateRenderer(renderer) < 0) {
|
||||
return -1;
|
||||
if (!GL_ActivateRenderer(renderer)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
data->drawstate.target = renderer->target;
|
||||
@@ -1327,7 +1327,7 @@ static int GL_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
|
||||
|
||||
case SDL_RENDERCMD_DRAW_LINES:
|
||||
{
|
||||
if (SetDrawState(data, cmd, SHADER_SOLID, NULL) == 0) {
|
||||
if (SetDrawState(data, cmd, SHADER_SOLID, NULL)) {
|
||||
size_t count = cmd->data.draw.count;
|
||||
const GLfloat *verts = (GLfloat *)(((Uint8 *)vertices) + cmd->data.draw.first);
|
||||
|
||||
@@ -1396,7 +1396,7 @@ static int GL_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
|
||||
ret = SetDrawState(data, cmd, SHADER_SOLID, NULL);
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
if (ret) {
|
||||
const GLfloat *verts = (GLfloat *)(((Uint8 *)vertices) + cmd->data.draw.first);
|
||||
int op = GL_TRIANGLES; // SDL_RENDERCMD_GEOMETRY
|
||||
if (thiscmdtype == SDL_RENDERCMD_DRAW_POINTS) {
|
||||
@@ -1488,7 +1488,7 @@ static SDL_Surface *GL_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *
|
||||
data->glReadPixels(rect->x, renderer->target ? rect->y : (h - rect->y) - rect->h,
|
||||
rect->w, rect->h, targetFormat, type, surface->pixels);
|
||||
|
||||
if (GL_CheckError("glReadPixels()", renderer) < 0) {
|
||||
if (!GL_CheckError("glReadPixels()", renderer)) {
|
||||
SDL_DestroySurface(surface);
|
||||
return NULL;
|
||||
}
|
||||
@@ -1513,7 +1513,7 @@ static SDL_Surface *GL_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *
|
||||
return surface;
|
||||
}
|
||||
|
||||
static int GL_RenderPresent(SDL_Renderer *renderer)
|
||||
static bool GL_RenderPresent(SDL_Renderer *renderer)
|
||||
{
|
||||
GL_ActivateRenderer(renderer);
|
||||
|
||||
@@ -1596,27 +1596,25 @@ static void GL_DestroyRenderer(SDL_Renderer *renderer)
|
||||
}
|
||||
}
|
||||
|
||||
static int GL_SetVSync(SDL_Renderer *renderer, const int vsync)
|
||||
static bool GL_SetVSync(SDL_Renderer *renderer, const int vsync)
|
||||
{
|
||||
int retval;
|
||||
int interval = 0;
|
||||
|
||||
retval = SDL_GL_SetSwapInterval(vsync);
|
||||
if (retval < 0) {
|
||||
return retval;
|
||||
if (!SDL_GL_SetSwapInterval(vsync)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
retval = SDL_GL_GetSwapInterval(&interval);
|
||||
if (retval < 0) {
|
||||
return retval;
|
||||
if (!SDL_GL_GetSwapInterval(&interval)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (interval != vsync) {
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int GL_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_PropertiesID create_props)
|
||||
static bool GL_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_PropertiesID create_props)
|
||||
{
|
||||
GL_RenderData *data = NULL;
|
||||
GLint value;
|
||||
@@ -1641,7 +1639,7 @@ static int GL_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Pro
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, RENDERER_CONTEXT_MAJOR);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, RENDERER_CONTEXT_MINOR);
|
||||
|
||||
if (SDL_RecreateWindow(window, (window_flags & ~(SDL_WINDOW_VULKAN | SDL_WINDOW_METAL)) | SDL_WINDOW_OPENGL) < 0) {
|
||||
if (!SDL_RecreateWindow(window, (window_flags & ~(SDL_WINDOW_VULKAN | SDL_WINDOW_METAL)) | SDL_WINDOW_OPENGL)) {
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
@@ -1697,11 +1695,11 @@ static int GL_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Pro
|
||||
if (!data->context) {
|
||||
goto error;
|
||||
}
|
||||
if (SDL_GL_MakeCurrent(window, data->context) < 0) {
|
||||
if (!SDL_GL_MakeCurrent(window, data->context)) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (GL_LoadFunctions(data) < 0) {
|
||||
if (!GL_LoadFunctions(data)) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
@@ -1713,7 +1711,7 @@ static int GL_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Pro
|
||||
#endif
|
||||
|
||||
// Check for debug output support
|
||||
if (SDL_GL_GetAttribute(SDL_GL_CONTEXT_FLAGS, &value) == 0 &&
|
||||
if (SDL_GL_GetAttribute(SDL_GL_CONTEXT_FLAGS, &value) &&
|
||||
(value & SDL_GL_CONTEXT_DEBUG_FLAG)) {
|
||||
data->debug_enabled = true;
|
||||
}
|
||||
@@ -1841,7 +1839,7 @@ static int GL_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Pro
|
||||
data->drawstate.clear_color.b = 1.0f;
|
||||
data->drawstate.clear_color.a = 1.0f;
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
|
||||
error:
|
||||
if (changed_window) {
|
||||
@@ -1854,7 +1852,7 @@ error:
|
||||
SDL_SetError("%s", error);
|
||||
SDL_free(error);
|
||||
}
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
SDL_RenderDriver GL_RenderDriver = {
|
||||
|
||||
@@ -223,13 +223,13 @@ static void GL_ClearErrors(SDL_Renderer *renderer)
|
||||
}
|
||||
}
|
||||
|
||||
static int GL_CheckAllErrors(const char *prefix, SDL_Renderer *renderer, const char *file, int line, const char *function)
|
||||
static bool GL_CheckAllErrors(const char *prefix, SDL_Renderer *renderer, const char *file, int line, const char *function)
|
||||
{
|
||||
GLES2_RenderData *data = (GLES2_RenderData *)renderer->internal;
|
||||
int ret = 0;
|
||||
bool result = true;
|
||||
|
||||
if (!data->debug_enabled) {
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
// check gl errors (can return multiple errors)
|
||||
for (;;) {
|
||||
@@ -239,12 +239,12 @@ static int GL_CheckAllErrors(const char *prefix, SDL_Renderer *renderer, const c
|
||||
prefix = "generic";
|
||||
}
|
||||
SDL_SetError("%s: %s (%d): %s %s (0x%X)", prefix, file, line, function, GL_TranslateError(error), error);
|
||||
ret = -1;
|
||||
result = false;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
return result;
|
||||
}
|
||||
|
||||
#if 0
|
||||
@@ -257,7 +257,7 @@ static int GL_CheckAllErrors(const char *prefix, SDL_Renderer *renderer, const c
|
||||
* Renderer state APIs *
|
||||
*************************************************************************************************/
|
||||
|
||||
static int GLES2_LoadFunctions(GLES2_RenderData *data)
|
||||
static bool GLES2_LoadFunctions(GLES2_RenderData *data)
|
||||
{
|
||||
#ifdef SDL_VIDEO_DRIVER_UIKIT
|
||||
#define __SDL_NOGETPROCADDR__
|
||||
@@ -279,7 +279,7 @@ static int GLES2_LoadFunctions(GLES2_RenderData *data)
|
||||
|
||||
#include "SDL_gles2funcs.h"
|
||||
#undef SDL_PROC
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static GLES2_FBOList *GLES2_GetFBO(GLES2_RenderData *data, Uint32 w, Uint32 h)
|
||||
@@ -299,7 +299,7 @@ static GLES2_FBOList *GLES2_GetFBO(GLES2_RenderData *data, Uint32 w, Uint32 h)
|
||||
return result;
|
||||
}
|
||||
|
||||
static int GLES2_ActivateRenderer(SDL_Renderer *renderer)
|
||||
static bool GLES2_ActivateRenderer(SDL_Renderer *renderer)
|
||||
{
|
||||
GLES2_RenderData *data = (GLES2_RenderData *)renderer->internal;
|
||||
|
||||
@@ -307,14 +307,14 @@ static int GLES2_ActivateRenderer(SDL_Renderer *renderer)
|
||||
// Null out the current program to ensure we set it again
|
||||
data->drawstate.program = NULL;
|
||||
|
||||
if (SDL_GL_MakeCurrent(renderer->window, data->context) < 0) {
|
||||
return -1;
|
||||
if (!SDL_GL_MakeCurrent(renderer->window, data->context)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
GL_ClearErrors(renderer);
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void GLES2_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *event)
|
||||
@@ -509,7 +509,7 @@ static GLuint GLES2_CacheShader(GLES2_RenderData *data, GLES2_ShaderType type, G
|
||||
|
||||
if (!shader_body) {
|
||||
SDL_SetError("No shader body src");
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
for (attempt = 0; attempt < 2 && !compileSuccessful; ++attempt) {
|
||||
@@ -570,7 +570,7 @@ static GLuint GLES2_CacheShader(GLES2_RenderData *data, GLES2_ShaderType type, G
|
||||
SDL_SetError("Failed to load the shader %d", type);
|
||||
}
|
||||
data->glDeleteShader(id);
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Cache
|
||||
@@ -579,7 +579,7 @@ static GLuint GLES2_CacheShader(GLES2_RenderData *data, GLES2_ShaderType type, G
|
||||
return id;
|
||||
}
|
||||
|
||||
static int GLES2_CacheShaders(GLES2_RenderData *data)
|
||||
static bool GLES2_CacheShaders(GLES2_RenderData *data)
|
||||
{
|
||||
int shader;
|
||||
|
||||
@@ -594,13 +594,13 @@ static int GLES2_CacheShaders(GLES2_RenderData *data)
|
||||
shader_type = GL_FRAGMENT_SHADER;
|
||||
}
|
||||
if (!GLES2_CacheShader(data, (GLES2_ShaderType)shader, shader_type)) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int GLES2_SelectProgram(GLES2_RenderData *data, GLES2_ImageSource source, SDL_Colorspace colorspace)
|
||||
static bool GLES2_SelectProgram(GLES2_RenderData *data, GLES2_ImageSource source, SDL_Colorspace colorspace)
|
||||
{
|
||||
GLuint vertex;
|
||||
GLuint fragment;
|
||||
@@ -689,7 +689,7 @@ static int GLES2_SelectProgram(GLES2_RenderData *data, GLES2_ImageSource source,
|
||||
data->drawstate.program->vertex_shader == vertex &&
|
||||
data->drawstate.program->fragment_shader == fragment &&
|
||||
data->drawstate.program->shader_params == shader_params) {
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Generate a matching program
|
||||
@@ -727,18 +727,18 @@ static int GLES2_SelectProgram(GLES2_RenderData *data, GLES2_ImageSource source,
|
||||
data->drawstate.program = program;
|
||||
|
||||
// Clean up and return
|
||||
return 0;
|
||||
return true;
|
||||
fault:
|
||||
data->drawstate.program = NULL;
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
static int GLES2_QueueNoOp(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
static bool GLES2_QueueNoOp(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
{
|
||||
return 0; // nothing to do in this backend.
|
||||
return true; // nothing to do in this backend.
|
||||
}
|
||||
|
||||
static int GLES2_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count)
|
||||
static bool GLES2_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count)
|
||||
{
|
||||
const bool colorswap = (renderer->target && (renderer->target->format == SDL_PIXELFORMAT_BGRA32 || renderer->target->format == SDL_PIXELFORMAT_BGRX32));
|
||||
SDL_VertexSolid *verts = (SDL_VertexSolid *)SDL_AllocateRenderVertices(renderer, count * sizeof(*verts), 0, &cmd->data.draw.first);
|
||||
@@ -747,7 +747,7 @@ static int GLES2_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
|
||||
const float color_scale = cmd->data.draw.color_scale;
|
||||
|
||||
if (!verts) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
color.r *= color_scale;
|
||||
@@ -768,10 +768,10 @@ static int GLES2_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
|
||||
verts++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int GLES2_QueueDrawLines(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count)
|
||||
static bool GLES2_QueueDrawLines(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count)
|
||||
{
|
||||
const bool colorswap = (renderer->target && (renderer->target->format == SDL_PIXELFORMAT_BGRA32 || renderer->target->format == SDL_PIXELFORMAT_BGRX32));
|
||||
int i;
|
||||
@@ -781,7 +781,7 @@ static int GLES2_QueueDrawLines(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
|
||||
const float color_scale = cmd->data.draw.color_scale;
|
||||
|
||||
if (!verts) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
color.r *= color_scale;
|
||||
@@ -825,10 +825,10 @@ static int GLES2_QueueDrawLines(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
|
||||
verts++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int GLES2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
|
||||
static bool GLES2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
|
||||
const float *xy, int xy_stride, const SDL_FColor *color, int color_stride, const float *uv, int uv_stride,
|
||||
int num_vertices, const void *indices, int num_indices, int size_indices,
|
||||
float scale_x, float scale_y)
|
||||
@@ -844,7 +844,7 @@ static int GLES2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, S
|
||||
if (texture) {
|
||||
SDL_Vertex *verts = (SDL_Vertex *)SDL_AllocateRenderVertices(renderer, count * sizeof(*verts), 0, &cmd->data.draw.first);
|
||||
if (!verts) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
@@ -888,7 +888,7 @@ static int GLES2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, S
|
||||
} else {
|
||||
SDL_VertexSolid *verts = (SDL_VertexSolid *)SDL_AllocateRenderVertices(renderer, count * sizeof(*verts), 0, &cmd->data.draw.first);
|
||||
if (!verts) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
@@ -927,10 +927,10 @@ static int GLES2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, S
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int SetDrawState(GLES2_RenderData *data, const SDL_RenderCommand *cmd, const GLES2_ImageSource imgsrc, void *vertices)
|
||||
static bool SetDrawState(GLES2_RenderData *data, const SDL_RenderCommand *cmd, const GLES2_ImageSource imgsrc, void *vertices)
|
||||
{
|
||||
SDL_Texture *texture = cmd->data.draw.texture;
|
||||
const SDL_BlendMode blend = cmd->data.draw.blend;
|
||||
@@ -992,8 +992,8 @@ static int SetDrawState(GLES2_RenderData *data, const SDL_RenderCommand *cmd, co
|
||||
data->glVertexAttribPointer(GLES2_ATTRIBUTE_TEXCOORD, 2, GL_FLOAT, GL_FALSE, stride, (const GLvoid *)&verts->tex_coord);
|
||||
}
|
||||
|
||||
if (GLES2_SelectProgram(data, imgsrc, texture ? texture->colorspace : SDL_COLORSPACE_SRGB) < 0) {
|
||||
return -1;
|
||||
if (!GLES2_SelectProgram(data, imgsrc, texture ? texture->colorspace : SDL_COLORSPACE_SRGB)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
program = data->drawstate.program;
|
||||
@@ -1027,10 +1027,10 @@ static int SetDrawState(GLES2_RenderData *data, const SDL_RenderCommand *cmd, co
|
||||
data->glVertexAttribPointer(GLES2_ATTRIBUTE_COLOR, 4, GL_FLOAT, GL_TRUE /* Normalized */, stride, (const GLvoid *)&verts->color);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int SetTextureAddressMode(GLES2_RenderData *data, GLenum textype, SDL_TextureAddressMode addressMode)
|
||||
static bool SetTextureAddressMode(GLES2_RenderData *data, GLenum textype, SDL_TextureAddressMode addressMode)
|
||||
{
|
||||
switch (addressMode) {
|
||||
case SDL_TEXTURE_ADDRESS_CLAMP:
|
||||
@@ -1044,10 +1044,10 @@ static int SetTextureAddressMode(GLES2_RenderData *data, GLenum textype, SDL_Tex
|
||||
default:
|
||||
return SDL_SetError("Unknown texture address mode: %d\n", addressMode);
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, void *vertices)
|
||||
static bool SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, void *vertices)
|
||||
{
|
||||
GLES2_RenderData *data = (GLES2_RenderData *)renderer->internal;
|
||||
GLES2_ImageSource sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;
|
||||
@@ -1179,15 +1179,15 @@ static int SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, vo
|
||||
data->glActiveTexture(GL_TEXTURE2);
|
||||
data->glBindTexture(tdata->texture_type, tdata->texture_v);
|
||||
|
||||
if (SetTextureAddressMode(data, tdata->texture_type, cmd->data.draw.texture_address_mode) < 0) {
|
||||
return -1;
|
||||
if (!SetTextureAddressMode(data, tdata->texture_type, cmd->data.draw.texture_address_mode)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
data->glActiveTexture(GL_TEXTURE1);
|
||||
data->glBindTexture(tdata->texture_type, tdata->texture_u);
|
||||
|
||||
if (SetTextureAddressMode(data, tdata->texture_type, cmd->data.draw.texture_address_mode) < 0) {
|
||||
return -1;
|
||||
if (!SetTextureAddressMode(data, tdata->texture_type, cmd->data.draw.texture_address_mode)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
data->glActiveTexture(GL_TEXTURE0);
|
||||
@@ -1195,8 +1195,8 @@ static int SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, vo
|
||||
data->glActiveTexture(GL_TEXTURE1);
|
||||
data->glBindTexture(tdata->texture_type, tdata->texture_u);
|
||||
|
||||
if (SetTextureAddressMode(data, tdata->texture_type, cmd->data.draw.texture_address_mode) < 0) {
|
||||
return -1;
|
||||
if (!SetTextureAddressMode(data, tdata->texture_type, cmd->data.draw.texture_address_mode)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
data->glActiveTexture(GL_TEXTURE0);
|
||||
@@ -1204,8 +1204,8 @@ static int SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, vo
|
||||
#endif
|
||||
data->glBindTexture(tdata->texture_type, tdata->texture);
|
||||
|
||||
if (SetTextureAddressMode(data, tdata->texture_type, cmd->data.draw.texture_address_mode) < 0) {
|
||||
return -1;
|
||||
if (!SetTextureAddressMode(data, tdata->texture_type, cmd->data.draw.texture_address_mode)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
data->drawstate.texture = texture;
|
||||
@@ -1229,7 +1229,7 @@ static void GLES2_InvalidateCachedState(SDL_Renderer *renderer)
|
||||
cache->program = NULL;
|
||||
}
|
||||
|
||||
static int GLES2_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize)
|
||||
static bool GLES2_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize)
|
||||
{
|
||||
GLES2_RenderData *data = (GLES2_RenderData *)renderer->internal;
|
||||
const bool colorswap = (renderer->target && (renderer->target->format == SDL_PIXELFORMAT_BGRA32 || renderer->target->format == SDL_PIXELFORMAT_BGRX32));
|
||||
@@ -1239,8 +1239,8 @@ static int GLES2_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
|
||||
const GLuint vbo = data->vertex_buffers[vboidx];
|
||||
#endif
|
||||
|
||||
if (GLES2_ActivateRenderer(renderer) < 0) {
|
||||
return -1;
|
||||
if (!GLES2_ActivateRenderer(renderer)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
data->drawstate.target = renderer->target;
|
||||
@@ -1345,7 +1345,7 @@ static int GLES2_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
|
||||
|
||||
case SDL_RENDERCMD_DRAW_LINES:
|
||||
{
|
||||
if (SetDrawState(data, cmd, GLES2_IMAGESOURCE_SOLID, vertices) == 0) {
|
||||
if (SetDrawState(data, cmd, GLES2_IMAGESOURCE_SOLID, vertices)) {
|
||||
size_t count = cmd->data.draw.count;
|
||||
if (count > 2) {
|
||||
// joined lines cannot be grouped
|
||||
@@ -1409,7 +1409,7 @@ static int GLES2_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
|
||||
ret = SetDrawState(data, cmd, GLES2_IMAGESOURCE_SOLID, vertices);
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
if (ret) {
|
||||
int op = GL_TRIANGLES; // SDL_RENDERCMD_GEOMETRY
|
||||
if (thiscmdtype == SDL_RENDERCMD_DRAW_POINTS) {
|
||||
op = GL_POINTS;
|
||||
@@ -1481,7 +1481,7 @@ static void GLES2_DestroyRenderer(SDL_Renderer *renderer)
|
||||
}
|
||||
}
|
||||
|
||||
static int GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_PropertiesID create_props)
|
||||
static bool GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_PropertiesID create_props)
|
||||
{
|
||||
GLES2_RenderData *renderdata = (GLES2_RenderData *)renderer->internal;
|
||||
GLES2_TextureData *data;
|
||||
@@ -1529,7 +1529,7 @@ static int GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL
|
||||
// Allocate a texture struct
|
||||
data = (GLES2_TextureData *)SDL_calloc(1, sizeof(GLES2_TextureData));
|
||||
if (!data) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
data->texture = 0;
|
||||
#ifdef GL_TEXTURE_EXTERNAL_OES
|
||||
@@ -1564,7 +1564,7 @@ static int GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL
|
||||
data->pixel_data = SDL_calloc(1, size);
|
||||
if (!data->pixel_data) {
|
||||
SDL_free(data);
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1578,8 +1578,8 @@ static int GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL
|
||||
data->texture_v_external = true;
|
||||
} else {
|
||||
renderdata->glGenTextures(1, &data->texture_v);
|
||||
if (GL_CheckError("glGenTexures()", renderer) < 0) {
|
||||
return -1;
|
||||
if (!GL_CheckError("glGenTexures()", renderer)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
renderdata->glActiveTexture(GL_TEXTURE2);
|
||||
@@ -1594,8 +1594,8 @@ static int GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL
|
||||
data->texture_u_external = true;
|
||||
} else {
|
||||
renderdata->glGenTextures(1, &data->texture_u);
|
||||
if (GL_CheckError("glGenTexures()", renderer) < 0) {
|
||||
return -1;
|
||||
if (!GL_CheckError("glGenTexures()", renderer)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
renderdata->glActiveTexture(GL_TEXTURE1);
|
||||
@@ -1603,8 +1603,8 @@ static int GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL
|
||||
renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_MIN_FILTER, scaleMode);
|
||||
renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_MAG_FILTER, scaleMode);
|
||||
renderdata->glTexImage2D(data->texture_type, 0, format, (texture->w + 1) / 2, (texture->h + 1) / 2, 0, format, type, NULL);
|
||||
if (GL_CheckError("glTexImage2D()", renderer) < 0) {
|
||||
return -1;
|
||||
if (!GL_CheckError("glTexImage2D()", renderer)) {
|
||||
return false;
|
||||
}
|
||||
SDL_SetNumberProperty(SDL_GetTextureProperties(texture), SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_U_NUMBER, data->texture_u);
|
||||
|
||||
@@ -1617,8 +1617,8 @@ static int GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL
|
||||
data->texture_u_external = true;
|
||||
} else {
|
||||
renderdata->glGenTextures(1, &data->texture_u);
|
||||
if (GL_CheckError("glGenTexures()", renderer) < 0) {
|
||||
return -1;
|
||||
if (!GL_CheckError("glGenTexures()", renderer)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
renderdata->glActiveTexture(GL_TEXTURE1);
|
||||
@@ -1626,8 +1626,8 @@ static int GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL
|
||||
renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_MIN_FILTER, scaleMode);
|
||||
renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_MAG_FILTER, scaleMode);
|
||||
renderdata->glTexImage2D(data->texture_type, 0, GL_LUMINANCE_ALPHA, (texture->w + 1) / 2, (texture->h + 1) / 2, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, NULL);
|
||||
if (GL_CheckError("glTexImage2D()", renderer) < 0) {
|
||||
return -1;
|
||||
if (!GL_CheckError("glTexImage2D()", renderer)) {
|
||||
return false;
|
||||
}
|
||||
SDL_SetNumberProperty(SDL_GetTextureProperties(texture), SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_UV_NUMBER, data->texture_u);
|
||||
|
||||
@@ -1642,8 +1642,8 @@ static int GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL
|
||||
data->texture_external = true;
|
||||
} else {
|
||||
renderdata->glGenTextures(1, &data->texture);
|
||||
if (GL_CheckError("glGenTexures()", renderer) < 0) {
|
||||
return -1;
|
||||
if (!GL_CheckError("glGenTexures()", renderer)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
texture->internal = data;
|
||||
@@ -1653,8 +1653,8 @@ static int GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL
|
||||
renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_MAG_FILTER, scaleMode);
|
||||
if (texture->format != SDL_PIXELFORMAT_EXTERNAL_OES) {
|
||||
renderdata->glTexImage2D(data->texture_type, 0, format, texture->w, texture->h, 0, format, type, NULL);
|
||||
if (GL_CheckError("glTexImage2D()", renderer) < 0) {
|
||||
return -1;
|
||||
if (!GL_CheckError("glTexImage2D()", renderer)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
SDL_SetNumberProperty(SDL_GetTextureProperties(texture), SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_NUMBER, data->texture);
|
||||
@@ -1669,7 +1669,7 @@ static int GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL
|
||||
return GL_CheckError("", renderer);
|
||||
}
|
||||
|
||||
static int GLES2_TexSubImage2D(GLES2_RenderData *data, GLenum target, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels, GLint pitch, GLint bpp)
|
||||
static bool GLES2_TexSubImage2D(GLES2_RenderData *data, GLenum target, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels, GLint pitch, GLint bpp)
|
||||
{
|
||||
Uint8 *blob = NULL;
|
||||
Uint8 *src;
|
||||
@@ -1677,7 +1677,7 @@ 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 true; // nothing to do
|
||||
}
|
||||
|
||||
// Reformat the texture data into a tightly packed array
|
||||
@@ -1686,7 +1686,7 @@ static int GLES2_TexSubImage2D(GLES2_RenderData *data, GLenum target, GLint xoff
|
||||
if ((size_t)pitch != src_pitch) {
|
||||
blob = (Uint8 *)SDL_malloc(src_pitch * height);
|
||||
if (!blob) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
src = blob;
|
||||
for (y = 0; y < height; ++y) {
|
||||
@@ -1701,10 +1701,10 @@ static int GLES2_TexSubImage2D(GLES2_RenderData *data, GLenum target, GLint xoff
|
||||
if (blob) {
|
||||
SDL_free(blob);
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect,
|
||||
static bool GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect,
|
||||
const void *pixels, int pitch)
|
||||
{
|
||||
GLES2_RenderData *data = (GLES2_RenderData *)renderer->internal;
|
||||
@@ -1714,7 +1714,7 @@ static int GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, con
|
||||
|
||||
// Bail out if we're supposed to update an empty rectangle
|
||||
if (rect->w <= 0 || rect->h <= 0) {
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
data->drawstate.texture = NULL; // we trash this state.
|
||||
@@ -1782,7 +1782,7 @@ static int GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, con
|
||||
}
|
||||
|
||||
#if SDL_HAVE_YUV
|
||||
static int GLES2_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
static bool GLES2_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *Uplane, int Upitch,
|
||||
@@ -1795,7 +1795,7 @@ static int GLES2_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
|
||||
// Bail out if we're supposed to update an empty rectangle
|
||||
if (rect->w <= 0 || rect->h <= 0) {
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
data->drawstate.texture = NULL; // we trash this state.
|
||||
@@ -1833,7 +1833,7 @@ static int GLES2_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
return GL_CheckError("glTexSubImage2D()", renderer);
|
||||
}
|
||||
|
||||
static int GLES2_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
static bool GLES2_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *UVplane, int UVpitch)
|
||||
@@ -1845,7 +1845,7 @@ static int GLES2_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
|
||||
// Bail out if we're supposed to update an empty rectangle
|
||||
if (rect->w <= 0 || rect->h <= 0) {
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
data->drawstate.texture = NULL; // we trash this state.
|
||||
@@ -1874,7 +1874,7 @@ static int GLES2_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
}
|
||||
#endif
|
||||
|
||||
static int GLES2_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect,
|
||||
static bool GLES2_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect,
|
||||
void **pixels, int *pitch)
|
||||
{
|
||||
GLES2_TextureData *tdata = (GLES2_TextureData *)texture->internal;
|
||||
@@ -1885,7 +1885,7 @@ static int GLES2_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, const
|
||||
(rect->x * SDL_BYTESPERPIXEL(texture->format));
|
||||
*pitch = tdata->pitch;
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void GLES2_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
@@ -1932,7 +1932,7 @@ static void GLES2_SetTextureScaleMode(SDL_Renderer *renderer, SDL_Texture *textu
|
||||
renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_MAG_FILTER, glScaleMode);
|
||||
}
|
||||
|
||||
static int GLES2_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
static bool GLES2_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
{
|
||||
GLES2_RenderData *data = (GLES2_RenderData *)renderer->internal;
|
||||
GLES2_TextureData *texturedata = NULL;
|
||||
@@ -1953,7 +1953,7 @@ static int GLES2_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
return SDL_SetError("glFramebufferTexture2D() failed");
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void GLES2_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
@@ -2005,7 +2005,7 @@ static SDL_Surface *GLES2_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rec
|
||||
|
||||
data->glReadPixels(rect->x, renderer->target ? rect->y : (h - rect->y) - rect->h,
|
||||
rect->w, rect->h, GL_RGBA, GL_UNSIGNED_BYTE, surface->pixels);
|
||||
if (GL_CheckError("glReadPixels()", renderer) < 0) {
|
||||
if (!GL_CheckError("glReadPixels()", renderer)) {
|
||||
SDL_DestroySurface(surface);
|
||||
return NULL;
|
||||
}
|
||||
@@ -2030,15 +2030,14 @@ static SDL_Surface *GLES2_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rec
|
||||
return surface;
|
||||
}
|
||||
|
||||
static int GLES2_RenderPresent(SDL_Renderer *renderer)
|
||||
static bool GLES2_RenderPresent(SDL_Renderer *renderer)
|
||||
{
|
||||
// Tell the video driver to swap buffers
|
||||
return SDL_GL_SwapWindow(renderer->window);
|
||||
}
|
||||
|
||||
static int GLES2_SetVSync(SDL_Renderer *renderer, const int vsync)
|
||||
static bool GLES2_SetVSync(SDL_Renderer *renderer, const int vsync)
|
||||
{
|
||||
int retval;
|
||||
int interval = 0;
|
||||
|
||||
#ifdef SDL_PLATFORM_WINRT
|
||||
@@ -2051,26 +2050,25 @@ static int GLES2_SetVSync(SDL_Renderer *renderer, const int vsync)
|
||||
}
|
||||
#endif
|
||||
|
||||
retval = SDL_GL_SetSwapInterval(vsync);
|
||||
if (retval < 0) {
|
||||
return retval;
|
||||
if (!SDL_GL_SetSwapInterval(vsync)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
retval = SDL_GL_GetSwapInterval(&interval);
|
||||
if (retval < 0) {
|
||||
return retval;
|
||||
if (!SDL_GL_GetSwapInterval(&interval)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (interval != vsync) {
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*************************************************************************************************
|
||||
* Renderer instantiation *
|
||||
*************************************************************************************************/
|
||||
|
||||
static int GLES2_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_PropertiesID create_props)
|
||||
static bool GLES2_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_PropertiesID create_props)
|
||||
{
|
||||
GLES2_RenderData *data = NULL;
|
||||
SDL_WindowFlags window_flags = 0; // -Wconditional-uninitialized
|
||||
@@ -2079,13 +2077,13 @@ static int GLES2_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_
|
||||
int profile_mask = 0, major = 0, minor = 0;
|
||||
bool changed_window = false;
|
||||
|
||||
if (SDL_GL_GetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, &profile_mask) < 0) {
|
||||
if (!SDL_GL_GetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, &profile_mask)) {
|
||||
goto error;
|
||||
}
|
||||
if (SDL_GL_GetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, &major) < 0) {
|
||||
if (!SDL_GL_GetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, &major)) {
|
||||
goto error;
|
||||
}
|
||||
if (SDL_GL_GetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, &minor) < 0) {
|
||||
if (!SDL_GL_GetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, &minor)) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
@@ -2101,7 +2099,7 @@ static int GLES2_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, RENDERER_CONTEXT_MAJOR);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, RENDERER_CONTEXT_MINOR);
|
||||
|
||||
if (SDL_RecreateWindow(window, (window_flags & ~(SDL_WINDOW_VULKAN | SDL_WINDOW_METAL)) | SDL_WINDOW_OPENGL) < 0) {
|
||||
if (!SDL_RecreateWindow(window, (window_flags & ~(SDL_WINDOW_VULKAN | SDL_WINDOW_METAL)) | SDL_WINDOW_OPENGL)) {
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
@@ -2132,20 +2130,20 @@ static int GLES2_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_
|
||||
if (!data->context) {
|
||||
goto error;
|
||||
}
|
||||
if (SDL_GL_MakeCurrent(window, data->context) < 0) {
|
||||
if (!SDL_GL_MakeCurrent(window, data->context)) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (GLES2_LoadFunctions(data) < 0) {
|
||||
if (!GLES2_LoadFunctions(data)) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (GLES2_CacheShaders(data) < 0) {
|
||||
if (!GLES2_CacheShaders(data)) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
// Check for debug output support
|
||||
if (SDL_GL_GetAttribute(SDL_GL_CONTEXT_FLAGS, &value) == 0 &&
|
||||
if (SDL_GL_GetAttribute(SDL_GL_CONTEXT_FLAGS, &value) &&
|
||||
(value & SDL_GL_CONTEXT_DEBUG_FLAG)) {
|
||||
data->debug_enabled = true;
|
||||
}
|
||||
@@ -2231,7 +2229,7 @@ static int GLES2_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_
|
||||
|
||||
GL_CheckError("", renderer);
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
|
||||
error:
|
||||
if (changed_window) {
|
||||
@@ -2244,7 +2242,7 @@ error:
|
||||
SDL_SetError("%s", error);
|
||||
SDL_free(error);
|
||||
}
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
SDL_RenderDriver GLES2_RenderDriver = {
|
||||
|
||||
@@ -127,12 +127,12 @@ static void PS2_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *event
|
||||
{
|
||||
}
|
||||
|
||||
static int PS2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_PropertiesID create_props)
|
||||
static bool PS2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_PropertiesID create_props)
|
||||
{
|
||||
GSTEXTURE *ps2_tex = (GSTEXTURE *)SDL_calloc(1, sizeof(GSTEXTURE));
|
||||
|
||||
if (!ps2_tex) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
ps2_tex->Width = texture->w;
|
||||
@@ -142,15 +142,15 @@ static int PS2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_P
|
||||
|
||||
if (!ps2_tex->Mem) {
|
||||
SDL_free(ps2_tex);
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
texture->internal = ps2_tex;
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int PS2_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
static bool PS2_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect, void **pixels, int *pitch)
|
||||
{
|
||||
GSTEXTURE *ps2_texture = (GSTEXTURE *)texture->internal;
|
||||
@@ -159,7 +159,7 @@ static int PS2_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
(void *)((Uint8 *)ps2_texture->Mem + rect->y * ps2_texture->Width * SDL_BYTESPERPIXEL(texture->format) +
|
||||
rect->x * SDL_BYTESPERPIXEL(texture->format));
|
||||
*pitch = ps2_texture->Width * SDL_BYTESPERPIXEL(texture->format);
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void PS2_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
@@ -170,7 +170,7 @@ static void PS2_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
gsKit_TexManager_invalidate(data->gsGlobal, ps2_texture);
|
||||
}
|
||||
|
||||
static int PS2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
static bool PS2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect, const void *pixels, int pitch)
|
||||
{
|
||||
const Uint8 *src;
|
||||
@@ -192,7 +192,7 @@ static int PS2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
|
||||
PS2_UnlockTexture(renderer, texture);
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void PS2_SetTextureScaleMode(SDL_Renderer *renderer, SDL_Texture *texture, SDL_ScaleMode scaleMode)
|
||||
@@ -210,12 +210,12 @@ static void PS2_SetTextureScaleMode(SDL_Renderer *renderer, SDL_Texture *texture
|
||||
ps2_texture->Filter = gsKitScaleMode;
|
||||
}
|
||||
|
||||
static int PS2_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
static bool PS2_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
{
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int PS2_QueueSetViewport(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
static bool PS2_QueueSetViewport(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
{
|
||||
PS2_RenderData *data = (PS2_RenderData *)renderer->internal;
|
||||
const SDL_Rect *viewport = &cmd->data.viewport.rect;
|
||||
@@ -225,15 +225,15 @@ static int PS2_QueueSetViewport(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
data->gsGlobal->OffsetY = (int)((2048.0f + (float)viewport->y) * 16.0f);
|
||||
gsKit_set_scissor(data->gsGlobal, GS_SETREG_SCISSOR(viewport->x, viewport->x + viewport->w, viewport->y, viewport->y + viewport->h));
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int PS2_QueueNoOp(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
static bool PS2_QueueNoOp(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
{
|
||||
return 0; // nothing to do in this backend.
|
||||
return true; // nothing to do in this backend.
|
||||
}
|
||||
|
||||
static int PS2_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count)
|
||||
static bool PS2_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count)
|
||||
{
|
||||
PS2_RenderData *data = (PS2_RenderData *)renderer->internal;
|
||||
GSPRIMPOINT *vertices = (GSPRIMPOINT *)SDL_AllocateRenderVertices(renderer, count * sizeof(GSPRIMPOINT), 4, &cmd->data.draw.first);
|
||||
@@ -241,7 +241,7 @@ static int PS2_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, c
|
||||
int i;
|
||||
|
||||
if (!vertices) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
cmd->data.draw.count = count;
|
||||
@@ -252,10 +252,10 @@ static int PS2_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, c
|
||||
vertices->xyz2 = vertex_to_XYZ2(data->gsGlobal, points->x, points->y, 0);
|
||||
vertices->rgbaq = rgbaq;
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int PS2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
|
||||
static bool PS2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
|
||||
const float *xy, int xy_stride, const SDL_FColor *color, int color_stride, const float *uv, int uv_stride,
|
||||
int num_vertices, const void *indices, int num_indices, int size_indices,
|
||||
float scale_x, float scale_y)
|
||||
@@ -273,7 +273,7 @@ static int PS2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL
|
||||
GSTEXTURE *ps2_tex = (GSTEXTURE *) texture->internal;
|
||||
|
||||
if (!vertices) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
@@ -306,7 +306,7 @@ static int PS2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL
|
||||
GSPRIMPOINT *vertices = (GSPRIMPOINT *)SDL_AllocateRenderVertices(renderer, count * sizeof(GSPRIMPOINT), 4, &cmd->data.draw.first);
|
||||
|
||||
if (!vertices) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
@@ -333,15 +333,15 @@ static int PS2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int PS2_RenderSetViewPort(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
static bool PS2_RenderSetViewPort(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
{
|
||||
return 0; // nothing to do in this backend.
|
||||
return true; // nothing to do in this backend.
|
||||
}
|
||||
|
||||
static int PS2_RenderSetClipRect(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
static bool PS2_RenderSetClipRect(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
{
|
||||
PS2_RenderData *data = (PS2_RenderData *)renderer->internal;
|
||||
SDL_Rect *viewport = data->viewport;
|
||||
@@ -357,18 +357,18 @@ static int PS2_RenderSetClipRect(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
}
|
||||
gsKit_set_scissor(data->gsGlobal, GS_SETREG_SCISSOR(viewport->x, viewport->x + viewport->w, viewport->y, viewport->y + viewport->h));
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int PS2_RenderSetDrawColor(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
static bool PS2_RenderSetDrawColor(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
{
|
||||
PS2_RenderData *data = (PS2_RenderData *)renderer->internal;
|
||||
|
||||
data->drawColor = float_GS_SETREG_RGBAQ(&cmd->data.color.color, cmd->data.color.color_scale);
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int PS2_RenderClear(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
static bool PS2_RenderClear(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
{
|
||||
int offsetX, offsetY;
|
||||
SDL_Rect *viewport;
|
||||
@@ -392,7 +392,7 @@ static int PS2_RenderClear(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
viewport = data->viewport;
|
||||
gsKit_set_scissor(data->gsGlobal, GS_SETREG_SCISSOR(viewport->x, viewport->x + viewport->w, viewport->y, viewport->y + viewport->h));
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void PS2_SetBlendMode(PS2_RenderData *data, int blendMode)
|
||||
@@ -447,7 +447,7 @@ static void PS2_SetBlendMode(PS2_RenderData *data, int blendMode)
|
||||
}
|
||||
}
|
||||
|
||||
static int PS2_RenderGeometry(SDL_Renderer *renderer, void *vertices, SDL_RenderCommand *cmd)
|
||||
static bool PS2_RenderGeometry(SDL_Renderer *renderer, void *vertices, SDL_RenderCommand *cmd)
|
||||
{
|
||||
PS2_RenderData *data = (PS2_RenderData *)renderer->internal;
|
||||
const size_t count = cmd->data.draw.count;
|
||||
@@ -465,10 +465,10 @@ static int PS2_RenderGeometry(SDL_Renderer *renderer, void *vertices, SDL_Render
|
||||
gsKit_prim_list_triangle_gouraud_3d(data->gsGlobal, count, verts);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
int PS2_RenderLines(SDL_Renderer *renderer, void *vertices, SDL_RenderCommand *cmd)
|
||||
static bool PS2_RenderLines(SDL_Renderer *renderer, void *vertices, SDL_RenderCommand *cmd)
|
||||
{
|
||||
PS2_RenderData *data = (PS2_RenderData *)renderer->internal;
|
||||
const size_t count = cmd->data.draw.count;
|
||||
@@ -478,10 +478,10 @@ int PS2_RenderLines(SDL_Renderer *renderer, void *vertices, SDL_RenderCommand *c
|
||||
gsKit_prim_list_line_goraud_3d(data->gsGlobal, count, verts);
|
||||
|
||||
// We're done!
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
int PS2_RenderPoints(SDL_Renderer *renderer, void *vertices, SDL_RenderCommand *cmd)
|
||||
static bool PS2_RenderPoints(SDL_Renderer *renderer, void *vertices, SDL_RenderCommand *cmd)
|
||||
{
|
||||
PS2_RenderData *data = (PS2_RenderData *)renderer->internal;
|
||||
const size_t count = cmd->data.draw.count;
|
||||
@@ -491,7 +491,7 @@ int PS2_RenderPoints(SDL_Renderer *renderer, void *vertices, SDL_RenderCommand *
|
||||
gsKit_prim_list_points(data->gsGlobal, count, verts);
|
||||
|
||||
// We're done!
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void PS2_InvalidateCachedState(SDL_Renderer *renderer)
|
||||
@@ -499,7 +499,7 @@ 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.
|
||||
}
|
||||
|
||||
static int PS2_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize)
|
||||
static bool PS2_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize)
|
||||
{
|
||||
while (cmd) {
|
||||
switch (cmd->command) {
|
||||
@@ -550,10 +550,10 @@ static int PS2_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, v
|
||||
}
|
||||
cmd = cmd->next;
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int PS2_RenderPresent(SDL_Renderer *renderer)
|
||||
static bool PS2_RenderPresent(SDL_Renderer *renderer)
|
||||
{
|
||||
PS2_RenderData *data = (PS2_RenderData *)renderer->internal;
|
||||
|
||||
@@ -576,7 +576,7 @@ static int PS2_RenderPresent(SDL_Renderer *renderer)
|
||||
}
|
||||
gsKit_TexManager_nextFrame(data->gsGlobal);
|
||||
gsKit_clear(data->gsGlobal, GS_BLACK);
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void PS2_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
@@ -618,7 +618,7 @@ static void PS2_DestroyRenderer(SDL_Renderer *renderer)
|
||||
}
|
||||
}
|
||||
|
||||
static int PS2_SetVSync(SDL_Renderer *renderer, const int vsync)
|
||||
static bool PS2_SetVSync(SDL_Renderer *renderer, const int vsync)
|
||||
{
|
||||
PS2_RenderData *data = (PS2_RenderData *)renderer->internal;
|
||||
switch (vsync) {
|
||||
@@ -631,10 +631,10 @@ static int PS2_SetVSync(SDL_Renderer *renderer, const int vsync)
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
data->vsync = vsync;
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int PS2_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_PropertiesID create_props)
|
||||
static bool PS2_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_PropertiesID create_props)
|
||||
{
|
||||
PS2_RenderData *data;
|
||||
GSGLOBAL *gsGlobal;
|
||||
@@ -648,7 +648,7 @@ static int PS2_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Pr
|
||||
|
||||
data = (PS2_RenderData *)SDL_calloc(1, sizeof(*data));
|
||||
if (!data) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Specific gsKit init
|
||||
@@ -717,7 +717,7 @@ static int PS2_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Pr
|
||||
SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_ABGR8888);
|
||||
SDL_SetNumberProperty(SDL_GetRendererProperties(renderer), SDL_PROP_RENDERER_MAX_TEXTURE_SIZE_NUMBER, 1024);
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
SDL_RenderDriver PS2_RenderDriver = {
|
||||
|
||||
@@ -258,7 +258,7 @@ static void TextureStorageFree(void *storage)
|
||||
}
|
||||
}
|
||||
|
||||
static int TextureSwizzle(PSP_TextureData *psp_texture, void *dst)
|
||||
static bool TextureSwizzle(PSP_TextureData *psp_texture, void *dst)
|
||||
{
|
||||
int bytewidth, height;
|
||||
int rowblocks, rowblocksadd;
|
||||
@@ -268,7 +268,7 @@ static int TextureSwizzle(PSP_TextureData *psp_texture, void *dst)
|
||||
unsigned char *data = NULL;
|
||||
|
||||
if (psp_texture->swizzled) {
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
bytewidth = psp_texture->textureWidth * (psp_texture->bits >> 3);
|
||||
@@ -285,7 +285,7 @@ static int TextureSwizzle(PSP_TextureData *psp_texture, void *dst)
|
||||
}
|
||||
|
||||
if (!data) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
for (j = 0; j < height; j++, blockaddress += 16) {
|
||||
@@ -311,10 +311,10 @@ static int TextureSwizzle(PSP_TextureData *psp_texture, void *dst)
|
||||
psp_texture->swizzled = true;
|
||||
|
||||
sceKernelDcacheWritebackRange(psp_texture->data, psp_texture->size);
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int TextureUnswizzle(PSP_TextureData *psp_texture, void *dst)
|
||||
static bool TextureUnswizzle(PSP_TextureData *psp_texture, void *dst)
|
||||
{
|
||||
int bytewidth, height;
|
||||
int widthblocks, heightblocks;
|
||||
@@ -326,7 +326,7 @@ static int TextureUnswizzle(PSP_TextureData *psp_texture, void *dst)
|
||||
unsigned char *ydst = NULL;
|
||||
|
||||
if (!psp_texture->swizzled) {
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
bytewidth = psp_texture->textureWidth * (psp_texture->bits >> 3);
|
||||
@@ -347,7 +347,7 @@ static int TextureUnswizzle(PSP_TextureData *psp_texture, void *dst)
|
||||
}
|
||||
|
||||
if (!data) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
ydst = (unsigned char *)data;
|
||||
@@ -381,29 +381,29 @@ static int TextureUnswizzle(PSP_TextureData *psp_texture, void *dst)
|
||||
psp_texture->swizzled = false;
|
||||
|
||||
sceKernelDcacheWritebackRange(psp_texture->data, psp_texture->size);
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int TextureSpillToSram(PSP_RenderData *data, PSP_TextureData *psp_texture)
|
||||
static bool TextureSpillToSram(PSP_RenderData *data, PSP_TextureData *psp_texture)
|
||||
{
|
||||
// Assumes the texture is in VRAM
|
||||
if (psp_texture->swizzled) {
|
||||
// Texture was swizzled in vram, just copy to system memory
|
||||
void *sdata = SDL_malloc(psp_texture->size);
|
||||
if (!sdata) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
SDL_memcpy(sdata, psp_texture->data, psp_texture->size);
|
||||
vfree(psp_texture->data);
|
||||
psp_texture->data = sdata;
|
||||
return 0;
|
||||
return true;
|
||||
} else {
|
||||
return TextureSwizzle(psp_texture, NULL); // Will realloc in sysram
|
||||
}
|
||||
}
|
||||
|
||||
static int TexturePromoteToVram(PSP_RenderData *data, PSP_TextureData *psp_texture, bool target)
|
||||
static bool TexturePromoteToVram(PSP_RenderData *data, PSP_TextureData *psp_texture, bool target)
|
||||
{
|
||||
// Assumes texture in sram and a large enough continuous block in vram
|
||||
void *tdata = vramalloc(psp_texture->size);
|
||||
@@ -413,46 +413,46 @@ static int TexturePromoteToVram(PSP_RenderData *data, PSP_TextureData *psp_textu
|
||||
SDL_memcpy(tdata, psp_texture->data, psp_texture->size);
|
||||
SDL_free(psp_texture->data);
|
||||
psp_texture->data = tdata;
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
static int TextureSpillLRU(PSP_RenderData *data, size_t wanted)
|
||||
static bool TextureSpillLRU(PSP_RenderData *data, size_t wanted)
|
||||
{
|
||||
PSP_TextureData *lru = data->least_recent_target;
|
||||
if (lru) {
|
||||
if (TextureSpillToSram(data, lru) < 0) {
|
||||
return -1;
|
||||
if (!TextureSpillToSram(data, lru)) {
|
||||
return false;
|
||||
}
|
||||
LRUTargetRemove(data, lru);
|
||||
} else {
|
||||
// Asked to spill but there nothing to spill
|
||||
return SDL_SetError("Could not spill more VRAM to system memory. VRAM : %dKB,(%dKB), wanted %dKB", vmemavail() / 1024, vlargestblock() / 1024, wanted / 1024);
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int TextureSpillTargetsForSpace(PSP_RenderData *data, size_t size)
|
||||
static bool TextureSpillTargetsForSpace(PSP_RenderData *data, size_t size)
|
||||
{
|
||||
while (vlargestblock() < size) {
|
||||
if (TextureSpillLRU(data, size) < 0) {
|
||||
return -1;
|
||||
if (!TextureSpillLRU(data, size)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int TextureBindAsTarget(PSP_RenderData *data, PSP_TextureData *psp_texture)
|
||||
static bool TextureBindAsTarget(PSP_RenderData *data, PSP_TextureData *psp_texture)
|
||||
{
|
||||
unsigned int dstFormat;
|
||||
|
||||
if (!InVram(psp_texture->data)) {
|
||||
// Bring back the texture in vram
|
||||
if (TextureSpillTargetsForSpace(data, psp_texture->size) < 0) {
|
||||
return -1;
|
||||
if (!TextureSpillTargetsForSpace(data, psp_texture->size)) {
|
||||
return false;
|
||||
}
|
||||
if (TexturePromoteToVram(data, psp_texture, true) < 0) {
|
||||
return -1;
|
||||
if (!TexturePromoteToVram(data, psp_texture, true)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
LRUTargetBringFront(data, psp_texture);
|
||||
@@ -470,20 +470,20 @@ static int TextureBindAsTarget(PSP_RenderData *data, PSP_TextureData *psp_textur
|
||||
sceGuDisable(GU_STENCIL_TEST);
|
||||
sceGuDisable(GU_ALPHA_TEST);
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void PSP_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *event)
|
||||
{
|
||||
}
|
||||
|
||||
static int PSP_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_PropertiesID create_props)
|
||||
static bool PSP_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_PropertiesID create_props)
|
||||
{
|
||||
PSP_RenderData *data = renderer->internal;
|
||||
PSP_TextureData *psp_texture = (PSP_TextureData *)SDL_calloc(1, sizeof(*psp_texture));
|
||||
|
||||
if (!psp_texture) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
psp_texture->swizzled = false;
|
||||
@@ -506,15 +506,15 @@ static int PSP_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_P
|
||||
|
||||
default:
|
||||
SDL_free(psp_texture);
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
psp_texture->pitch = psp_texture->textureWidth * SDL_BYTESPERPIXEL(texture->format);
|
||||
psp_texture->size = psp_texture->textureHeight * psp_texture->pitch;
|
||||
if (texture->access == SDL_TEXTUREACCESS_TARGET) {
|
||||
if (TextureSpillTargetsForSpace(renderer->internal, psp_texture->size) < 0) {
|
||||
if (!TextureSpillTargetsForSpace(renderer->internal, psp_texture->size)) {
|
||||
SDL_free(psp_texture);
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
psp_texture->data = vramalloc(psp_texture->size);
|
||||
if (psp_texture->data) {
|
||||
@@ -526,14 +526,14 @@ static int PSP_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_P
|
||||
|
||||
if (!psp_texture->data) {
|
||||
SDL_free(psp_texture);
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
texture->internal = psp_texture;
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int TextureShouldSwizzle(PSP_TextureData *psp_texture, SDL_Texture *texture)
|
||||
static bool TextureShouldSwizzle(PSP_TextureData *psp_texture, SDL_Texture *texture)
|
||||
{
|
||||
return !((texture->access == SDL_TEXTUREACCESS_TARGET) && InVram(psp_texture->data)) && texture->access != SDL_TEXTUREACCESS_STREAMING && (texture->w >= 16 || texture->h >= 16);
|
||||
}
|
||||
@@ -555,10 +555,10 @@ static void TextureActivate(SDL_Texture *texture)
|
||||
sceGuTexImage(0, psp_texture->textureWidth, psp_texture->textureHeight, psp_texture->textureWidth, psp_texture->data);
|
||||
}
|
||||
|
||||
static int PSP_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
static bool PSP_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect, void **pixels, int *pitch);
|
||||
|
||||
static int PSP_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
static bool PSP_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect, const void *pixels, int pitch)
|
||||
{
|
||||
/* PSP_TextureData *psp_texture = (PSP_TextureData *) texture->internal; */
|
||||
@@ -580,10 +580,10 @@ static int PSP_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
}
|
||||
|
||||
sceKernelDcacheWritebackAll();
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int PSP_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
static bool PSP_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect, void **pixels, int *pitch)
|
||||
{
|
||||
PSP_TextureData *psp_texture = (PSP_TextureData *)texture->internal;
|
||||
@@ -592,7 +592,7 @@ static int PSP_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
(void *)((Uint8 *)psp_texture->data + rect->y * psp_texture->pitch +
|
||||
rect->x * SDL_BYTESPERPIXEL(texture->format));
|
||||
*pitch = psp_texture->pitch;
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void PSP_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
@@ -613,23 +613,23 @@ static void PSP_SetTextureScaleMode(SDL_Renderer *renderer, SDL_Texture *texture
|
||||
// Nothing to do because TextureActivate takes care of it
|
||||
}
|
||||
|
||||
static int PSP_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
static bool PSP_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
{
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int PSP_QueueNoOp(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
static bool PSP_QueueNoOp(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
{
|
||||
return 0; // nothing to do in this backend.
|
||||
return true; // nothing to do in this backend.
|
||||
}
|
||||
|
||||
static int PSP_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count)
|
||||
static bool PSP_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count)
|
||||
{
|
||||
VertV *verts = (VertV *)SDL_AllocateRenderVertices(renderer, count * sizeof(VertV), 4, &cmd->data.draw.first);
|
||||
int i;
|
||||
|
||||
if (!verts) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
cmd->data.draw.count = count;
|
||||
@@ -640,10 +640,10 @@ static int PSP_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, c
|
||||
verts->z = 0.0f;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int PSP_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
|
||||
static bool PSP_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
|
||||
const float *xy, int xy_stride, const SDL_FColor *color, int color_stride, const float *uv, int uv_stride,
|
||||
int num_vertices, const void *indices, int num_indices, int size_indices,
|
||||
float scale_x, float scale_y)
|
||||
@@ -659,7 +659,7 @@ static int PSP_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL
|
||||
VertCV *verts;
|
||||
verts = (VertCV *)SDL_AllocateRenderVertices(renderer, count * sizeof(VertCV), 4, &cmd->data.draw.first);
|
||||
if (!verts) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
@@ -695,7 +695,7 @@ static int PSP_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL
|
||||
VertTCV *verts;
|
||||
verts = (VertTCV *)SDL_AllocateRenderVertices(renderer, count * sizeof(VertTCV), 4, &cmd->data.draw.first);
|
||||
if (!verts) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
@@ -734,16 +734,16 @@ static int PSP_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int PSP_QueueFillRects(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FRect *rects, int count)
|
||||
static bool PSP_QueueFillRects(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FRect *rects, int count)
|
||||
{
|
||||
VertV *verts = (VertV *)SDL_AllocateRenderVertices(renderer, count * 2 * sizeof(VertV), 4, &cmd->data.draw.first);
|
||||
int i;
|
||||
|
||||
if (!verts) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
cmd->data.draw.count = count;
|
||||
@@ -759,10 +759,10 @@ static int PSP_QueueFillRects(SDL_Renderer *renderer, SDL_RenderCommand *cmd, co
|
||||
verts++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int PSP_QueueCopy(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
|
||||
static bool PSP_QueueCopy(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
|
||||
const SDL_FRect *srcrect, const SDL_FRect *dstrect)
|
||||
{
|
||||
VertTV *verts;
|
||||
@@ -779,7 +779,7 @@ static int PSP_QueueCopy(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Tex
|
||||
if ((MathAbs(u1) - MathAbs(u0)) < 64.0f) {
|
||||
verts = (VertTV *)SDL_AllocateRenderVertices(renderer, 2 * sizeof(VertTV), 4, &cmd->data.draw.first);
|
||||
if (!verts) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
cmd->data.draw.count = 1;
|
||||
@@ -815,7 +815,7 @@ static int PSP_QueueCopy(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Tex
|
||||
|
||||
verts = (VertTV *)SDL_AllocateRenderVertices(renderer, count * 2 * sizeof(VertTV), 4, &cmd->data.draw.first);
|
||||
if (!verts) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
for (i = 0, start = 0, end = width; i < count; i++, start += slice) {
|
||||
@@ -843,10 +843,10 @@ static int PSP_QueueCopy(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Tex
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int PSP_QueueCopyEx(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
|
||||
static bool PSP_QueueCopyEx(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
|
||||
const SDL_FRect *srcrect, const SDL_FRect *dstrect,
|
||||
const double angle, const SDL_FPoint *center, const SDL_FlipMode flip, float scale_x, float scale_y)
|
||||
{
|
||||
@@ -866,7 +866,7 @@ static int PSP_QueueCopyEx(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_T
|
||||
float v1 = srcrect->y + srcrect->h;
|
||||
|
||||
if (!verts) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
cmd->data.draw.count = 1;
|
||||
@@ -931,7 +931,7 @@ static int PSP_QueueCopyEx(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_T
|
||||
verts->y *= scale_y;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void ResetBlendState(PSP_BlendState *state)
|
||||
@@ -1042,7 +1042,7 @@ 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.
|
||||
}
|
||||
|
||||
static int PSP_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize)
|
||||
static bool PSP_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize)
|
||||
{
|
||||
PSP_RenderData *data = (PSP_RenderData *)renderer->internal;
|
||||
Uint8 *gpumem = NULL;
|
||||
@@ -1215,14 +1215,14 @@ static int PSP_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, v
|
||||
cmd = cmd->next;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int PSP_RenderPresent(SDL_Renderer *renderer)
|
||||
static bool PSP_RenderPresent(SDL_Renderer *renderer)
|
||||
{
|
||||
PSP_RenderData *data = (PSP_RenderData *)renderer->internal;
|
||||
if (!data->displayListAvail) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
data->displayListAvail = false;
|
||||
@@ -1237,7 +1237,7 @@ static int PSP_RenderPresent(SDL_Renderer *renderer)
|
||||
data->backbuffer = data->frontbuffer;
|
||||
data->frontbuffer = vabsptr(sceGuSwapBuffers());
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void PSP_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
@@ -1281,14 +1281,14 @@ static void PSP_DestroyRenderer(SDL_Renderer *renderer)
|
||||
}
|
||||
}
|
||||
|
||||
static int PSP_SetVSync(SDL_Renderer *renderer, const int vsync)
|
||||
static bool PSP_SetVSync(SDL_Renderer *renderer, const int vsync)
|
||||
{
|
||||
PSP_RenderData *data = renderer->internal;
|
||||
data->vsync = vsync;
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int PSP_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_PropertiesID create_props)
|
||||
static bool PSP_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_PropertiesID create_props)
|
||||
{
|
||||
PSP_RenderData *data;
|
||||
int pixelformat;
|
||||
@@ -1302,7 +1302,7 @@ static int PSP_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Pr
|
||||
|
||||
data = (PSP_RenderData *)SDL_calloc(1, sizeof(*data));
|
||||
if (!data) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
renderer->WindowEvent = PSP_WindowEvent;
|
||||
@@ -1394,7 +1394,7 @@ static int PSP_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Pr
|
||||
sceKernelRegisterSubIntrHandler(PSP_VBLANK_INT, 0, psp_on_vblank, data);
|
||||
sceKernelEnableSubIntr(PSP_VBLANK_INT, 0);
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
SDL_RenderDriver PSP_RenderDriver = {
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include "SDL_draw.h"
|
||||
#include "SDL_blendfillrect.h"
|
||||
|
||||
static int SDL_BlendFillRect_RGB555(SDL_Surface *dst, const SDL_Rect *rect,
|
||||
static bool SDL_BlendFillRect_RGB555(SDL_Surface *dst, const SDL_Rect *rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
unsigned inva = 0xff - a;
|
||||
@@ -51,10 +51,10 @@ static int SDL_BlendFillRect_RGB555(SDL_Surface *dst, const SDL_Rect *rect,
|
||||
FILLRECT(Uint16, DRAW_SETPIXEL_RGB555);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int SDL_BlendFillRect_RGB565(SDL_Surface *dst, const SDL_Rect *rect,
|
||||
static bool SDL_BlendFillRect_RGB565(SDL_Surface *dst, const SDL_Rect *rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
unsigned inva = 0xff - a;
|
||||
@@ -80,10 +80,10 @@ static int SDL_BlendFillRect_RGB565(SDL_Surface *dst, const SDL_Rect *rect,
|
||||
FILLRECT(Uint16, DRAW_SETPIXEL_RGB565);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int SDL_BlendFillRect_XRGB8888(SDL_Surface *dst, const SDL_Rect *rect,
|
||||
static bool SDL_BlendFillRect_XRGB8888(SDL_Surface *dst, const SDL_Rect *rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
unsigned inva = 0xff - a;
|
||||
@@ -109,10 +109,10 @@ static int SDL_BlendFillRect_XRGB8888(SDL_Surface *dst, const SDL_Rect *rect,
|
||||
FILLRECT(Uint32, DRAW_SETPIXEL_XRGB8888);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int SDL_BlendFillRect_ARGB8888(SDL_Surface *dst, const SDL_Rect *rect,
|
||||
static bool SDL_BlendFillRect_ARGB8888(SDL_Surface *dst, const SDL_Rect *rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
unsigned inva = 0xff - a;
|
||||
@@ -138,10 +138,10 @@ static int SDL_BlendFillRect_ARGB8888(SDL_Surface *dst, const SDL_Rect *rect,
|
||||
FILLRECT(Uint32, DRAW_SETPIXEL_ARGB8888);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int SDL_BlendFillRect_RGB(SDL_Surface *dst, const SDL_Rect *rect,
|
||||
static bool SDL_BlendFillRect_RGB(SDL_Surface *dst, const SDL_Rect *rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
const SDL_PixelFormatDetails *fmt = dst->internal->format;
|
||||
@@ -170,7 +170,7 @@ static int SDL_BlendFillRect_RGB(SDL_Surface *dst, const SDL_Rect *rect,
|
||||
FILLRECT(Uint16, DRAW_SETPIXEL_RGB);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
case 4:
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
@@ -193,13 +193,13 @@ static int SDL_BlendFillRect_RGB(SDL_Surface *dst, const SDL_Rect *rect,
|
||||
FILLRECT(Uint32, DRAW_SETPIXEL_RGB);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
default:
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
}
|
||||
|
||||
static int SDL_BlendFillRect_RGBA(SDL_Surface *dst, const SDL_Rect *rect,
|
||||
static bool SDL_BlendFillRect_RGBA(SDL_Surface *dst, const SDL_Rect *rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
const SDL_PixelFormatDetails *fmt = dst->internal->format;
|
||||
@@ -228,14 +228,13 @@ static int SDL_BlendFillRect_RGBA(SDL_Surface *dst, const SDL_Rect *rect,
|
||||
FILLRECT(Uint32, DRAW_SETPIXEL_RGBA);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
default:
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
}
|
||||
|
||||
int SDL_BlendFillRect(SDL_Surface *dst, const SDL_Rect *rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
bool SDL_BlendFillRect(SDL_Surface *dst, const SDL_Rect *rect, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
SDL_Rect clipped;
|
||||
|
||||
@@ -252,7 +251,7 @@ int SDL_BlendFillRect(SDL_Surface *dst, const SDL_Rect *rect,
|
||||
if (rect) {
|
||||
// Perform clipping
|
||||
if (!SDL_GetRectIntersection(rect, &dst->internal->clip_rect, &clipped)) {
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
rect = &clipped;
|
||||
} else {
|
||||
@@ -300,14 +299,12 @@ int SDL_BlendFillRect(SDL_Surface *dst, const SDL_Rect *rect,
|
||||
}
|
||||
}
|
||||
|
||||
int SDL_BlendFillRects(SDL_Surface *dst, const SDL_Rect *rects, int count,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
bool SDL_BlendFillRects(SDL_Surface *dst, const SDL_Rect *rects, int count, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
SDL_Rect rect;
|
||||
int i;
|
||||
int (*func)(SDL_Surface * dst, const SDL_Rect *rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) = NULL;
|
||||
int status = 0;
|
||||
bool (*func)(SDL_Surface * dst, const SDL_Rect *rect, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) = NULL;
|
||||
bool result = true;
|
||||
|
||||
if (!SDL_SurfaceValid(dst)) {
|
||||
return SDL_InvalidParamError("SDL_BlendFillRects(): dst");
|
||||
@@ -366,9 +363,9 @@ int SDL_BlendFillRects(SDL_Surface *dst, const SDL_Rect *rects, int count,
|
||||
if (!SDL_GetRectIntersection(&rects[i], &dst->internal->clip_rect, &rect)) {
|
||||
continue;
|
||||
}
|
||||
status = func(dst, &rect, blendMode, r, g, b, a);
|
||||
result = func(dst, &rect, blendMode, r, g, b, a);
|
||||
}
|
||||
return status;
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif // SDL_VIDEO_RENDER_SW
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
#include "SDL_internal.h"
|
||||
|
||||
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);
|
||||
extern bool SDL_BlendFillRect(SDL_Surface *dst, const SDL_Rect *rect, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
extern bool 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_
|
||||
|
||||
@@ -919,8 +919,7 @@ static BlendLineFunc SDL_CalculateBlendLineFunc(const SDL_PixelFormatDetails *fm
|
||||
return NULL;
|
||||
}
|
||||
|
||||
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)
|
||||
bool SDL_BlendLine(SDL_Surface *dst, int x1, int y1, int x2, int y2, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
BlendLineFunc func;
|
||||
|
||||
@@ -936,15 +935,14 @@ int SDL_BlendLine(SDL_Surface *dst, int x1, int y1, int x2, int y2,
|
||||
// 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;
|
||||
return true;
|
||||
}
|
||||
|
||||
func(dst, x1, y1, x2, y2, blendMode, r, g, b, a, true);
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
int SDL_BlendLines(SDL_Surface *dst, const SDL_Point *points, int count,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
bool SDL_BlendLines(SDL_Surface *dst, const SDL_Point *points, int count, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
int i;
|
||||
int x1, y1;
|
||||
@@ -982,7 +980,7 @@ int SDL_BlendLines(SDL_Surface *dst, const SDL_Point *points, int count,
|
||||
SDL_BlendPoint(dst, points[count - 1].x, points[count - 1].y,
|
||||
blendMode, r, g, b, a);
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif // SDL_VIDEO_RENDER_SW
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
#include "SDL_internal.h"
|
||||
|
||||
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);
|
||||
extern bool 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 bool 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_
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include "SDL_draw.h"
|
||||
#include "SDL_blendpoint.h"
|
||||
|
||||
static int SDL_BlendPoint_RGB555(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
||||
static bool SDL_BlendPoint_RGB555(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
||||
Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
unsigned inva = 0xff - a;
|
||||
@@ -51,10 +51,10 @@ static int SDL_BlendPoint_RGB555(SDL_Surface *dst, int x, int y, SDL_BlendMode b
|
||||
DRAW_SETPIXELXY_RGB555(x, y);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int SDL_BlendPoint_RGB565(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
||||
static bool SDL_BlendPoint_RGB565(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
||||
Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
unsigned inva = 0xff - a;
|
||||
@@ -80,10 +80,10 @@ static int SDL_BlendPoint_RGB565(SDL_Surface *dst, int x, int y, SDL_BlendMode b
|
||||
DRAW_SETPIXELXY_RGB565(x, y);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int SDL_BlendPoint_XRGB8888(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
||||
static bool SDL_BlendPoint_XRGB8888(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
||||
Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
unsigned inva = 0xff - a;
|
||||
@@ -109,10 +109,10 @@ static int SDL_BlendPoint_XRGB8888(SDL_Surface *dst, int x, int y, SDL_BlendMode
|
||||
DRAW_SETPIXELXY_XRGB8888(x, y);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int SDL_BlendPoint_ARGB8888(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode,
|
||||
static bool SDL_BlendPoint_ARGB8888(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode,
|
||||
Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
unsigned inva = 0xff - a;
|
||||
@@ -138,10 +138,10 @@ static int SDL_BlendPoint_ARGB8888(SDL_Surface *dst, int x, int y, SDL_BlendMode
|
||||
DRAW_SETPIXELXY_ARGB8888(x, y);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int SDL_BlendPoint_RGB(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
||||
static bool SDL_BlendPoint_RGB(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
||||
Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
const SDL_PixelFormatDetails *fmt = dst->internal->format;
|
||||
@@ -170,7 +170,7 @@ static int SDL_BlendPoint_RGB(SDL_Surface *dst, int x, int y, SDL_BlendMode blen
|
||||
DRAW_SETPIXELXY2_RGB(x, y);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
case 4:
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
@@ -193,13 +193,13 @@ static int SDL_BlendPoint_RGB(SDL_Surface *dst, int x, int y, SDL_BlendMode blen
|
||||
DRAW_SETPIXELXY4_RGB(x, y);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
default:
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
}
|
||||
|
||||
static int SDL_BlendPoint_RGBA(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
||||
static bool SDL_BlendPoint_RGBA(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
||||
Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
const SDL_PixelFormatDetails *fmt = dst->internal->format;
|
||||
@@ -228,14 +228,13 @@ static int SDL_BlendPoint_RGBA(SDL_Surface *dst, int x, int y, SDL_BlendMode ble
|
||||
DRAW_SETPIXELXY4_RGBA(x, y);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
default:
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
}
|
||||
|
||||
int SDL_BlendPoint(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
||||
Uint8 g, Uint8 b, Uint8 a)
|
||||
bool SDL_BlendPoint(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
if (!SDL_SurfaceValid(dst)) {
|
||||
return SDL_InvalidParamError("SDL_BlendPoint(): dst");
|
||||
@@ -250,7 +249,7 @@ int SDL_BlendPoint(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint
|
||||
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)) {
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
|
||||
@@ -294,16 +293,14 @@ int SDL_BlendPoint(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint
|
||||
}
|
||||
}
|
||||
|
||||
int SDL_BlendPoints(SDL_Surface *dst, const SDL_Point *points, int count,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
bool SDL_BlendPoints(SDL_Surface *dst, const SDL_Point *points, int count, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
int minx, miny;
|
||||
int maxx, maxy;
|
||||
int i;
|
||||
int x, y;
|
||||
int (*func)(SDL_Surface * dst, int x, int y,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) = NULL;
|
||||
int status = 0;
|
||||
bool (*func)(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) = NULL;
|
||||
bool result = true;
|
||||
|
||||
if (!SDL_SurfaceValid(dst)) {
|
||||
return SDL_InvalidParamError("SDL_BlendPoints(): dst");
|
||||
@@ -371,9 +368,9 @@ int SDL_BlendPoints(SDL_Surface *dst, const SDL_Point *points, int count,
|
||||
if (x < minx || x > maxx || y < miny || y > maxy) {
|
||||
continue;
|
||||
}
|
||||
status = func(dst, x, y, blendMode, r, g, b, a);
|
||||
result = func(dst, x, y, blendMode, r, g, b, a);
|
||||
}
|
||||
return status;
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif // SDL_VIDEO_RENDER_SW
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
#include "SDL_internal.h"
|
||||
|
||||
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);
|
||||
extern bool SDL_BlendPoint(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
extern bool 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_
|
||||
|
||||
@@ -133,7 +133,7 @@ static DrawLineFunc SDL_CalculateDrawLineFunc(const SDL_PixelFormatDetails *fmt)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int SDL_DrawLine(SDL_Surface *dst, int x1, int y1, int x2, int y2, Uint32 color)
|
||||
bool SDL_DrawLine(SDL_Surface *dst, int x1, int y1, int x2, int y2, Uint32 color)
|
||||
{
|
||||
DrawLineFunc func;
|
||||
|
||||
@@ -149,15 +149,14 @@ int SDL_DrawLine(SDL_Surface *dst, int x1, int y1, int x2, int y2, Uint32 color)
|
||||
// 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;
|
||||
return true;
|
||||
}
|
||||
|
||||
func(dst, x1, y1, x2, y2, color, true);
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
int SDL_DrawLines(SDL_Surface *dst, const SDL_Point *points, int count,
|
||||
Uint32 color)
|
||||
bool SDL_DrawLines(SDL_Surface *dst, const SDL_Point *points, int count, Uint32 color)
|
||||
{
|
||||
int i;
|
||||
int x1, y1;
|
||||
@@ -194,7 +193,7 @@ int SDL_DrawLines(SDL_Surface *dst, const SDL_Point *points, int count,
|
||||
if (points[0].x != points[count - 1].x || points[0].y != points[count - 1].y) {
|
||||
SDL_DrawPoint(dst, points[count - 1].x, points[count - 1].y, color);
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif // SDL_VIDEO_RENDER_SW
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
#include "SDL_internal.h"
|
||||
|
||||
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);
|
||||
extern bool SDL_DrawLine(SDL_Surface *dst, int x1, int y1, int x2, int y2, Uint32 color);
|
||||
extern bool SDL_DrawLines(SDL_Surface *dst, const SDL_Point *points, int count, Uint32 color);
|
||||
|
||||
#endif // SDL_drawline_h_
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include "SDL_draw.h"
|
||||
#include "SDL_drawpoint.h"
|
||||
|
||||
int SDL_DrawPoint(SDL_Surface *dst, int x, int y, Uint32 color)
|
||||
bool SDL_DrawPoint(SDL_Surface *dst, int x, int y, Uint32 color)
|
||||
{
|
||||
if (!SDL_SurfaceValid(dst)) {
|
||||
return SDL_InvalidParamError("SDL_DrawPoint(): dst");
|
||||
@@ -40,7 +40,7 @@ int SDL_DrawPoint(SDL_Surface *dst, int x, int y, Uint32 color)
|
||||
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)) {
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (dst->internal->format->bytes_per_pixel) {
|
||||
@@ -56,11 +56,10 @@ int SDL_DrawPoint(SDL_Surface *dst, int x, int y, Uint32 color)
|
||||
DRAW_FASTSETPIXELXY4(x, y);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
int SDL_DrawPoints(SDL_Surface *dst, const SDL_Point *points, int count,
|
||||
Uint32 color)
|
||||
bool SDL_DrawPoints(SDL_Surface *dst, const SDL_Point *points, int count, Uint32 color)
|
||||
{
|
||||
int minx, miny;
|
||||
int maxx, maxy;
|
||||
@@ -103,7 +102,7 @@ int SDL_DrawPoints(SDL_Surface *dst, const SDL_Point *points, int count,
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif // SDL_VIDEO_RENDER_SW
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
#include "SDL_internal.h"
|
||||
|
||||
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);
|
||||
extern bool SDL_DrawPoint(SDL_Surface *dst, int x, int y, Uint32 color);
|
||||
extern bool SDL_DrawPoints(SDL_Surface *dst, const SDL_Point *points, int count, Uint32 color);
|
||||
|
||||
#endif // SDL_drawpoint_h_
|
||||
|
||||
@@ -77,7 +77,7 @@ static void SW_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *event)
|
||||
}
|
||||
}
|
||||
|
||||
static int SW_GetOutputSize(SDL_Renderer *renderer, int *w, int *h)
|
||||
static bool SW_GetOutputSize(SDL_Renderer *renderer, int *w, int *h)
|
||||
{
|
||||
SW_RenderData *data = (SW_RenderData *)renderer->internal;
|
||||
|
||||
@@ -88,18 +88,18 @@ static int SW_GetOutputSize(SDL_Renderer *renderer, int *w, int *h)
|
||||
if (h) {
|
||||
*h = data->surface->h;
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (renderer->window) {
|
||||
SDL_GetWindowSizeInPixels(renderer->window, w, h);
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
return SDL_SetError("Software renderer doesn't have an output surface");
|
||||
}
|
||||
|
||||
static int SW_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_PropertiesID create_props)
|
||||
static bool SW_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_PropertiesID create_props)
|
||||
{
|
||||
SDL_Surface *surface = SDL_CreateSurface(texture->w, texture->h, texture->format);
|
||||
Uint8 r, g, b, a;
|
||||
@@ -123,10 +123,10 @@ static int SW_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_Pr
|
||||
SDL_SetSurfaceRLE(surface, 1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int SW_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
static bool SW_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect, const void *pixels, int pitch)
|
||||
{
|
||||
SDL_Surface *surface = (SDL_Surface *)texture->internal;
|
||||
@@ -135,8 +135,8 @@ static int SW_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
size_t length;
|
||||
|
||||
if (SDL_MUSTLOCK(surface)) {
|
||||
if (SDL_LockSurface(surface) < 0) {
|
||||
return -1;
|
||||
if (!SDL_LockSurface(surface)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
src = (Uint8 *)pixels;
|
||||
@@ -152,10 +152,10 @@ static int SW_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
if (SDL_MUSTLOCK(surface)) {
|
||||
SDL_UnlockSurface(surface);
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int SW_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
static bool SW_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect, void **pixels, int *pitch)
|
||||
{
|
||||
SDL_Surface *surface = (SDL_Surface *)texture->internal;
|
||||
@@ -164,7 +164,7 @@ static int SW_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
(void *)((Uint8 *)surface->pixels + rect->y * surface->pitch +
|
||||
rect->x * surface->internal->format->bytes_per_pixel);
|
||||
*pitch = surface->pitch;
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void SW_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
@@ -175,7 +175,7 @@ static void SW_SetTextureScaleMode(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
{
|
||||
}
|
||||
|
||||
static int SW_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
static bool SW_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
{
|
||||
SW_RenderData *data = (SW_RenderData *)renderer->internal;
|
||||
|
||||
@@ -184,21 +184,21 @@ static int SW_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
} else {
|
||||
data->surface = data->window;
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int SW_QueueNoOp(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
static bool SW_QueueNoOp(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
{
|
||||
return 0; // nothing to do in this backend.
|
||||
return true; // nothing to do in this backend.
|
||||
}
|
||||
|
||||
static int SW_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count)
|
||||
static bool SW_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count)
|
||||
{
|
||||
SDL_Point *verts = (SDL_Point *)SDL_AllocateRenderVertices(renderer, count * sizeof(SDL_Point), 0, &cmd->data.draw.first);
|
||||
int i;
|
||||
|
||||
if (!verts) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
cmd->data.draw.count = count;
|
||||
@@ -208,16 +208,16 @@ static int SW_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, co
|
||||
verts->y = (int)points->y;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int SW_QueueFillRects(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FRect *rects, int count)
|
||||
static bool SW_QueueFillRects(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FRect *rects, int count)
|
||||
{
|
||||
SDL_Rect *verts = (SDL_Rect *)SDL_AllocateRenderVertices(renderer, count * sizeof(SDL_Rect), 0, &cmd->data.draw.first);
|
||||
int i;
|
||||
|
||||
if (!verts) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
cmd->data.draw.count = count;
|
||||
@@ -229,16 +229,16 @@ static int SW_QueueFillRects(SDL_Renderer *renderer, SDL_RenderCommand *cmd, con
|
||||
verts->h = SDL_max((int)rects->h, 1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int SW_QueueCopy(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
|
||||
static bool SW_QueueCopy(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
|
||||
const SDL_FRect *srcrect, const SDL_FRect *dstrect)
|
||||
{
|
||||
SDL_Rect *verts = (SDL_Rect *)SDL_AllocateRenderVertices(renderer, 2 * sizeof(SDL_Rect), 0, &cmd->data.draw.first);
|
||||
|
||||
if (!verts) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
cmd->data.draw.count = 1;
|
||||
@@ -254,7 +254,7 @@ static int SW_QueueCopy(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Text
|
||||
verts->w = (int)dstrect->w;
|
||||
verts->h = (int)dstrect->h;
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
typedef struct CopyExData
|
||||
@@ -268,14 +268,14 @@ typedef struct CopyExData
|
||||
float scale_y;
|
||||
} CopyExData;
|
||||
|
||||
static int SW_QueueCopyEx(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
|
||||
static bool SW_QueueCopyEx(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
|
||||
const SDL_FRect *srcrect, const SDL_FRect *dstrect,
|
||||
const double angle, const SDL_FPoint *center, const SDL_FlipMode flip, float scale_x, float scale_y)
|
||||
{
|
||||
CopyExData *verts = (CopyExData *)SDL_AllocateRenderVertices(renderer, sizeof(CopyExData), 0, &cmd->data.draw.first);
|
||||
|
||||
if (!verts) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
cmd->data.draw.count = 1;
|
||||
@@ -294,13 +294,13 @@ static int SW_QueueCopyEx(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Te
|
||||
verts->scale_x = scale_x;
|
||||
verts->scale_y = scale_y;
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int Blit_to_Screen(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *surface, SDL_Rect *dstrect,
|
||||
static bool Blit_to_Screen(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *surface, SDL_Rect *dstrect,
|
||||
float scale_x, float scale_y, SDL_ScaleMode scaleMode)
|
||||
{
|
||||
int retval;
|
||||
bool result;
|
||||
// Renderer scaling, if needed
|
||||
if (scale_x != 1.0f || scale_y != 1.0f) {
|
||||
SDL_Rect r;
|
||||
@@ -308,22 +308,22 @@ static int Blit_to_Screen(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *surf
|
||||
r.y = (int)((float)dstrect->y * scale_y);
|
||||
r.w = (int)((float)dstrect->w * scale_x);
|
||||
r.h = (int)((float)dstrect->h * scale_y);
|
||||
retval = SDL_BlitSurfaceScaled(src, srcrect, surface, &r, scaleMode);
|
||||
result = SDL_BlitSurfaceScaled(src, srcrect, surface, &r, scaleMode);
|
||||
} else {
|
||||
retval = SDL_BlitSurface(src, srcrect, surface, dstrect);
|
||||
result = SDL_BlitSurface(src, srcrect, surface, dstrect);
|
||||
}
|
||||
return retval;
|
||||
return result;
|
||||
}
|
||||
|
||||
static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Texture *texture,
|
||||
const SDL_Rect *srcrect, const SDL_Rect *final_rect,
|
||||
const double angle, const SDL_FPoint *center, const SDL_FlipMode flip, float scale_x, float scale_y)
|
||||
static bool SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Texture *texture,
|
||||
const SDL_Rect *srcrect, const SDL_Rect *final_rect,
|
||||
const double angle, const SDL_FPoint *center, const SDL_FlipMode flip, float scale_x, float scale_y)
|
||||
{
|
||||
SDL_Surface *src = (SDL_Surface *)texture->internal;
|
||||
SDL_Rect tmp_rect;
|
||||
SDL_Surface *src_clone, *src_rotated, *src_scaled;
|
||||
SDL_Surface *mask = NULL, *mask_rotated = NULL;
|
||||
int retval = 0;
|
||||
bool result = true;
|
||||
SDL_BlendMode blendmode;
|
||||
Uint8 alphaMod, rMod, gMod, bMod;
|
||||
int applyModulation = false;
|
||||
@@ -331,7 +331,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex
|
||||
int isOpaque = false;
|
||||
|
||||
if (!SDL_SurfaceValid(surface)) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
tmp_rect.x = 0;
|
||||
@@ -343,8 +343,8 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex
|
||||
* necessary because this code is going to access the pixel buffer directly.
|
||||
*/
|
||||
if (SDL_MUSTLOCK(src)) {
|
||||
if (SDL_LockSurface(src) < 0) {
|
||||
return -1;
|
||||
if (!SDL_LockSurface(src)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -356,7 +356,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex
|
||||
if (SDL_MUSTLOCK(src)) {
|
||||
SDL_UnlockSurface(src);
|
||||
}
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
SDL_GetSurfaceBlendMode(src, &blendmode);
|
||||
@@ -396,7 +396,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex
|
||||
if (blendmode == SDL_BLENDMODE_NONE && !isOpaque) {
|
||||
mask = SDL_CreateSurface(final_rect->w, final_rect->h, SDL_PIXELFORMAT_ARGB8888);
|
||||
if (!mask) {
|
||||
retval = -1;
|
||||
result = false;
|
||||
} else {
|
||||
SDL_SetSurfaceBlendMode(mask, SDL_BLENDMODE_MOD);
|
||||
}
|
||||
@@ -405,14 +405,14 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex
|
||||
/* Create a new surface should there be a format mismatch or if scaling, cropping,
|
||||
* or modulation is required. It's possible to use the source surface directly otherwise.
|
||||
*/
|
||||
if (!retval && (blitRequired || applyModulation)) {
|
||||
if (result && (blitRequired || applyModulation)) {
|
||||
SDL_Rect scale_rect = tmp_rect;
|
||||
src_scaled = SDL_CreateSurface(final_rect->w, final_rect->h, SDL_PIXELFORMAT_ARGB8888);
|
||||
if (!src_scaled) {
|
||||
retval = -1;
|
||||
result = false;
|
||||
} else {
|
||||
SDL_SetSurfaceBlendMode(src_clone, SDL_BLENDMODE_NONE);
|
||||
retval = SDL_BlitSurfaceScaled(src_clone, srcrect, src_scaled, &scale_rect, texture->scaleMode);
|
||||
result = SDL_BlitSurfaceScaled(src_clone, srcrect, src_scaled, &scale_rect, texture->scaleMode);
|
||||
SDL_DestroySurface(src_clone);
|
||||
src_clone = src_scaled;
|
||||
src_scaled = NULL;
|
||||
@@ -422,7 +422,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.
|
||||
SDL_SetSurfaceBlendMode(src_clone, blendmode);
|
||||
|
||||
if (!retval) {
|
||||
if (result) {
|
||||
SDL_Rect rect_dest;
|
||||
double cangle, sangle;
|
||||
|
||||
@@ -432,18 +432,18 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex
|
||||
(texture->scaleMode == SDL_SCALEMODE_NEAREST) ? 0 : 1, flip & SDL_FLIP_HORIZONTAL, flip & SDL_FLIP_VERTICAL,
|
||||
&rect_dest, cangle, sangle, center);
|
||||
if (!src_rotated) {
|
||||
retval = -1;
|
||||
result = false;
|
||||
}
|
||||
if (!retval && mask) {
|
||||
if (result && mask) {
|
||||
// The mask needed for the NONE blend mode gets rotated with the same parameters.
|
||||
mask_rotated = SDLgfx_rotateSurface(mask, angle,
|
||||
false, 0, 0,
|
||||
&rect_dest, cangle, sangle, center);
|
||||
if (!mask_rotated) {
|
||||
retval = -1;
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
if (!retval) {
|
||||
if (result) {
|
||||
|
||||
tmp_rect.x = final_rect->x + rect_dest.x;
|
||||
tmp_rect.y = final_rect->y + rect_dest.y;
|
||||
@@ -460,7 +460,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex
|
||||
SDL_SetSurfaceColorMod(src_rotated, rMod, gMod, bMod);
|
||||
}
|
||||
// Renderer scaling, if needed
|
||||
retval = Blit_to_Screen(src_rotated, NULL, surface, &tmp_rect, scale_x, scale_y, texture->scaleMode);
|
||||
result = 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.
|
||||
* First, the area where the rotated pixels will be blitted to get set to zero.
|
||||
@@ -470,8 +470,8 @@ 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
|
||||
retval = Blit_to_Screen(mask_rotated, NULL, surface, &mask_rect, scale_x, scale_y, texture->scaleMode);
|
||||
if (!retval) {
|
||||
result = Blit_to_Screen(mask_rotated, NULL, surface, &mask_rect, scale_x, scale_y, texture->scaleMode);
|
||||
if (result) {
|
||||
/* The next step copies the alpha value. This is done with the BLEND blend mode and
|
||||
* by modulating the source colors with 0. Since the destination is all zeros, this
|
||||
* will effectively set the destination alpha to the source alpha.
|
||||
@@ -479,8 +479,8 @@ 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
|
||||
retval = Blit_to_Screen(src_rotated, NULL, surface, &mask_rect, scale_x, scale_y, texture->scaleMode);
|
||||
if (!retval) {
|
||||
result = Blit_to_Screen(src_rotated, NULL, surface, &mask_rect, scale_x, scale_y, texture->scaleMode);
|
||||
if (result) {
|
||||
/* The last step gets the color values in place. The ADD blend mode simply adds them to
|
||||
* the destination (where the color values are all zero). However, because the ADD blend
|
||||
* mode modulates the colors with the alpha channel, a surface without an alpha mask needs
|
||||
@@ -488,11 +488,11 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex
|
||||
*/
|
||||
SDL_Surface *src_rotated_rgb = SDL_CreateSurfaceFrom(src_rotated->w, src_rotated->h, src_rotated->format, src_rotated->pixels, src_rotated->pitch);
|
||||
if (!src_rotated_rgb) {
|
||||
retval = -1;
|
||||
result = false;
|
||||
} else {
|
||||
SDL_SetSurfaceBlendMode(src_rotated_rgb, SDL_BLENDMODE_ADD);
|
||||
// Renderer scaling, if needed
|
||||
retval = Blit_to_Screen(src_rotated_rgb, NULL, surface, &tmp_rect, scale_x, scale_y, texture->scaleMode);
|
||||
result = Blit_to_Screen(src_rotated_rgb, NULL, surface, &tmp_rect, scale_x, scale_y, texture->scaleMode);
|
||||
SDL_DestroySurface(src_rotated_rgb);
|
||||
}
|
||||
}
|
||||
@@ -514,7 +514,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex
|
||||
if (src_clone) {
|
||||
SDL_DestroySurface(src_clone);
|
||||
}
|
||||
return retval;
|
||||
return result;
|
||||
}
|
||||
|
||||
typedef struct GeometryFillData
|
||||
@@ -530,7 +530,7 @@ typedef struct GeometryCopyData
|
||||
SDL_Color color;
|
||||
} GeometryCopyData;
|
||||
|
||||
static int SW_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
|
||||
static bool SW_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
|
||||
const float *xy, int xy_stride, const SDL_FColor *color, int color_stride, const float *uv, int uv_stride,
|
||||
int num_vertices, const void *indices, int num_indices, int size_indices,
|
||||
float scale_x, float scale_y)
|
||||
@@ -543,7 +543,7 @@ static int SW_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_
|
||||
|
||||
verts = SDL_AllocateRenderVertices(renderer, count * sz, 0, &cmd->data.draw.first);
|
||||
if (!verts) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
cmd->data.draw.count = count;
|
||||
@@ -617,7 +617,7 @@ static int SW_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_
|
||||
ptr++;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void PrepTextureForCopy(const SDL_RenderCommand *cmd, SW_DrawStateCache *drawstate)
|
||||
@@ -671,13 +671,13 @@ static void SW_InvalidateCachedState(SDL_Renderer *renderer)
|
||||
}
|
||||
|
||||
|
||||
static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize)
|
||||
static bool SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize)
|
||||
{
|
||||
SDL_Surface *surface = SW_ActivateRenderer(renderer);
|
||||
SW_DrawStateCache drawstate;
|
||||
|
||||
if (!SDL_SurfaceValid(surface)) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
drawstate.viewport = NULL;
|
||||
@@ -960,7 +960,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
|
||||
cmd = cmd->next;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static SDL_Surface *SW_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect)
|
||||
@@ -989,12 +989,12 @@ static SDL_Surface *SW_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *
|
||||
return SDL_DuplicatePixels(rect->w, rect->h, surface->format, SDL_COLORSPACE_SRGB, pixels, surface->pitch);
|
||||
}
|
||||
|
||||
static int SW_RenderPresent(SDL_Renderer *renderer)
|
||||
static bool SW_RenderPresent(SDL_Renderer *renderer)
|
||||
{
|
||||
SDL_Window *window = renderer->window;
|
||||
|
||||
if (!window) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
return SDL_UpdateWindowSurface(window);
|
||||
}
|
||||
@@ -1112,7 +1112,7 @@ static void SW_SelectBestFormats(SDL_Renderer *renderer, SDL_PixelFormat format)
|
||||
}
|
||||
}
|
||||
|
||||
int SW_CreateRendererForSurface(SDL_Renderer *renderer, SDL_Surface *surface, SDL_PropertiesID create_props)
|
||||
bool SW_CreateRendererForSurface(SDL_Renderer *renderer, SDL_Surface *surface, SDL_PropertiesID create_props)
|
||||
{
|
||||
SW_RenderData *data;
|
||||
|
||||
@@ -1124,7 +1124,7 @@ int SW_CreateRendererForSurface(SDL_Renderer *renderer, SDL_Surface *surface, SD
|
||||
|
||||
data = (SW_RenderData *)SDL_calloc(1, sizeof(*data));
|
||||
if (!data) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
data->surface = surface;
|
||||
data->window = surface;
|
||||
@@ -1164,10 +1164,10 @@ int SW_CreateRendererForSurface(SDL_Renderer *renderer, SDL_Surface *surface, SD
|
||||
return SDL_SetError("Unsupported output colorspace");
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int SW_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_PropertiesID create_props)
|
||||
static bool 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
|
||||
const char *hint = SDL_GetHint(SDL_HINT_RENDER_VSYNC);
|
||||
@@ -1189,7 +1189,7 @@ static int SW_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Pro
|
||||
}
|
||||
|
||||
if (!SDL_SurfaceValid(surface)) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
return SW_CreateRendererForSurface(renderer, surface, create_props);
|
||||
|
||||
@@ -22,6 +22,6 @@
|
||||
#ifndef SDL_render_sw_c_h_
|
||||
#define SDL_render_sw_c_h_
|
||||
|
||||
extern int SW_CreateRendererForSurface(SDL_Renderer *renderer, SDL_Surface *surface, SDL_PropertiesID create_props);
|
||||
extern bool SW_CreateRendererForSurface(SDL_Renderer *renderer, SDL_Surface *surface, SDL_PropertiesID create_props);
|
||||
|
||||
#endif // SDL_render_sw_c_h_
|
||||
|
||||
@@ -501,7 +501,7 @@ SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, in
|
||||
}
|
||||
|
||||
if (SDL_SurfaceHasColorKey(src)) {
|
||||
if (SDL_GetSurfaceColorKey(src, &colorkey) == 0) {
|
||||
if (SDL_GetSurfaceColorKey(src, &colorkey)) {
|
||||
colorKeyAvailable = true;
|
||||
}
|
||||
}
|
||||
@@ -561,7 +561,7 @@ SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, in
|
||||
|
||||
// Lock source surface
|
||||
if (SDL_MUSTLOCK(src)) {
|
||||
if (SDL_LockSurface(src) < 0) {
|
||||
if (!SDL_LockSurface(src)) {
|
||||
SDL_DestroySurface(rz_dst);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -45,13 +45,13 @@ static void SDL_BlitTriangle_Slow(SDL_BlitInfo *info,
|
||||
SDL_Color c0, SDL_Color c1, SDL_Color c2, bool is_uniform, SDL_TextureAddressMode texture_address_mode);
|
||||
|
||||
#if 0
|
||||
int SDL_BlitTriangle(SDL_Surface *src, const SDL_Point srcpoints[3], SDL_Surface *dst, const SDL_Point dstpoints[3])
|
||||
bool SDL_BlitTriangle(SDL_Surface *src, const SDL_Point srcpoints[3], SDL_Surface *dst, const SDL_Point dstpoints[3])
|
||||
{
|
||||
int i;
|
||||
SDL_Point points[6];
|
||||
|
||||
if (src == NULL || dst == NULL) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
@@ -72,12 +72,12 @@ int SDL_BlitTriangle(SDL_Surface *src, const SDL_Point srcpoints[3], SDL_Surface
|
||||
return SDL_SW_BlitTriangle(src, dst, points);
|
||||
}
|
||||
|
||||
int SDL_FillTriangle(SDL_Surface *dst, const SDL_Point points[3], Uint32 color)
|
||||
bool SDL_FillTriangle(SDL_Surface *dst, const SDL_Point points[3], Uint32 color)
|
||||
{
|
||||
int i;
|
||||
SDL_Point points_tmp[3];
|
||||
if (dst == NULL) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
for (i = 0; i < 3; i++) {
|
||||
points_tmp[i] = points[i];
|
||||
@@ -94,24 +94,24 @@ static Sint64 cross_product(const SDL_Point *a, const SDL_Point *b, int c_x, int
|
||||
}
|
||||
|
||||
// check for top left rules
|
||||
static int is_top_left(const SDL_Point *a, const SDL_Point *b, int is_clockwise)
|
||||
static bool is_top_left(const SDL_Point *a, const SDL_Point *b, int is_clockwise)
|
||||
{
|
||||
if (is_clockwise) {
|
||||
if (a->y == b->y && a->x < b->x) {
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
if (b->y < a->y) {
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (a->y == b->y && b->x < a->x) {
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
if (a->y < b->y) {
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
// x = (y << FP_BITS)
|
||||
@@ -223,9 +223,9 @@ static void bounding_rect(const SDL_Point *a, const SDL_Point *b, const SDL_Poin
|
||||
} \
|
||||
}
|
||||
|
||||
int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Point *d2, SDL_BlendMode blend, SDL_Color c0, SDL_Color c1, SDL_Color c2)
|
||||
bool SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Point *d2, SDL_BlendMode blend, SDL_Color c0, SDL_Color c1, SDL_Color c2)
|
||||
{
|
||||
int ret = 0;
|
||||
bool result = true;
|
||||
int dst_locked = 0;
|
||||
|
||||
SDL_Rect dstrect;
|
||||
@@ -246,7 +246,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin
|
||||
SDL_Surface *tmp = NULL;
|
||||
|
||||
if (!SDL_SurfaceValid(dst)) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
area = cross_product(d0, d1, d2->x, d2->y);
|
||||
@@ -255,13 +255,13 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin
|
||||
|
||||
// Flat triangle
|
||||
if (area == 0) {
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Lock the destination, if needed
|
||||
if (SDL_MUSTLOCK(dst)) {
|
||||
if (SDL_LockSurface(dst) < 0) {
|
||||
ret = -1;
|
||||
if (!SDL_LockSurface(dst)) {
|
||||
result = false;
|
||||
goto end;
|
||||
} else {
|
||||
dst_locked = 1;
|
||||
@@ -298,7 +298,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin
|
||||
// Use an intermediate surface
|
||||
tmp = SDL_CreateSurface(dstrect.w, dstrect.h, format);
|
||||
if (!tmp) {
|
||||
ret = -1;
|
||||
result = false;
|
||||
goto end;
|
||||
}
|
||||
|
||||
@@ -456,10 +456,10 @@ end:
|
||||
SDL_UnlockSurface(dst);
|
||||
}
|
||||
|
||||
return ret;
|
||||
return result;
|
||||
}
|
||||
|
||||
int SDL_SW_BlitTriangle(
|
||||
bool SDL_SW_BlitTriangle(
|
||||
SDL_Surface *src,
|
||||
SDL_Point *s0, SDL_Point *s1, SDL_Point *s2,
|
||||
SDL_Surface *dst,
|
||||
@@ -467,8 +467,8 @@ int SDL_SW_BlitTriangle(
|
||||
SDL_Color c0, SDL_Color c1, SDL_Color c2,
|
||||
SDL_TextureAddressMode texture_address_mode)
|
||||
{
|
||||
bool result = true;
|
||||
SDL_Surface *src_surface = src;
|
||||
int ret = 0;
|
||||
int src_locked = 0;
|
||||
int dst_locked = 0;
|
||||
|
||||
@@ -509,13 +509,13 @@ int SDL_SW_BlitTriangle(
|
||||
|
||||
// Flat triangle
|
||||
if (area == 0) {
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Lock the destination, if needed
|
||||
if (SDL_MUSTLOCK(dst)) {
|
||||
if (SDL_LockSurface(dst) < 0) {
|
||||
ret = -1;
|
||||
if (!SDL_LockSurface(dst)) {
|
||||
result = false;
|
||||
goto end;
|
||||
} else {
|
||||
dst_locked = 1;
|
||||
@@ -524,8 +524,8 @@ int SDL_SW_BlitTriangle(
|
||||
|
||||
// Lock the source, if needed
|
||||
if (SDL_MUSTLOCK(src)) {
|
||||
if (SDL_LockSurface(src) < 0) {
|
||||
ret = -1;
|
||||
if (!SDL_LockSurface(src)) {
|
||||
result = false;
|
||||
goto end;
|
||||
} else {
|
||||
src_locked = 1;
|
||||
@@ -648,14 +648,14 @@ int SDL_SW_BlitTriangle(
|
||||
if (tmp64 >= INT_MIN && tmp64 <= INT_MAX) {
|
||||
s2_x_area.x = (int)tmp64;
|
||||
} else {
|
||||
ret = SDL_SetError("triangle area overflow");
|
||||
result = SDL_SetError("triangle area overflow");
|
||||
goto end;
|
||||
}
|
||||
tmp64 = s2->y * area;
|
||||
if (tmp64 >= INT_MIN && tmp64 <= INT_MAX) {
|
||||
s2_x_area.y = (int)tmp64;
|
||||
} else {
|
||||
ret = SDL_SetError("triangle area overflow");
|
||||
result = SDL_SetError("triangle area overflow");
|
||||
goto end;
|
||||
}
|
||||
|
||||
@@ -706,7 +706,7 @@ int SDL_SW_BlitTriangle(
|
||||
|
||||
#define CHECK_INT_RANGE(X) \
|
||||
if ((X) < INT_MIN || (X) > INT_MAX) { \
|
||||
ret = SDL_SetError("integer overflow (%s = %" SDL_PRIs64 ")", #X, X); \
|
||||
result = SDL_SetError("integer overflow (%s = %" SDL_PRIs64 ")", #X, X); \
|
||||
goto end; \
|
||||
}
|
||||
CHECK_INT_RANGE(area);
|
||||
@@ -765,7 +765,7 @@ end:
|
||||
SDL_UnlockSurface(src);
|
||||
}
|
||||
|
||||
return ret;
|
||||
return result;
|
||||
}
|
||||
|
||||
#define FORMAT_ALPHA 0
|
||||
|
||||
@@ -26,17 +26,16 @@
|
||||
|
||||
#include "../SDL_sysrender.h" // For SDL_TextureAddressMode
|
||||
|
||||
extern int SDL_SW_FillTriangle(SDL_Surface *dst,
|
||||
SDL_Point *d0, SDL_Point *d1, SDL_Point *d2,
|
||||
SDL_BlendMode blend, SDL_Color c0, SDL_Color c1, SDL_Color c2);
|
||||
extern bool SDL_SW_FillTriangle(SDL_Surface *dst,
|
||||
SDL_Point *d0, SDL_Point *d1, SDL_Point *d2,
|
||||
SDL_BlendMode blend, SDL_Color c0, SDL_Color c1, SDL_Color c2);
|
||||
|
||||
extern int SDL_SW_BlitTriangle(
|
||||
SDL_Surface *src,
|
||||
SDL_Point *s0, SDL_Point *s1, SDL_Point *s2,
|
||||
SDL_Surface *dst,
|
||||
SDL_Point *d0, SDL_Point *d1, SDL_Point *d2,
|
||||
SDL_Color c0, SDL_Color c1, SDL_Color c2,
|
||||
SDL_TextureAddressMode texture_address_mode);
|
||||
extern bool SDL_SW_BlitTriangle(SDL_Surface *src,
|
||||
SDL_Point *s0, SDL_Point *s1, SDL_Point *s2,
|
||||
SDL_Surface *dst,
|
||||
SDL_Point *d0, SDL_Point *d1, SDL_Point *d2,
|
||||
SDL_Color c0, SDL_Color c1, SDL_Color c2,
|
||||
SDL_TextureAddressMode texture_address_mode);
|
||||
|
||||
extern void trianglepoint_2_fixedpoint(SDL_Point *a);
|
||||
|
||||
|
||||
@@ -42,29 +42,29 @@
|
||||
#include <psp2/sysmodule.h>
|
||||
#endif
|
||||
|
||||
static int VITA_GXM_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_PropertiesID create_props);
|
||||
static bool VITA_GXM_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_PropertiesID create_props);
|
||||
|
||||
static void VITA_GXM_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *event);
|
||||
|
||||
static bool VITA_GXM_SupportsBlendMode(SDL_Renderer *renderer, SDL_BlendMode blendMode);
|
||||
|
||||
static int VITA_GXM_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_PropertiesID create_props);
|
||||
static bool VITA_GXM_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_PropertiesID create_props);
|
||||
|
||||
static int VITA_GXM_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
static bool VITA_GXM_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect, const void *pixels, int pitch);
|
||||
|
||||
static int VITA_GXM_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
static bool VITA_GXM_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *Uplane, int Upitch,
|
||||
const Uint8 *Vplane, int Vpitch);
|
||||
|
||||
static int VITA_GXM_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
static bool VITA_GXM_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *UVplane, int UVpitch);
|
||||
|
||||
static int VITA_GXM_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
static bool VITA_GXM_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect, void **pixels, int *pitch);
|
||||
|
||||
static void VITA_GXM_UnlockTexture(SDL_Renderer *renderer,
|
||||
@@ -72,30 +72,30 @@ static void VITA_GXM_UnlockTexture(SDL_Renderer *renderer,
|
||||
|
||||
static void VITA_GXM_SetTextureScaleMode(SDL_Renderer *renderer, SDL_Texture *texture, SDL_ScaleMode scaleMode);
|
||||
|
||||
static int VITA_GXM_SetRenderTarget(SDL_Renderer *renderer,
|
||||
static bool VITA_GXM_SetRenderTarget(SDL_Renderer *renderer,
|
||||
SDL_Texture *texture);
|
||||
|
||||
static int VITA_GXM_QueueNoOp(SDL_Renderer *renderer, SDL_RenderCommand *cmd);
|
||||
static bool VITA_GXM_QueueNoOp(SDL_Renderer *renderer, SDL_RenderCommand *cmd);
|
||||
|
||||
static int VITA_GXM_QueueSetDrawColor(SDL_Renderer *renderer, SDL_RenderCommand *cmd);
|
||||
static bool VITA_GXM_QueueSetDrawColor(SDL_Renderer *renderer, SDL_RenderCommand *cmd);
|
||||
|
||||
static int VITA_GXM_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count);
|
||||
static int VITA_GXM_QueueDrawLines(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count);
|
||||
static bool VITA_GXM_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count);
|
||||
static bool VITA_GXM_QueueDrawLines(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count);
|
||||
|
||||
static int VITA_GXM_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
|
||||
static bool VITA_GXM_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
|
||||
const float *xy, int xy_stride, const SDL_FColor *color, int color_stride, const float *uv, int uv_stride,
|
||||
int num_vertices, const void *indices, int num_indices, int size_indices,
|
||||
float scale_x, float scale_y);
|
||||
|
||||
static int VITA_GXM_RenderClear(SDL_Renderer *renderer, SDL_RenderCommand *cmd);
|
||||
static bool VITA_GXM_RenderClear(SDL_Renderer *renderer, SDL_RenderCommand *cmd);
|
||||
|
||||
static void VITA_GXM_InvalidateCachedState(SDL_Renderer *renderer);
|
||||
|
||||
static int VITA_GXM_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize);
|
||||
static bool VITA_GXM_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize);
|
||||
|
||||
static SDL_Surface *VITA_GXM_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect);
|
||||
|
||||
static int VITA_GXM_RenderPresent(SDL_Renderer *renderer);
|
||||
static bool VITA_GXM_RenderPresent(SDL_Renderer *renderer);
|
||||
static void VITA_GXM_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture);
|
||||
static void VITA_GXM_DestroyRenderer(SDL_Renderer *renderer);
|
||||
|
||||
@@ -180,7 +180,7 @@ void StartDrawing(SDL_Renderer *renderer)
|
||||
data->drawing = true;
|
||||
}
|
||||
|
||||
static int VITA_GXM_SetVSync(SDL_Renderer *renderer, const int vsync)
|
||||
static bool VITA_GXM_SetVSync(SDL_Renderer *renderer, const int vsync)
|
||||
{
|
||||
VITA_GXM_RenderData *data = renderer->internal;
|
||||
if (vsync) {
|
||||
@@ -188,10 +188,10 @@ static int VITA_GXM_SetVSync(SDL_Renderer *renderer, const int vsync)
|
||||
} else {
|
||||
data->displayData.wait_vblank = false;
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int VITA_GXM_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_PropertiesID create_props)
|
||||
static bool VITA_GXM_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_PropertiesID create_props)
|
||||
{
|
||||
VITA_GXM_RenderData *data;
|
||||
|
||||
@@ -203,7 +203,7 @@ static int VITA_GXM_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, S
|
||||
|
||||
data = (VITA_GXM_RenderData *)SDL_calloc(1, sizeof(VITA_GXM_RenderData));
|
||||
if (!data) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
renderer->WindowEvent = VITA_GXM_WindowEvent;
|
||||
@@ -257,7 +257,7 @@ static int VITA_GXM_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, S
|
||||
return SDL_SetError("gxm_init failed");
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void VITA_GXM_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *event)
|
||||
@@ -270,13 +270,13 @@ static bool VITA_GXM_SupportsBlendMode(SDL_Renderer *renderer, SDL_BlendMode ble
|
||||
return false;
|
||||
}
|
||||
|
||||
static int VITA_GXM_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_PropertiesID create_props)
|
||||
static bool VITA_GXM_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_PropertiesID create_props)
|
||||
{
|
||||
VITA_GXM_RenderData *data = (VITA_GXM_RenderData *)renderer->internal;
|
||||
VITA_GXM_TextureData *vita_texture = (VITA_GXM_TextureData *)SDL_calloc(1, sizeof(VITA_GXM_TextureData));
|
||||
|
||||
if (!vita_texture) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
vita_texture->tex = create_gxm_texture(
|
||||
@@ -304,7 +304,7 @@ static int VITA_GXM_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
vita_texture->nv12 = ((texture->format == SDL_PIXELFORMAT_NV12) || (texture->format == SDL_PIXELFORMAT_NV21));
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void VITA_GXM_SetYUVProfile(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
@@ -332,7 +332,7 @@ static void VITA_GXM_SetYUVProfile(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
}
|
||||
}
|
||||
|
||||
static int VITA_GXM_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
static bool VITA_GXM_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect, const void *pixels, int pitch)
|
||||
{
|
||||
VITA_GXM_TextureData *vita_texture = (VITA_GXM_TextureData *)texture->internal;
|
||||
@@ -420,11 +420,11 @@ static int VITA_GXM_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
#if SDL_HAVE_YUV
|
||||
static int VITA_GXM_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
static bool VITA_GXM_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *Uplane, int Upitch,
|
||||
@@ -495,10 +495,10 @@ static int VITA_GXM_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *textur
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int VITA_GXM_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
static bool VITA_GXM_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *UVplane, int UVpitch)
|
||||
@@ -550,12 +550,12 @@ static int VITA_GXM_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static int VITA_GXM_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
static bool VITA_GXM_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect, void **pixels, int *pitch)
|
||||
{
|
||||
VITA_GXM_RenderData *data = (VITA_GXM_RenderData *)renderer->internal;
|
||||
@@ -570,7 +570,7 @@ static int VITA_GXM_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
sceGxmFinish(data->gxm_context);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void VITA_GXM_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
@@ -599,9 +599,9 @@ static void VITA_GXM_SetTextureScaleMode(SDL_Renderer *renderer, SDL_Texture *te
|
||||
return;
|
||||
}
|
||||
|
||||
static int VITA_GXM_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
static bool VITA_GXM_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
{
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void VITA_GXM_SetBlendMode(VITA_GXM_RenderData *data, int blendMode)
|
||||
@@ -632,12 +632,12 @@ static void VITA_GXM_SetBlendMode(VITA_GXM_RenderData *data, int blendMode)
|
||||
}
|
||||
}
|
||||
|
||||
static int VITA_GXM_QueueNoOp(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
static bool VITA_GXM_QueueNoOp(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
{
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int VITA_GXM_QueueSetDrawColor(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
static bool VITA_GXM_QueueSetDrawColor(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
{
|
||||
VITA_GXM_RenderData *data = (VITA_GXM_RenderData *)renderer->internal;
|
||||
|
||||
@@ -646,10 +646,10 @@ static int VITA_GXM_QueueSetDrawColor(SDL_Renderer *renderer, SDL_RenderCommand
|
||||
data->drawstate.color.b = cmd->data.color.color.b * cmd->data.color.color_scale;
|
||||
data->drawstate.color.a = cmd->data.color.color.a;
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int VITA_GXM_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count)
|
||||
static bool VITA_GXM_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count)
|
||||
{
|
||||
VITA_GXM_RenderData *data = (VITA_GXM_RenderData *)renderer->internal;
|
||||
|
||||
@@ -668,10 +668,10 @@ static int VITA_GXM_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *c
|
||||
vertex[i].color = color;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int VITA_GXM_QueueDrawLines(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count)
|
||||
static bool VITA_GXM_QueueDrawLines(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count)
|
||||
{
|
||||
VITA_GXM_RenderData *data = (VITA_GXM_RenderData *)renderer->internal;
|
||||
SDL_FColor color = data->drawstate.color;
|
||||
@@ -693,10 +693,10 @@ static int VITA_GXM_QueueDrawLines(SDL_Renderer *renderer, SDL_RenderCommand *cm
|
||||
vertex[i * 2 + 1].color = color;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int VITA_GXM_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
|
||||
static bool VITA_GXM_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
|
||||
const float *xy, int xy_stride, const SDL_FColor *color, int color_stride, const float *uv, int uv_stride,
|
||||
int num_vertices, const void *indices, int num_indices, int size_indices,
|
||||
float scale_x, float scale_y)
|
||||
@@ -718,7 +718,7 @@ static int VITA_GXM_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd
|
||||
count * sizeof(texture_vertex));
|
||||
|
||||
if (!vertices) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
@@ -761,7 +761,7 @@ static int VITA_GXM_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd
|
||||
count * sizeof(color_vertex));
|
||||
|
||||
if (!vertices) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
@@ -792,10 +792,10 @@ static int VITA_GXM_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd
|
||||
cmd->data.draw.first = (size_t)vertices;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int VITA_GXM_RenderClear(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
static bool VITA_GXM_RenderClear(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
{
|
||||
void *color_buffer;
|
||||
SDL_FColor color;
|
||||
@@ -822,10 +822,10 @@ static int VITA_GXM_RenderClear(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
sceGxmDraw(data->gxm_context, SCE_GXM_PRIMITIVE_TRIANGLES, SCE_GXM_INDEX_FORMAT_U16, data->linearIndices, 3);
|
||||
|
||||
data->drawstate.cliprect_dirty = true;
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int SetDrawState(VITA_GXM_RenderData *data, const SDL_RenderCommand *cmd)
|
||||
static bool SetDrawState(VITA_GXM_RenderData *data, const SDL_RenderCommand *cmd)
|
||||
{
|
||||
SDL_Texture *texture = cmd->data.draw.texture;
|
||||
const SDL_BlendMode blend = cmd->data.draw.blend;
|
||||
@@ -918,7 +918,7 @@ static int SetDrawState(VITA_GXM_RenderData *data, const SDL_RenderCommand *cmd)
|
||||
// all drawing commands use this
|
||||
sceGxmSetVertexStream(data->gxm_context, 0, (const void *)cmd->data.draw.first);
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void VITA_GXM_InvalidateCachedState(SDL_Renderer *renderer)
|
||||
@@ -926,7 +926,7 @@ 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.
|
||||
}
|
||||
|
||||
static int VITA_GXM_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize)
|
||||
static bool VITA_GXM_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize)
|
||||
{
|
||||
VITA_GXM_RenderData *data = (VITA_GXM_RenderData *)renderer->internal;
|
||||
StartDrawing(renderer);
|
||||
@@ -1018,7 +1018,7 @@ static int VITA_GXM_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *c
|
||||
|
||||
ret = SetDrawState(data, cmd);
|
||||
|
||||
if (ret == 0) {
|
||||
if (ret) {
|
||||
int op = SCE_GXM_PRIMITIVE_TRIANGLES;
|
||||
|
||||
if (thiscmdtype == SDL_RENDERCMD_DRAW_POINTS) {
|
||||
@@ -1050,7 +1050,7 @@ static int VITA_GXM_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *c
|
||||
sceGxmEndScene(data->gxm_context, NULL, NULL);
|
||||
data->drawing = false;
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
void read_pixels(int x, int y, size_t width, size_t height, void *data)
|
||||
@@ -1120,7 +1120,7 @@ static SDL_Surface *VITA_GXM_RenderReadPixels(SDL_Renderer *renderer, const SDL_
|
||||
return surface;
|
||||
}
|
||||
|
||||
static int VITA_GXM_RenderPresent(SDL_Renderer *renderer)
|
||||
static bool VITA_GXM_RenderPresent(SDL_Renderer *renderer)
|
||||
{
|
||||
VITA_GXM_RenderData *data = (VITA_GXM_RenderData *)renderer->internal;
|
||||
SceCommonDialogUpdateParam updateParam;
|
||||
@@ -1159,7 +1159,7 @@ static int VITA_GXM_RenderPresent(SDL_Renderer *renderer)
|
||||
data->pool_index = 0;
|
||||
|
||||
data->current_pool = (data->current_pool + 1) % 2;
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void VITA_GXM_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
|
||||
@@ -1331,7 +1331,7 @@ static VkResult VULKAN_CreateVertexBuffer(VULKAN_RenderData *rendererData, size_
|
||||
return result;
|
||||
}
|
||||
|
||||
static int VULKAN_LoadGlobalFunctions(VULKAN_RenderData *rendererData)
|
||||
static bool VULKAN_LoadGlobalFunctions(VULKAN_RenderData *rendererData)
|
||||
{
|
||||
#define VULKAN_DEVICE_FUNCTION(name)
|
||||
#define VULKAN_GLOBAL_FUNCTION(name) \
|
||||
@@ -1339,7 +1339,7 @@ static int VULKAN_LoadGlobalFunctions(VULKAN_RenderData *rendererData)
|
||||
if (!name) { \
|
||||
SDL_LogError(SDL_LOG_CATEGORY_RENDER, \
|
||||
"vkGetInstanceProcAddr(VK_NULL_HANDLE, \"" #name "\") failed\n"); \
|
||||
return -1; \
|
||||
return false; \
|
||||
}
|
||||
#define VULKAN_INSTANCE_FUNCTION(name)
|
||||
#define VULKAN_OPTIONAL_INSTANCE_FUNCTION(name)
|
||||
@@ -1351,10 +1351,10 @@ static int VULKAN_LoadGlobalFunctions(VULKAN_RenderData *rendererData)
|
||||
#undef VULKAN_OPTIONAL_INSTANCE_FUNCTION
|
||||
#undef VULKAN_OPTIONAL_DEVICE_FUNCTION
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int VULKAN_LoadInstanceFunctions(VULKAN_RenderData *rendererData)
|
||||
static bool VULKAN_LoadInstanceFunctions(VULKAN_RenderData *rendererData)
|
||||
{
|
||||
#define VULKAN_DEVICE_FUNCTION(name)
|
||||
#define VULKAN_GLOBAL_FUNCTION(name)
|
||||
@@ -1363,7 +1363,7 @@ static int VULKAN_LoadInstanceFunctions(VULKAN_RenderData *rendererData)
|
||||
if (!name) { \
|
||||
SDL_LogError(SDL_LOG_CATEGORY_RENDER, \
|
||||
"vkGetInstanceProcAddr(instance, \"" #name "\") failed\n"); \
|
||||
return -1; \
|
||||
return false; \
|
||||
}
|
||||
#define VULKAN_OPTIONAL_INSTANCE_FUNCTION(name) \
|
||||
name = (PFN_##name)rendererData->vkGetInstanceProcAddr(rendererData->instance, #name);
|
||||
@@ -1376,17 +1376,17 @@ static int VULKAN_LoadInstanceFunctions(VULKAN_RenderData *rendererData)
|
||||
#undef VULKAN_OPTIONAL_INSTANCE_FUNCTION
|
||||
#undef VULKAN_OPTIONAL_DEVICE_FUNCTION
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int VULKAN_LoadDeviceFunctions(VULKAN_RenderData *rendererData)
|
||||
static bool VULKAN_LoadDeviceFunctions(VULKAN_RenderData *rendererData)
|
||||
{
|
||||
#define VULKAN_DEVICE_FUNCTION(name) \
|
||||
name = (PFN_##name)vkGetDeviceProcAddr(rendererData->device, #name); \
|
||||
if (!name) { \
|
||||
SDL_LogError(SDL_LOG_CATEGORY_RENDER, \
|
||||
"vkGetDeviceProcAddr(device, \"" #name "\") failed\n"); \
|
||||
return -1; \
|
||||
return false; \
|
||||
}
|
||||
#define VULKAN_GLOBAL_FUNCTION(name)
|
||||
#define VULKAN_OPTIONAL_DEVICE_FUNCTION(name) \
|
||||
@@ -1399,7 +1399,7 @@ static int VULKAN_LoadDeviceFunctions(VULKAN_RenderData *rendererData)
|
||||
#undef VULKAN_INSTANCE_FUNCTION
|
||||
#undef VULKAN_OPTIONAL_INSTANCE_FUNCTION
|
||||
#undef VULKAN_OPTIONAL_DEVICE_FUNCTION
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static VkResult VULKAN_FindPhysicalDevice(VULKAN_RenderData *rendererData)
|
||||
@@ -1694,7 +1694,7 @@ static VkResult VULKAN_CreateDeviceResources(SDL_Renderer *renderer, SDL_Propert
|
||||
bool createDebug = SDL_GetHintBoolean(SDL_HINT_RENDER_VULKAN_DEBUG, false);
|
||||
const char *validationLayerName[] = { SDL_VULKAN_VALIDATION_LAYER_NAME };
|
||||
|
||||
if (SDL_Vulkan_LoadLibrary(NULL) < 0) {
|
||||
if (!SDL_Vulkan_LoadLibrary(NULL)) {
|
||||
SDL_LogDebug(SDL_LOG_CATEGORY_RENDER, "SDL_Vulkan_LoadLibrary failed." );
|
||||
return VK_ERROR_UNKNOWN;
|
||||
}
|
||||
@@ -1706,7 +1706,7 @@ static VkResult VULKAN_CreateDeviceResources(SDL_Renderer *renderer, SDL_Propert
|
||||
|
||||
// Load global Vulkan functions
|
||||
rendererData->vkGetInstanceProcAddr = vkGetInstanceProcAddr;
|
||||
if (VULKAN_LoadGlobalFunctions(rendererData) != 0) {
|
||||
if (!VULKAN_LoadGlobalFunctions(rendererData)) {
|
||||
return VK_ERROR_UNKNOWN;
|
||||
}
|
||||
|
||||
@@ -1763,7 +1763,7 @@ static VkResult VULKAN_CreateDeviceResources(SDL_Renderer *renderer, SDL_Propert
|
||||
}
|
||||
|
||||
// Load instance Vulkan functions
|
||||
if (VULKAN_LoadInstanceFunctions(rendererData) != 0) {
|
||||
if (!VULKAN_LoadInstanceFunctions(rendererData)) {
|
||||
VULKAN_DestroyAll(renderer);
|
||||
return VK_ERROR_UNKNOWN;
|
||||
}
|
||||
@@ -1773,7 +1773,7 @@ static VkResult VULKAN_CreateDeviceResources(SDL_Renderer *renderer, SDL_Propert
|
||||
if (rendererData->surface) {
|
||||
rendererData->surface_external = true;
|
||||
} else {
|
||||
if (!device->Vulkan_CreateSurface || (device->Vulkan_CreateSurface(device, renderer->window, rendererData->instance, NULL, &rendererData->surface) < 0)) {
|
||||
if (!device->Vulkan_CreateSurface || !device->Vulkan_CreateSurface(device, renderer->window, rendererData->instance, NULL, &rendererData->surface)) {
|
||||
VULKAN_DestroyAll(renderer);
|
||||
SDL_LogError(SDL_LOG_CATEGORY_RENDER, "Vulkan_CreateSurface() failed.\n");
|
||||
return VK_ERROR_UNKNOWN;
|
||||
@@ -1850,7 +1850,7 @@ static VkResult VULKAN_CreateDeviceResources(SDL_Renderer *renderer, SDL_Propert
|
||||
}
|
||||
}
|
||||
|
||||
if (VULKAN_LoadDeviceFunctions(rendererData) != 0) {
|
||||
if (!VULKAN_LoadDeviceFunctions(rendererData)) {
|
||||
VULKAN_DestroyAll(renderer);
|
||||
return VK_ERROR_UNKNOWN;
|
||||
}
|
||||
@@ -2496,7 +2496,7 @@ static bool VULKAN_SupportsBlendMode(SDL_Renderer *renderer, SDL_BlendMode blend
|
||||
return true;
|
||||
}
|
||||
|
||||
static int VULKAN_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_PropertiesID create_props)
|
||||
static bool VULKAN_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_PropertiesID create_props)
|
||||
{
|
||||
VULKAN_RenderData *rendererData = (VULKAN_RenderData *)renderer->internal;
|
||||
VULKAN_TextureData *textureData;
|
||||
@@ -2511,7 +2511,7 @@ static int VULKAN_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SD
|
||||
|
||||
textureData = (VULKAN_TextureData *)SDL_calloc(1, sizeof(*textureData));
|
||||
if (!textureData) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
texture->internal = textureData;
|
||||
if (SDL_COLORSPACETRANSFER(texture->colorspace) == SDL_TRANSFER_CHARACTERISTICS_SRGB) {
|
||||
@@ -2822,7 +2822,7 @@ static VkResult VULKAN_UpdateTextureInternal(VULKAN_RenderData *rendererData, Vk
|
||||
}
|
||||
|
||||
|
||||
static int VULKAN_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
static bool VULKAN_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect, const void *srcPixels,
|
||||
int srcPitch)
|
||||
{
|
||||
@@ -2833,8 +2833,8 @@ static int VULKAN_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
return SDL_SetError("Texture is not currently available");
|
||||
}
|
||||
|
||||
if (VULKAN_UpdateTextureInternal(rendererData, textureData->mainImage.image, textureData->mainImage.format, 0, rect->x, rect->y, rect->w, rect->h, srcPixels, srcPitch, &textureData->mainImage.imageLayout) < 0) {
|
||||
return -1;
|
||||
if (!VULKAN_UpdateTextureInternal(rendererData, textureData->mainImage.image, textureData->mainImage.format, 0, rect->x, rect->y, rect->w, rect->h, srcPixels, srcPitch, &textureData->mainImage.imageLayout)) {
|
||||
return false;
|
||||
}
|
||||
#if SDL_HAVE_YUV
|
||||
Uint32 numPlanes = VULKAN_VkFormatGetNumPlanes(textureData->mainImage.format);
|
||||
@@ -2843,8 +2843,8 @@ static int VULKAN_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
// YUV data
|
||||
if (numPlanes == 3) {
|
||||
for (Uint32 plane = 1; plane < numPlanes; plane++) {
|
||||
if (VULKAN_UpdateTextureInternal(rendererData, textureData->mainImage.image, textureData->mainImage.format, plane, rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2, srcPixels, (srcPitch + 1) / 2, &textureData->mainImage.imageLayout) < 0) {
|
||||
return -1;
|
||||
if (!VULKAN_UpdateTextureInternal(rendererData, textureData->mainImage.image, textureData->mainImage.format, plane, rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2, srcPixels, (srcPitch + 1) / 2, &textureData->mainImage.imageLayout)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Skip to the correct offset into the next texture
|
||||
@@ -2860,16 +2860,16 @@ static int VULKAN_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
srcPitch = (srcPitch + 1) & ~1;
|
||||
}
|
||||
|
||||
if (VULKAN_UpdateTextureInternal(rendererData, textureData->mainImage.image, textureData->mainImage.format, 1, rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2, srcPixels, srcPitch, &textureData->mainImage.imageLayout) < 0) {
|
||||
return -1;
|
||||
if (!VULKAN_UpdateTextureInternal(rendererData, textureData->mainImage.image, textureData->mainImage.format, 1, rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2, srcPixels, srcPitch, &textureData->mainImage.imageLayout)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
#if SDL_HAVE_YUV
|
||||
static int VULKAN_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
static bool VULKAN_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *Uplane, int Upitch,
|
||||
@@ -2882,19 +2882,19 @@ static int VULKAN_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
return SDL_SetError("Texture is not currently available");
|
||||
}
|
||||
|
||||
if (VULKAN_UpdateTextureInternal(rendererData, textureData->mainImage.image, textureData->mainImage.format, 0, rect->x, rect->y, rect->w, rect->h, Yplane, Ypitch, &textureData->mainImage.imageLayout) < 0) {
|
||||
return -1;
|
||||
if (!VULKAN_UpdateTextureInternal(rendererData, textureData->mainImage.image, textureData->mainImage.format, 0, rect->x, rect->y, rect->w, rect->h, Yplane, Ypitch, &textureData->mainImage.imageLayout)) {
|
||||
return false;
|
||||
}
|
||||
if (VULKAN_UpdateTextureInternal(rendererData, textureData->mainImage.image, textureData->mainImage.format, 1, rect->x / 2, rect->y / 2, rect->w / 2, rect->h / 2, Uplane, Upitch, &textureData->mainImage.imageLayout) < 0) {
|
||||
return -1;
|
||||
if (!VULKAN_UpdateTextureInternal(rendererData, textureData->mainImage.image, textureData->mainImage.format, 1, rect->x / 2, rect->y / 2, rect->w / 2, rect->h / 2, Uplane, Upitch, &textureData->mainImage.imageLayout)) {
|
||||
return false;
|
||||
}
|
||||
if (VULKAN_UpdateTextureInternal(rendererData, textureData->mainImage.image, textureData->mainImage.format, 2, rect->x / 2, rect->y / 2, rect->w / 2, rect->h / 2, Vplane, Vpitch, &textureData->mainImage.imageLayout) < 0) {
|
||||
return -1;
|
||||
if (!VULKAN_UpdateTextureInternal(rendererData, textureData->mainImage.image, textureData->mainImage.format, 2, rect->x / 2, rect->y / 2, rect->w / 2, rect->h / 2, Vplane, Vpitch, &textureData->mainImage.imageLayout)) {
|
||||
return false;
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int VULKAN_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
static bool VULKAN_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *UVplane, int UVpitch)
|
||||
@@ -2906,18 +2906,18 @@ static int VULKAN_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
return SDL_SetError("Texture is not currently available");
|
||||
}
|
||||
|
||||
if (VULKAN_UpdateTextureInternal(rendererData, textureData->mainImage.image, textureData->mainImage.format, 0, rect->x, rect->y, rect->w, rect->h, Yplane, Ypitch, &textureData->mainImage.imageLayout) < 0) {
|
||||
return -1;
|
||||
if (!VULKAN_UpdateTextureInternal(rendererData, textureData->mainImage.image, textureData->mainImage.format, 0, rect->x, rect->y, rect->w, rect->h, Yplane, Ypitch, &textureData->mainImage.imageLayout)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (VULKAN_UpdateTextureInternal(rendererData, textureData->mainImage.image, textureData->mainImage.format, 1, rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2, UVplane, UVpitch, &textureData->mainImage.imageLayout) < 0) {
|
||||
return -1;
|
||||
if (!VULKAN_UpdateTextureInternal(rendererData, textureData->mainImage.image, textureData->mainImage.format, 1, rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2, UVplane, UVpitch, &textureData->mainImage.imageLayout)) {
|
||||
return false;
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int VULKAN_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
static bool VULKAN_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect, void **pixels, int *pitch)
|
||||
{
|
||||
VULKAN_RenderData *rendererData = (VULKAN_RenderData *)renderer->internal;
|
||||
@@ -2955,7 +2955,7 @@ static int VULKAN_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
*/
|
||||
*pixels = textureData->stagingBuffer.mappedBufferPtr;
|
||||
*pitch = (int)length;
|
||||
return 0;
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@@ -3023,7 +3023,7 @@ static void VULKAN_SetTextureScaleMode(SDL_Renderer *renderer, SDL_Texture *text
|
||||
textureData->scaleMode = (scaleMode == SDL_SCALEMODE_NEAREST) ? VK_FILTER_NEAREST : VK_FILTER_LINEAR;
|
||||
}
|
||||
|
||||
static int VULKAN_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
static bool VULKAN_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
{
|
||||
VULKAN_RenderData *rendererData = (VULKAN_RenderData *)renderer->internal;
|
||||
VULKAN_TextureData *textureData = NULL;
|
||||
@@ -3043,7 +3043,7 @@ static int VULKAN_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
&rendererData->textureRenderTarget->mainImage.imageLayout);
|
||||
}
|
||||
rendererData->textureRenderTarget = NULL;
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
textureData = (VULKAN_TextureData *)texture->internal;
|
||||
@@ -3062,22 +3062,22 @@ static int VULKAN_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
rendererData->textureRenderTarget->mainImage.image,
|
||||
&rendererData->textureRenderTarget->mainImage.imageLayout);
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int VULKAN_QueueNoOp(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
static bool VULKAN_QueueNoOp(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
{
|
||||
return 0; // nothing to do in this backend.
|
||||
return true; // nothing to do in this backend.
|
||||
}
|
||||
|
||||
static int VULKAN_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count)
|
||||
static bool VULKAN_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count)
|
||||
{
|
||||
VertexPositionColor *verts = (VertexPositionColor *)SDL_AllocateRenderVertices(renderer, count * sizeof(VertexPositionColor), 0, &cmd->data.draw.first);
|
||||
int i;
|
||||
bool convert_color = SDL_RenderingLinearSpace(renderer);
|
||||
|
||||
if (!verts) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
cmd->data.draw.count = count;
|
||||
@@ -3092,10 +3092,10 @@ static int VULKAN_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd
|
||||
}
|
||||
verts++;
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int VULKAN_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
|
||||
static bool VULKAN_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
|
||||
const float *xy, int xy_stride, const SDL_FColor *color, int color_stride, const float *uv, int uv_stride,
|
||||
int num_vertices, const void *indices, int num_indices, int size_indices,
|
||||
float scale_x, float scale_y)
|
||||
@@ -3109,7 +3109,7 @@ static int VULKAN_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
|
||||
float v_scale = textureData ? (float)texture->h / textureData->height : 0.0f;
|
||||
|
||||
if (!verts) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
cmd->data.draw.count = count;
|
||||
@@ -3148,7 +3148,7 @@ static int VULKAN_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
|
||||
|
||||
verts += 1;
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool VULKAN_UpdateVertexBuffer(SDL_Renderer *renderer,
|
||||
@@ -3189,7 +3189,7 @@ static bool VULKAN_UpdateVertexBuffer(SDL_Renderer *renderer,
|
||||
return true;
|
||||
}
|
||||
|
||||
static int VULKAN_UpdateViewport(SDL_Renderer *renderer)
|
||||
static bool VULKAN_UpdateViewport(SDL_Renderer *renderer)
|
||||
{
|
||||
VULKAN_RenderData *rendererData = (VULKAN_RenderData *)renderer->internal;
|
||||
const SDL_Rect *viewport = &rendererData->currentViewport;
|
||||
@@ -3202,7 +3202,7 @@ static int VULKAN_UpdateViewport(SDL_Renderer *renderer)
|
||||
* with a non-empty viewport.
|
||||
*/
|
||||
// SDL_Log("%s, no viewport was set!\n", __FUNCTION__);
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
projection = MatrixIdentity();
|
||||
@@ -3230,10 +3230,10 @@ static int VULKAN_UpdateViewport(SDL_Renderer *renderer)
|
||||
vkCmdSetViewport(rendererData->currentCommandBuffer, 0, 1, &vkViewport);
|
||||
|
||||
rendererData->viewportDirty = false;
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int VULKAN_UpdateClipRect(SDL_Renderer *renderer)
|
||||
static bool VULKAN_UpdateClipRect(SDL_Renderer *renderer)
|
||||
{
|
||||
VULKAN_RenderData *rendererData = (VULKAN_RenderData *)renderer->internal;
|
||||
const SDL_Rect *viewport = &rendererData->currentViewport;
|
||||
@@ -3253,7 +3253,7 @@ static int VULKAN_UpdateClipRect(SDL_Renderer *renderer)
|
||||
vkCmdSetScissor(rendererData->currentCommandBuffer, 0, 1, &scissor);
|
||||
|
||||
rendererData->cliprectDirty = false;
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void VULKAN_SetupShaderConstants(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, const SDL_Texture *texture, PixelShaderConstants *constants)
|
||||
@@ -3535,7 +3535,7 @@ static bool VULKAN_SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand
|
||||
}
|
||||
|
||||
if (rendererData->viewportDirty) {
|
||||
if (VULKAN_UpdateViewport(renderer) == 0) {
|
||||
if (!VULKAN_UpdateViewport(renderer)) {
|
||||
// vertexShaderConstantsData.projectionAndView has changed
|
||||
updateConstants = true;
|
||||
}
|
||||
@@ -3707,7 +3707,7 @@ static void VULKAN_InvalidateCachedState(SDL_Renderer *renderer)
|
||||
rendererData->cliprectDirty = true;
|
||||
}
|
||||
|
||||
static int VULKAN_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize)
|
||||
static bool VULKAN_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize)
|
||||
{
|
||||
VULKAN_RenderData *rendererData = (VULKAN_RenderData *)renderer->internal;
|
||||
VULKAN_DrawStateCache stateCache;
|
||||
@@ -3715,13 +3715,13 @@ static int VULKAN_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd
|
||||
|
||||
if (rendererData->recreateSwapchain) {
|
||||
if (VULKAN_UpdateForWindowSizeChange(renderer) != VK_SUCCESS) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
rendererData->recreateSwapchain = false;
|
||||
}
|
||||
|
||||
if (!VULKAN_UpdateVertexBuffer(renderer, vertices, vertsize, &stateCache)) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
while (cmd) {
|
||||
@@ -3833,7 +3833,7 @@ static int VULKAN_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd
|
||||
|
||||
cmd = cmd->next;
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static SDL_Surface* VULKAN_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect)
|
||||
@@ -3932,7 +3932,7 @@ static SDL_Surface* VULKAN_RenderReadPixels(SDL_Renderer *renderer, const SDL_Re
|
||||
return output;
|
||||
}
|
||||
|
||||
static int VULKAN_AddVulkanRenderSemaphores(SDL_Renderer *renderer, Uint32 wait_stage_mask, Sint64 wait_semaphore, Sint64 signal_semaphore)
|
||||
static bool VULKAN_AddVulkanRenderSemaphores(SDL_Renderer *renderer, Uint32 wait_stage_mask, Sint64 wait_semaphore, Sint64 signal_semaphore)
|
||||
{
|
||||
VULKAN_RenderData *rendererData = (VULKAN_RenderData *)renderer->internal;
|
||||
|
||||
@@ -3941,13 +3941,13 @@ static int VULKAN_AddVulkanRenderSemaphores(SDL_Renderer *renderer, Uint32 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;
|
||||
return false;
|
||||
}
|
||||
rendererData->waitDestStageMasks = waitDestStageMasks;
|
||||
|
||||
VkSemaphore *semaphores = (VkSemaphore *)SDL_realloc(rendererData->waitRenderSemaphores, (rendererData->waitRenderSemaphoreMax + 2) * sizeof(*semaphores));
|
||||
if (!semaphores) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
rendererData->waitRenderSemaphores = semaphores;
|
||||
++rendererData->waitRenderSemaphoreMax;
|
||||
@@ -3962,7 +3962,7 @@ static int VULKAN_AddVulkanRenderSemaphores(SDL_Renderer *renderer, Uint32 wait_
|
||||
// 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;
|
||||
return false;
|
||||
}
|
||||
rendererData->signalRenderSemaphores = semaphores;
|
||||
++rendererData->signalRenderSemaphoreMax;
|
||||
@@ -3971,10 +3971,10 @@ static int VULKAN_AddVulkanRenderSemaphores(SDL_Renderer *renderer, Uint32 wait_
|
||||
++rendererData->signalRenderSemaphoreCount;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int VULKAN_RenderPresent(SDL_Renderer *renderer)
|
||||
static bool VULKAN_RenderPresent(SDL_Renderer *renderer)
|
||||
{
|
||||
VULKAN_RenderData *rendererData = (VULKAN_RenderData *)renderer->internal;
|
||||
VkResult result = VK_SUCCESS;
|
||||
@@ -3997,7 +3997,7 @@ static int VULKAN_RenderPresent(SDL_Renderer *renderer)
|
||||
result = vkResetFences(rendererData->device, 1, &rendererData->fences[rendererData->currentCommandBufferIndex]);
|
||||
if (result != VK_SUCCESS) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_RENDER, "vkResetFences(): %s\n", SDL_Vulkan_GetResultString(result));
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
VkPipelineStageFlags waitDestStageMask = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
|
||||
@@ -4032,7 +4032,7 @@ static int VULKAN_RenderPresent(SDL_Renderer *renderer)
|
||||
result = vkQueueSubmit(rendererData->graphicsQueue, 1, &submitInfo, rendererData->fences[rendererData->currentCommandBufferIndex]);
|
||||
if (result != VK_SUCCESS) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_RENDER, "vkQueueSubmit(): %s\n", SDL_Vulkan_GetResultString(result));
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
rendererData->currentCommandBuffer = VK_NULL_HANDLE;
|
||||
rendererData->currentImageAvailableSemaphore = VK_NULL_HANDLE;
|
||||
@@ -4048,7 +4048,7 @@ static int VULKAN_RenderPresent(SDL_Renderer *renderer)
|
||||
result = vkQueuePresentKHR(rendererData->presentQueue, &presentInfo);
|
||||
if ((result != VK_SUCCESS) && (result != VK_ERROR_OUT_OF_DATE_KHR) && (result != VK_ERROR_SURFACE_LOST_KHR) && (result != VK_SUBOPTIMAL_KHR )) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_RENDER, "vkQueuePresentKHR(): %s\n", SDL_Vulkan_GetResultString(result));
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
rendererData->currentCommandBufferIndex = ( rendererData->currentCommandBufferIndex + 1 ) % rendererData->swapchainImageCount;
|
||||
@@ -4057,16 +4057,16 @@ static int VULKAN_RenderPresent(SDL_Renderer *renderer)
|
||||
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));
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
VULKAN_AcquireNextSwapchainImage(renderer);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int VULKAN_SetVSync(SDL_Renderer *renderer, const int vsync)
|
||||
static bool VULKAN_SetVSync(SDL_Renderer *renderer, const int vsync)
|
||||
{
|
||||
VULKAN_RenderData *rendererData = (VULKAN_RenderData *)renderer->internal;
|
||||
|
||||
@@ -4083,10 +4083,10 @@ static int VULKAN_SetVSync(SDL_Renderer *renderer, const int vsync)
|
||||
rendererData->vsync = vsync;
|
||||
rendererData->recreateSwapchain = true;
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int VULKAN_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_PropertiesID create_props)
|
||||
static bool VULKAN_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_PropertiesID create_props)
|
||||
{
|
||||
VULKAN_RenderData *rendererData;
|
||||
|
||||
@@ -4100,7 +4100,7 @@ static int VULKAN_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL
|
||||
|
||||
rendererData = (VULKAN_RenderData *)SDL_calloc(1, sizeof(*rendererData));
|
||||
if (!rendererData) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
rendererData->identity = MatrixIdentity();
|
||||
@@ -4151,9 +4151,9 @@ static int VULKAN_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL
|
||||
|
||||
// Initialize Vulkan resources
|
||||
if (VULKAN_CreateDeviceResources(renderer, create_props) != VK_SUCCESS) {
|
||||
return -1;
|
||||
return false;
|
||||
} else if (VULKAN_CreateWindowSizeDependentResources(renderer) != VK_SUCCESS) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
#if SDL_HAVE_YUV
|
||||
@@ -4166,7 +4166,7 @@ static int VULKAN_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
SDL_RenderDriver VULKAN_RenderDriver = {
|
||||
|
||||
Reference in New Issue
Block a user