Permalink
Browse files

prepare to draw changes

  • Loading branch information...
1 parent 435e9f8 commit dce1d420db7d1c2157b58af499bb4c7f7c40ee90 Ced2911 committed Sep 24, 2011
View
4 shaders/ps_psx.hlsl
@@ -10,15 +10,15 @@ struct _IN
float4 psG(_IN data): COLOR {
float4 Color;
- Color = tex2D( tex0, data.uv) * data.col;
+ Color = tex2D( tex0, data.uv.xy) * data.col;
return Color;
}
float4 psF(_IN data): COLOR {
float4 Color;
- Color = tex2D( tex0, data.uv) + data.col;
+ Color = tex2D( tex0, data.uv.xy) + data.col;
return Color;
}
View
62 shaders/psx.vs.h
@@ -4,9 +4,23 @@
//
// fxc /Fh psx.vs.h /Tvs_3_0 vs_psx.hlsl
//
+//
+// Parameters:
+//
+// float2 screenSize;
+//
+//
+// Registers:
+//
+// Name Reg Size
+// ------------ ----- ----
+// screenSize c1 1
+//
+
// Shader type: vertex
xvs_3_0
+defconst screenSize, float, vector, [1, 2], c1
config AutoSerialize=false
config AutoResource=false
config VsMaxReg=2
@@ -20,20 +34,26 @@ dcl_color o1
def c252, 0, 0, 0, 0
def c253, 0, 0, 0, 0
def c254, 0, 0, 0, 0
-def c255, 0, 1, 0, 0
+def c255, 1, 0, 0, 0
exec
- vfetch r2, r0.x, position
- vfetch r1.xy__, r0.x, texcoord
- vfetch r0, r0.x, color
+ vfetch r2.xyz1, r0.x, position
+ vfetch r0.__xy, r0.x, texcoord
+ vfetch r1, r0.x, color
alloc position
exec
- cndeq oPos, c255.yxy, -r2.y, r2.xxzw
+ rcp r0.x, c1.x
+ mov oPos.zw, r2.zzzw
+ add r2.xy, r2.xy, r2.xy
+ + rcp r0.y, c1.y
+ mul r0.xy, r2.yx, r0.yx
+ add oPos.y, -r0.x, c255.x
+ + subsc oPos.x, -c255.x, -r0.y
alloc interpolators
exece
- mov o0.xy, r1.xy
- mov o1, r0
+ mov o0.xy, r0.zw
+ mov o1, r1
// PDB hint 00000000-00000000-00000000
@@ -43,20 +63,24 @@ def c255, 0, 1, 0, 0
const DWORD g_xvs_main[] =
{
- 0x102a1101, 0x000000c4, 0x000000b8, 0x00000000, 0x00000024, 0x00000058,
- 0x00000080, 0x00000000, 0x00000000, 0x00000030, 0x0000001c, 0x00000023,
- 0xfffe0300, 0x00000000, 0x00000000, 0x00000000, 0x0000001c, 0x76735f33,
+ 0x102a1101, 0x000000f4, 0x000000e8, 0x00000000, 0x00000024, 0x00000088,
+ 0x000000b0, 0x00000000, 0x00000000, 0x00000060, 0x0000001c, 0x00000053,
+ 0xfffe0300, 0x00000001, 0x0000001c, 0x00000000, 0x0000004c, 0x00000030,
+ 0x00020001, 0x00010000, 0x0000003c, 0x00000000, 0x73637265, 0x656e5369,
+ 0x7a6500ab, 0x00010003, 0x00010002, 0x00010000, 0x00000000, 0x76735f33,
0x5f300032, 0x2e302e32, 0x30333533, 0x2e3000ab, 0x00000000, 0x00000001,
0x00000000, 0x00000000, 0x00000014, 0x00fc0010, 0x00000000, 0x00000000,
- 0x00000000, 0x00000000, 0x00000040, 0x00000078, 0x00110002, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000040, 0x000000a8, 0x00110002, 0x00000000,
0x00000000, 0x00001842, 0x00000001, 0x00000003, 0x00000002, 0x00000290,
- 0x00100003, 0x00005004, 0x0030a005, 0x00003050, 0x0001f1a0, 0x00001007,
- 0x00001008, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00100003, 0x00005004, 0x0020a005, 0x00003050, 0x0001f1a0, 0x0000100b,
+ 0x0000100c, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
- 0x00000000, 0x00000000, 0x3f800000, 0x00000000, 0x00000000, 0x70153003,
- 0x00001200, 0xc2000000, 0x00001006, 0x00001200, 0xc4000000, 0x00002007,
- 0x00002200, 0x00000000, 0x05f82000, 0x00000688, 0x00000000, 0x05f81000,
- 0x00000fc8, 0x00000000, 0x05f80000, 0x00000688, 0x00000000, 0xc80f803e,
- 0x02bdb10c, 0x6cff0202, 0xc8038000, 0x00b0b000, 0xe2010100, 0xc80f8001,
- 0x00000000, 0xe2000000, 0x00000000, 0x00000000, 0x00000000
+ 0x00000000, 0x3f800000, 0x00000000, 0x00000000, 0x00000000, 0x70153003,
+ 0x00001200, 0xc2000000, 0x00005006, 0x00001200, 0xc4000000, 0x0000200b,
+ 0x00002200, 0x00000000, 0x05f82000, 0x00000a88, 0x00000000, 0x05f80000,
+ 0x0000023f, 0x00000000, 0x05f81000, 0x00000688, 0x00000000, 0x4c100000,
+ 0x0000006c, 0xc2000001, 0xc80c803e, 0x00060600, 0xe2020200, 0x4c230002,
+ 0x00b0b0b1, 0xc0020201, 0xc8030000, 0x006d6d00, 0xe1020000, 0xb812803e,
+ 0x056c6c41, 0x8000ffff, 0xc8038000, 0x001a1a00, 0xe2000000, 0xc80f8001,
+ 0x00000000, 0xe2010100, 0x00000000, 0x00000000, 0x00000000
};
View
19 shaders/vs_psx.hlsl
@@ -1,6 +1,6 @@
struct _IN
{
- float4 pos: POSITION;
+ float3 pos: POSITION;
float2 uv: TEXCOORD0;
float4 col: COLOR0;
};
@@ -12,29 +12,20 @@ struct _OUT
float4 col: COLOR0;
};
-//float4x4 persp: register (c0);// unused
-
float2 screenSize : register(c1);
_OUT main(_IN In )
{
_OUT Out;
- //Out.pos = mul(In.pos,persp);
- // convert coordonate
- // coord 0 - 1
- #if 0
float2 pos;
pos.x = (((In.pos.x)/screenSize.x)*2.f)-1.f;
pos.y = (((In.pos.y)/screenSize.y)*2.f)-1.f;
- //pos.x = (In.pos.x/screenSize.x);
- //pos.y = (In.pos.y/screenSize.y);
+
Out.pos.xy = pos;
- #else
- Out.pos.x = In.pos.x;
- Out.pos.y = -In.pos.y;
- #endif
- Out.pos.zw = In.pos.zw;
+ Out.pos.y = -Out.pos.y;
+ Out.pos.z = In.pos.z;
+ Out.pos.w = 1.0f;
Out.col = In.col;
Out.uv = In.uv;
return Out;
View
115 source/plugins/peopsxgl/gl_api.cpp
@@ -18,7 +18,7 @@
extern struct XenosDevice *xe;
-#define MAX_VERTEX_COUNT 16384
+#define MAX_VERTEX_COUNT 65536
#define MAX_INDICE_COUNT 65536
@@ -35,31 +35,69 @@ int gl_mode = 0;
int off_v = 0;
static struct XenosVertexBuffer *vb = NULL;
+
+static struct XenosVertexBuffer *vb_3 = NULL;
+static struct XenosVertexBuffer *vb_4 = NULL;
+static struct XenosVertexBuffer *vb_3s = NULL;
+
static struct XenosIndexBuffer *ib_tri = NULL;
static struct XenosIndexBuffer *ib_quads = NULL;
static uint16_t prim_tri_strip[] = {0, 1, 2, 2, 1, 3}; // GL_TRIANGLE_STRIP
static uint16_t prim_quads[] = {0, 1, 2, 3, 0, 3}; // GL_QUADS // not used
int indiceCount=0;
-int vertexCount=0;
+//int vertexCount=0;
typedef struct __attribute__((__packed__)) glVerticeFormats {
- float x, y, z, w;
- float u, v;
+ float x, y, z;
+ // float u, v;
float color;
//float r,g,b,a;
} glVerticeFormats;
-glVerticeFormats * currentVertex = NULL;
-
-
+//glVerticeFormats * currentVertex = NULL;
+float * currentVertex = NULL;
static int texture_combiner_enabled = 0;
static int color_combiner_enabled = 0;
+
+int vertexCount_3=0;
+int vertexCount_3s=0;
+int vertexCount_4=0;
+
+int vertexCountZero(){
+ vertexCount_3=0;
+ vertexCount_3s=0;
+ vertexCount_4=0;
+}
+
+int vertexCount(){
+ if(vb){
+ if(vb==vb_3)
+ return vertexCount_3;
+ if(vb==vb_3s)
+ return vertexCount_3s;
+ if(vb==vb_4)
+ return vertexCount_4;
+ }
+ return 0;
+}
+
+void vertexCountAdd(int nb){
+ if(vb){
+ if(vb==vb_3)
+ vertexCount_3+=nb;
+ if(vb==vb_3s)
+ vertexCount_3s+=nb;
+ if(vb==vb_4)
+ vertexCount_4+=nb;
+ }
+}
+
//------------------------------------------------------------------------------
// Changes gl states
//------------------------------------------------------------------------------
@@ -81,9 +119,12 @@ void XeDisableTexture() {
// Lock Unlock Prepare VB
//------------------------------------------------------------------------------
static void glLockVb(int count) {
+// if(vertexCount()>2000)
+// vertexCountZero();
// se deplace dans le vb
- Xe_SetStreamSource(xe, 0, vb, vertexCount, 4);
- currentVertex = (glVerticeFormats *) Xe_VB_Lock(xe, vb, vertexCount, count * sizeof(glVerticeFormats), XE_LOCK_WRITE);
+ Xe_SetStreamSource(xe, 0, vb, vertexCount(), 4);
+ // currentVertex = (glVerticeFormats *) Xe_VB_Lock(xe, vb, vertexCount(), count * sizeof(glVerticeFormats), XE_LOCK_WRITE);
+ currentVertex = (float *) Xe_VB_Lock(xe, vb, vertexCount(), count * sizeof(glVerticeFormats), XE_LOCK_WRITE);
}
@@ -106,13 +147,19 @@ static void glPrepare(int count) {
// Called from xe_display.cpp
//------------------------------------------------------------------------------
void glReset(){
- vertexCount = 0;
+ vertexCountZero();
+}
+
+void glSync(){
+
}
void glInit() {
// Create VB and IB
- vb = Xe_CreateVertexBuffer(xe, MAX_VERTEX_COUNT * sizeof(glVerticeFormats));
+ vb_3 = Xe_CreateVertexBuffer(xe, MAX_VERTEX_COUNT * sizeof(glVerticeFormats));
+ vb_4 = Xe_CreateVertexBuffer(xe, MAX_VERTEX_COUNT * sizeof(glVerticeFormats));
+ vb_3s = Xe_CreateVertexBuffer(xe, MAX_VERTEX_COUNT * sizeof(glVerticeFormats));
ib_tri = Xe_CreateIndexBuffer(xe, 6 * sizeof (uint16_t), XE_FMT_INDEX16);
ib_quads = Xe_CreateIndexBuffer(xe, 6 * sizeof (uint16_t), XE_FMT_INDEX16);
@@ -157,6 +204,22 @@ int glGetModelSize() {
void glBegin(int mode) {
+ switch (gl_mode) {
+ case GL_TRIANGLE_STRIP:
+ {
+ vb = vb_3s;
+ }
+ case GL_TRIANGLES:
+ {
+ vb = vb_3;
+ }
+ case GL_QUADS:
+ {
+ vb = vb_4;
+ }
+ }
+
+
// Lock and zero current vb
glPrepare(glGetModelSize());
@@ -198,12 +261,13 @@ void glEnd() {
{
Xe_SetIndices(xe,NULL);
Xe_DrawPrimitive(xe, XE_PRIMTYPE_QUADLIST, 0, 1);
-
break;
}
}
+
// todo: better alignement fixe
- vertexCount += glGetModelSize() * ( sizeof (glVerticeFormats) );
+ //vertexCount += glGetModelSize() * ( sizeof (glVerticeFormats) );
+ vertexCountAdd(glGetModelSize() * ( sizeof (glVerticeFormats) ));
// Reset color
// gl_color = 0;
@@ -219,18 +283,23 @@ void glTexCoord2fv(float * st) {
}
void glVertex3fv(float * v) {
- currentVertex[off_v].x = ((v[0] / screen[0])*2.f) - 1.0f;
- currentVertex[off_v].y = ((v[1] / screen[1])*2.f) - 1.0f;
-
- currentVertex[off_v].z = v[2];
- currentVertex[off_v].w = 1.f;
- currentVertex[off_v].u = gl_u;
- currentVertex[off_v].v = gl_v;
- currentVertex[off_v].color = gl_color.f;
- off_v++;
+// currentVertex[0].x = v[0];
+// currentVertex[0].y = v[1];
+// currentVertex[0].z = v[2];
+// currentVertex[0].u = gl_u;
+// currentVertex[0].v = gl_v;
+// currentVertex[0].color = gl_color.f;
+// currentVertex++;
+
+ currentVertex[0] = v[0];
+ currentVertex[1] = v[1];
+ currentVertex[2] = v[2];
+ currentVertex[3] = gl_color.f;
+
+ currentVertex+=4;
}
-
void glColor4ubv(u8 *v) {
+
uint32_t c = *(uint32_t*) v;
gl_color.u = c;
color_combiner_enabled = 1;
View
2 source/plugins/peopsxgl/gl_api.h
@@ -21,6 +21,8 @@ void glEnd();
void glInit();
void glReset();
+void glSync();
+
void glTexCoord2fv(float * st);
void glVertex3fv(float * v);
void glColor4ubv (u8 *v);
View
6 source/plugins/peopsxgl/xe_display.cpp
@@ -65,7 +65,7 @@ unsigned long ulInitDisplay() {
static const struct XenosVBFFormat vbf = {
3,
{
- {XE_USAGE_POSITION, 0, XE_TYPE_FLOAT4},
+ {XE_USAGE_POSITION, 0, XE_TYPE_FLOAT3},
{XE_USAGE_TEXCOORD, 0, XE_TYPE_FLOAT2},
{XE_USAGE_COLOR, 0, XE_TYPE_UBYTE4},
}
@@ -122,6 +122,10 @@ extern "C" {
}
void DoBufferSwap() {
+#ifdef USE_GL_API
+ glSync();
+#endif
+
Xe_Resolve(xe);
//while (!Xe_IsVBlank(xe));
Xe_Sync(xe);

0 comments on commit dce1d42

Please sign in to comment.