RetroArch/wiiu/tex_shader.c
2018-01-04 17:38:04 +01:00

128 lines
4.5 KiB
C

/* 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 "tex_shader.h"
#include "gx2_shader_inl.h"
__attribute__((aligned(GX2_SHADER_ALIGNMENT)))
static struct
{
u64 cf[16];
} vs_program =
{
{
CALL_FS NO_BARRIER,
EXP_DONE(POS0, _R1, _x, _y, _0, _1),
EXP_DONE(PARAM0, _R2, _x, _y, _0, _0) NO_BARRIER
END_OF_PROGRAM
}
};
__attribute__((aligned(GX2_SHADER_ALIGNMENT)))
static struct
{
u64 cf[16];
u64 tex[1 * 2];
}
ps_program =
{
{
TEX(16, 1) VALID_PIX,
EXP_DONE(PIX0, _R0, _x, _y, _z, _w)
END_OF_PROGRAM
},
{
TEX_SAMPLE(_R0,_x,_y,_z,_w, _R0,_x,_y,_0,_0, _t0, _s0)
}
};
static GX2AttribVar attributes[] =
{
{ "position", GX2_SHADER_VAR_TYPE_FLOAT2, 0, 0},
{ "tex_coord", GX2_SHADER_VAR_TYPE_FLOAT2, 0, 1},
};
static GX2AttribStream attribute_stream[] =
{
{0, 0, offsetof(tex_shader_vertex_t, pos), GX2_ATTRIB_FORMAT_FLOAT_32_32,
GX2_ATTRIB_INDEX_PER_VERTEX, 0, GX2_COMP_SEL(_x, _y, _0, _1), GX2_ENDIAN_SWAP_DEFAULT},
{1, 0, offsetof(tex_shader_vertex_t, coord), GX2_ATTRIB_FORMAT_FLOAT_32_32,
GX2_ATTRIB_INDEX_PER_VERTEX, 0, GX2_COMP_SEL(_x, _y, _0, _1), GX2_ENDIAN_SWAP_DEFAULT},
};
static GX2SamplerVar samplers[] =
{
{ "s", GX2_SAMPLER_VAR_TYPE_SAMPLER_2D, 0 },
};
GX2Shader tex_shader =
{
{
{
.sq_pgm_resources_vs.num_gprs = 3,
.sq_pgm_resources_vs.stack_size = 1,
.spi_vs_out_config.vs_export_count = 1,
.num_spi_vs_out_id = 1,
{
{.semantic_0 = 0x00, .semantic_1 = 0x01, .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 = ~0x3,
.num_sq_vtx_semantic = 2,
{
0, 1, 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,
},
.vgt_vertex_reuse_block_cntl.vtx_reuse_depth = 0xE,
.vgt_hos_reuse_depth.reuse_depth = 0x10,
}, /* regs */
.size = sizeof(vs_program),
.program = (uint8_t*)&vs_program,
.mode = GX2_SHADER_MODE_UNIFORM_REGISTER,
.attribVarCount = countof(attributes), attributes,
},
{
{
.sq_pgm_resources_ps.num_gprs = 1,
.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_UNIFORM_REGISTER,
.samplerVarCount = countof(samplers), samplers,
},
.attribute_stream = attribute_stream,
};