Merge pull request #172 from Crow-bar/upd-gu

gu: speedup
This commit is contained in:
Wouter Wijsman
2024-02-02 14:51:34 +01:00
committed by GitHub
3 changed files with 79 additions and 95 deletions

View File

@@ -31,5 +31,5 @@ libpspgu_a_SOURCES = callbackFin.c callbackSig.c guInternal.c resetValues.c sceG
sceGuSignal.c sceGuSpecular.c sceGuStart.c sceGuStencilFunc.c sceGuStencilOp.c \ sceGuSignal.c sceGuSpecular.c sceGuStart.c sceGuStencilFunc.c sceGuStencilOp.c \
sceGuSwapBuffers.c sceGuSync.c sceGuTerm.c sceGuTexEnvColor.c sceGuTexFilter.c sceGuTexFlush.c sceGuTexFunc.c \ sceGuSwapBuffers.c sceGuSync.c sceGuTerm.c sceGuTexEnvColor.c sceGuTexFilter.c sceGuTexFlush.c sceGuTexFunc.c \
sceGuTexImage.c sceGuTexLevelMode.c sceGuTexMapMode.c sceGuTexMode.c sceGuTexOffset.c sceGuTexProjMapMode.c \ sceGuTexImage.c sceGuTexLevelMode.c sceGuTexMapMode.c sceGuTexMode.c sceGuTexOffset.c sceGuTexProjMapMode.c \
sceGuTexScale.c sceGuTexSlope.c sceGuTexSync.c sceGuTexWrap.c sceGuViewport.c sendCommand.c sceGuTexScale.c sceGuTexSlope.c sceGuTexSync.c sceGuTexWrap.c sceGuViewport.c

View File

@@ -17,109 +17,130 @@ typedef struct
{ {
GuCallback sig; GuCallback sig;
GuCallback fin; GuCallback fin;
short signal_history[16]; short signal_history[16];
int signal_offset; int signal_offset;
int kernel_event_flag; int kernel_event_flag;
int ge_callback_id; int ge_callback_id;
GuSwapBuffersCallback swapBuffersCallback; GuSwapBuffersCallback swapBuffersCallback;
int swapBuffersBehaviour; int swapBuffersBehaviour;
} GuSettings; } GuSettings;
typedef struct typedef struct
{ {
unsigned int* start; unsigned int* start;
unsigned int* current; unsigned int* current;
int parent_context; int parent_context;
} GuDisplayList; } GuDisplayList;
typedef struct typedef struct
{ {
GuDisplayList list; GuDisplayList list;
int scissor_enable; int scissor_enable;
int scissor_start[2]; int scissor_start[2];
int scissor_end[2]; int scissor_end[2];
int near_plane; int near_plane;
int far_plane; int far_plane;
int depth_offset; int depth_offset;
int fragment_2x; int fragment_2x;
int texture_function; int texture_function;
int texture_proj_map_mode; int texture_proj_map_mode;
int texture_map_mode; int texture_map_mode;
int sprite_mode[4]; int sprite_mode[4];
unsigned int clear_color; unsigned int clear_color;
unsigned int clear_stencil; unsigned int clear_stencil;
unsigned int clear_depth; unsigned int clear_depth;
int texture_mode; int texture_mode;
} GuContext; } GuContext;
typedef struct typedef struct
{ {
int pixel_size; int pixel_size;
int frame_width; int frame_width;
void* frame_buffer; void* frame_buffer;
void* disp_buffer; void* disp_buffer;
void* depth_buffer; void* depth_buffer;
int depth_width; int depth_width;
int width; int width;
int height; int height;
} GuDrawBuffer; } GuDrawBuffer;
typedef struct typedef struct
{ {
/* row 0 */ /* row 0 */
unsigned char enable; // Light enable unsigned char enable; // Light enable
unsigned char type; // Light type unsigned char type; // Light type
unsigned char xpos; // X position unsigned char xpos; // X position
unsigned char ypos; // Y position unsigned char ypos; // Y position
/* row 1 */ /* row 1 */
unsigned char zpos; // Z position unsigned char zpos; // Z position
unsigned char xdir; // X direction unsigned char xdir; // X direction
unsigned char ydir; // Y direction unsigned char ydir; // Y direction
unsigned char zdir; // Z direction unsigned char zdir; // Z direction
/* row 2 */ /* row 2 */
unsigned char ambient; // Ambient color unsigned char ambient; // Ambient color
unsigned char diffuse; // Diffuse color unsigned char diffuse; // Diffuse color
unsigned char specular; // Specular color unsigned char specular; // Specular color
unsigned char constant; // Constant attenuation unsigned char constant; // Constant attenuation
/* row 3 */ /* row 3 */
unsigned char linear; // Linear attenuation unsigned char linear; // Linear attenuation
unsigned char quadratic;// Quadratic attenuation unsigned char quadratic;// Quadratic attenuation
unsigned char exponent; // Light exponent unsigned char exponent; // Light exponent
unsigned char cutoff; // Light cutoff unsigned char cutoff; // Light cutoff
} GuLightSettings; } GuLightSettings;
extern unsigned int gu_current_frame; extern unsigned int gu_current_frame;
extern GuContext gu_contexts[3]; extern GuContext gu_contexts[3];
extern int ge_list_executed[2]; extern int ge_list_executed[2];
extern void* ge_edram_address; extern void* ge_edram_address;
extern GuSettings gu_settings; extern GuSettings gu_settings;
extern GuDisplayList* gu_list; extern GuDisplayList* gu_list;
extern int gu_curr_context; extern int gu_curr_context;
extern int gu_init; extern int gu_init;
extern int gu_display_on; extern int gu_display_on;
extern int gu_call_mode; extern int gu_call_mode;
extern int gu_states; extern int gu_states;
extern GuDrawBuffer gu_draw_buffer; extern GuDrawBuffer gu_draw_buffer;
extern unsigned int* gu_object_stack[]; extern unsigned int* gu_object_stack[];
extern int gu_object_stack_depth; extern int gu_object_stack_depth;
extern GuLightSettings light_settings[4]; extern GuLightSettings light_settings[4];
void sendCommandi(int cmd, int argument);
void sendCommandiStall(int cmd, int argument);
void sendCommandf(int cmd, float argument);
void callbackSig(int id, void* arg); void callbackSig(int id, void* arg);
void callbackFin(int id, void* arg); void callbackFin(int id, void* arg);
void resetValues(); void resetValues();
static __inline__ void sendCommandi(int cmd, int argument)
{
*(gu_list->current++) = (cmd << 24) | (argument & 0xffffff);
}
static __inline__ void sendCommandf(int cmd, float argument)
{
union
{
float f;
unsigned int i;
} t;
t.f = argument;
sendCommandi(cmd,t.i >> 8);
}
static __inline__ void sendCommandiStall(int cmd, int argument)
{
sendCommandi(cmd,argument);
if (!gu_object_stack_depth && !gu_curr_context)
sceGeListUpdateStallAddr(ge_list_executed[0],gu_list->current);
}
#endif #endif

View File

@@ -1,37 +0,0 @@
/*
* PSP Software Development Kit - https://github.com/pspdev
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* Copyright (c) 2005 Jesper Svennevid
*/
#include "guInternal.h"
#include <pspkernel.h>
#include <pspge.h>
void sendCommandi(int cmd, int argument)
{
*(gu_list->current++) = (cmd << 24) | (argument & 0xffffff);
}
void sendCommandf(int cmd, float argument)
{
union
{
float f;
unsigned int i;
} t;
t.f = argument;
sendCommandi(cmd,t.i >> 8);
}
void sendCommandiStall(int cmd, int argument)
{
sendCommandi(cmd,argument);
if (!gu_object_stack_depth && !gu_curr_context)
sceGeListUpdateStallAddr(ge_list_executed[0],gu_list->current);
}