mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-08 06:47:23 -04:00
Xbox: Simplify shaders by integrating viewport multiply into matrix multiply
This commit is contained in:
parent
e3d91630ee
commit
199be2f489
Binary file not shown.
@ -10,9 +10,7 @@ struct vOut {
|
||||
|
||||
vOut main(
|
||||
vIn input,
|
||||
uniform float4x4 mvp,
|
||||
uniform float4 vp_scale,
|
||||
uniform float4 vp_offset
|
||||
uniform float4x4 mvp
|
||||
)
|
||||
{
|
||||
vOut result;
|
||||
@ -22,11 +20,6 @@ vOut main(
|
||||
position = mul(position, mvp);
|
||||
position.xyz = position.xyz / position.w;
|
||||
|
||||
position.x = position.x * vp_scale.x + vp_offset.x;
|
||||
position.y = position.y * vp_scale.y + vp_offset.y;
|
||||
position.z = position.z * vp_scale.z + vp_offset.z;
|
||||
//position.w = 1.0 / half_viewport.w;
|
||||
|
||||
result.pos = position;
|
||||
result.col = input.color;
|
||||
return result;
|
||||
|
@ -12,9 +12,7 @@ struct vOut {
|
||||
|
||||
vOut main(
|
||||
vIn input,
|
||||
uniform float4x4 mvp,
|
||||
uniform float4 vp_scale,
|
||||
uniform float4 vp_offset
|
||||
uniform float4x4 mvp
|
||||
)
|
||||
{
|
||||
vOut result;
|
||||
@ -24,11 +22,6 @@ vOut main(
|
||||
position = mul(position, mvp);
|
||||
position.xyz = position.xyz / position.w;
|
||||
|
||||
position.x = position.x * vp_scale.x + vp_offset.x;
|
||||
position.y = position.y * vp_scale.y + vp_offset.y;
|
||||
position.z = position.z * vp_scale.z + vp_offset.z;
|
||||
//position.w = 1.0 / half_viewport.w;
|
||||
|
||||
result.pos = position;
|
||||
result.col = input.color;
|
||||
result.tex = input.tex;
|
||||
|
@ -1206,8 +1206,11 @@ cc_result Audio_QueueChunk(struct AudioContext* ctx, struct AudioChunk* chunk) {
|
||||
|
||||
cc_result Audio_Play(struct AudioContext* ctx) {
|
||||
int format = (ctx->channels == 2) ? VOICE_STEREO_16BIT : VOICE_MONO_16BIT;
|
||||
ASND_SetVoice(ctx->chanID, format, ctx->sampleRate, 0, ctx->bufs[0].samples, ctx->bufs[0].size, ctx->volume, ctx->volume, (ctx->count > 1) ? MusicCallback : NULL);
|
||||
if (ctx->count == 1) ctx->bufs[0].available = true;
|
||||
cc_bool music = ctx->count > 1;
|
||||
|
||||
ASND_SetVoice(ctx->chanID, format, ctx->sampleRate, 0, ctx->bufs[0].samples, ctx->bufs[0].size,
|
||||
ctx->volume, ctx->volume, music ? MusicCallback : NULL);
|
||||
if (!music) ctx->bufs[0].available = true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -555,11 +555,8 @@ static void UpdateVSConstants(void) {
|
||||
p = pb_push1(p, NV097_SET_TRANSFORM_CONSTANT_LOAD, 96);
|
||||
|
||||
// upload transformation matrix
|
||||
pb_push(p++, NV097_SET_TRANSFORM_CONSTANT, 4*4 + 4 + 4);
|
||||
Mem_Copy(p, &_mvp, 16 * 4); p += 16;
|
||||
// Upload viewport too
|
||||
Mem_Copy(p, &vp_scale, 4 * 4); p += 4;
|
||||
Mem_Copy(p, &vp_offset, 4 * 4); p += 4;
|
||||
pb_push(p++, NV097_SET_TRANSFORM_CONSTANT, 4*4);
|
||||
Mem_Copy(p, &_mvp, 16 * 4); p += 16;
|
||||
// Upload constants too
|
||||
//struct Vec4 v = { 1, 1, 1, 1 };
|
||||
//Mem_Copy(p, &v, 4 * 4); p += 4;
|
||||
@ -573,6 +570,16 @@ void Gfx_LoadMatrix(MatrixType type, const struct Matrix* matrix) {
|
||||
*dst = *matrix;
|
||||
|
||||
Matrix_Mul(&_mvp, &_view, &_proj);
|
||||
|
||||
struct Matrix vp = Matrix_Identity;
|
||||
vp.row1.x = vp_scale.x;
|
||||
vp.row2.y = vp_scale.y;
|
||||
vp.row3.z = 8388608;
|
||||
vp.row4.x = vp_offset.x;
|
||||
vp.row4.y = vp_offset.y;
|
||||
vp.row4.z = 8388608;
|
||||
|
||||
Matrix_Mul(&_mvp, &_mvp, &vp);
|
||||
UpdateVSConstants();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user