mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-22 23:49:50 +00:00
(WIIU) fix net logger.
This commit is contained in:
parent
73c36c47e2
commit
e63697dca7
@ -351,16 +351,17 @@ static ssize_t wiiu_log_write(struct _reent *r, void *fd, const char *ptr, size_
|
||||
wiiu_log_lock = 1;
|
||||
|
||||
int ret;
|
||||
int remaining = len;
|
||||
|
||||
while (len > 0)
|
||||
while (remaining > 0)
|
||||
{
|
||||
int block = len < 1400 ? len : 1400; // take max 1400 bytes per UDP packet
|
||||
int block = remaining < 1400 ? remaining : 1400; // take max 1400 bytes per UDP packet
|
||||
ret = send(wiiu_log_socket, ptr, block, 0);
|
||||
|
||||
if (ret < 0)
|
||||
break;
|
||||
|
||||
len -= ret;
|
||||
remaining -= ret;
|
||||
ptr += ret;
|
||||
}
|
||||
|
||||
|
14
wiiu/run.sh
Normal file
14
wiiu/run.sh
Normal file
@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ -z $1 ] ; then
|
||||
echo
|
||||
echo "usage: $0 <rpx>"
|
||||
echo
|
||||
exit 0
|
||||
fi
|
||||
|
||||
wiiload $1
|
||||
|
||||
echo ===== START: `date` =====
|
||||
netcat -p 4405 -l
|
||||
echo ===== END: `date` =====
|
151
wiiu/shader_utils.c
Normal file
151
wiiu/shader_utils.c
Normal file
@ -0,0 +1,151 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <wiiu/gx2.h>
|
||||
#include <wiiu/system/memory.h>
|
||||
#include <wiiu/shader_utils.h>
|
||||
#include <wiiu/wiiu_dbg.h>
|
||||
|
||||
/* this is a hack for elf builds since their data section is below 0x10000000
|
||||
* and thus can't be accessed by the GX2 hardware */
|
||||
#ifndef GX2_CAN_ACCESS_DATA_SECTION
|
||||
typedef struct
|
||||
{
|
||||
void* vs_program;
|
||||
void* ps_program;
|
||||
void* gs_program;
|
||||
void* gs_copy_program;
|
||||
}org_programs_t;
|
||||
#endif
|
||||
|
||||
void GX2InitShader(GX2Shader* shader)
|
||||
{
|
||||
if (shader->fs.program)
|
||||
return;
|
||||
|
||||
shader->fs.size = GX2CalcFetchShaderSizeEx(shader->vs.attribVarCount,
|
||||
GX2_FETCH_SHADER_TESSELLATION_NONE, GX2_TESSELLATION_MODE_DISCRETE);
|
||||
#ifdef GX2_CAN_ACCESS_DATA_SECTION
|
||||
shader->fs.program = MEM2_alloc(shader->fs.size, GX2_SHADER_ALIGNMENT);
|
||||
#else
|
||||
shader->fs.program = MEM2_alloc(shader->fs.size + sizeof(org_programs_t), GX2_SHADER_ALIGNMENT);
|
||||
#endif
|
||||
GX2InitFetchShaderEx(&shader->fs, (uint8_t*)shader->fs.program,
|
||||
shader->vs.attribVarCount,
|
||||
shader->attribute_stream,
|
||||
GX2_FETCH_SHADER_TESSELLATION_NONE, GX2_TESSELLATION_MODE_DISCRETE);
|
||||
GX2Invalidate(GX2_INVALIDATE_MODE_CPU_SHADER, shader->fs.program, shader->fs.size);
|
||||
|
||||
#ifndef GX2_CAN_ACCESS_DATA_SECTION
|
||||
org_programs_t* org = (org_programs_t*)(shader->fs.program + shader->fs.size);
|
||||
org->vs_program = shader->vs.program;
|
||||
org->ps_program = shader->ps.program;
|
||||
org->gs_program = shader->gs.program;
|
||||
org->gs_copy_program = shader->gs.copyProgram;
|
||||
|
||||
shader->vs.program = MEM2_alloc(shader->vs.size, GX2_SHADER_ALIGNMENT);
|
||||
memcpy(shader->vs.program, org->vs_program, shader->vs.size);
|
||||
GX2Invalidate(GX2_INVALIDATE_MODE_CPU_SHADER, shader->vs.program, shader->vs.size);
|
||||
|
||||
shader->ps.program = MEM2_alloc(shader->ps.size, GX2_SHADER_ALIGNMENT);
|
||||
memcpy(shader->ps.program, org->ps_program, shader->ps.size);
|
||||
GX2Invalidate(GX2_INVALIDATE_MODE_CPU_SHADER, shader->ps.program, shader->ps.size);
|
||||
|
||||
if(org->gs_program)
|
||||
{
|
||||
shader->gs.program = MEM2_alloc(shader->gs.size, GX2_SHADER_ALIGNMENT);
|
||||
memcpy(shader->gs.program, org->gs_program, shader->gs.size);
|
||||
GX2Invalidate(GX2_INVALIDATE_MODE_CPU_SHADER, shader->gs.program, shader->gs.size);
|
||||
|
||||
shader->gs.copyProgram = MEM2_alloc(shader->gs.copyProgramSize, GX2_SHADER_ALIGNMENT);
|
||||
memcpy(shader->gs.copyProgram, org->gs_copy_program, shader->gs.copyProgramSize);
|
||||
GX2Invalidate(GX2_INVALIDATE_MODE_CPU_SHADER, shader->gs.copyProgram, shader->gs.copyProgramSize);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void GX2DestroyShader(GX2Shader* shader)
|
||||
{
|
||||
#ifndef GX2_CAN_ACCESS_DATA_SECTION
|
||||
MEM2_free(shader->vs.program);
|
||||
MEM2_free(shader->ps.program);
|
||||
MEM2_free(shader->gs.program);
|
||||
MEM2_free(shader->gs.copyProgram);
|
||||
|
||||
org_programs_t* org = (org_programs_t*)(shader->fs.program + shader->fs.size);
|
||||
|
||||
shader->vs.program = org->vs_program;
|
||||
shader->ps.program = org->ps_program;
|
||||
shader->gs.program = org->gs_program;
|
||||
shader->gs.copyProgram = org->gs_copy_program;
|
||||
#endif
|
||||
|
||||
MEM2_free(shader->fs.program);
|
||||
shader->fs.program = NULL;
|
||||
}
|
||||
|
||||
void GX2SetShader(GX2Shader* shader)
|
||||
{
|
||||
GX2SetVertexShader(&shader->vs);
|
||||
GX2SetPixelShader(&shader->ps);
|
||||
GX2SetFetchShader(&shader->fs);
|
||||
if(shader->gs.program)
|
||||
GX2SetGeometryShader(&shader->gs);
|
||||
}
|
||||
|
||||
|
||||
void check_shader_verbose(u32* shader, u32 shader_size, u32* org, u32 org_size, const char* name)
|
||||
{
|
||||
printf("%s :\n", name);
|
||||
DEBUG_VAR(shader_size);
|
||||
DEBUG_VAR(org_size);
|
||||
|
||||
if(shader_size != org_size)
|
||||
printf("size mismatch : 0x%08X should be 0x%08X\n", shader_size, org_size);
|
||||
|
||||
for(int i = 0; i < shader_size / 4; i+=4)
|
||||
{
|
||||
printf("0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X\n",
|
||||
shader[i], shader[i+1], shader[i+2], shader[i+3],
|
||||
org[i], org[i+1], org[i+2], org[i+3]);
|
||||
}
|
||||
|
||||
for(int i = 0; i < shader_size / 4; i++)
|
||||
{
|
||||
if (shader[i] != org[i])
|
||||
{
|
||||
printf("%i(%X): 0x%08X(0x%08X) should be 0x%08X(0x%08X) \n", i, i, shader[i], __builtin_bswap32(shader[i]) , org[i], __builtin_bswap32(org[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
void check_shader(const void* shader_, u32 shader_size, const void* org_, u32 org_size, const char* name)
|
||||
{
|
||||
u32* shader = (u32*)shader_;
|
||||
u32* org = (u32*)org_;
|
||||
bool different = false;
|
||||
printf("%-20s : ", name);
|
||||
if(shader_size != org_size)
|
||||
{
|
||||
different = true;
|
||||
printf("\nsize mismatch : 0x%08X should be 0x%08X", shader_size, org_size);
|
||||
}
|
||||
|
||||
|
||||
for(int i = 0; i < shader_size / 4; i++)
|
||||
{
|
||||
if (shader[i] != org[i])
|
||||
{
|
||||
different = true;
|
||||
printf("\n%i(%X): 0x%08X(0x%08X) should be 0x%08X(0x%08X)", i, i, shader[i], __builtin_bswap32(shader[i]) , org[i], __builtin_bswap32(org[i]));
|
||||
}
|
||||
}
|
||||
|
||||
if(!different)
|
||||
printf("no errors");
|
||||
|
||||
printf("\n");
|
||||
|
||||
}
|
||||
|
67
wiiu/shader_utils.h
Normal file
67
wiiu/shader_utils.h
Normal file
@ -0,0 +1,67 @@
|
||||
#pragma once
|
||||
|
||||
#include <wiiu/gx2/shaders.h>
|
||||
|
||||
/* incompatible with elf builds */
|
||||
//#define GX2_CAN_ACCESS_DATA_SECTION
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef union
|
||||
__attribute__((aligned (16)))
|
||||
{
|
||||
struct __attribute__((scalar_storage_order ("little-endian")))
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
};
|
||||
struct __attribute__((scalar_storage_order ("little-endian")))
|
||||
{
|
||||
float width;
|
||||
float height;
|
||||
};
|
||||
}GX2_vec2;
|
||||
|
||||
typedef struct
|
||||
__attribute__((aligned (16)))
|
||||
__attribute__((scalar_storage_order ("little-endian")))
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
union
|
||||
{
|
||||
struct __attribute__((scalar_storage_order ("little-endian")))
|
||||
{
|
||||
float z;
|
||||
float w;
|
||||
};
|
||||
struct __attribute__((scalar_storage_order ("little-endian")))
|
||||
{
|
||||
float width;
|
||||
float height;
|
||||
};
|
||||
};
|
||||
}GX2_vec4;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GX2VertexShader vs;
|
||||
GX2PixelShader ps;
|
||||
GX2GeometryShader gs;
|
||||
GX2FetchShader fs;
|
||||
GX2AttribStream* attribute_stream;
|
||||
}GX2Shader;
|
||||
|
||||
void GX2InitShader(GX2Shader* shader);
|
||||
void GX2DestroyShader(GX2Shader* shader);
|
||||
void GX2SetShader(GX2Shader* shader);
|
||||
|
||||
void check_shader(const void* shader_, u32 shader_size, const void* org_, u32 org_size, const char* name);
|
||||
void check_shader_verbose(u32* shader, u32 shader_size, u32* org, u32 org_size, const char* name);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
319
wiiu/sprite_shader.c
Normal file
319
wiiu/sprite_shader.c
Normal file
@ -0,0 +1,319 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2014-2016 - Ali Bouhlel
|
||||
*
|
||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <malloc.h>
|
||||
#include <string.h>
|
||||
#include <wiiu/gx2/common.h>
|
||||
#include "sprite_shader.h"
|
||||
#include "gx2_shader_inl.h"
|
||||
|
||||
__attribute__((aligned(GX2_SHADER_ALIGNMENT)))
|
||||
static struct
|
||||
{
|
||||
u64 cf[32];
|
||||
u64 alu[26];
|
||||
} vs_program =
|
||||
{
|
||||
{
|
||||
CALL_FS NO_BARRIER,
|
||||
ALU(32, 26) KCACHE0(CB1, _0_15) KCACHE1(CB2, _0_15),
|
||||
MEM_RING(WRITE( 0), _R1, _xyzw, ARRAY_SIZE(1), ELEM_SIZE(3)) BURSTCNT(1),
|
||||
MEM_RING(WRITE(32), _R0, _xyzw, ARRAY_SIZE(0), ELEM_SIZE(3)) NO_BARRIER
|
||||
END_OF_PROGRAM
|
||||
},
|
||||
{
|
||||
ALU_MOV_x2(_R127,_x, _R3,_y), //@64
|
||||
ALU_MOV_x2(__,_y, _R3,_x),
|
||||
ALU_MOV_x2(_R127,_z, _R3,_w),
|
||||
ALU_MOV_x2(__,_w, _R3,_z), //@70
|
||||
ALU_RECIP_IEEE(__,__, KC0(0), _x) SCL_210
|
||||
ALU_LAST,
|
||||
ALU_MUL_IEEE(_R0,_z, ALU_SRC_PV, _w, ALU_SRC_PS, _x),
|
||||
ALU_MUL_IEEE(__,_w, ALU_SRC_PV,_y, ALU_SRC_PS,_x),
|
||||
ALU_RECIP_IEEE(__,_z, KC0(0),_y) SCL_210
|
||||
ALU_LAST,
|
||||
ALU_ADD(_R0,_x, ALU_SRC_PV,_w, ALU_SRC_1 _NEG,_x), //@80
|
||||
ALU_MUL_IEEE(__,_z, _R127,_x, ALU_SRC_PS,_x),
|
||||
ALU_MUL_IEEE(_R0,_w, _R127,_z, ALU_SRC_PS,_x),
|
||||
ALU_RECIP_IEEE(__,__, KC1(0),_x) SCL_210
|
||||
ALU_LAST,
|
||||
ALU_MUL_IEEE(_R3,_x, _R2,_x, ALU_SRC_PS,_x),
|
||||
ALU_ADD(_R0,_y, ALU_SRC_PV _NEG,_z, ALU_SRC_1,_x), //@90
|
||||
ALU_MUL_IEEE(_R3,_z, _R2,_z, ALU_SRC_PS,_x),
|
||||
ALU_RECIP_IEEE(__,__, KC1(0),_y) SCL_210
|
||||
ALU_LAST,
|
||||
ALU_MUL_IEEE(_R3,_y, _R2,_y, ALU_SRC_PS,_x),
|
||||
ALU_MUL_IEEE(_R3,_w, _R2,_w, ALU_SRC_PS,_x)
|
||||
ALU_LAST,
|
||||
ALU_MOV(_R1,_x, _R1,_x), //@100
|
||||
ALU_MOV(_R1,_y, _R1,_y),
|
||||
ALU_MOV(_R1,_z, _R1,_z),
|
||||
ALU_MOV(_R1,_w, _R1,_w)
|
||||
ALU_LAST,
|
||||
ALU_MOV(_R2,_x, _R3,_x),
|
||||
ALU_MOV(_R2,_y, _R3,_y),
|
||||
ALU_MOV(_R2,_z, _R3,_z),
|
||||
ALU_MOV(_R2,_w, _R3,_w)
|
||||
ALU_LAST,
|
||||
}
|
||||
};
|
||||
|
||||
__attribute__((aligned(GX2_SHADER_ALIGNMENT)))
|
||||
static struct
|
||||
{
|
||||
u64 cf[32]; // @0
|
||||
u64 alu[16]; // @32
|
||||
u64 tex[1 * 2]; // @48
|
||||
} ps_program =
|
||||
{
|
||||
{
|
||||
TEX(48, 1) VALID_PIX,
|
||||
ALU(32, 4),
|
||||
EXP_DONE(PIX0, _R0, _x, _y, _z, _w)
|
||||
END_OF_PROGRAM
|
||||
},
|
||||
{
|
||||
ALU_MUL(_R0,_x, _R0,_x, _R1,_x),
|
||||
ALU_MUL(_R0,_y, _R0,_y, _R1,_y),
|
||||
ALU_MUL(_R0,_z, _R0,_z, _R1,_z),
|
||||
ALU_MUL(_R0,_w, _R0,_w, _R1,_w)
|
||||
ALU_LAST,
|
||||
},
|
||||
{
|
||||
TEX_SAMPLE(_R1,_x,_y,_z,_w, _R1,_x,_y,_0,_x, _t0, _s0)
|
||||
}
|
||||
};
|
||||
|
||||
__attribute__((aligned(GX2_SHADER_ALIGNMENT)))
|
||||
static struct
|
||||
{
|
||||
u64 cf[32]; // @0
|
||||
u64 alu[80-32]; // @32
|
||||
u64 tex[3 * 2]; // @80
|
||||
} gs_program =
|
||||
{
|
||||
{
|
||||
TEX(80, 3),
|
||||
MEM_RING(WRITE( 0), _R7, _xyzw, ARRAY_SIZE(0), ELEM_SIZE(3)),
|
||||
ALU(32, 33),
|
||||
MEM_RING(WRITE( 16), _R2, _xy__, ARRAY_SIZE(0), ELEM_SIZE(3)),
|
||||
MEM_RING(WRITE( 32), _R3, _xyzw, ARRAY_SIZE(0), ELEM_SIZE(3)) NO_BARRIER,
|
||||
EMIT_VERTEX,
|
||||
MEM_RING(WRITE( 48), _R7, _xyzw, ARRAY_SIZE(0), ELEM_SIZE(3)) NO_BARRIER,
|
||||
MEM_RING(WRITE( 64), _R4, _xy__, ARRAY_SIZE(0), ELEM_SIZE(3)) NO_BARRIER,
|
||||
MEM_RING(WRITE( 80), _R0, _xyzw, ARRAY_SIZE(0), ELEM_SIZE(3)) NO_BARRIER,
|
||||
EMIT_VERTEX,
|
||||
MEM_RING(WRITE( 96), _R7, _xyzw, ARRAY_SIZE(0), ELEM_SIZE(3)) NO_BARRIER,
|
||||
MEM_RING(WRITE(112), _R5, _xy__, ARRAY_SIZE(0), ELEM_SIZE(3)) NO_BARRIER,
|
||||
MEM_RING(WRITE(128), _R6, _xyzw, ARRAY_SIZE(0), ELEM_SIZE(3)) NO_BARRIER,
|
||||
EMIT_VERTEX,
|
||||
MEM_RING(WRITE(144), _R7, _xyzw, ARRAY_SIZE(0), ELEM_SIZE(3)) NO_BARRIER,
|
||||
MEM_RING(WRITE(160), _R8, _xy__, ARRAY_SIZE(0), ELEM_SIZE(3)) NO_BARRIER,
|
||||
MEM_RING(WRITE(176), _R9, _xyzw, ARRAY_SIZE(0), ELEM_SIZE(3)) NO_BARRIER,
|
||||
EMIT_VERTEX
|
||||
END_OF_PROGRAM
|
||||
},
|
||||
{
|
||||
ALU_MOV(_R127,_x, _R1,_z),
|
||||
ALU_MOV(__,_y, ALU_SRC_0,_x),
|
||||
ALU_MOV(_R3,_z, ALU_SRC_0,_x),
|
||||
ALU_MOV(_R127,_w, ALU_SRC_0,_x),
|
||||
ALU_MOV(_R3,_w, ALU_SRC_LITERAL,_x)
|
||||
ALU_LAST,
|
||||
ALU_LITERAL(0x3F800000),
|
||||
ALU_ADD(_R3,_x, _R1,_x, ALU_SRC_PV,_x),
|
||||
ALU_ADD(_R3,_y, _R1,_y, ALU_SRC_PV,_y),
|
||||
ALU_MOV(__,_z, _R0,_z),
|
||||
ALU_MOV(__,_w, ALU_SRC_0,_x),
|
||||
ALU_ADD(_R4,_x, _R0,_x, ALU_SRC_0,_x)
|
||||
ALU_LAST,
|
||||
ALU_ADD(_R2,_x, _R0,_x, ALU_SRC_PV,_z),
|
||||
ALU_ADD(_R2,_y, _R0,_y, ALU_SRC_PV,_w),
|
||||
ALU_MOV(_R127,_z, _R1 _NEG,_w),
|
||||
ALU_MOV(_R126,_w, _R1 _NEG,_w),
|
||||
ALU_ADD(_R4,_y, _R0,_y, ALU_SRC_0,_x)
|
||||
ALU_LAST,
|
||||
ALU_ADD(_R5,_x, _R0,_x, _R0,_z),
|
||||
ALU_ADD(_R5,_y, _R0,_y, _R0,_w),
|
||||
ALU_MOV(__,_z, _R0,_w),
|
||||
ALU_ADD(_R8,_x, _R127,_w, _R0,_x)
|
||||
ALU_LAST,
|
||||
ALU_ADD(_R0,_x, _R1,_x, ALU_SRC_0,_x),
|
||||
ALU_ADD(_R8,_y, ALU_SRC_PV,_z, _R0,_y),
|
||||
ALU_MOV(_R0,_z, _R3,_z),
|
||||
ALU_MOV(_R0,_w, _R3,_w),
|
||||
ALU_ADD(_R0,_y, _R1,_y, ALU_SRC_0,_x)
|
||||
ALU_LAST,
|
||||
ALU_ADD(_R6,_x, _R1,_x, _R127,_x) VEC_021,
|
||||
ALU_ADD(_R6,_y, _R1,_y, _R127,_z),
|
||||
ALU_MOV(_R6,_z, _R3,_z),
|
||||
ALU_MOV(_R6,_w, _R3,_w),
|
||||
ALU_ADD(_R9,_x, _R127,_w, _R1,_x)
|
||||
ALU_LAST,
|
||||
ALU_ADD(_R9,_y, _R126,_w, _R1,_y),
|
||||
ALU_MOV(_R9,_z, _R3,_z),
|
||||
ALU_MOV(_R9,_w, _R3,_w) VEC_120
|
||||
ALU_LAST,
|
||||
},
|
||||
{
|
||||
VTX_FETCH(_R7,_x,_y,_z,_w, _R0,_x, _b(159), FETCH_TYPE(NO_INDEX_OFFSET), MEGA(16), OFFSET(0)), // @160
|
||||
VTX_FETCH(_R1,_x,_y,_z,_w, _R0,_x, _b(159), FETCH_TYPE(NO_INDEX_OFFSET), MEGA(16), OFFSET(32)),
|
||||
VTX_FETCH(_R0,_x,_y,_z,_w, _R0,_x, _b(159), FETCH_TYPE(NO_INDEX_OFFSET), MEGA(16), OFFSET(16)),
|
||||
}
|
||||
};
|
||||
|
||||
__attribute__((aligned(GX2_SHADER_ALIGNMENT)))
|
||||
static struct
|
||||
{
|
||||
u64 cf[16]; // @0
|
||||
u64 vtx[3 * 2]; // @16
|
||||
} gs_copy_program=
|
||||
{
|
||||
{
|
||||
VTX(16, 3),
|
||||
EXP_DONE(POS0, _R1,_x,_y,_z,_w),
|
||||
EXP_DONE(PARAM0, _R2,_x,_y,_z,_w) BURSTCNT(1)
|
||||
END_OF_PROGRAM
|
||||
},
|
||||
{
|
||||
VTX_FETCH(_R1,_x,_y,_z,_w, _R0,_x, _b(159), FETCH_TYPE(NO_INDEX_OFFSET), MEGA(16), OFFSET(32)),
|
||||
VTX_FETCH(_R2,_x,_y,_z,_w, _R0,_x, _b(159), FETCH_TYPE(NO_INDEX_OFFSET), MEGA(32), OFFSET(0)),
|
||||
VTX_FETCH(_R3,_x,_y,_z,_w, _R0,_x, _b(159), FETCH_TYPE(NO_INDEX_OFFSET), MINI(16), OFFSET(16)),
|
||||
}
|
||||
};
|
||||
|
||||
static GX2AttribVar attributes[] =
|
||||
{
|
||||
{"position", GX2_SHADER_VAR_TYPE_FLOAT4, 0, 0},
|
||||
{"coords", GX2_SHADER_VAR_TYPE_FLOAT4, 0, 1},
|
||||
{"color", GX2_SHADER_VAR_TYPE_FLOAT4, 0, 2},
|
||||
};
|
||||
|
||||
static GX2AttribStream attribute_stream[] =
|
||||
{
|
||||
{0, 0, offsetof(sprite_vertex_t, pos), GX2_ATTRIB_FORMAT_FLOAT_32_32_32_32,
|
||||
GX2_ATTRIB_INDEX_PER_VERTEX, 0, GX2_COMP_SEL(_x, _y, _z, _w), GX2_ENDIAN_SWAP_DEFAULT},
|
||||
{1, 0, offsetof(sprite_vertex_t, coord), GX2_ATTRIB_FORMAT_FLOAT_32_32_32_32,
|
||||
GX2_ATTRIB_INDEX_PER_VERTEX, 0, GX2_COMP_SEL(_x, _y, _z, _w), GX2_ENDIAN_SWAP_DEFAULT},
|
||||
{2, 0, offsetof(sprite_vertex_t, color), GX2_ATTRIB_FORMAT_UNORM_8_8_8_8,
|
||||
GX2_ATTRIB_INDEX_PER_VERTEX, 0, GX2_COMP_SEL(_x, _y, _z, _w), GX2_ENDIAN_SWAP_DEFAULT},
|
||||
};
|
||||
|
||||
static GX2SamplerVar samplers[] =
|
||||
{
|
||||
{ "s", GX2_SAMPLER_VAR_TYPE_SAMPLER_2D, 0 },
|
||||
};
|
||||
|
||||
GX2UniformBlock uniform_blocks[] =
|
||||
{
|
||||
{"UBO_vp", 1, sizeof(GX2_vec2)},
|
||||
{"UBO_tex", 2, sizeof(GX2_vec2)},
|
||||
};
|
||||
|
||||
|
||||
GX2UniformVar uniform_vars[] =
|
||||
{
|
||||
{"vp_size", GX2_SHADER_VAR_TYPE_FLOAT2, 1, 0, 0},
|
||||
{"tex_size", GX2_SHADER_VAR_TYPE_FLOAT2, 1, 0, 1},
|
||||
};
|
||||
|
||||
GX2Shader sprite_shader =
|
||||
{
|
||||
{
|
||||
{
|
||||
.sq_pgm_resources_vs.num_gprs = 4,
|
||||
.sq_pgm_resources_vs.stack_size = 1,
|
||||
.vgt_primitiveid_en.enable = TRUE,
|
||||
.spi_vs_out_config.vs_export_count = 0,
|
||||
.num_spi_vs_out_id = 0,
|
||||
{
|
||||
{.semantic_0 = 0xFF, .semantic_1 = 0xFF, .semantic_2 = 0xFF, .semantic_3 = 0xFF},
|
||||
{.semantic_0 = 0xFF, .semantic_1 = 0xFF, .semantic_2 = 0xFF, .semantic_3 = 0xFF},
|
||||
{.semantic_0 = 0xFF, .semantic_1 = 0xFF, .semantic_2 = 0xFF, .semantic_3 = 0xFF},
|
||||
{.semantic_0 = 0xFF, .semantic_1 = 0xFF, .semantic_2 = 0xFF, .semantic_3 = 0xFF},
|
||||
{.semantic_0 = 0xFF, .semantic_1 = 0xFF, .semantic_2 = 0xFF, .semantic_3 = 0xFF},
|
||||
{.semantic_0 = 0xFF, .semantic_1 = 0xFF, .semantic_2 = 0xFF, .semantic_3 = 0xFF},
|
||||
{.semantic_0 = 0xFF, .semantic_1 = 0xFF, .semantic_2 = 0xFF, .semantic_3 = 0xFF},
|
||||
{.semantic_0 = 0xFF, .semantic_1 = 0xFF, .semantic_2 = 0xFF, .semantic_3 = 0xFF},
|
||||
{.semantic_0 = 0xFF, .semantic_1 = 0xFF, .semantic_2 = 0xFF, .semantic_3 = 0xFF},
|
||||
{.semantic_0 = 0xFF, .semantic_1 = 0xFF, .semantic_2 = 0xFF, .semantic_3 = 0xFF},
|
||||
},
|
||||
.sq_vtx_semantic_clear = ~0x7,
|
||||
.num_sq_vtx_semantic = 3,
|
||||
{
|
||||
2, 1, 0, 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,
|
||||
},
|
||||
.vgt_vertex_reuse_block_cntl.vtx_reuse_depth = 0x0,
|
||||
.vgt_hos_reuse_depth.reuse_depth = 0x0,
|
||||
}, /* regs */
|
||||
.size = sizeof(vs_program),
|
||||
.program = (uint8_t*)&vs_program,
|
||||
.mode = GX2_SHADER_MODE_GEOMETRY_SHADER,
|
||||
.uniformBlockCount = countof(uniform_blocks), uniform_blocks,
|
||||
.uniformVarCount = countof(uniform_vars), uniform_vars,
|
||||
.attribVarCount = countof(attributes), attributes,
|
||||
.ringItemSize = 12,
|
||||
},
|
||||
{
|
||||
{
|
||||
.sq_pgm_resources_ps.num_gprs = 2,
|
||||
.sq_pgm_exports_ps.export_mode = 0x2,
|
||||
.spi_ps_in_control_0.num_interp = 2,
|
||||
.spi_ps_in_control_0.persp_gradient_ena = 1,
|
||||
.spi_ps_in_control_0.baryc_sample_cntl = spi_baryc_cntl_centers_only,
|
||||
.num_spi_ps_input_cntl = 2, {{.semantic = 0, .default_val = 1},{.semantic = 1, .default_val = 1}},
|
||||
.cb_shader_mask.output0_enable = 0xF,
|
||||
.cb_shader_control.rt0_enable = TRUE,
|
||||
.db_shader_control.z_order = db_z_order_early_z_then_late_z,
|
||||
}, /* regs */
|
||||
.size = sizeof(ps_program),
|
||||
.program = (uint8_t*)&ps_program,
|
||||
.mode = GX2_SHADER_MODE_GEOMETRY_SHADER,
|
||||
.samplerVarCount = countof(samplers), samplers,
|
||||
},
|
||||
{
|
||||
{
|
||||
.sq_pgm_resources_gs.num_gprs = 10,
|
||||
.vgt_gs_out_prim_type = VGT_GS_OUT_PRIMITIVE_TYPE_TRISTRIP,
|
||||
.vgt_gs_mode.mode = VGT_GS_ENABLE_MODE_SCENARIO_G,
|
||||
.vgt_gs_mode.cut_mode = VGT_GS_CUT_MODE_128,
|
||||
.num_spi_vs_out_id = 1,
|
||||
{
|
||||
{.semantic_0 = 0, .semantic_1 = 1, .semantic_2 = 0xFF, .semantic_3 = 0xFF},
|
||||
{.semantic_0 = 0xFF, .semantic_1 = 0xFF, .semantic_2 = 0xFF, .semantic_3 = 0xFF},
|
||||
{.semantic_0 = 0xFF, .semantic_1 = 0xFF, .semantic_2 = 0xFF, .semantic_3 = 0xFF},
|
||||
{.semantic_0 = 0xFF, .semantic_1 = 0xFF, .semantic_2 = 0xFF, .semantic_3 = 0xFF},
|
||||
{.semantic_0 = 0xFF, .semantic_1 = 0xFF, .semantic_2 = 0xFF, .semantic_3 = 0xFF},
|
||||
{.semantic_0 = 0xFF, .semantic_1 = 0xFF, .semantic_2 = 0xFF, .semantic_3 = 0xFF},
|
||||
{.semantic_0 = 0xFF, .semantic_1 = 0xFF, .semantic_2 = 0xFF, .semantic_3 = 0xFF},
|
||||
{.semantic_0 = 0xFF, .semantic_1 = 0xFF, .semantic_2 = 0xFF, .semantic_3 = 0xFF},
|
||||
{.semantic_0 = 0xFF, .semantic_1 = 0xFF, .semantic_2 = 0xFF, .semantic_3 = 0xFF},
|
||||
{.semantic_0 = 0xFF, .semantic_1 = 0xFF, .semantic_2 = 0xFF, .semantic_3 = 0xFF},
|
||||
},
|
||||
.sq_pgm_resources_vs.num_gprs = 4,
|
||||
.sq_gs_vert_itemsize = 12,
|
||||
.spi_vs_out_config.vs_export_count = 1,
|
||||
}, /* regs */
|
||||
.size = sizeof(gs_program),
|
||||
.program = (uint8_t*)&gs_program,
|
||||
.copyProgramSize = sizeof(gs_copy_program),
|
||||
.copyProgram = (uint8_t*)&gs_copy_program,
|
||||
.mode = GX2_SHADER_MODE_GEOMETRY_SHADER,
|
||||
.ringItemSize = 48,
|
||||
},
|
||||
.attribute_stream = attribute_stream,
|
||||
};
|
52
wiiu/sprite_shader.h
Normal file
52
wiiu/sprite_shader.h
Normal file
@ -0,0 +1,52 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2014-2016 - Ali Bouhlel
|
||||
*
|
||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef SPRITE_SHADER_H
|
||||
#define SPRITE_SHADER_H
|
||||
|
||||
#include <wiiu/shader_utils.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
struct
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
float width;
|
||||
float height;
|
||||
}pos;
|
||||
|
||||
struct
|
||||
{
|
||||
float u;
|
||||
float v;
|
||||
float width;
|
||||
float height;
|
||||
}coord;
|
||||
|
||||
u32 color;
|
||||
}sprite_vertex_t;
|
||||
|
||||
extern GX2Shader sprite_shader;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // SPRITE_SHADER_H
|
Loading…
Reference in New Issue
Block a user