mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-26 09:41:15 +00:00
Merge pull request #2869 from aliaspider/master
(3DS) change shader format/assembler
This commit is contained in:
commit
8616b21e1f
16
Makefile.ctr
16
Makefile.ctr
@ -352,14 +352,15 @@ else
|
||||
BANNERTOOL = ctr/tools/bannertool.exe
|
||||
endif
|
||||
|
||||
%.o: %.shader
|
||||
python $(AEMSTRO)/aemstro_as.py $< $(notdir $<).shbin
|
||||
$(DEVKITARM)/bin/bin2s $(notdir $<).shbin | $(PREFIX)as -o $@
|
||||
echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(notdir $<).shbin | tr . _)`.h
|
||||
echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(notdir $<).shbin | tr . _)`.h
|
||||
echo "extern const u32" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(notdir $<).shbin | tr . _)`.h
|
||||
rm $(notdir $<).shbin
|
||||
%.o: %.vsh %.gsh
|
||||
$(DEVKITARM)/bin/picasso $^ -o $*.shbin
|
||||
$(DEVKITARM)/bin/bin2s $*.shbin | $(PREFIX)as -o $@
|
||||
rm $*.shbin
|
||||
|
||||
%.o: %.vsh
|
||||
$(DEVKITARM)/bin/picasso $^ -o $*.shbin
|
||||
$(DEVKITARM)/bin/bin2s $*.shbin | $(PREFIX)as -o $@
|
||||
rm $*.shbin
|
||||
|
||||
%.o: %.cpp
|
||||
$(CXX) -c -o $@ $< $(CXXFLAGS) $(INCDIRS)
|
||||
@ -415,7 +416,6 @@ clean:
|
||||
rm -f $(TARGET).smdh
|
||||
rm -f $(TARGET).bnr
|
||||
rm -f $(TARGET).icn
|
||||
rm -f *_shader_shbin.h
|
||||
rm -f ctr/ctr_config_*.o
|
||||
rm -f ctr/3dsx_custom_crt0.o
|
||||
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include <retro_inline.h>
|
||||
|
||||
#include "ctr_gu.h"
|
||||
#include "ctr_sprite_shader_shbin.h"
|
||||
|
||||
#include "../../command_event.h"
|
||||
#include "../../general.h"
|
||||
@ -36,6 +35,8 @@
|
||||
#define CTR_GPU_FRAMEBUFFER ((void*)0x1F119400)
|
||||
#define CTR_GPU_DEPTHBUFFER ((void*)0x1F370800)
|
||||
|
||||
extern const u8 ctr_sprite_shbin[];
|
||||
extern const u32 ctr_sprite_shbin_size;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@ -306,7 +307,7 @@ static void* ctr_init(const video_info_t* video,
|
||||
CTR_TOP_FRAMEBUFFER_WIDTH, CTR_TOP_FRAMEBUFFER_HEIGHT,
|
||||
ctr->menu.texture_width, ctr->menu.texture_height);
|
||||
|
||||
ctr->dvlb = DVLB_ParseFile((u32*)ctr_sprite_shader_shbin, ctr_sprite_shader_shbin_size);
|
||||
ctr->dvlb = DVLB_ParseFile((u32*)ctr_sprite_shbin, ctr_sprite_shbin_size);
|
||||
ctrGuSetVshGsh(&ctr->shader, ctr->dvlb, 2, 2);
|
||||
shaderProgramUse(&ctr->shader);
|
||||
|
||||
@ -337,19 +338,12 @@ static void* ctr_init(const video_info_t* video,
|
||||
|
||||
GPU_SetTextureEnable(GPU_TEXUNIT0);
|
||||
|
||||
GPU_SetTexEnv(0,
|
||||
GPU_TEVSOURCES(GPU_TEXTURE0, GPU_PRIMARY_COLOR, 0),
|
||||
GPU_TEVSOURCES(GPU_TEXTURE0, GPU_PRIMARY_COLOR, 0),
|
||||
GPU_TEVOPERANDS(0, 0, 0),
|
||||
GPU_TEVOPERANDS(0, 0, 0),
|
||||
GPU_MODULATE, GPU_MODULATE,
|
||||
0xFFFFFFFF);
|
||||
|
||||
GPU_SetTexEnv(1, GPU_PREVIOUS,GPU_PREVIOUS, 0, 0, 0, 0, 0);
|
||||
GPU_SetTexEnv(2, GPU_PREVIOUS,GPU_PREVIOUS, 0, 0, 0, 0, 0);
|
||||
GPU_SetTexEnv(3, GPU_PREVIOUS,GPU_PREVIOUS, 0, 0, 0, 0, 0);
|
||||
GPU_SetTexEnv(4, GPU_PREVIOUS,GPU_PREVIOUS, 0, 0, 0, 0, 0);
|
||||
GPU_SetTexEnv(5, GPU_PREVIOUS,GPU_PREVIOUS, 0, 0, 0, 0, 0);
|
||||
GPU_SetTexEnv(0, GPU_TEXTURE0, GPU_TEXTURE0, 0, 0, GPU_REPLACE, GPU_REPLACE, 0);
|
||||
GPU_SetTexEnv(1, GPU_PREVIOUS, GPU_PREVIOUS, 0, 0, 0, 0, 0);
|
||||
GPU_SetTexEnv(2, GPU_PREVIOUS, GPU_PREVIOUS, 0, 0, 0, 0, 0);
|
||||
GPU_SetTexEnv(3, GPU_PREVIOUS, GPU_PREVIOUS, 0, 0, 0, 0, 0);
|
||||
GPU_SetTexEnv(4, GPU_PREVIOUS, GPU_PREVIOUS, 0, 0, 0, 0, 0);
|
||||
GPU_SetTexEnv(5, GPU_PREVIOUS, GPU_PREVIOUS, 0, 0, 0, 0, 0);
|
||||
|
||||
ctrGuSetAttributeBuffers(2,
|
||||
VIRT_TO_PHYS(ctr->menu.frame_coords),
|
||||
@ -614,15 +608,9 @@ static bool ctr_frame(void* data, const void* frame,
|
||||
/* restore */
|
||||
if (ctr->rgb32)
|
||||
{
|
||||
GPU_SetTexEnv(0,
|
||||
GPU_TEVSOURCES(GPU_TEXTURE0, GPU_PRIMARY_COLOR, 0),
|
||||
GPU_TEVSOURCES(GPU_TEXTURE0, GPU_PRIMARY_COLOR, 0),
|
||||
GPU_TEVOPERANDS(0, 0, 0),
|
||||
GPU_TEVOPERANDS(0, 0, 0),
|
||||
GPU_MODULATE, GPU_MODULATE,
|
||||
0xFFFFFFFF);
|
||||
GPU_SetTexEnv(1, GPU_PREVIOUS,GPU_PREVIOUS, 0, 0, 0, 0, 0);
|
||||
GPU_SetTexEnv(2, GPU_PREVIOUS,GPU_PREVIOUS, 0, 0, 0, 0, 0);
|
||||
GPU_SetTexEnv(0, GPU_TEXTURE0, GPU_TEXTURE0, 0, 0, GPU_REPLACE, GPU_REPLACE, 0);
|
||||
GPU_SetTexEnv(1, GPU_PREVIOUS, GPU_PREVIOUS, 0, 0, 0, 0, 0);
|
||||
GPU_SetTexEnv(2, GPU_PREVIOUS, GPU_PREVIOUS, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
if (ctr->menu_texture_enable)
|
||||
|
51
gfx/drivers/ctr_sprite.gsh
Normal file
51
gfx/drivers/ctr_sprite.gsh
Normal file
@ -0,0 +1,51 @@
|
||||
.gsh
|
||||
.entry main_gsh
|
||||
|
||||
; Constants
|
||||
.constf _01N1 (0.0, 1.0, -1.0, 1.0)
|
||||
.alias _0000 _01N1.xxxx
|
||||
.alias _1111 _01N1.yyyy
|
||||
.alias _0101 _01N1.xyxy
|
||||
.alias _N1N1 _01N1.zwzw
|
||||
|
||||
; Inputs
|
||||
.alias sprite_coords v0
|
||||
.alias tex_size v1
|
||||
.alias top_left sprite_coords.xyxy
|
||||
.alias bottom_right sprite_coords.zwzw
|
||||
|
||||
; Outputs
|
||||
.out pos position
|
||||
.out texcoord texcoord0
|
||||
|
||||
.proc main_gsh
|
||||
setemit 0
|
||||
mov pos.xy, top_left.xy
|
||||
mov pos.zw, _N1N1
|
||||
mov texcoord.xy, tex_size.xy
|
||||
emit
|
||||
|
||||
setemit 1
|
||||
mov pos.x, top_left.x
|
||||
mov pos.y, bottom_right.y
|
||||
mov pos.zw, _N1N1
|
||||
mov texcoord.x, tex_size.z
|
||||
mov texcoord.y, tex_size.y
|
||||
emit
|
||||
|
||||
setemit 2, prim inv
|
||||
mov pos.xy, bottom_right.xy
|
||||
mov pos.zw, _N1N1
|
||||
mov texcoord.xy, tex_size.zw
|
||||
emit
|
||||
|
||||
setemit 1, prim
|
||||
mov pos.x, bottom_right.x
|
||||
mov pos.y, top_left.y
|
||||
mov pos.zw, _N1N1
|
||||
mov texcoord.x, tex_size.x
|
||||
mov texcoord.y, tex_size.w
|
||||
emit
|
||||
|
||||
end
|
||||
.end
|
@ -1,86 +0,0 @@
|
||||
.const c20, 1.0, 1.0, 1.0, 1.0
|
||||
.const c21, 0.0, 0.0, 0.0, 0.0
|
||||
.const c22, 0.0, 1.0, 0.0, 1.0
|
||||
.const c23, 0.0, 0.0, -1.0, 1.0
|
||||
|
||||
|
||||
; .in v0, x0,y0,x1,y1
|
||||
; .in v1, tex_w,tex_h
|
||||
|
||||
.out o0, result.position, 0xF
|
||||
.out o1, result.color, 0xF
|
||||
.out o2, result.texcoord0, 0x3
|
||||
|
||||
; .uniform c0, c0, scale_vector
|
||||
|
||||
.vsh main_vsh, endmain_vsh
|
||||
.gsh main_gsh, endmain_gsh
|
||||
|
||||
main_vsh:
|
||||
mul r0, c0, v0 (0x1)
|
||||
add o0, c20, r0 (0x0)
|
||||
mul r1, c0, v1 (0x2)
|
||||
mov r1, c21 (0x3)
|
||||
add o1, c22, r1 (0x0)
|
||||
nop
|
||||
end
|
||||
endmain_vsh:
|
||||
|
||||
main_gsh:
|
||||
setemit vtx0, false, false
|
||||
mov o0, v0 (0x3)
|
||||
|
||||
mov o0, c23 (0x2)
|
||||
mov o1, c20 (0x0)
|
||||
|
||||
mov o2, v1 (0x0)
|
||||
emit
|
||||
|
||||
setemit vtx1, false, false
|
||||
mov o0, v0 (0x4)
|
||||
mov o0, v0 (0x8)
|
||||
|
||||
mov o0, c23 (0x2)
|
||||
mov o1, c20 (0x0)
|
||||
|
||||
mov o2, v1 (0x7)
|
||||
mov o2, v1 (0x9)
|
||||
emit
|
||||
|
||||
setemit vtx2, true, true
|
||||
mov o0, v0 (0x6)
|
||||
|
||||
mov o0, c23 (0x2)
|
||||
mov o1, c20 (0x0)
|
||||
|
||||
mov o2, v1 (0xB)
|
||||
emit
|
||||
|
||||
setemit vtx1, true, false
|
||||
mov o0, v0 (0x7)
|
||||
mov o0, v0 (0x5)
|
||||
|
||||
mov o0, c23 (0x2)
|
||||
mov o1, c20 (0x0)
|
||||
|
||||
mov o2, v1 (0x4)
|
||||
mov o2, v1 (0xA)
|
||||
emit
|
||||
|
||||
nop
|
||||
end
|
||||
endmain_gsh:
|
||||
|
||||
; operand descriptors
|
||||
.opdesc xyzw, xyzw, xyzw ; 0x0
|
||||
.opdesc xyzw, yxyx, yxwz ; 0x1
|
||||
.opdesc __zw, zwzw, xyxy ; 0x2
|
||||
.opdesc xy__, xyzw, xyzw ; 0x3
|
||||
.opdesc x___, xyzw, xyzw ; 0x4
|
||||
.opdesc _y__, xyzw, xyzw ; 0x5
|
||||
.opdesc xy__, zwzw, zwzw ; 0x6
|
||||
.opdesc x___, zwzw, zwzw ; 0x7
|
||||
.opdesc _y__, zwzw, zwzw ; 0x8
|
||||
.opdesc _yzw, xyxy, xyxy ; 0x9
|
||||
.opdesc _yzw, zwzw, zwzw ; 0xA
|
||||
.opdesc xyzw, zwzw, zwzw ; 0xB
|
33
gfx/drivers/ctr_sprite.vsh
Normal file
33
gfx/drivers/ctr_sprite.vsh
Normal file
@ -0,0 +1,33 @@
|
||||
;.vsh
|
||||
.entry main_vsh
|
||||
|
||||
; Uniforms
|
||||
.fvec scale_vector
|
||||
.alias viewport_scale scale_vector.yxyx
|
||||
.alias texture_scale scale_vector.zwzw
|
||||
|
||||
; Constants
|
||||
.constf _01N1 (0.0, 1.0, -1.0, 1.0)
|
||||
.alias _0000 _01N1.xxxx
|
||||
.alias _1111 _01N1.yyyy
|
||||
.alias _0101 _01N1.xyxy
|
||||
|
||||
; Inputs
|
||||
.alias pos_in v0
|
||||
.alias texcoord_in v1
|
||||
|
||||
; Output
|
||||
.out pos position
|
||||
.out texcoord texcoord0
|
||||
.out color color
|
||||
|
||||
.proc main_vsh
|
||||
|
||||
mul r0, viewport_scale, pos_in.yxwz
|
||||
add pos, _1111, r0
|
||||
mul r1.zw, texture_scale, texcoord_in.xyxy
|
||||
mov r1.xy, _0000
|
||||
add texcoord, _0101, r1
|
||||
|
||||
end
|
||||
.end
|
Loading…
Reference in New Issue
Block a user