mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-10 07:49:57 -04:00
PS3: Make texture animations work
This commit is contained in:
parent
9ee529c8c3
commit
4f6d3850f0
@ -3,11 +3,11 @@
|
|||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
.SUFFIXES:
|
.SUFFIXES:
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
ifeq ($(strip $(PSL1GHT)),)
|
ifeq ($(strip $(PS3DEV)),)
|
||||||
$(error "Please set PSL1GHT in your environment. export PSL1GHT=<path>")
|
$(error "Please set PS3DEV in your environment. export PS3DEV=<path>")
|
||||||
endif
|
endif
|
||||||
|
|
||||||
include $(PSL1GHT)/ppu_rules
|
include $(PS3DEV)/ppu_rules
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
# TARGET is the name of the output
|
# TARGET is the name of the output
|
||||||
|
9
misc/ps3/ps_coloured_alpha.fcg
Normal file
9
misc/ps3/ps_coloured_alpha.fcg
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
float4 main
|
||||||
|
(
|
||||||
|
float4 in_color: COLOR
|
||||||
|
) : COLOR
|
||||||
|
{
|
||||||
|
if (in_color.a < 0.5) discard;
|
||||||
|
|
||||||
|
return in_color;
|
||||||
|
}
|
12
misc/ps3/ps_textured_alpha.fcg
Normal file
12
misc/ps3/ps_textured_alpha.fcg
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
float4 main
|
||||||
|
(
|
||||||
|
float4 in_color : COLOR,
|
||||||
|
float2 in_tex0 : TEXCOORD0,
|
||||||
|
uniform sampler2D tex
|
||||||
|
) : COLOR
|
||||||
|
{
|
||||||
|
float4 color = tex2D(tex, in_texcoord) * in_color;
|
||||||
|
|
||||||
|
if (color.a < 0.5) discard;
|
||||||
|
return color;
|
||||||
|
}
|
@ -1,24 +1,11 @@
|
|||||||
struct vIn {
|
void main(
|
||||||
float4 color : DIFFUSE;
|
float4 in_position : POSITION,
|
||||||
float4 position : POSITION;
|
float4 in_color : DIFFUSE,
|
||||||
};
|
uniform float4x4 mvp,
|
||||||
|
out float4 out_pos : POSITION,
|
||||||
struct vOut {
|
out float4 out_color : COLOR)
|
||||||
float4 col : COLOR;
|
|
||||||
float4 pos : POSITION;
|
|
||||||
};
|
|
||||||
|
|
||||||
vOut main(
|
|
||||||
vIn input,
|
|
||||||
uniform float4x4 mvp
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
vOut result;
|
float4 pos = float4(in_position.xyz, 1.0f);
|
||||||
float4 position;
|
out_pos = mul(pos, mvp);
|
||||||
|
out_color = in_color;
|
||||||
position = float4(input.position.xyz, 1.0f);
|
|
||||||
|
|
||||||
result.pos = mul(position, mvp);
|
|
||||||
result.col = input.color;
|
|
||||||
return result;
|
|
||||||
}
|
}
|
@ -1,27 +1,14 @@
|
|||||||
struct vIn {
|
void main(
|
||||||
float4 tex : TEXCOORD;
|
float4 in_position : POSITION,
|
||||||
float4 color : DIFFUSE;
|
float4 in_color : DIFFUSE,
|
||||||
float4 position : POSITION;
|
float4 in_tex : TEXCOORD,
|
||||||
};
|
uniform float4x4 mvp,
|
||||||
|
out float4 out_pos : POSITION,
|
||||||
struct vOut {
|
out float4 out_color : COLOR,
|
||||||
float4 pos : POSITION;
|
out float2 out_tex : TEXCOORD0)
|
||||||
float4 col : COLOR;
|
|
||||||
float4 tex : TEXCOORD0;
|
|
||||||
};
|
|
||||||
|
|
||||||
vOut main(
|
|
||||||
vIn input,
|
|
||||||
uniform float4x4 mvp
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
vOut result;
|
float4 pos = float4(in_position.xyz, 1.0f);
|
||||||
float4 position;
|
out_pos = mul(pos, mvp);
|
||||||
|
out_color = in_color;
|
||||||
position = float4(input.position.xyz, 1.0f);
|
out_tex = in_tex;
|
||||||
|
|
||||||
result.pos = mul(position, mvp);
|
|
||||||
result.col = input.color;
|
|
||||||
result.tex = input.tex;
|
|
||||||
return result;
|
|
||||||
}
|
}
|
@ -1,5 +1,7 @@
|
|||||||
float4 main(
|
float4 main
|
||||||
float4 out_color: COLOR) : COLOR
|
(
|
||||||
|
float4 out_color: COLOR
|
||||||
|
) : COLOR
|
||||||
{
|
{
|
||||||
if (out_color.a < 0.5) discard;
|
if (out_color.a < 0.5) discard;
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
float4 main(
|
float4 main
|
||||||
float4 out_color: COLOR) : COLOR
|
(
|
||||||
|
float4 out_color : COLOR
|
||||||
|
) : COLOR
|
||||||
{
|
{
|
||||||
return out_color;
|
return out_color;
|
||||||
}
|
}
|
@ -1,7 +1,9 @@
|
|||||||
float4 main(
|
float4 main
|
||||||
|
(
|
||||||
uniform sampler2D tex,
|
uniform sampler2D tex,
|
||||||
float4 out_color: COLOR,
|
float4 out_color : COLOR,
|
||||||
float2 out_texcoord : TEXCOORD0) : COLOR
|
float2 out_texcoord : TEXCOORD0
|
||||||
|
) : COLOR
|
||||||
{
|
{
|
||||||
float4 color = tex2D(tex, out_texcoord) * out_color;
|
float4 color = tex2D(tex, out_texcoord) * out_color;
|
||||||
|
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
float4 main(
|
float4 main
|
||||||
|
(
|
||||||
uniform sampler2D tex,
|
uniform sampler2D tex,
|
||||||
float4 out_color: COLOR,
|
float4 out_color : COLOR,
|
||||||
float2 out_texcoord : TEXCOORD0) : COLOR
|
float2 out_texcoord : TEXCOORD0
|
||||||
|
) : COLOR
|
||||||
{
|
{
|
||||||
return tex2D(tex, out_texcoord) * out_color;
|
return tex2D(tex, out_texcoord) * out_color;
|
||||||
}
|
}
|
@ -11,8 +11,10 @@
|
|||||||
/* Current format and size of vertices */
|
/* Current format and size of vertices */
|
||||||
static int gfx_stride, gfx_format = -1;
|
static int gfx_stride, gfx_format = -1;
|
||||||
static cc_bool renderingDisabled;
|
static cc_bool renderingDisabled;
|
||||||
|
static cc_bool alphaTesting;
|
||||||
|
|
||||||
static gcmContextData* context;
|
static gcmContextData* context;
|
||||||
static u32 cur_fb = 0;
|
static u32 cur_fb;
|
||||||
|
|
||||||
#define CB_SIZE 0x100000 // TODO: smaller command buffer?
|
#define CB_SIZE 0x100000 // TODO: smaller command buffer?
|
||||||
#define HOST_SIZE (32 * 1024 * 1024)
|
#define HOST_SIZE (32 * 1024 * 1024)
|
||||||
@ -70,8 +72,10 @@ typedef struct CCFragmentProgram {
|
|||||||
|
|
||||||
extern const u8 ps_textured_fpo[];
|
extern const u8 ps_textured_fpo[];
|
||||||
extern const u8 ps_coloured_fpo[];
|
extern const u8 ps_coloured_fpo[];
|
||||||
|
extern const u8 ps_textured_alpha_fpo[];
|
||||||
|
extern const u8 ps_coloured_alpha_fpo[];
|
||||||
|
|
||||||
static FragmentProgram FP_list[2];
|
static FragmentProgram FP_list[4];
|
||||||
static FragmentProgram* FP_active;
|
static FragmentProgram* FP_active;
|
||||||
|
|
||||||
|
|
||||||
@ -88,10 +92,13 @@ static void FP_Load(FragmentProgram* fp, const u8* source) {
|
|||||||
static void LoadFragmentPrograms(void) {
|
static void LoadFragmentPrograms(void) {
|
||||||
FP_Load(&FP_list[0], ps_coloured_fpo);
|
FP_Load(&FP_list[0], ps_coloured_fpo);
|
||||||
FP_Load(&FP_list[1], ps_textured_fpo);
|
FP_Load(&FP_list[1], ps_textured_fpo);
|
||||||
|
FP_Load(&FP_list[2], ps_coloured_alpha_fpo);
|
||||||
|
FP_Load(&FP_list[3], ps_textured_alpha_fpo);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void FP_SwitchActive(void) {
|
static void FP_SwitchActive(void) {
|
||||||
int index = gfx_format == VERTEX_FORMAT_TEXTURED ? 1 : 0;
|
int index = gfx_format == VERTEX_FORMAT_TEXTURED ? 1 : 0;
|
||||||
|
if (alphaTesting) index += 2; // TODO: Doesn't work
|
||||||
|
|
||||||
FragmentProgram* FP = &FP_list[index];
|
FragmentProgram* FP = &FP_list[index];
|
||||||
if (FP == FP_active) return;
|
if (FP == FP_active) return;
|
||||||
@ -264,7 +271,6 @@ void Gfx_TransferImage(u32 offset, s32 w, s32 h) {
|
|||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*-----------------------------------------------------State management----------------------------------------------------*
|
*-----------------------------------------------------State management----------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
static PackedCol gfx_clearColor;
|
|
||||||
void Gfx_SetFaceCulling(cc_bool enabled) {
|
void Gfx_SetFaceCulling(cc_bool enabled) {
|
||||||
rsxSetCullFaceEnable(context, enabled);
|
rsxSetCullFaceEnable(context, enabled);
|
||||||
}
|
}
|
||||||
@ -298,7 +304,10 @@ void Gfx_SetDepthTest(cc_bool enabled) {
|
|||||||
|
|
||||||
void Gfx_SetTexturing(cc_bool enabled) { }
|
void Gfx_SetTexturing(cc_bool enabled) { }
|
||||||
|
|
||||||
void Gfx_SetAlphaTest(cc_bool enabled) { /* TODO */ }
|
void Gfx_SetAlphaTest(cc_bool enabled) {
|
||||||
|
alphaTesting = enabled;
|
||||||
|
FP_SwitchActive();
|
||||||
|
}
|
||||||
|
|
||||||
void Gfx_DepthOnlyRendering(cc_bool depthOnly) {/* TODO */
|
void Gfx_DepthOnlyRendering(cc_bool depthOnly) {/* TODO */
|
||||||
}
|
}
|
||||||
@ -393,7 +402,7 @@ void Gfx_OnWindowResize(void) {
|
|||||||
f32 zmin = 0.0f;
|
f32 zmin = 0.0f;
|
||||||
f32 zmax = 1.0f;
|
f32 zmax = 1.0f;
|
||||||
|
|
||||||
scale[0] = w * 0.5f;
|
scale[0] = w * 0.5f;
|
||||||
scale[1] = h * -0.5f;
|
scale[1] = h * -0.5f;
|
||||||
scale[2] = (zmax - zmin) * 0.5f;
|
scale[2] = (zmax - zmin) * 0.5f;
|
||||||
scale[3] = 0.0f;
|
scale[3] = 0.0f;
|
||||||
@ -403,7 +412,7 @@ void Gfx_OnWindowResize(void) {
|
|||||||
offset[3] = 0.0f;
|
offset[3] = 0.0f;
|
||||||
|
|
||||||
rsxSetViewport(context, 0, 0, w, h, zmin, zmax, scale, offset);
|
rsxSetViewport(context, 0, 0, w, h, zmin, zmax, scale, offset);
|
||||||
rsxSetScissor(context, 0, 0, w, h);
|
rsxSetScissor(context, 0, 0, w, h);
|
||||||
|
|
||||||
// TODO: even needed?
|
// TODO: even needed?
|
||||||
for (int i = 0; i < 8; i++)
|
for (int i = 0; i < 8; i++)
|
||||||
@ -558,6 +567,12 @@ void Gfx_DeleteTexture(GfxResourceID* texId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Gfx_UpdateTexture(GfxResourceID texId, int x, int y, struct Bitmap* part, int rowWidth, cc_bool mipmaps) {
|
void Gfx_UpdateTexture(GfxResourceID texId, int x, int y, struct Bitmap* part, int rowWidth, cc_bool mipmaps) {
|
||||||
|
CCTexture* tex = (CCTexture*)texId;
|
||||||
|
|
||||||
|
// NOTE: Only valid for LINEAR textures
|
||||||
|
cc_uint32* dst = (tex->pixels + x) + y * tex->width;
|
||||||
|
CopyTextureData(dst, tex->width * 4, part, rowWidth << 2);
|
||||||
|
|
||||||
rsxInvalidateTextureCache(context, GCM_INVALIDATE_TEXTURE);
|
rsxInvalidateTextureCache(context, GCM_INVALIDATE_TEXTURE);
|
||||||
/* TODO */
|
/* TODO */
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user