From 3ad7fe8bf5ddfecfbe72b821f7c69392bb1f8420 Mon Sep 17 00:00:00 2001 From: rw-r-r-0644 Date: Wed, 24 Oct 2018 21:59:02 +0200 Subject: [PATCH] render/wiiu: Fix compiling, implement RenderCopyEx, make some render vars unique for objects, add missing shaders --- src/render/wiiu/SDL_rdraw_wiiu.c | 199 ++++++++-------- src/render/wiiu/SDL_render_wiiu.c | 90 +++---- src/render/wiiu/SDL_render_wiiu.h | 26 ++- src/render/wiiu/SDL_rtexture_wiiu.c | 69 +++--- src/render/wiiu/SDL_rwindow_wiiu.c | 4 +- src/video/wiiu/texture_shader.c | 175 -------------- src/video/wiiu/wiiu_shaders.c | 349 ++++++++++++++++++++++++++++ src/video/wiiu/wiiu_shaders.h | 6 +- 8 files changed, 555 insertions(+), 363 deletions(-) delete mode 100644 src/video/wiiu/texture_shader.c create mode 100644 src/video/wiiu/wiiu_shaders.c diff --git a/src/render/wiiu/SDL_rdraw_wiiu.c b/src/render/wiiu/SDL_rdraw_wiiu.c index 0673c9c0f..e7be84650 100644 --- a/src/render/wiiu/SDL_rdraw_wiiu.c +++ b/src/render/wiiu/SDL_rdraw_wiiu.c @@ -50,67 +50,102 @@ 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; + WIIU_TextureData *tdata = (WIIU_TextureData *) texture->driverdata; - float swidth = data->cbuf.surface.width; - float sheight = data->cbuf.surface.height; + float *a_position = WIIU_AllocRenderData(data, sizeof(float) * 8); + float *a_texCoord = WIIU_AllocRenderData(data, sizeof(float) * 8); - //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; + /* Compute vertex points */ + float x_min = (((renderer->viewport.x + dstrect->x) / (float)data->cbuf.surface.width) * 2.0f) - 1.0f; + float y_min = (((renderer->viewport.y + dstrect->y) / (float)data->cbuf.surface.height) * 2.0f) - 1.0f; + float x_max = (((renderer->viewport.x + dstrect->x + dstrect->w) / (float)data->cbuf.surface.width) * 2.0f) - 1.0f; + float y_max = (((renderer->viewport.y + dstrect->y + dstrect->h) / (float)data->cbuf.surface.height) * 2.0f) - 1.0f; + a_position[0] = x_min; a_position[1] = y_min; + a_position[2] = x_max; a_position[3] = y_min; + a_position[4] = x_max; a_position[5] = y_max; + a_position[6] = x_min; a_position[7] = y_max; + GX2Invalidate(GX2_INVALIDATE_MODE_CPU_ATTRIBUTE_BUFFER, a_position, sizeof(float) * 8); - float vb[] = - { - tr_x, tr_y, - tr_x + tr_w, tr_y, - tr_x + tr_w, tr_y + tr_h, - tr_x, tr_y + tr_h, - }; + /* Compute texture coords */ + float tex_x_min = (float)srcrect->x / (float)tdata->texture.surface.width; + float tex_x_max = (float)(srcrect->x + srcrect->w) / (float)tdata->texture.surface.width; + float tex_y_min = (float)srcrect->y / (float)tdata->texture.surface.height; + float tex_y_max = (float)(srcrect->y + srcrect->h) / (float)tdata->texture.surface.height; + a_texCoord[0] = tex_x_min; a_texCoord[1] = tex_y_max; + a_texCoord[2] = tex_x_max; a_texCoord[3] = tex_y_max; + a_texCoord[4] = tex_x_max; a_texCoord[5] = tex_y_min; + a_texCoord[6] = tex_x_min; a_texCoord[7] = tex_y_min; + GX2Invalidate(GX2_INVALIDATE_MODE_CPU_ATTRIBUTE_BUFFER, a_texCoord, sizeof(float) * 8); - GX2RLockBufferEx(&data->texPositionBuffer, 0); - memcpy(data->texPositionBuffer.buffer, vb, data->texPositionBuffer.elemCount * data->texPositionBuffer.elemSize); - GX2RUnlockBufferEx(&data->texPositionBuffer, 0); - - 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[] = - { - tex_x_min, tex_y_max, - tex_x_max, tex_y_max, - tex_x_max, tex_y_min, - tex_x_min, tex_y_min, - }; - - GX2RLockBufferEx(&data->texCoordBuffer, 0); - memcpy(data->texCoordBuffer.buffer, aTexCoord, data->texCoordBuffer.elemCount * data->texCoordBuffer.elemSize); - GX2RUnlockBufferEx(&data->texCoordBuffer, 0); - - //RENDER + /* Render */ GX2SetContextState(&data->ctx); wiiuSetTextureShader(); - - GX2SetPixelTexture(texture, 0); - GX2SetPixelSampler(sampler, 0); - - GX2RSetAttributeBuffer(&data->texPositionBuffer, 0, data->texPositionBuffer.elemSize, 0); - GX2RSetAttributeBuffer(&data->texCoordBuffer, 1, data->texCoordBuffer.elemSize, 0); - GX2RSetAttributeBuffer(&data->texColourBuffer, 2, data->texColourBuffer.elemSize, 0); - + GX2SetPixelTexture(&tdata->texture, 0); + GX2SetPixelSampler(&tdata->sampler, 0); + GX2SetAttribBuffer(0, sizeof(float) * 8, sizeof(float) * 2, a_position); + GX2SetAttribBuffer(1, sizeof(float) * 8, sizeof(float) * 2, a_texCoord); GX2DrawEx(GX2_PRIMITIVE_MODE_QUADS, 4, 0, 1); } + +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) +{ + WIIU_RenderData *data = (WIIU_RenderData *) renderer->driverdata; + WIIU_TextureData *tdata = (WIIU_TextureData *) texture->driverdata; + + float *a_position = WIIU_AllocRenderData(data, sizeof(float) * 8); + float *a_texCoord = WIIU_AllocRenderData(data, sizeof(float) * 8); + + /* Compute real vertex points */ + float x_min = renderer->viewport.x + dstrect->x; + float y_min = renderer->viewport.y + dstrect->y; + float x_max = x_min + dstrect->w; + float y_max = y_min + dstrect->h; + float cx = x_min + center->x; + float cy = y_min + center->y; + double r = angle * (M_PI / 180.0); + float rvb[8] = { + (flip & SDL_FLIP_HORIZONTAL) ? x_max : x_min, (flip & SDL_FLIP_VERTICAL) ? y_max : y_min, + (flip & SDL_FLIP_HORIZONTAL) ? x_min : x_max, (flip & SDL_FLIP_VERTICAL) ? y_max : y_min, + (flip & SDL_FLIP_HORIZONTAL) ? x_min : x_max, (flip & SDL_FLIP_VERTICAL) ? y_min : y_max, + (flip & SDL_FLIP_HORIZONTAL) ? x_max : x_min, (flip & SDL_FLIP_VERTICAL) ? y_min : y_max, + }; + for (int i = 0; i < 8; i += 2) { + a_position[i+0] = (((cx + (SDL_cos(r) * (rvb[i+0] - cx) + SDL_sin(r) * (rvb[i+1] - cy))) / (float)data->cbuf.surface.width) * 2.0f) - 1.0f; + a_position[i+1] = (((cy + (SDL_cos(r) * (rvb[i+1] - cy) - SDL_sin(r) * (rvb[i+0] - cx))) / (float)data->cbuf.surface.height) * 2.0f) - 1.0f; + } + GX2Invalidate(GX2_INVALIDATE_MODE_CPU_ATTRIBUTE_BUFFER, a_position, sizeof(float) * 8); + + /* Compute texture coords */ + float tex_x_min = (float)srcrect->x / (float)tdata->texture.surface.width; + float tex_x_max = (float)(srcrect->x + srcrect->w) / (float)tdata->texture.surface.width; + float tex_y_min = (float)srcrect->y / (float)tdata->texture.surface.height; + float tex_y_max = (float)(srcrect->y + srcrect->h) / (float)tdata->texture.surface.height; + a_texCoord[0] = tex_x_min; a_texCoord[1] = tex_y_max; + a_texCoord[2] = tex_x_max; a_texCoord[3] = tex_y_max; + a_texCoord[4] = tex_x_max; a_texCoord[5] = tex_y_min; + a_texCoord[6] = tex_x_min; a_texCoord[7] = tex_y_min; + GX2Invalidate(GX2_INVALIDATE_MODE_CPU_ATTRIBUTE_BUFFER, a_texCoord, sizeof(float) * 8); + + /* Render */ + GX2SetContextState(&data->ctx); + wiiuSetTextureShader(); + GX2SetPixelTexture(&tdata->texture, 0); + GX2SetPixelSampler(&tdata->sampler, 0); + GX2SetAttribBuffer(0, sizeof(float) * 8, sizeof(float) * 2, a_position); + GX2SetAttribBuffer(1, sizeof(float) * 8, sizeof(float) * 2, a_texCoord); + GX2DrawEx(GX2_PRIMITIVE_MODE_QUADS, 4, 0, 1); + + return 0; +} + 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; + float *a_position = WIIU_AllocRenderData(data, sizeof(float) * 2 * count); /* Compute vertex pos */ float swidth = data->cbuf.surface.width; @@ -119,8 +154,8 @@ int WIIU_SDL_RenderDrawPoints(SDL_Renderer * renderer, const SDL_FPoint * points 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; + a_position[i*2+0] = (((vx + points[i].x) / swidth) * 2.0f)-1.0f; + a_position[i*2+1] = (((vy + points[i].y) / sheight) * 2.0f)-1.0f; } /* Render points */ @@ -131,16 +166,10 @@ int WIIU_SDL_RenderDrawPoints(SDL_Renderer * renderer, const SDL_FPoint * points 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); - + GX2SetAttribBuffer(0, sizeof(float) * 2 * count, sizeof(float) * 2, a_position); + 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; } @@ -149,9 +178,7 @@ 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; + float *a_position = WIIU_AllocRenderData(data, sizeof(float) * 2 * count); /* Compute vertex pos */ float swidth = data->cbuf.surface.width; @@ -160,8 +187,8 @@ int WIIU_SDL_RenderDrawLines(SDL_Renderer * renderer, const SDL_FPoint * points, 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; + a_position[i*2+0] = (((vx + points[i].x) / swidth) * 2.0f) - 1.0f; + a_position[i*2+1] = (((vy + points[i].y) / sheight) * 2.0f) - 1.0f; } /* Render lines */ @@ -172,25 +199,17 @@ int WIIU_SDL_RenderDrawLines(SDL_Renderer * renderer, const SDL_FPoint * points, 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); - + GX2SetAttribBuffer(0, sizeof(float) * 2 * count, sizeof(float) * 2, a_position); + 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; + float *a_position = WIIU_AllocRenderData(data, sizeof(float) * 8 * count); /* Compute vertex pos */ float swidth = data->cbuf.surface.width; @@ -203,14 +222,14 @@ int WIIU_SDL_RenderFillRects(SDL_Renderer * renderer, const SDL_FRect * rects, i 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; + a_position[i*8+0] = tr_x; + a_position[i*8+1] = tr_y; + a_position[i*8+2] = tr_x + tr_w; + a_position[i*8+3] = tr_y; + a_position[i*8+4] = tr_x + tr_w; + a_position[i*8+5] = tr_y + tr_h; + a_position[i*8+6] = tr_x; + a_position[i*8+7] = tr_y + tr_h; } /* Render rects */ @@ -221,16 +240,10 @@ int WIIU_SDL_RenderFillRects(SDL_Renderer * renderer, const SDL_FRect * rects, i 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); - + GX2SetAttribBuffer(0, sizeof(float) * 2 * 4 * count, sizeof(float) * 2, a_position); + 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; } @@ -247,11 +260,7 @@ void WIIU_SDL_RenderPresent(SDL_Renderer * renderer) SDL_UpdateWindowSurface(window); } - while (data->listfree) { - void *ptr = data->listfree; - data->listfree = data->listfree->next; - SDL_free(ptr); - } + WIIU_FreeRenderData(data); } int WIIU_SDL_RenderClear(SDL_Renderer * renderer) diff --git a/src/render/wiiu/SDL_render_wiiu.c b/src/render/wiiu/SDL_render_wiiu.c index 70bf61b1a..421f793a9 100644 --- a/src/render/wiiu/SDL_render_wiiu.c +++ b/src/render/wiiu/SDL_render_wiiu.c @@ -23,22 +23,24 @@ #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" +#include + #include #include #include #include #include -/* SDL surface based renderer implementation */ +SDL_RenderDriver WIIU_RenderDriver; SDL_Renderer *WIIU_SDL_CreateRenderer(SDL_Window * window, Uint32 flags) { - SDL_Surface *surface SDL_Renderer *renderer; WIIU_RenderData *data; @@ -50,35 +52,35 @@ SDL_Renderer *WIIU_SDL_CreateRenderer(SDL_Window * window, Uint32 flags) data = (WIIU_RenderData *) SDL_calloc(1, sizeof(*data)); if (!data) { - WIIU_DestroyRenderer(renderer); + WIIU_SDL_DestroyRenderer(renderer); SDL_OutOfMemory(); return NULL; } // See sdl_render_wiiu.h for explanations of commented-out functions - renderer->WindowEvent = WIIU_WindowEvent; - renderer->GetOutputSize = WIIU_GetOutputSize; - renderer->CreateTexture = WIIU_CreateTexture; - //renderer->SetTextureColorMod = WIIU_SetTextureColorMod; - //renderer->SetTextureAlphaMod = WIIU_SetTextureAlphaMod; - //renderer->SetTextureBlendMode = WIIU_SetTextureBlendMode; - renderer->UpdateTexture = WIIU_UpdateTexture; - renderer->LockTexture = WIIU_LockTexture; - renderer->UnlockTexture = WIIU_UnlockTexture; - renderer->SetRenderTarget = WIIU_SetRenderTarget; - renderer->UpdateViewport = WIIU_UpdateViewport; - renderer->UpdateClipRect = WIIU_UpdateClipRect; - renderer->RenderClear = WIIU_RenderClear; - renderer->RenderDrawPoints = WIIU_RenderDrawPoints; - renderer->RenderDrawLines = WIIU_RenderDrawLines; - renderer->RenderFillRects = WIIU_RenderFillRects; - renderer->RenderCopy = WIIU_RenderCopy; - renderer->RenderCopyEx = WIIU_RenderCopyEx; - renderer->RenderReadPixels = WIIU_RenderReadPixels; - renderer->RenderPresent = WIIU_RenderPresent; - renderer->DestroyTexture = WIIU_DestroyTexture; - renderer->DestroyRenderer = WIIU_DestroyRenderer; + renderer->WindowEvent = WIIU_SDL_WindowEvent; + renderer->GetOutputSize = WIIU_SDL_GetOutputSize; + renderer->CreateTexture = WIIU_SDL_CreateTexture; + //renderer->SetTextureColorMod = WIIU_SDL_SetTextureColorMod; + //renderer->SetTextureAlphaMod = WIIU_SDL_SetTextureAlphaMod; + //renderer->SetTextureBlendMode = WIIU_SDL_SetTextureBlendMode; + renderer->UpdateTexture = WIIU_SDL_UpdateTexture; + renderer->LockTexture = WIIU_SDL_LockTexture; + renderer->UnlockTexture = WIIU_SDL_UnlockTexture; + renderer->SetRenderTarget = WIIU_SDL_SetRenderTarget; + renderer->UpdateViewport = WIIU_SDL_UpdateViewport; + renderer->UpdateClipRect = WIIU_SDL_UpdateClipRect; + renderer->RenderClear = WIIU_SDL_RenderClear; + renderer->RenderDrawPoints = WIIU_SDL_RenderDrawPoints; + renderer->RenderDrawLines = WIIU_SDL_RenderDrawLines; + renderer->RenderFillRects = WIIU_SDL_RenderFillRects; + renderer->RenderCopy = WIIU_SDL_RenderCopy; + renderer->RenderCopyEx = WIIU_SDL_RenderCopyEx; + renderer->RenderReadPixels = WIIU_SDL_RenderReadPixels; + renderer->RenderPresent = WIIU_SDL_RenderPresent; + renderer->DestroyTexture = WIIU_SDL_DestroyTexture; + renderer->DestroyRenderer = WIIU_SDL_DestroyRenderer; renderer->info = WIIU_RenderDriver.info; renderer->driverdata = data; renderer->window = window; @@ -90,33 +92,15 @@ SDL_Renderer *WIIU_SDL_CreateRenderer(SDL_Window * window, Uint32 flags) // List of attibutes to free after render data->listfree = NULL; - // Setup texture shader attribute buffers - data->texPositionBuffer.flags = - data->texCoordBuffer.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) * 2; - data->texCoordBuffer.elemSize = sizeof(float) * 2; - data->texPositionBuffer.elemCount = - data->texCoordBuffer.elemCount = 4; - - GX2RCreateBuffer(&data->texPositionBuffer); - GX2RCreateBuffer(&data->texCoordBuffer); - // 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); - // Create a fresh context state GX2SetupContextStateEx(&data->ctx, TRUE); // Setup colour buffer, rendering to the window - WIIU_SetRenderTarget(renderer, NULL); + WIIU_SDL_SetRenderTarget(renderer, NULL); return renderer; } @@ -129,11 +113,11 @@ int WIIU_SDL_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture) if (texture) { // Set texture as target - GX2Texture *wiiu_tex = (GX2Texture *) texture->driverdata; - target = wiiu_tex->surface; + WIIU_TextureData *tdata = (WIIU_TextureData *) texture->driverdata; + target = &tdata->texture.surface; } else { // Set window texture as target - WIIU_WindowData *wdata = (WIIU_WindowData *) SDL_GetWindowData(window, WIIU_WINDOW_DATA); + WIIU_WindowData *wdata = (WIIU_WindowData *) SDL_GetWindowData(renderer->window, WIIU_WINDOW_DATA); target = &wdata->texture.surface; } @@ -163,7 +147,7 @@ void WIIU_SDL_DestroyRenderer(SDL_Renderer * renderer) while (data->listfree) { void *ptr = data->listfree; data->listfree = data->listfree->next; - SDL_free(ptr); + SDL_free(ptr); } wiiuFreeColorShader(); @@ -190,9 +174,9 @@ int WIIU_SDL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, } 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); + src_pixels = (void*)((Uint8 *) data->cbuf.surface.image + + rect->y * data->cbuf.surface.pitch + + rect->x * 4); return SDL_ConvertPixels(rect->w, rect->h, src_format, src_pixels, data->cbuf.surface.pitch, @@ -201,7 +185,7 @@ int WIIU_SDL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, SDL_RenderDriver WIIU_RenderDriver = { - .CreateRenderer = WIIU_CreateRenderer, + .CreateRenderer = WIIU_SDL_CreateRenderer, .info = { .name = "WiiU GX2", .flags = SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE, diff --git a/src/render/wiiu/SDL_render_wiiu.h b/src/render/wiiu/SDL_render_wiiu.h index 1e62d4cc2..b98fa6ea1 100644 --- a/src/render/wiiu/SDL_render_wiiu.h +++ b/src/render/wiiu/SDL_render_wiiu.h @@ -27,6 +27,7 @@ #include "../SDL_sysrender.h" #include +#include typedef struct { @@ -37,15 +38,32 @@ typedef struct //Driver internal data structures typedef struct { - GX2Sampler sampler; GX2ColorBuffer cbuf; GX2ContextState ctx; - GX2RBuffer texPositionBuffer; - GX2RBuffer texCoordBuffer; - GX2RBuffer texColourBuffer; WIIU_RenderAllocData *listfree; } WIIU_RenderData; +typedef struct +{ + GX2Sampler sampler; + GX2Texture texture; +} WIIU_TextureData; + +static inline void *WIIU_AllocRenderData(WIIU_RenderData *r, size_t size) { + WIIU_RenderAllocData *rdata = SDL_malloc(sizeof(WIIU_RenderAllocData) + size); + rdata->next = r->listfree; + r->listfree = rdata; + return (void *)rdata->ptr; +} + +static inline void WIIU_FreeRenderData(WIIU_RenderData *r) { + while (r->listfree) { + void *ptr = r->listfree; + r->listfree = r->listfree->next; + SDL_free(ptr); + } +} + //SDL_render API implementation SDL_Renderer *WIIU_SDL_CreateRenderer(SDL_Window * window, Uint32 flags); void WIIU_SDL_WindowEvent(SDL_Renderer * renderer, diff --git a/src/render/wiiu/SDL_rtexture_wiiu.c b/src/render/wiiu/SDL_rtexture_wiiu.c index f60aeef0a..1f0c3461c 100644 --- a/src/render/wiiu/SDL_rtexture_wiiu.c +++ b/src/render/wiiu/SDL_rtexture_wiiu.c @@ -23,14 +23,17 @@ #if SDL_VIDEO_RENDER_WIIU -#include "../../video/wiiu/wiiuvideo.h" +#include "../../video/wiiu/SDL_wiiuvideo.h" #include "../SDL_sysrender.h" #include "SDL_hints.h" #include "SDL_render_wiiu.h" #include #include +#include +#include +#include #include #include #include @@ -39,30 +42,33 @@ int WIIU_SDL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) { - GX2Texture *wiiu_tex = (GX2Texture*) SDL_calloc(1, sizeof(*wiiu_tex)); - if (!wiiu_tex) + WIIU_TextureData *tdata = (WIIU_TextureData *) SDL_calloc(1, sizeof(*tdata)); + if (!tdata) return SDL_OutOfMemory(); - wiiu_tex->surface.width = TextureNextPow2(texture->w); - wiiu_tex->surface.height = TextureNextPow2(texture->h); - wiiu_tex->surface.format = PixelFormatToWIIUFMT(texture->format); - wiiu_tex->surface.depth = 1; //? - wiiu_tex->surface.dim = GX2_SURFACE_DIM_TEXTURE_2D; - wiiu_tex->surface.tileMode = GX2_TILE_MODE_LINEAR_ALIGNED; - wiiu_tex->surface.use = GX2_SURFACE_USE_TEXTURE; - wiiu_tex->surface.mipLevels = 1; - wiiu_tex->viewNumMips = 1; - wiiu_tex->viewNumSlices = 1; - wiiu_tex->compMap = 0x00010203; + // Setup sampler + GX2InitSampler(&tdata->sampler, GX2_TEX_CLAMP_MODE_CLAMP, GX2_TEX_XY_FILTER_MODE_LINEAR); - GX2CalcSurfaceSizeAndAlignment(&wiiu_tex->surface); - wiiu_tex->surface.image = memalign(wiiu_tex->surface.alignment, wiiu_tex->surface.imageSize); - if(!wiiu_tex->surface.image) + tdata->texture.surface.width = TextureNextPow2(texture->w); + tdata->texture.surface.height = TextureNextPow2(texture->h); + tdata->texture.surface.format = PixelFormatToWIIUFMT(texture->format); + tdata->texture.surface.depth = 1; //? + tdata->texture.surface.dim = GX2_SURFACE_DIM_TEXTURE_2D; + tdata->texture.surface.tileMode = GX2_TILE_MODE_LINEAR_ALIGNED; + tdata->texture.surface.use = GX2_SURFACE_USE_TEXTURE; + tdata->texture.surface.mipLevels = 1; + tdata->texture.viewNumMips = 1; + tdata->texture.viewNumSlices = 1; + tdata->texture.compMap = 0x00010203; + + GX2CalcSurfaceSizeAndAlignment(&tdata->texture.surface); + tdata->texture.surface.image = memalign(tdata->texture.surface.alignment, tdata->texture.surface.imageSize); + if(!tdata->texture.surface.image) { - SDL_free(wiiu_tex); + SDL_free(tdata); return SDL_OutOfMemory(); } - texture->driverdata = wiiu_tex; + texture->driverdata = tdata; return 0; } @@ -73,13 +79,13 @@ int WIIU_SDL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) int WIIU_SDL_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Rect * rect, void **pixels, int *pitch) { - GX2Texture *wiiu_tex = (GX2Texture *) texture->driverdata; + WIIU_TextureData *tdata = (WIIU_TextureData *) texture->driverdata; // Calculate pointer to first pixel in rect - *pixels = (void *) ((Uint8 *) wiiu_tex->surface.image + - rect->y * wiiu_tex->surface.pitch + + *pixels = (void *) ((Uint8 *) tdata->texture.surface.image + + rect->y * tdata->texture.surface.pitch + rect->x * SDL_BYTESPERPIXEL(texture->format)); - *pitch = wiiu_tex->surface.pitch; + *pitch = tdata->texture.surface.pitch; // Not sure we even need to bother keeping track of this texture->locked_rect = *rect; @@ -88,16 +94,16 @@ int WIIU_SDL_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, void WIIU_SDL_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture) { - GX2Texture *wiiu_tex = (GX2Texture *) texture->driverdata; + WIIU_TextureData *tdata = (WIIU_TextureData *) texture->driverdata; // TODO check this is actually needed GX2Invalidate(GX2_INVALIDATE_MODE_CPU | GX2_INVALIDATE_MODE_TEXTURE, - wiiu_tex->surface.image, wiiu_tex->surface.imageSize); + tdata->texture.surface.image, tdata->texture.surface.imageSize); } 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; + WIIU_TextureData *tdata = (WIIU_TextureData *) texture->driverdata; Uint32 BytesPerPixel; Uint8 *src, *dst; int row; @@ -106,14 +112,14 @@ int WIIU_SDL_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, BytesPerPixel = PixelFormatByteSizeWIIU(texture->format); src = (Uint8 *) pixels; - dst = (Uint8 *) wiiu_tex->surface.image + - rect->y * wiiu_tex->surface.pitch + + dst = (Uint8 *) tdata->texture.surface.image + + rect->y * tdata->texture.surface.pitch + rect->x * BytesPerPixel; length = rect->w * BytesPerPixel; for (row = 0; row < rect->h; ++row) { SDL_memcpy(dst, src, length); src += pitch; - dst += wiiu_tex->surface.pitch; + dst += tdata->texture.surface.pitch; } return 0; @@ -121,8 +127,9 @@ int WIIU_SDL_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, void WIIU_SDL_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) { - GX2Texture *wiiu_tex = (GX2Texture *) texture->driverdata; - SDL_Free(wiiu_tex); + WIIU_TextureData *tdata = (WIIU_TextureData *) texture->driverdata; + free(tdata->texture.surface.image); + SDL_free(tdata); } #endif //SDL_VIDEO_RENDER_WIIU diff --git a/src/render/wiiu/SDL_rwindow_wiiu.c b/src/render/wiiu/SDL_rwindow_wiiu.c index b741a0fa8..afaf3bb93 100644 --- a/src/render/wiiu/SDL_rwindow_wiiu.c +++ b/src/render/wiiu/SDL_rwindow_wiiu.c @@ -24,7 +24,7 @@ #if SDL_VIDEO_RENDER_WIIU -#include "../../video/wiiu/wiiuvideo.h" +#include "../../video/wiiu/SDL_wiiuvideo.h" #include "../SDL_sysrender.h" #include "SDL_hints.h" #include "SDL_render_wiiu.h" @@ -41,7 +41,7 @@ void WIIU_SDL_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event) // Re-init the colour buffer etc. for new window size // TODO check: what if we're rendering to a texture when this happens? // SDL may handle this already, see SDL_render.c: SDL_RendererEventWatch - WIIU_SetRenderTarget(renderer, NULL); + WIIU_SDL_SetRenderTarget(renderer, NULL); } } diff --git a/src/video/wiiu/texture_shader.c b/src/video/wiiu/texture_shader.c deleted file mode 100644 index e2cb7d7fe..000000000 --- a/src/video/wiiu/texture_shader.c +++ /dev/null @@ -1,175 +0,0 @@ -/* -(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, 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, 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, - 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, 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, 0x00, - 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, 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, 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, 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, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x09, 0x20, 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, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 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, 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, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 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, 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 -}; \ No newline at end of file diff --git a/src/video/wiiu/wiiu_shaders.c b/src/video/wiiu/wiiu_shaders.c new file mode 100644 index 000000000..a7c098abe --- /dev/null +++ b/src/video/wiiu/wiiu_shaders.c @@ -0,0 +1,349 @@ +/* + +======================================= +Texture shader +======================================= + +--------------------------------------- +Vertex shader +--------------------------------------- + +; $MODE = "UniformRegister" +; $ATTRIB_VARS[0].name = "a_position" +; $ATTRIB_VARS[0].type = "float2" +; $ATTRIB_VARS[0].location = 0 +; $ATTRIB_VARS[1].name = "a_texCoordIn" +; $ATTRIB_VARS[1].type = "float2" +; $ATTRIB_VARS[1].location = 1 +; $NUM_SPI_VS_OUT_ID = 1 +; $SPI_VS_OUT_ID[0].semantic_0 = 0 + +00 CALL_FS NO_BARRIER +01 ALU: ADDR(32) CNT(4) + 0 x: MOV R2.x, R2.x + y: MOV R2.y, R2.y + z: MOV R1.z, 0.0f + w: MOV R1.w, (0x3F800000, 1.0f).x +02 EXP_DONE: POS0, R1 +03 EXP_DONE: PARAM0, R2.xyzz NO_BARRIER +04 ALU: ADDR(36) CNT(1) + 1 x: NOP ____ +05 NOP NO_BARRIER +END_OF_PROGRAM + +--------------------------------------- +Pixel shader +--------------------------------------- + +; $MODE = "UniformRegister" +; $SAMPLER_VARS[0].name= "s_texture" +; $SAMPLER_VARS[0].type= "sampler2D" +; $SAMPLER_VARS[0].location = 0 +; $NUM_SPI_PS_INPUT_CNTL = 1 +; $SPI_PS_INPUT_CNTL[0].semantic = 0 +; $SPI_PS_INPUT_CNTL[0].default_val = 1 + +00 TEX: ADDR(32) CNT(1) VALID_PIX + 0 SAMPLE R0, R0.xy0x, t0, s0 +01 EXP_DONE: PIX0, R0 +END_OF_PROGRAM + +*/ + +unsigned char wiiuTextureShaderData[] = { + 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, + 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, 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, 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, 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, 0x28, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 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, 0x61, 0x5f, 0x70, 0x6f, + 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x00, 0x61, 0x5f, 0x74, 0x65, + 0x78, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x49, 0x6e, 0x00, 0x00, 0x00, 0x00, + 0xd0, 0x60, 0x01, 0x08, 0xca, 0x70, 0x01, 0x34, 0xca, 0x70, 0x01, 0x44, + 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, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, + 0x00, 0x00, 0x01, 0x28, 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, 0x00, 0x14, 0x24, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 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, 0x80, 0x00, 0x0d, 0x00, 0x00, 0x42, 0x4c, 0x4b, 0x7b, + 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x01, 0x30, 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, 0x5f, 0x74, 0x65, + 0x78, 0x74, 0x75, 0x72, 0x65, 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, 0x01, 0x00, 0xd0, 0x60, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x0c, 0xd0, 0x60, 0x00, 0xf4, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x02, 0xd0, 0x60, 0x01, 0x00, 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, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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, 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 +}; + +/* + +======================================= +Color/Fill shader +======================================= + +--------------------------------------- +Vertex shader +--------------------------------------- + +; $MODE = "UniformRegister" +; $ATTRIB_VARS[0].name = "a_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.____ +04 ALU: ADDR(34) CNT(1) + 1 x: NOP ____ +05 NOP NO_BARRIER +END_OF_PROGRAM + +--------------------------------------- +Pixel shader +--------------------------------------- + +; $MODE = "UniformRegister" +; $UNIFORM_VARS[0].name = "u_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, 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, 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, + 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, 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, 0x00, + 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x18, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 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, 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, 0x44, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x61, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, + 0x6f, 0x6e, 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, 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, 0x18, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x09, 0x20, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x04, 0xa0, 0x3c, 0xa0, 0x00, 0x00, 0x88, 0x06, 0x00, 0x94, + 0x00, 0x40, 0x00, 0x00, 0xff, 0x0f, 0x00, 0x94, 0x22, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xf8, 0x08, 0x00, 0x00, 0x90, 0x0c, 0x20, 0x40, + 0xf9, 0x00, 0x00, 0x80, 0x90, 0x0c, 0x20, 0x60, 0x00, 0x00, 0x00, 0x80, + 0x00, 0x0d, 0x00, 0x00, 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, + 0x75, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 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, 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, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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, 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 +}; diff --git a/src/video/wiiu/wiiu_shaders.h b/src/video/wiiu/wiiu_shaders.h index bd878b8c9..812229a71 100644 --- a/src/video/wiiu/wiiu_shaders.h +++ b/src/video/wiiu/wiiu_shaders.h @@ -37,8 +37,8 @@ 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); + WHBGfxInitShaderAttribute(&wiiuTextureShader, "a_position", 0, 0, GX2_ATTRIB_FORMAT_FLOAT_32_32); + WHBGfxInitShaderAttribute(&wiiuTextureShader, "a_texCoordIn", 1, 0, GX2_ATTRIB_FORMAT_FLOAT_32_32); WHBGfxInitFetchShader(&wiiuTextureShader); } wiiuTextureShaderInit++; @@ -62,7 +62,7 @@ int wiiuColorShaderInit = 0; static inline void wiiuInitColorShader() { if (!wiiuColorShaderInit) { WHBGfxLoadGFDShaderGroup(&wiiuColorShader, 0, wiiuColorShaderData); - WHBGfxInitShaderAttribute(&wiiuColorShader, "position", 0, 0, GX2_ATTRIB_FORMAT_FLOAT_32_32); + WHBGfxInitShaderAttribute(&wiiuColorShader, "a_position", 0, 0, GX2_ATTRIB_FORMAT_FLOAT_32_32); WHBGfxInitFetchShader(&wiiuColorShader); } wiiuColorShaderInit++;