Skip to content

Commit

Permalink
rsx_Basic_Wallpaper fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
crystalct committed Mar 16, 2021
1 parent fb147a6 commit f7eda89
Show file tree
Hide file tree
Showing 4 changed files with 351 additions and 226 deletions.
93 changes: 14 additions & 79 deletions samples/graphics/rsx_Basic_Wallpaper/include/mesh.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
#ifndef __MESH_H__
#define __MESH_H__

#include <ppu-types.h>
#include <vectormath/cpp/vectormath_aos.h>

#include <rsx/rsx.h>

#include "irrarray.h"

using namespace irr;
using namespace Vectormath::Aos;

template< class T >
Expand All @@ -29,100 +23,41 @@ inline const T clamp(const T& val,const T& low,const T& high)
return min_(max_(val,low),high);
}

class SColor
{
public:
SColor() : color(0) {};
SColor(u32 c) : color(c) {};
SColor(u8 a,u8 r,u8 g,u8 b) : R(r),G(g),B(b),A(a) {};
SColor(const SColor& other) : color(other.color) {};

u8 getRed() const { return R; }
u8 getGreen() const { return G; }
u8 getBlue() const { return B; }
u8 getAlpha() const { return A; }

union {
u32 color;
struct {
u8 R,G,B,A;
};
};
};

struct S3DVertex
{
S3DVertex() {};
S3DVertex(f32 x,f32 y,f32 z,f32 nx,f32 ny,f32 nz,SColor c,f32 tu,f32 tv)
: pos(x,y,z),nrm(nx,ny,nz),col(c),u(tu),v(tv) {};
S3DVertex(const Vector3& _pos,const Vector3& _nrm,const SColor& c,f32 tu,f32 tv)
: pos(_pos),nrm(_nrm),col(c),u(tu),v(tv) {};
S3DVertex(f32 x,f32 y,f32 z,f32 nx,f32 ny,f32 nz,f32 tu,f32 tv, u32 c)
: pos(x, y, z), nrm(nx, ny, nz), u(tu), v(tv), col(c) {};

inline S3DVertex& operator=(const S3DVertex& other)
{
pos = other.pos;
nrm = other.nrm;
col = other.col;
u = other.u;
v = other.v;
col = other.col;
return *this;
}

Vector3 pos;
Vector3 nrm;
SColor col;

f32 u,v;
f32 u, v;
u32 col;
};


class SMeshBuffer
template< class T >
class CMeshBuffer
{
public:
SMeshBuffer() : pos_off(0),nrm_off(0),col_off(0),uv_off(0),ind_off(0) {};
virtual ~SMeshBuffer()
{
}
CMeshBuffer() : indices(NULL),cnt_indices(0),vertices(NULL),cnt_vertices(0) {};

virtual const void* getVertices() const
{
return vertices.const_pointer();
}
u16 *indices;
u32 cnt_indices;

virtual void* getVertices()
{
return vertices.pointer();
}

virtual u32 getVertexCount() const
{
return vertices.size();
}

virtual const u32* getIndices() const
{
return indices.const_pointer();
}

virtual u32* getIndices()
{
return indices.pointer();
}

virtual u32 getIndexCount() const
{
return indices.size();
}

core::array< u32, core::allocatorRSX< u32 > > indices;
core::array< S3DVertex, core::allocatorRSX< S3DVertex > > vertices;

u32 pos_off;
u32 nrm_off;
u32 col_off;
u32 uv_off;

u32 ind_off;
S3DVertex *vertices;
u32 cnt_vertices;
};

typedef CMeshBuffer<S3DVertex> SMeshBuffer;

#endif
34 changes: 21 additions & 13 deletions samples/graphics/rsx_Basic_Wallpaper/include/rsxutil.h
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
#ifndef __RSXUTIL_H__
#define __RSXUTIL_H__

#include <ppu-types.h>
#include <rsx/rsx.h>

#include <debugfont.h>


#define DEFUALT_CB_SIZE 0x80000 // 512Kb default command buffer size
#define DEFAULT_CB_SIZE 0x80000 // 512Kb default command buffer size
#define HOST_STATE_CB_SIZE 0x10000 // 64Kb state command buffer size (used for resetting certain default states)
#define HOST_ADDR_ALIGNMENT (1024*1024)
#define HOSTBUFFER_SIZE (128*1024*1024)
#define CB_SIZE 0x100000

#define FRAME_BUFFER_COUNT 2
#define GCM_PREPARED_BUFFER_INDEX 65
#define GCM_BUFFER_STATUS_INDEX 66
#define GCM_WAIT_LABEL_INDEX 255

#define MAX_BUFFER_QUEUE_SIZE 1

extern gcmContextData *context;
#define BUFFER_IDLE 0
#define BUFFER_BUSY 1

#define FRAME_BUFFER_COUNT 4

extern u32 curr_fb;

Expand All @@ -24,17 +27,22 @@ extern u32 display_height;

extern u32 depth_pitch;
extern u32 depth_offset;
extern u32 *depth_buffer;
extern void *depth_buffer;

extern u32 color_pitch;
extern u32 color_offset[FRAME_BUFFER_COUNT];
extern u32 *color_buffer[FRAME_BUFFER_COUNT];
extern void *color_buffer[FRAME_BUFFER_COUNT];

extern void *state_buffer;
extern u32 state_offset;


extern f32 aspect_ratio;

void setRenderTarget(u32 index);
void init_screen(void *host_addr,u32 size);
void waitflip();
void initScreen(u32 hostBufferSize);
void flip();
void finish();

void setRenderTarget(u32 index);

#endif
#endif // __RSXUTIL_H__
Loading

0 comments on commit f7eda89

Please sign in to comment.