mirror of
https://github.com/yawut/SDL.git
synced 2026-07-09 05:05:26 -05:00
wiiu: Add more renderer function, make functions non-static, start adding new shaders
This commit is contained in:
parent
d120ddd096
commit
a1fe555cad
|
|
@ -23,7 +23,8 @@
|
|||
|
||||
#if SDL_VIDEO_RENDER_WIIU
|
||||
|
||||
#include "../../video/wiiu/wiiuvideo.h"
|
||||
#include "../../video/wiiu/SDL_wiiuvideo.h"
|
||||
#include "../../video/wiiu/wiiu_shaders.h"
|
||||
#include "../SDL_sysrender.h"
|
||||
#include "SDL_hints.h"
|
||||
#include "SDL_render_wiiu.h"
|
||||
|
|
@ -34,41 +35,37 @@
|
|||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
static int
|
||||
WIIU_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * srcrect, const SDL_FRect * dstrect)
|
||||
int WIIU_SDL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * srcrect, const SDL_FRect * dstrect)
|
||||
{
|
||||
WIIU_RenderData *data = (WIIU_RenderData *) renderer->driverdata;
|
||||
GX2Texture *wiiu_tex = (GX2Texture*) texture->driverdata;
|
||||
|
||||
//TODO: Move texCoord/pos math to shader / GX2SetViewport
|
||||
float transform_x, transform_y;
|
||||
if (renderer->viewport.x || renderer->viewport.y) {
|
||||
transform_x = (((renderer->viewport.x + dstrect->x) / (float)data->cbuf.surface.width) * 2.0f)-1.0f;
|
||||
transform_y = (((renderer->viewport.y + dstrect->y) / (float)data->cbuf.surface.height) * 2.0f)-1.0f;
|
||||
} else {
|
||||
transform_x = ((dstrect->x / (float)data->cbuf.surface.width) * 2.0f)-1.0f;
|
||||
transform_y = ((dstrect->y / (float)data->cbuf.surface.height) * 2.0f)-1.0f;
|
||||
}
|
||||
float transform_width = (dstrect->w / (float)data->cbuf.surface.width) * 2.0f;
|
||||
float transform_height = (dstrect->h / (float)data->cbuf.surface.height) * 2.0f;
|
||||
float swidth = data->cbuf.surface.width;
|
||||
float sheight = data->cbuf.surface.height;
|
||||
|
||||
float aPosition[] =
|
||||
//TODO: Move texCoord/pos math to shader / GX2SetViewport
|
||||
float tr_x = (((renderer->viewport.x + dstrect->x) / swidth)*2.0f)-1.0f;
|
||||
float tr_y = (((renderer->viewport.y + dstrect->y) / sheight)*2.0f)-1.0f;
|
||||
float tr_w = (dstrect->w / swidth) * 2.0f;
|
||||
float tr_h = (dstrect->h / sheight) * 2.0f;
|
||||
|
||||
float vb[] =
|
||||
{
|
||||
transform_x, transform_y, 0.0f,
|
||||
transform_x + transform_width, transform_y, 0.0f,
|
||||
transform_x + transform_width, transform_y + transform_height, 0.0f,
|
||||
transform_x, transform_y + transform_height, 0.0f,
|
||||
tr_x, tr_y,
|
||||
tr_x + tr_w, tr_y,
|
||||
tr_x + tr_w, tr_y + tr_h,
|
||||
tr_x, tr_y + tr_h,
|
||||
};
|
||||
|
||||
GX2RLockBufferEx(&data->texPositionBuffer, 0);
|
||||
memcpy(data->texPositionBuffer.buffer, aPosition, data->texPositionBuffer.elemCount * data->texPositionBuffer.elemSize);
|
||||
memcpy(data->texPositionBuffer.buffer, vb, data->texPositionBuffer.elemCount * data->texPositionBuffer.elemSize);
|
||||
GX2RUnlockBufferEx(&data->texPositionBuffer, 0);
|
||||
|
||||
float tex_x_min = (float)srcrect->x / (float)wiiu_tex->surface.width;
|
||||
float tex_x_max = (float)(srcrect->x + srcrect->w) / (float)wiiu_tex->surface.width;
|
||||
float tex_y_min = (float)srcrect->y / (float)wiiu_tex->surface.height;
|
||||
float tex_y_max = (float)(srcrect->y + srcrect->h) / (float)wiiu_tex->surface.height;
|
||||
float tex_x_min = (float)srcrect->x / swidth;
|
||||
float tex_x_max = (float)(srcrect->x + srcrect->w) / swidth;
|
||||
float tex_y_min = (float)srcrect->y / sheight;
|
||||
float tex_y_max = (float)(srcrect->y + srcrect->h) / sheight;
|
||||
|
||||
float aTexCoord[] =
|
||||
{
|
||||
|
|
@ -84,10 +81,7 @@ WIIU_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
|
|||
|
||||
//RENDER
|
||||
GX2SetContextState(&data->ctx);
|
||||
|
||||
GX2SetFetchShader(&texShaders.fetchShader);
|
||||
GX2SetVertexShader(texShaders.vertexShader);
|
||||
GX2SetPixelShader(texShaders.pixelShader);
|
||||
wiiuSetTextureShader();
|
||||
|
||||
GX2SetPixelTexture(texture, 0);
|
||||
GX2SetPixelSampler(sampler, 0);
|
||||
|
|
@ -99,24 +93,164 @@ WIIU_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
|
|||
GX2DrawEx(GX2_PRIMITIVE_MODE_QUADS, 4, 0, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
WIIU_RenderPresent(SDL_Renderer * renderer)
|
||||
int WIIU_SDL_RenderDrawPoints(SDL_Renderer * renderer, const SDL_FPoint * points,
|
||||
int count)
|
||||
{
|
||||
WIIU_RenderData *data = (WIIU_RenderData *) renderer->driverdata;
|
||||
WIIU_RenderAllocData *rdata = SDL_malloc(sizeof(WIIU_RenderAllocData) + sizeof(float) * 2 * count);
|
||||
if (!rdata) return SDL_OutOfMemory();
|
||||
float *vb = rdata->ptr;
|
||||
|
||||
/* Compute vertex pos */
|
||||
float swidth = data->cbuf.surface.width;
|
||||
float sheight = data->cbuf.surface.height;
|
||||
float vx = (float)renderer->viewport.x;
|
||||
float vy = (float)renderer->viewport.y;
|
||||
|
||||
for (int i = 0; i < count; ++i) {
|
||||
vb[i*2+0] = (((vx + points[i].x) / swidth) * 2.0f)-1.0f;
|
||||
vb[i*2+1] = (((vy + points[i].y) / sheight) * 2.0f)-1.0f;
|
||||
}
|
||||
|
||||
/* Render points */
|
||||
float u_color[4] = {(float)renderer->r / 255.0f,
|
||||
(float)renderer->g / 255.0f,
|
||||
(float)renderer->b / 255.0f,
|
||||
(float)renderer->a / 255.0f};
|
||||
|
||||
GX2SetContextState(&data->ctx);
|
||||
wiiuSetColorShader();
|
||||
|
||||
GX2SetAttribBuffer(0, sizeof(float) * 2 * count, sizeof(float) * 2, vb);
|
||||
GX2SetPixelUniformReg(wiiuColorShader->pixelShader->uniformVars[0].offset, 4, (uint32_t*)u_color);
|
||||
|
||||
GX2DrawEx(GX2_PRIMITIVE_MODE_POINTS, count, 0, 1);
|
||||
|
||||
/* vertex buffer can't be free'd until rendering is finished */
|
||||
rdata->next = data->listfree;
|
||||
data->listfree = rdata;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int WIIU_SDL_RenderDrawLines(SDL_Renderer * renderer, const SDL_FPoint * points,
|
||||
int count)
|
||||
{
|
||||
WIIU_RenderData *data = (WIIU_RenderData *) renderer->driverdata;
|
||||
WIIU_RenderAllocData *rdata = SDL_malloc(sizeof(WIIU_RenderAllocData) + sizeof(float) * 2 * count);
|
||||
if (!rdata) return SDL_OutOfMemory();
|
||||
float *vb = rdata->ptr;
|
||||
|
||||
/* Compute vertex pos */
|
||||
float swidth = data->cbuf.surface.width;
|
||||
float sheight = data->cbuf.surface.height;
|
||||
float vx = (float)renderer->viewport.x;
|
||||
float vy = (float)renderer->viewport.y;
|
||||
|
||||
for (int i = 0; i < count; ++i) {
|
||||
vb[i*2+0] = (((vx + points[i].x) / swidth) * 2.0f) - 1.0f;
|
||||
vb[i*2+1] = (((vy + points[i].y) / sheight) * 2.0f) - 1.0f;
|
||||
}
|
||||
|
||||
/* Render lines */
|
||||
float u_color[4] = {(float)renderer->r / 255.0f,
|
||||
(float)renderer->g / 255.0f,
|
||||
(float)renderer->b / 255.0f,
|
||||
(float)renderer->a / 255.0f};
|
||||
|
||||
GX2SetContextState(&data->ctx);
|
||||
wiiuSetColorShader();
|
||||
|
||||
GX2SetAttribBuffer(0, sizeof(float) * 2 * count, sizeof(float) * 2, vb);
|
||||
GX2SetPixelUniformReg(wiiuColorShader->pixelShader->uniformVars[0].offset, 4, (uint32_t*)u_color);
|
||||
|
||||
GX2DrawEx(GX2_PRIMITIVE_MODE_LINE_STRIP, count, 0, 1);
|
||||
|
||||
/* vertex buffer can't be free'd until rendering is finished */
|
||||
rdata->next = data->listfree;
|
||||
data->listfree = rdata;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int WIIU_SDL_RenderFillRects(SDL_Renderer * renderer, const SDL_FRect * rects, int count)
|
||||
{
|
||||
WIIU_RenderData *data = (WIIU_RenderData *) renderer->driverdata;
|
||||
WIIU_RenderAllocData *rdata = SDL_malloc(sizeof(WIIU_RenderAllocData) + sizeof(float) * 2 * 4 * count);
|
||||
if (!rdata) return SDL_OutOfMemory();
|
||||
float *vb = rdata->ptr;
|
||||
|
||||
/* Compute vertex pos */
|
||||
float swidth = data->cbuf.surface.width;
|
||||
float sheight = data->cbuf.surface.height;
|
||||
float vx = (float)renderer->viewport.x;
|
||||
float vy = (float)renderer->viewport.y;
|
||||
|
||||
for (int i = 0; i < count; ++i) {
|
||||
float tr_x = (((vx + rects[i].x) / swidth) * 2.0f) - 1.0f;
|
||||
float tr_y = (((vy + rects[i].y) / sheight) * 2.0f) - 1.0f;
|
||||
float tr_w = (rects[i].w / swidth) * 2.0f;
|
||||
float tr_h = (rects[i].h / sheight) * 2.0f;
|
||||
vb[i*8+0] = tr_x;
|
||||
vb[i*8+1] = tr_y;
|
||||
vb[i*8+2] = tr_x + tr_w;
|
||||
vb[i*8+3] = tr_y;
|
||||
vb[i*8+4] = tr_x + tr_w;
|
||||
vb[i*8+5] = tr_y + tr_h;
|
||||
vb[i*8+6] = tr_x;
|
||||
vb[i*8+7] = tr_y + tr_h;
|
||||
}
|
||||
|
||||
/* Render rects */
|
||||
float u_color[4] = {(float)renderer->r / 255.0f,
|
||||
(float)renderer->g / 255.0f,
|
||||
(float)renderer->b / 255.0f,
|
||||
(float)renderer->a / 255.0f};
|
||||
|
||||
GX2SetContextState(&data->ctx);
|
||||
wiiuSetColorShader();
|
||||
|
||||
GX2SetAttribBuffer(0, sizeof(float) * 2 * 4 * count, sizeof(float) * 2, vb);
|
||||
GX2SetPixelUniformReg(wiiuColorShader->pixelShader->uniformVars[0].offset, 4, (uint32_t*)u_color);
|
||||
|
||||
GX2DrawEx(GX2_PRIMITIVE_MODE_QUADS, 4 * count, 0, 1);
|
||||
|
||||
/* vertex buffer can't be free'd until rendering is finished */
|
||||
rdata->next = data->listfree;
|
||||
data->listfree = rdata;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void WIIU_SDL_RenderPresent(SDL_Renderer * renderer)
|
||||
{
|
||||
WIIU_RenderData *data = (WIIU_RenderData *) renderer->driverdata;
|
||||
SDL_Window *window = renderer->window;
|
||||
|
||||
GX2Invalidate(GX2_INVALIDATE_MODE_CPU | GX2_INVALIDATE_MODE_TEXTURE, data->cbuf.surface.image, data->cbuf.surface.imageSize);
|
||||
GX2Flush();
|
||||
GX2DrawDone();
|
||||
GX2Invalidate(GX2_INVALIDATE_MODE_CPU_TEXTURE, data->cbuf.surface.image, data->cbuf.surface.imageSize);
|
||||
|
||||
if (window) {
|
||||
SDL_UpdateWindowSurface(window);
|
||||
}
|
||||
|
||||
while (data->listfree) {
|
||||
void *ptr = data->listfree;
|
||||
data->listfree = data->listfree->next;
|
||||
SDL_free(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
WIIU_RenderClear(SDL_Renderer * renderer)
|
||||
int WIIU_SDL_RenderClear(SDL_Renderer * renderer)
|
||||
{
|
||||
WIIU_RenderData *data = (WIIU_RenderData *) renderer->driverdata;
|
||||
GX2ClearColor(&data->cbuf, renderer->r, renderer->g, renderer->b, renderer->a);
|
||||
GX2ClearColor(&data->cbuf,
|
||||
(float)renderer->r / 255.0f,
|
||||
(float)renderer->g / 255.0f,
|
||||
(float)renderer->b / 255.0f,
|
||||
(float)renderer->a / 255.0f);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,19 +36,12 @@
|
|||
|
||||
/* SDL surface based renderer implementation */
|
||||
|
||||
SDL_Renderer *
|
||||
WIIU_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||
SDL_Renderer *WIIU_SDL_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||
{
|
||||
SDL_Surface *surface
|
||||
SDL_Renderer *renderer;
|
||||
WIIU_RenderData *data;
|
||||
|
||||
surface = SDL_GetWindowSurface(window);
|
||||
if (!surface) {
|
||||
SDL_SetError("Can't create renderer for NULL surface");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
|
||||
if (!renderer) {
|
||||
SDL_OutOfMemory();
|
||||
|
|
@ -90,35 +83,31 @@ WIIU_CreateRenderer(SDL_Window * window, Uint32 flags)
|
|||
renderer->driverdata = data;
|
||||
renderer->window = window;
|
||||
|
||||
// Prepare shaders
|
||||
wiiuInitTextureShader();
|
||||
wiiuInitColorShader();
|
||||
|
||||
// List of attibutes to free after render
|
||||
data->listfree = NULL;
|
||||
|
||||
// Setup texture shader attribute buffers
|
||||
data->texPositionBuffer.flags =
|
||||
data->texCoordBuffer.flags =
|
||||
data->texColourBuffer.flags =
|
||||
GX2R_RESOURCE_BIND_VERTEX_BUFFER |
|
||||
GX2R_RESOURCE_USAGE_CPU_READ |
|
||||
GX2R_RESOURCE_USAGE_CPU_WRITE |
|
||||
GX2R_RESOURCE_USAGE_GPU_READ;
|
||||
data->texPositionBuffer.elemSize = sizeof(float) * 3;
|
||||
data->texPositionBuffer.elemSize = sizeof(float) * 2;
|
||||
data->texCoordBuffer.elemSize = sizeof(float) * 2;
|
||||
data->texColourBuffer.elemSize = sizeof(float) * 4;
|
||||
data->texPositionBuffer.elemCount =
|
||||
data->texCoordBuffer.elemCount =
|
||||
data->texColourBuffer.elemCount = 4;
|
||||
data->texCoordBuffer.elemCount = 4;
|
||||
|
||||
GX2RCreateBuffer(&data->texPositionBuffer);
|
||||
GX2RCreateBuffer(&data->texCoordBuffer);
|
||||
GX2RCreateBuffer(&data->texColourBuffer);
|
||||
|
||||
// Prepare texture color buffer data (it's costant between textures)
|
||||
float aColourDefault[] = {
|
||||
1.0f, 1.0f, 1.0f, 1.0f,
|
||||
1.0f, 1.0f, 1.0f, 1.0f,
|
||||
1.0f, 1.0f, 1.0f, 1.0f,
|
||||
1.0f, 1.0f, 1.0f, 1.0f,
|
||||
};
|
||||
GX2RLockBufferEx(&data->texColourBuffer, 0);
|
||||
memcpy(data->texColourBuffer.buffer, aColourDefault, data->texColourBuffer.elemCount * data->texColourBuffer.elemSize);
|
||||
GX2RUnlockBufferEx(&data->texColourBuffer, 0);
|
||||
// Setup line and point size
|
||||
GX2SetLineWidth(1.0f);
|
||||
GX2SetPointSize(1.0f, 1.0f);
|
||||
|
||||
// Setup sampler
|
||||
GX2InitSampler(&data->sampler, GX2_TEX_CLAMP_MODE_CLAMP, GX2_TEX_XY_FILTER_MODE_LINEAR);
|
||||
|
|
@ -132,8 +121,7 @@ WIIU_CreateRenderer(SDL_Window * window, Uint32 flags)
|
|||
return renderer;
|
||||
}
|
||||
|
||||
static int
|
||||
WIIU_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
int WIIU_SDL_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
{
|
||||
WIIU_RenderData *data = (WIIU_RenderData *) renderer->driverdata;
|
||||
|
||||
|
|
@ -168,6 +156,50 @@ WIIU_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void WIIU_SDL_DestroyRenderer(SDL_Renderer * renderer)
|
||||
{
|
||||
WIIU_RenderData *data = (WIIU_RenderData *) renderer->driverdata;
|
||||
|
||||
while (data->listfree) {
|
||||
void *ptr = data->listfree;
|
||||
data->listfree = data->listfree->next;
|
||||
SDL_free(ptr);
|
||||
}
|
||||
|
||||
wiiuFreeColorShader();
|
||||
wiiuFreeTextureShader();
|
||||
|
||||
SDL_free(data);
|
||||
SDL_free(renderer);
|
||||
}
|
||||
|
||||
int WIIU_SDL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
||||
Uint32 format, void * pixels, int pitch)
|
||||
{
|
||||
WIIU_RenderData *data = (WIIU_RenderData *) renderer->driverdata;
|
||||
Uint32 src_format;
|
||||
void *src_pixels;
|
||||
|
||||
/* NOTE: The rect is already adjusted according to the viewport by
|
||||
* SDL_RenderReadPixels.
|
||||
*/
|
||||
|
||||
if (rect->x < 0 || rect->x+rect->w > data->cbuf.surface.width ||
|
||||
rect->y < 0 || rect->y+rect->h > data->cbuf.surface.height) {
|
||||
return SDL_SetError("Tried to read outside of surface bounds");
|
||||
}
|
||||
|
||||
src_format = SDL_PIXELFORMAT_RGBA8888; // TODO once working: other formats/checks
|
||||
src_pixels = (void*)((Uint8 *) surface->pixels +
|
||||
rect->y * data->cbuf.surface.pitch +
|
||||
rect->x * 4);
|
||||
|
||||
return SDL_ConvertPixels(rect->w, rect->h,
|
||||
src_format, src_pixels, data->cbuf.surface.pitch,
|
||||
format, pixels, pitch);
|
||||
}
|
||||
|
||||
|
||||
SDL_RenderDriver WIIU_RenderDriver = {
|
||||
.CreateRenderer = WIIU_CreateRenderer,
|
||||
.info = {
|
||||
|
|
|
|||
|
|
@ -27,10 +27,11 @@
|
|||
|
||||
#include "../SDL_sysrender.h"
|
||||
|
||||
//Utility/helper functions
|
||||
static Uint32 PixelFormatByteSizeWIIU(Uint32 format);
|
||||
static GX2SurfaceFormat PixelFormatToWIIUFMT(Uint32 format);
|
||||
static Uint32 TextureNextPow2(Uint32 w);
|
||||
typedef struct
|
||||
{
|
||||
void *next;
|
||||
int ptr[];
|
||||
} WIIU_RenderAllocData;
|
||||
|
||||
//Driver internal data structures
|
||||
typedef struct
|
||||
|
|
@ -41,47 +42,92 @@ typedef struct
|
|||
GX2RBuffer texPositionBuffer;
|
||||
GX2RBuffer texCoordBuffer;
|
||||
GX2RBuffer texColourBuffer;
|
||||
WIIU_RenderAllocData *listfree;
|
||||
} WIIU_RenderData;
|
||||
|
||||
//SDL_render API implementation
|
||||
static SDL_Renderer *WIIU_CreateRenderer(SDL_Window * window, Uint32 flags);
|
||||
static void WIIU_WindowEvent(SDL_Renderer * renderer,
|
||||
SDL_Renderer *WIIU_SDL_CreateRenderer(SDL_Window * window, Uint32 flags);
|
||||
void WIIU_SDL_WindowEvent(SDL_Renderer * renderer,
|
||||
const SDL_WindowEvent *event);
|
||||
static int WIIU_GetOutputSize(SDL_Renderer * renderer, int *w, int *h);
|
||||
static int WIIU_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture);
|
||||
int WIIU_SDL_GetOutputSize(SDL_Renderer * renderer, int *w, int *h);
|
||||
int WIIU_SDL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture);
|
||||
// SDL changes colour/alpha/blend values internally, this is just to notify us.
|
||||
// We don't care yet. TODO: could update GX2RBuffers less frequently with these?
|
||||
/*static int WIIU_SetTextureColorMod(SDL_Renderer * renderer,
|
||||
SDL_Texture * texture);
|
||||
static int WIIU_SetTextureAlphaMod(SDL_Renderer * renderer,
|
||||
SDL_Texture * texture);
|
||||
static int WIIU_SetTextureBlendMode(SDL_Renderer * renderer,
|
||||
SDL_Texture * texture);*/
|
||||
static int WIIU_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect, const void *pixels,
|
||||
int pitch);
|
||||
static int WIIU_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect, void **pixels, int *pitch);
|
||||
static void WIIU_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
|
||||
static int WIIU_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture);
|
||||
static int WIIU_UpdateViewport(SDL_Renderer * renderer);
|
||||
static int WIIU_UpdateClipRect(SDL_Renderer * renderer);
|
||||
static int WIIU_RenderClear(SDL_Renderer * renderer);
|
||||
static int WIIU_RenderDrawPoints(SDL_Renderer * renderer,
|
||||
const SDL_FPoint * points, int count);
|
||||
static int WIIU_RenderDrawLines(SDL_Renderer * renderer,
|
||||
const SDL_FPoint * points, int count);
|
||||
static int WIIU_RenderFillRects(SDL_Renderer * renderer,
|
||||
const SDL_FRect * rects, int count);
|
||||
static int WIIU_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * srcrect, const SDL_FRect * dstrect);
|
||||
static int WIIU_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * srcrect, const SDL_FRect * dstrect,
|
||||
const double angle, const SDL_FPoint * center, const SDL_RendererFlip flip);
|
||||
static int WIIU_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
||||
Uint32 format, void * pixels, int pitch);
|
||||
static void WIIU_RenderPresent(SDL_Renderer * renderer);
|
||||
static void WIIU_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture);
|
||||
static void WIIU_DestroyRenderer(SDL_Renderer * renderer);
|
||||
/*int WIIU_SDL_SetTextureColorMod(SDL_Renderer * renderer,
|
||||
SDL_Texture * texture);
|
||||
int WIIU_SDL_SetTextureAlphaMod(SDL_Renderer * renderer,
|
||||
SDL_Texture * texture);
|
||||
int WIIU_SDL_SetTextureBlendMode(SDL_Renderer * renderer,
|
||||
SDL_Texture * texture);*/
|
||||
int WIIU_SDL_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect, const void *pixels,
|
||||
int pitch);
|
||||
int WIIU_SDL_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect, void **pixels, int *pitch);
|
||||
void WIIU_SDL_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
|
||||
int WIIU_SDL_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture);
|
||||
int WIIU_SDL_UpdateViewport(SDL_Renderer * renderer);
|
||||
int WIIU_SDL_UpdateClipRect(SDL_Renderer * renderer);
|
||||
int WIIU_SDL_RenderClear(SDL_Renderer * renderer);
|
||||
int WIIU_SDL_RenderDrawPoints(SDL_Renderer * renderer,
|
||||
const SDL_FPoint * points, int count);
|
||||
int WIIU_SDL_RenderDrawLines(SDL_Renderer * renderer,
|
||||
const SDL_FPoint * points, int count);
|
||||
int WIIU_SDL_RenderFillRects(SDL_Renderer * renderer,
|
||||
const SDL_FRect * rects, int count);
|
||||
int WIIU_SDL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * srcrect, const SDL_FRect * dstrect);
|
||||
int WIIU_SDL_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * srcrect, const SDL_FRect * dstrect,
|
||||
const double angle, const SDL_FPoint * center, const SDL_RendererFlip flip);
|
||||
int WIIU_SDL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
||||
Uint32 format, void * pixels, int pitch);
|
||||
void WIIU_SDL_RenderPresent(SDL_Renderer * renderer);
|
||||
void WIIU_SDL_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture);
|
||||
void WIIU_SDL_DestroyRenderer(SDL_Renderer * renderer);
|
||||
|
||||
//Utility/helper functions
|
||||
static inline Uint32 TextureNextPow2(Uint32 w) {
|
||||
if(w == 0)
|
||||
return 0;
|
||||
Uint32 n = 2;
|
||||
while(w > n)
|
||||
n <<= 1;
|
||||
return n;
|
||||
}
|
||||
|
||||
static inline Uint32 PixelFormatByteSizeWIIU(Uint32 format) {
|
||||
switch (format) {
|
||||
case SDL_PIXELFORMAT_RGBA4444:
|
||||
case SDL_PIXELFORMAT_ABGR1555:
|
||||
case SDL_PIXELFORMAT_RGBA5551:
|
||||
case SDL_PIXELFORMAT_RGB565:
|
||||
return 2;
|
||||
case SDL_PIXELFORMAT_RGBA8888:
|
||||
default:
|
||||
return 4;
|
||||
}
|
||||
return 4;
|
||||
}
|
||||
|
||||
//TODO: This could return a compMap to support stuff like ARGB or ABGR
|
||||
static inline GX2SurfaceFormat PixelFormatToWIIUFMT(Uint32 format) {
|
||||
switch (format) {
|
||||
case SDL_PIXELFORMAT_RGBA8888:
|
||||
return GX2_SURFACE_FORMAT_UNORM_R8_G8_B8_A8;
|
||||
case SDL_PIXELFORMAT_RGBA4444:
|
||||
return GX2_SURFACE_FORMAT_UNORM_R4_G4_B4_A4;
|
||||
case SDL_PIXELFORMAT_ABGR1555:
|
||||
return GX2_SURFACE_FORMAT_UNORM_A1_B5_G5_R5;
|
||||
case SDL_PIXELFORMAT_RGBA5551:
|
||||
return GX2_SURFACE_FORMAT_UNORM_R5_G5_B5_A1;
|
||||
case SDL_PIXELFORMAT_RGB565:
|
||||
return GX2_SURFACE_FORMAT_UNORM_R5_G6_B5;
|
||||
default:
|
||||
return GX2_SURFACE_FORMAT_UNORM_R8_G8_B8_A8;
|
||||
}
|
||||
return GX2_SURFACE_FORMAT_UNORM_R8_G8_B8_A8;
|
||||
}
|
||||
|
||||
|
||||
#endif //SDL_render_wiiu_h
|
||||
|
|
|
|||
|
|
@ -34,8 +34,7 @@
|
|||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
static int
|
||||
WIIU_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
int WIIU_SDL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
{
|
||||
GX2Texture *wiiu_tex = (GX2Texture*) SDL_calloc(1, sizeof(*wiiu_tex));
|
||||
if (!wiiu_tex)
|
||||
|
|
@ -68,8 +67,8 @@ WIIU_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
|||
// Somewhat adapted from SDL_render.c: SDL_LockTextureNative
|
||||
// The app basically wants a pointer to a particular rectangle as well as
|
||||
// write access to it. We can do that without any special graphics code
|
||||
static int WIIU_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect, void **pixels, int *pitch)
|
||||
int WIIU_SDL_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect, void **pixels, int *pitch)
|
||||
{
|
||||
GX2Texture *wiiu_tex = (GX2Texture *) texture->driverdata;
|
||||
|
||||
|
|
@ -84,7 +83,7 @@ static int WIIU_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void WIIU_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
void WIIU_SDL_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
{
|
||||
GX2Texture *wiiu_tex = (GX2Texture *) texture->driverdata;
|
||||
// TODO check this is actually needed
|
||||
|
|
@ -92,9 +91,8 @@ static void WIIU_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
|||
wiiu_tex->surface.image, wiiu_tex->surface.imageSize);
|
||||
}
|
||||
|
||||
static int
|
||||
WIIU_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect, const void *pixels, int pitch)
|
||||
int WIIU_SDL_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect, const void *pixels, int pitch)
|
||||
{
|
||||
GX2Texture *wiiu_tex = (GX2Texture *) texture->driverdata;
|
||||
Uint32 BytesPerPixel;
|
||||
|
|
@ -118,52 +116,10 @@ WIIU_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static Uint32
|
||||
TextureNextPow2(Uint32 w)
|
||||
void WIIU_SDL_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
{
|
||||
if(w == 0)
|
||||
return 0;
|
||||
Uint32 n = 2;
|
||||
while(w > n)
|
||||
n <<= 1;
|
||||
return n;
|
||||
}
|
||||
|
||||
static Uint32
|
||||
PixelFormatByteSizeWIIU(Uint32 format)
|
||||
{
|
||||
switch (format) {
|
||||
case SDL_PIXELFORMAT_RGBA4444:
|
||||
case SDL_PIXELFORMAT_ABGR1555:
|
||||
case SDL_PIXELFORMAT_RGBA5551:
|
||||
case SDL_PIXELFORMAT_RGB565:
|
||||
return 2;
|
||||
case SDL_PIXELFORMAT_RGBA8888:
|
||||
default:
|
||||
return 4;
|
||||
}
|
||||
return 4;
|
||||
}
|
||||
|
||||
//TODO: This could return a compMap to support stuff like ARGB or ABGR
|
||||
static GX2SurfaceFormat
|
||||
PixelFormatToWIIUFMT(Uint32 format)
|
||||
{
|
||||
switch (format) {
|
||||
case SDL_PIXELFORMAT_RGBA8888:
|
||||
return GX2_SURFACE_FORMAT_UNORM_R8_G8_B8_A8;
|
||||
case SDL_PIXELFORMAT_RGBA4444:
|
||||
return GX2_SURFACE_FORMAT_UNORM_R4_G4_B4_A4;
|
||||
case SDL_PIXELFORMAT_ABGR1555:
|
||||
return GX2_SURFACE_FORMAT_UNORM_A1_B5_G5_R5;
|
||||
case SDL_PIXELFORMAT_RGBA5551:
|
||||
return GX2_SURFACE_FORMAT_UNORM_R5_G5_B5_A1;
|
||||
case SDL_PIXELFORMAT_RGB565:
|
||||
return GX2_SURFACE_FORMAT_UNORM_R5_G6_B5;
|
||||
default:
|
||||
return GX2_SURFACE_FORMAT_UNORM_R8_G8_B8_A8;
|
||||
}
|
||||
return GX2_SURFACE_FORMAT_UNORM_R8_G8_B8_A8;
|
||||
GX2Texture *wiiu_tex = (GX2Texture *) texture->driverdata;
|
||||
SDL_Free(wiiu_tex);
|
||||
}
|
||||
|
||||
#endif //SDL_VIDEO_RENDER_WIIU
|
||||
|
|
|
|||
|
|
@ -35,8 +35,7 @@
|
|||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
static void
|
||||
WIIU_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event)
|
||||
void WIIU_SDL_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event)
|
||||
{
|
||||
if (event->event == SDL_WINDOWEVENT_SIZE_CHANGED) {
|
||||
// Re-init the colour buffer etc. for new window size
|
||||
|
|
@ -49,20 +48,19 @@ WIIU_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event)
|
|||
// We always output at whatever res the window is.
|
||||
// This may need to change if SDL_wiiuvideo is ever folded into SDL_render -
|
||||
// see SDL_*WindowTexture from SDL_video.c for how this could be done
|
||||
static int
|
||||
WIIU_GetOutputSize(SDL_Renderer * renderer, int *w, int *h) {
|
||||
int WIIU_SDL_GetOutputSize(SDL_Renderer * renderer, int *w, int *h) {
|
||||
SDL_GetWindowSize(renderer->window, w, h);
|
||||
}
|
||||
|
||||
// We handle all viewport changes in the render functions and shaders, so we
|
||||
// don't actually have to do anything here. SDL still requires we implement it.
|
||||
static int WIIU_UpdateViewport(SDL_Renderer * renderer) {
|
||||
int WIIU_SDL_UpdateViewport(SDL_Renderer * renderer) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Ideally this should change the GX2SetScissor values, but SetRenderTarget
|
||||
// needs refactoring first or these get overwritten.
|
||||
static int WIIU_UpdateClipRect(SDL_Renderer * renderer) {
|
||||
int WIIU_SDL_UpdateClipRect(SDL_Renderer * renderer) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@
|
|||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "texture_shader.h"
|
||||
#include "wiiu_shaders.h"
|
||||
|
||||
static int WIIU_VideoInit(_THIS);
|
||||
static int WIIU_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode);
|
||||
|
|
@ -83,7 +83,6 @@ static GX2RBuffer position_buffer = {
|
|||
2 * sizeof(float), 4, NULL
|
||||
};
|
||||
|
||||
static WHBGfxShaderGroup group = { 0 };
|
||||
static GX2Sampler sampler = {0};
|
||||
|
||||
static int WIIU_VideoInit(_THIS)
|
||||
|
|
@ -95,10 +94,7 @@ static int WIIU_VideoInit(_THIS)
|
|||
WHBGfxInit();
|
||||
|
||||
// setup shader
|
||||
WHBGfxLoadGFDShaderGroup(&group, 0, texture_shader_gsh);
|
||||
WHBGfxInitShaderAttribute(&group, "position", 0, 0, GX2_ATTRIB_FORMAT_FLOAT_32_32);
|
||||
WHBGfxInitShaderAttribute(&group, "tex_coord_in", 1, 0, GX2_ATTRIB_FORMAT_FLOAT_32_32);
|
||||
WHBGfxInitFetchShader(&group);
|
||||
wiiuInitTextureShader();
|
||||
|
||||
// setup vertex position attribute
|
||||
GX2RCreateBuffer(&position_buffer);
|
||||
|
|
@ -132,6 +128,7 @@ static void WIIU_VideoQuit(_THIS)
|
|||
{
|
||||
GX2RDestroyBufferEx(&position_buffer, 0);
|
||||
GX2RDestroyBufferEx(&tex_coord_buffer, 0);
|
||||
wiiuFreeTextureShader();
|
||||
WHBGfxShutdown();
|
||||
WHBProcShutdown();
|
||||
}
|
||||
|
|
@ -181,14 +178,12 @@ static int WIIU_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *forma
|
|||
|
||||
static void render_scene(WIIU_WindowData *data) {
|
||||
WHBGfxClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
GX2SetFetchShader(&group.fetchShader);
|
||||
GX2SetVertexShader(group.vertexShader);
|
||||
GX2SetPixelShader(group.pixelShader);
|
||||
wiiuSetTextureShader();
|
||||
GX2RSetAttributeBuffer(&position_buffer, 0, position_buffer.elemSize, 0);
|
||||
GX2RSetAttributeBuffer(&tex_coord_buffer, 1, tex_coord_buffer.elemSize, 0);
|
||||
|
||||
GX2SetPixelTexture(&data->texture, group.pixelShader->samplerVars[0].location);
|
||||
GX2SetPixelSampler(&sampler, group.pixelShader->samplerVars[0].location);
|
||||
GX2SetPixelTexture(&data->texture, wiiuTextureShader.pixelShader->samplerVars[0].location);
|
||||
GX2SetPixelSampler(&sampler, wiiuTextureShader.pixelShader->samplerVars[0].location);
|
||||
|
||||
GX2DrawEx(GX2_PRIMITIVE_MODE_QUADS, 4, 0, 1);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,68 @@
|
|||
unsigned char texture_shader_gsh[] = {
|
||||
/*
|
||||
(TODO, will need some changes)
|
||||
*/
|
||||
|
||||
unsigned char wiiuTextureShaderData[] = {
|
||||
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
=======================================
|
||||
Color/Fill shader
|
||||
=======================================
|
||||
|
||||
---------------------------------------
|
||||
Vertex shader
|
||||
---------------------------------------
|
||||
|
||||
; $MODE = "UniformRegister"
|
||||
; $ATTRIB_VARS[0].name = "position"
|
||||
; $ATTRIB_VARS[0].type = "Float2"
|
||||
; $ATTRIB_VARS[0].location = 0
|
||||
|
||||
00 CALL_FS NO_BARRIER
|
||||
01 ALU: ADDR(32) CNT(2)
|
||||
0 z: MOV R1.z, 0.0f
|
||||
w: MOV R1.w, (0x3F800000, 1.0f).x
|
||||
02 EXP_DONE: POS0, R1
|
||||
03 EXP_DONE: PARAM0, R0.____
|
||||
END_OF_PROGRAM
|
||||
|
||||
---------------------------------------
|
||||
Pixel shader
|
||||
---------------------------------------
|
||||
|
||||
; $MODE = "UniformRegister"
|
||||
; $UNIFORM_VARS[0].name = "color"
|
||||
; $UNIFORM_VARS[0].type = "Float4"
|
||||
; $UNIFORM_VARS[0].count = 1
|
||||
; $UNIFORM_VARS[0].offset = 0
|
||||
; $UNIFORM_VARS[0].block = -1
|
||||
|
||||
00 ALU: ADDR(32) CNT(4)
|
||||
0 x: MOV R0.x, C0.x
|
||||
y: MOV R0.y, C0.y
|
||||
z: MOV R0.z, C0.z
|
||||
w: MOV R0.w, C0.w
|
||||
01 EXP_DONE: PIX0, R0
|
||||
END_OF_PROGRAM
|
||||
|
||||
*/
|
||||
|
||||
unsigned char wiiuColorShaderData[] = {
|
||||
0x47, 0x66, 0x78, 0x32, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x07,
|
||||
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x4c, 0x4b, 0x7b,
|
||||
0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x01, 0xa4, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xff, 0xff, 0x00,
|
||||
0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x02,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xff,
|
||||
0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x01,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff,
|
||||
0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff,
|
||||
0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff,
|
||||
0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff,
|
||||
|
|
@ -21,30 +73,27 @@ unsigned char texture_shader_gsh[] = {
|
|||
0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff,
|
||||
0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff,
|
||||
0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x20,
|
||||
0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x10,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x02, 0xd0, 0x60, 0x01, 0x34, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x01, 0xd0, 0x60, 0x01, 0x34, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xca, 0x70, 0x01, 0x54, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xca, 0x70, 0x01, 0x60, 0x00, 0x00, 0x00, 0x09,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x70, 0x6f, 0x73, 0x69,
|
||||
0x74, 0x69, 0x6f, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x74, 0x65, 0x78, 0x5f,
|
||||
0x63, 0x6f, 0x6f, 0x72, 0x64, 0x5f, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00,
|
||||
0xd0, 0x60, 0x01, 0x08, 0xca, 0x70, 0x01, 0x34, 0xca, 0x70, 0x01, 0x44,
|
||||
0xca, 0x70, 0x01, 0x44, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e,
|
||||
0x00, 0x00, 0x00, 0x00, 0xd0, 0x60, 0x01, 0x08, 0xca, 0x70, 0x01, 0x34,
|
||||
0x7d, 0x42, 0x4c, 0x4b, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x01, 0x70, 0xd0, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c,
|
||||
0xd0, 0x60, 0x01, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03,
|
||||
0xd0, 0x60, 0x01, 0x70, 0x42, 0x4c, 0x4b, 0x7b, 0x00, 0x00, 0x00, 0x20,
|
||||
0x00, 0x00, 0x01, 0x50, 0xd0, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c,
|
||||
0xd0, 0x60, 0x01, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
|
||||
0xd0, 0x60, 0x01, 0x50, 0x42, 0x4c, 0x4b, 0x7b, 0x00, 0x00, 0x00, 0x20,
|
||||
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05,
|
||||
0x00, 0x00, 0x01, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x09, 0x20, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x0c, 0xa0, 0x3c, 0xa0, 0x00, 0x00, 0x88, 0x06, 0x00, 0x94,
|
||||
0x00, 0x40, 0x01, 0x00, 0x88, 0x04, 0x20, 0x14, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x04, 0xa0, 0x3c, 0xa0, 0x00, 0x00, 0x88, 0x06, 0x00, 0x94,
|
||||
0x00, 0x40, 0x00, 0x00, 0xff, 0x0f, 0x20, 0x94, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
|
|
@ -63,41 +112,40 @@ unsigned char texture_shader_gsh[] = {
|
|||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x90, 0x0c, 0x40, 0x00,
|
||||
0x02, 0x04, 0x00, 0x00, 0x90, 0x0c, 0x40, 0x20, 0xf8, 0x08, 0x00, 0x00,
|
||||
0x90, 0x0c, 0x20, 0x40, 0xf9, 0x00, 0x00, 0x80, 0x90, 0x0c, 0x20, 0x60,
|
||||
0x00, 0x00, 0x00, 0x00, 0xf8, 0x08, 0x00, 0x00, 0x90, 0x0c, 0x20, 0x40,
|
||||
0xf9, 0x00, 0x00, 0x80, 0x90, 0x0c, 0x20, 0x60, 0x42, 0x4c, 0x4b, 0x7b,
|
||||
0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x01, 0x34, 0x00, 0x00, 0x00, 0x02,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02,
|
||||
0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f,
|
||||
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x01, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
|
||||
0xd0, 0x60, 0x00, 0xe8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xca, 0x70, 0x00, 0xfc,
|
||||
0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0x00, 0x00,
|
||||
0xd0, 0x60, 0x00, 0xbc, 0xca, 0x70, 0x00, 0xe8, 0x7d, 0x42, 0x4c, 0x4b,
|
||||
0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x04,
|
||||
0xd0, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xd0, 0x60, 0x00, 0xfc,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xd0, 0x60, 0x01, 0x04,
|
||||
0x42, 0x4c, 0x4b, 0x7b, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x01,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x01, 0x28,
|
||||
0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
|
||||
0x00, 0x00, 0x00, 0x02, 0x14, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x01, 0xd0, 0x60, 0x00, 0xe8, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xca, 0x70, 0x00, 0xf4, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
|
||||
0x73, 0x00, 0x00, 0x00, 0xd0, 0x60, 0x00, 0xd4, 0xca, 0x70, 0x00, 0xe8,
|
||||
0x7d, 0x42, 0x4c, 0x4b, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0xf8, 0xd0, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04,
|
||||
0xd0, 0x60, 0x00, 0xf4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
|
||||
0xd0, 0x60, 0x00, 0xf8, 0x42, 0x4c, 0x4b, 0x7b, 0x00, 0x00, 0x00, 0x20,
|
||||
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07,
|
||||
0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
|
||||
0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x80, 0x00, 0x00, 0x00, 0x00,
|
||||
0x88, 0x06, 0x20, 0x94, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x01, 0x20,
|
||||
0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x0c, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x88, 0x06, 0x20, 0x94,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
|
|
@ -117,10 +165,11 @@ unsigned char texture_shader_gsh[] = {
|
|||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0d, 0xf0,
|
||||
0x00, 0x00, 0x80, 0x10, 0x00, 0x00, 0x00, 0x00, 0x42, 0x4c, 0x4b, 0x7b,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x01, 0x00, 0x00, 0x90, 0x0c, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00,
|
||||
0x90, 0x0c, 0x00, 0x20, 0x00, 0x09, 0x00, 0x00, 0x90, 0x0c, 0x00, 0x40,
|
||||
0x00, 0x0d, 0x00, 0x80, 0x90, 0x0c, 0x00, 0x60, 0x42, 0x4c, 0x4b, 0x7b,
|
||||
0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04,
|
||||
0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
unsigned int texture_shader_gsh_len = 1468;
|
||||
};
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
#ifndef _WIIU_texture_shader_h
|
||||
#define _WIIU_texture_shader_h
|
||||
|
||||
extern unsigned char texture_shader_gsh[];
|
||||
extern unsigned int texture_shader_gsh_len;
|
||||
|
||||
#endif /* _WIIU_texture_shader_h */
|
||||
80
src/video/wiiu/wiiu_shaders.h
Normal file
80
src/video/wiiu/wiiu_shaders.h
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 2018-2018 Ash Logan <ash@heyquark.com>
|
||||
Copyright (C) 2018-2018 Roberto Van Eeden <r.r.qwertyuiop.r.r@gmail.com>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#ifndef _WIIU_shaders_h
|
||||
#define _WIIU_shaders_h
|
||||
|
||||
extern unsigned char wiiuTextureShaderData[];
|
||||
extern unsigned char wiiuColorShaderData[];
|
||||
|
||||
WHBGfxShaderGroup wiiuTextureShader;
|
||||
int wiiuTextureShaderInit = 0;
|
||||
|
||||
static inline void wiiuInitTextureShader() {
|
||||
if (!wiiuTextureShaderInit) {
|
||||
WHBGfxLoadGFDShaderGroup(&wiiuTextureShader, 0, wiiuTextureShaderData);
|
||||
WHBGfxInitShaderAttribute(&wiiuTextureShader, "position", 0, 0, GX2_ATTRIB_FORMAT_FLOAT_32_32);
|
||||
WHBGfxInitShaderAttribute(&wiiuTextureShader, "tex_coord_in", 1, 0, GX2_ATTRIB_FORMAT_FLOAT_32_32);
|
||||
WHBGfxInitFetchShader(&wiiuTextureShader);
|
||||
}
|
||||
wiiuTextureShaderInit++;
|
||||
}
|
||||
|
||||
static inline void wiiuFreeTextureShader() {
|
||||
if (wiiuTextureShaderInit)
|
||||
if (!--wiiuTextureShaderInit)
|
||||
WHBGfxFreeShaderGroup(&wiiuTextureShader);
|
||||
}
|
||||
|
||||
static inline void wiiuSetTextureShader() {
|
||||
GX2SetFetchShader(&wiiuTextureShader.fetchShader);
|
||||
GX2SetVertexShader(wiiuTextureShader.vertexShader);
|
||||
GX2SetPixelShader(wiiuTextureShader.pixelShader);
|
||||
}
|
||||
|
||||
WHBGfxShaderGroup wiiuColorShader;
|
||||
int wiiuColorShaderInit = 0;
|
||||
|
||||
static inline void wiiuInitColorShader() {
|
||||
if (!wiiuColorShaderInit) {
|
||||
WHBGfxLoadGFDShaderGroup(&wiiuColorShader, 0, wiiuColorShaderData);
|
||||
WHBGfxInitShaderAttribute(&wiiuColorShader, "position", 0, 0, GX2_ATTRIB_FORMAT_FLOAT_32_32);
|
||||
WHBGfxInitFetchShader(&wiiuColorShader);
|
||||
}
|
||||
wiiuColorShaderInit++;
|
||||
}
|
||||
|
||||
static inline void wiiuFreeColorShader() {
|
||||
if (wiiuColorShaderInit)
|
||||
if (!--wiiuColorShaderInit)
|
||||
WHBGfxFreeShaderGroup(&wiiuColorShader);
|
||||
}
|
||||
|
||||
static inline void wiiuSetColorShader() {
|
||||
GX2SetFetchShader(&wiiuColorShader.fetchShader);
|
||||
GX2SetVertexShader(wiiuColorShader.vertexShader);
|
||||
GX2SetPixelShader(wiiuColorShader.pixelShader);
|
||||
}
|
||||
|
||||
#endif //_WIIU_shaders_h
|
||||
Loading…
Reference in New Issue
Block a user