mirror of https://github.com/ClassiCube/ClassiCube
PS3: WIP on writing GPU commands directly
This commit is contained in:
parent
8c4d2db9d1
commit
f68f7ffaf0
|
|
@ -6,6 +6,7 @@
|
|||
#include <malloc.h>
|
||||
#include <rsx/rsx.h>
|
||||
#include <sysutil/video.h>
|
||||
#include "rsx_gpu.h"
|
||||
|
||||
static gcmContextData* context;
|
||||
static u32 cur_fb;
|
||||
|
|
@ -335,13 +336,7 @@ static void SetAlphaTest(cc_bool enabled) {
|
|||
}
|
||||
|
||||
static void SetColorWrite(cc_bool r, cc_bool g, cc_bool b, cc_bool a) {
|
||||
unsigned mask = 0;
|
||||
if (r) mask |= GCM_COLOR_MASK_R;
|
||||
if (g) mask |= GCM_COLOR_MASK_G;
|
||||
if (b) mask |= GCM_COLOR_MASK_B;
|
||||
if (a) mask |= GCM_COLOR_MASK_A;
|
||||
|
||||
rsxSetColorMask(context, mask);
|
||||
RSX_set_color_write_mask(context, r, g, b, a);
|
||||
}
|
||||
|
||||
void Gfx_DepthOnlyRendering(cc_bool depthOnly) {
|
||||
|
|
@ -487,7 +482,7 @@ void Gfx_SetViewport(int x, int y, int w, int h) {
|
|||
}
|
||||
|
||||
void Gfx_SetScissor(int x, int y, int w, int h) {
|
||||
rsxSetScissor(context, x, y, w, h);
|
||||
RSX_set_scissor_rect(context, x, y, w, h);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,58 @@
|
|||
/*########################################################################################################################*
|
||||
*-----------------------------------------------------GPU commands--------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
// NOTE: shared with nv2a (Xbox) GPU
|
||||
|
||||
// disables the default increment behaviour when writing multiple registers
|
||||
// E.g. with RSX_3D_COMMAND(cmd, 4):
|
||||
// - default: REG+0 = v1, REG+4 = v2, REG+8 = v3, REG+12= v4
|
||||
// - disable: REG = v1, REG = v2, REG = v3, REG = v4
|
||||
#define RSX_WRITE_SAME_REGISTER 0x40000000
|
||||
|
||||
#define RSX_COMMAND(subchan, cmd, num_params) (((num_params) << 18) | ((subchan) << 13) | (cmd))
|
||||
#define RSX_3D_COMMAND(cmd, num_params) RSX_COMMAND(0, cmd, num_params)
|
||||
|
||||
#include <rsx/nv40.h>
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*---------------------------------------------------GPU command buffer----------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
static CC_INLINE uint32_t* RSX_reserve(gcmContextData* ctx, int count) {
|
||||
if (ctx->current + count > ctx->end) {
|
||||
// TODO handle command buffer overflow properly
|
||||
Process_Abort("Command buffer overflow");
|
||||
}
|
||||
|
||||
uint32_t* p = ctx->current;
|
||||
ctx->current += count;
|
||||
return p;
|
||||
}
|
||||
|
||||
static CC_INLINE uint32_t* RSX_reserve_command(gcmContextData* context, uint32_t cmd, int num_params) {
|
||||
uint32_t* p = RSX_reserve(context, num_params + 1);
|
||||
*p++ = RSX_3D_COMMAND(cmd, num_params);
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*-----------------------------------------------------Raster control------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
static CC_INLINE void RSX_set_scissor_rect(gcmContextData* ctx, int x, int y, int w, int h) {
|
||||
// NV40TCL_SCISSOR_HORIZ, then NV40TCL_SCISSOR_VERTI
|
||||
uint32_t* p = RSX_reserve_command(ctx, NV40TCL_SCISSOR_HORIZ, 2);
|
||||
*p++ = x | (w << 16);
|
||||
*p++ = y | (h << 16);
|
||||
}
|
||||
|
||||
static CC_INLINE void RSX_set_color_write_mask(gcmContextData* ctx, int r, int g, int b, int a) {
|
||||
uint32_t mask = 0;
|
||||
if (r) mask |= GCM_COLOR_MASK_R;
|
||||
if (g) mask |= GCM_COLOR_MASK_G;
|
||||
if (b) mask |= GCM_COLOR_MASK_B;
|
||||
if (a) mask |= GCM_COLOR_MASK_A;
|
||||
|
||||
uint32_t* p = RSX_reserve_command(ctx, NV40TCL_COLOR_MASK, 1);
|
||||
*p++ = mask;
|
||||
}
|
||||
|
|
@ -1,3 +1,8 @@
|
|||
/*########################################################################################################################*
|
||||
*-----------------------------------------------------GPU commands--------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
// NOTE: shared with RSX (PS3) GPU
|
||||
|
||||
// disables the default increment behaviour when writing multiple registers
|
||||
// E.g. with NV2A_3D_COMMAND(cmd, 4):
|
||||
// - default: REG+0 = v1, REG+4 = v2, REG+8 = v3, REG+12= v4
|
||||
|
|
@ -9,6 +14,10 @@
|
|||
|
||||
#define _NV_ALPHAKILL_EN (1 << 2)
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*-----------------------------------------------------GPU pushbuffer------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
static CC_INLINE uint32_t* NV2A_push1(uint32_t* p, int cmd, uint32_t value) {
|
||||
*p++ = NV2A_3D_COMMAND(cmd, 1);
|
||||
*p++ = value;
|
||||
|
|
|
|||
Loading…
Reference in New Issue