mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-24 05:10:42 -04:00
Xbox: Simplify clearing slightly
This commit is contained in:
parent
f701f9a9cb
commit
f5541e7518
@ -96,6 +96,10 @@ static void ResetState(void) {
|
|||||||
// the order ClassiCube specifies quad vertices in are in the wrong order
|
// the order ClassiCube specifies quad vertices in are in the wrong order
|
||||||
// compared to what the GPU expects for front and back facing quads
|
// compared to what the GPU expects for front and back facing quads
|
||||||
|
|
||||||
|
int width = pb_back_buffer_width();
|
||||||
|
int height = pb_back_buffer_height();
|
||||||
|
p = NV2A_set_clear_rect(p, 0, 0, width, height);
|
||||||
|
|
||||||
pb_end(p);
|
pb_end(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,10 +285,10 @@ void Gfx_BindTexture(GfxResourceID texId) {
|
|||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*-----------------------------------------------------State management----------------------------------------------------*
|
*-----------------------------------------------------State management----------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
static PackedCol clearColor;
|
|
||||||
|
|
||||||
void Gfx_ClearColor(PackedCol color) {
|
void Gfx_ClearColor(PackedCol color) {
|
||||||
clearColor = color;
|
uint32_t* p = pb_begin();
|
||||||
|
p = NV2A_set_clear_colour(p, color);
|
||||||
|
pb_end(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gfx_SetFaceCulling(cc_bool enabled) {
|
void Gfx_SetFaceCulling(cc_bool enabled) {
|
||||||
@ -360,17 +364,16 @@ void Gfx_BeginFrame(void) {
|
|||||||
pb_wait_for_vbl();
|
pb_wait_for_vbl();
|
||||||
pb_reset();
|
pb_reset();
|
||||||
pb_target_back_buffer();
|
pb_target_back_buffer();
|
||||||
|
|
||||||
|
uint32_t* p = pb_begin();
|
||||||
|
p = NV2A_reset_control0(p);
|
||||||
|
pb_end(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gfx_ClearBuffers(GfxBuffers buffers) {
|
void Gfx_ClearBuffers(GfxBuffers buffers) {
|
||||||
int width = pb_back_buffer_width();
|
uint32_t* p = pb_begin();
|
||||||
int height = pb_back_buffer_height();
|
p = NV2A_start_clear(p, buffers & GFX_BUFFER_COLOR, buffers & GFX_BUFFER_DEPTH);
|
||||||
|
pb_end(p);
|
||||||
// TODO do ourselves
|
|
||||||
if (buffers & GFX_BUFFER_DEPTH)
|
|
||||||
pb_erase_depth_stencil_buffer(0, 0, width, height);
|
|
||||||
if (buffers & GFX_BUFFER_COLOR)
|
|
||||||
pb_fill(0, 0, width, height, clearColor);
|
|
||||||
|
|
||||||
//pb_erase_text_screen();
|
//pb_erase_text_screen();
|
||||||
while (pb_busy()) { } // Wait for completion TODO: necessary??
|
while (pb_busy()) { } // Wait for completion TODO: necessary??
|
||||||
@ -540,9 +543,6 @@ static struct Matrix _view, _proj, _mvp;
|
|||||||
static void UpdateVSConstants(void) {
|
static void UpdateVSConstants(void) {
|
||||||
uint32_t* p;
|
uint32_t* p;
|
||||||
p = pb_begin();
|
p = pb_begin();
|
||||||
|
|
||||||
// TODO: Have to call this to avoid graphical artifacts. Figure out why
|
|
||||||
p = NV2A_reset_control0(p);
|
|
||||||
|
|
||||||
p = NV2A_set_constant_upload_offset(p, 0);
|
p = NV2A_set_constant_upload_offset(p, 0);
|
||||||
|
|
||||||
|
@ -78,3 +78,31 @@ static uint32_t* NV2A_set_vertex_attrib_format(uint32_t* p, int index, int forma
|
|||||||
MASK(NV097_SET_VERTEX_DATA_ARRAY_FORMAT_SIZE, size) |
|
MASK(NV097_SET_VERTEX_DATA_ARRAY_FORMAT_SIZE, size) |
|
||||||
MASK(NV097_SET_VERTEX_DATA_ARRAY_FORMAT_STRIDE, stride));
|
MASK(NV097_SET_VERTEX_DATA_ARRAY_FORMAT_STRIDE, stride));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*########################################################################################################################*
|
||||||
|
*------------------------------------------------------Buffer clearing----------------------------------------------------*
|
||||||
|
*#########################################################################################################################*/
|
||||||
|
static CC_INLINE uint32_t* NV2A_set_clear_rect(uint32_t* p, int x, int y, int w, int h) {
|
||||||
|
// Sets NV097_SET_CLEAR_RECT_HORIZONTAL then NV097_SET_CLEAR_RECT_VERTICAL
|
||||||
|
return pb_push2(p, NV097_SET_CLEAR_RECT_HORIZONTAL,
|
||||||
|
((x + w - 1) << 16) | x,
|
||||||
|
((y + h - 1) << 16) | y);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CC_INLINE uint32_t* NV2A_set_clear_colour(uint32_t* p, uint32_t colour) {
|
||||||
|
// Sets NV097_SET_ZSTENCIL_CLEAR_VALUE then NV097_SET_COLOR_CLEAR_VALUE
|
||||||
|
return pb_push2(p, NV097_SET_ZSTENCIL_CLEAR_VALUE,
|
||||||
|
0xFFFFFF00, // (depth << 8) | stencil
|
||||||
|
colour);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CC_INLINE uint32_t* NV2A_start_clear(uint32_t* p, int color, int depth) {
|
||||||
|
uint32_t mask = 0;
|
||||||
|
if (color) mask |= NV097_CLEAR_SURFACE_COLOR;
|
||||||
|
if (depth) mask |= NV097_CLEAR_SURFACE_Z;
|
||||||
|
if (depth) mask |= NV097_CLEAR_SURFACE_STENCIL;
|
||||||
|
|
||||||
|
return pb_push1(p, NV097_CLEAR_SURFACE, mask);
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user