Subversion Repositories ps3ware

Compare Revisions

Ignore whitespace Rev 200 → Rev 201

/trunk/libps3rsx/src/fifo/ioctl.h
7,6 → 7,7
#define PS3RSX_IOCTL_CONTEXT_INFO _IOR('r', 0x100, int)
#define PS3RSX_IOCTL_KICK_FIFO _IO('r', 0x101)
#define PS3RSX_IOCTL_EXCLUSIVE _IO('r', 0x102)
#define PS3RSX_IOCTL_FLIP_SCRN _IOR('r', 0x103, int)
 
struct ps3rsx_ioctl_context_info {
__u32 hw_id; /* hardware context number */
/trunk/libps3rsx/src/fifo/utils.c
142,7 → 142,7
uint16_t width = buffers->width;
uint16_t height = buffers->height;
 
printf( "width = %d height = %d \n", (uint32_t)width, (uint32_t)height );
//printf( "width = %d height = %d \n", (uint32_t)width, (uint32_t)height );
 
BEGIN_RING(Nv3D, NV40TCL_VIEWPORT_TRANSLATE_X, 8);
OUT_RINGf (0.5f * width );
309,6 → 309,13
}
 
 
int flip_scrn(struct gpu *gpu, int off)
{
int val = ioctl(gpu->rsx_fd, PS3RSX_IOCTL_FLIP_SCRN, off );
return val;
}
 
 
int gpu_init(struct gpu *gpu)
{
struct ps3rsx_ioctl_context_info info;
/trunk/libps3rsx/src/fifo/utils.h
102,6 → 102,7
void fifo_push(struct gpu *gpu, int len);
void fifo_wait(struct gpu *gpu);
int sync_gpu(struct gpu *gpu );
int flip_scrn(struct gpu *gpu, int off );
uint32_t hash_handle(int channel, uint32_t handle);
uint32_t endian( uint32_t v );
uint32_t endian_fp( uint32_t v );
/trunk/libps3rsx/src/init/ps3rsx/ps3rsx.h
7,7 → 7,9
#define PS3RSX_IOCTL_CONTEXT_INFO _IOR('r', 0x100, int)
#define PS3RSX_IOCTL_KICK_FIFO _IO('r', 0x101)
#define PS3RSX_IOCTL_EXCLUSIVE _IO('r', 0x102)
#define PS3RSX_IOCTL_FLIP_SCRN _IOR('r', 0x103, int)
 
 
struct ps3rsx_ioctl_context_info {
__u32 hw_id; /* hardware context number */
__u32 vram_size; /* size of available video memory */
/trunk/libps3rsx/src/init/ps3rsx/ps3rsx.c
82,7 → 82,9
 
#define L1GPU_CONTEXT_ATTRIBUTE_FIFO_SETUP 0x001
#define L1GPU_CONTEXT_ATTRIBUTE_FB_BLIT 0x601
#define L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_FLIP 0x102
 
 
int debug;
module_param(debug, bool, 0);
MODULE_PARM_DESC(debug, "debug mode");
478,6 → 480,14
context = &ps3rsx.ucontext;
 
switch (cmd) {
case PS3RSX_IOCTL_FLIP_SCRN:
lv1_gpu_context_attribute( context->context_handle, L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_FLIP, 0, arg, 0, 0 );
break;
 
case PS3RSX_IOCTL_CONTEXT_INFO:
{
/trunk/libps3rsx/data/troll.0.model
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/libps3rsx/data/troll.0.vb
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/libps3rsx/data/troll.0.ib
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/libps3rsx/examples/simple_dxt/ps3gpu
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/libps3rsx/examples/simple_dxt/ps3gpu.c
223,25 → 223,32
}
 
 
 
int bind3d( uint32_t *fifo, uint32_t *fbmem, uint8_t *xdrmem, uint32_t obj, uint32_t jmp )
int setup_surfaces_with_offset( uint32_t *fifo, int off )
{
 
uint32_t *ptr = fifo;
xdrmem = xdrmem;
 
setup_buffer_t setup;
setup.pitchDepth = pitch;
setup.pitchColor = pitch;
setup.offsetDepth = width * height * 4;
setup.offsetColor = 0;
setup.offsetDepth = width * height * 4 * 2;
setup.offsetColor = width * height * 4 * off;
setup.typeDepth = Z16;
setup.width = width;
setup.height = height;
ptr += setup_buffers( &setup, ptr, Nv3D );
return ptr - fifo;
}
 
int bind3d( uint32_t *fifo, uint32_t *fbmem, uint8_t *xdrmem, uint32_t obj, uint32_t jmp )
{
 
uint32_t *ptr = fifo;
xdrmem = xdrmem;
 
ptr += setup_and_voodoo( 0x66604200, 0xfeed0000, obj, ptr, Nv3D );
ptr += setup_buffers( &setup, ptr, Nv3D );
ptr += setup_surfaces_with_offset( ptr, 1 );
ptr += load_texture( ptr, (uint8_t *)fbmem );
ptr += load_vertex_shader( ptr );
ptr += set_mvp( ptr, 180.0f );
252,7 → 259,7
return ptr - fifo;
}
 
int gfx_step( uint32_t *fifo, uint32_t jmp )
int gfx_step( uint32_t *fifo, uint32_t jmp, int off )
{
clear_buffer_t clear;
clear.clearR = clear.clearG = clear.clearB = clear.clearA = clear.clearD = 1;
263,6 → 270,7
 
uint32_t *ptr = fifo;
static float angle = 180.0f;
ptr += setup_surfaces_with_offset( ptr, off );
ptr += clear_buffers( &clear, ptr, Nv3D );
ptr += set_mvp( ptr, angle += 0.4f );
ptr += draw_indexed_primitives( indices, 0, indices_num, ptr, Nv3D );
308,7 → 316,7
uint32 old_jump = jmp;
for( i = 0; i < 200; ++i )
for( i = 0; i < 1000; ++i )
{
memset( fifo, 0, gpu->fifo.len );
315,9 → 323,10
uint32_t jmpt = jmp + 4 + 4 * ( i & 1 );
fifo[ ( old_jump - jmp ) / 4 ] = 0x20000000 | ( jmp + 0x10 );
old_jump = jmpt;
gfx_step( &fifo[0x10], jmpt );
gfx_step( &fifo[0x10], jmpt, i & 1 );
wait( ctrl, jmpt );
sync_gpu( gpu );
flip_scrn( gpu, ( ( i + 1 ) & 1 ) * width * height * 4 );
}
printf( "done...\n" );
/trunk/libps3rsx/tools/toolgeometry/collada/colladatool.cpp
17,39 → 17,13
 
#include "../../../src/geometry/geometry.h"
#include "../../../src/geometry/model.h"
 
 
 
struct cache_opt_t
{
uint16 entries[4 + 3];
 
uint16 cache[256];
uint16 cache_ptr;
uint16 vertices;
uint16 parts;
 
 
void add_pt( uint16 value )
 
cache_opt_t( )
{
for( uint16 i = 0; i < cache_ptr; ++i )
{
if( cache[i] == value )
{
return;
}
}
cache[cache_ptr++] = value;
++vertices;
if( cache_ptr == 256 )
{
memcpy( &cache[0], &cache[128], 256 );
++parts;
cache_ptr = 128;
}
}
 
cache_opt_t( ) : cache_ptr( 0 ), vertices( 0 )
{
entries[0] = 0xffff;
entries[1] = 0xffff;
entries[2] = 0xffff;
75,9 → 49,7
 
entries[ptr++] = trn[j];
 
skip:
 
add_pt( trn[j] );
skip:;
}
 
ptr -= 4;
114,7 → 86,8
}
 
};
 
 
 
void re_arrange( const std::vector<uint16> &_indices, std::vector<uint16> &dst )
{
if( _indices.empty() )
158,14 → 131,205
}
}
 
printf( "vertices %d parts %d \n", cache.vertices, cache.parts );
 
 
misses = 3.0f * misses / (float)indices.size();
printf( "cache misses per tri %f \n", misses );
 
}
 
 
 
#define CHUNK 64
 
 
struct MeshHeader
{
}
 
struct MatrixAffector
{
uint8 bone;
uint8 geomChunks[3];
uint8 weights[3][4];
MatrixAffector();
MatrixAffector( uint8 _bone, uint8 chunk, uint8 *_weights ) : bone( _bone )
{
 
geomChunks[0] = 0xff;
geomChunks[1] = 0xff;
geomChunks[2] = 0xff;
SetChunk( bone, chunk, _weights );
}
bool SetChunk( uint8 _bone, uint8 chunk, uint8 *_weights )
{
 
if( bone != _bone )
{
return false;
}
for( size_t i = 0; i < 3; ++i )
{
if( geomChunks[i] == 0xff )
{
geomChunks[i] = chunk;
memcpy( weights[i], weights, 4 );
return true;
}
}
return false;
}
};
 
 
void AddMatrix( size_t lastMark, std::vector<MatrixAffector> &chunks, uint8 bone, uint8 chunk, uint8 *weights )
{
for( size_t i = lastMark; i < chunks.size(); ++i )
{
if( chunks[i].SetChunk( bone, chunk, weights ) )
{
return;
}
}
chunks.push_back( MatrixAffector( bone, chunk, weights ) );
}
 
void remap_vertices( std::vector<SFatVertex> &vertices, std::vector<uint16> &indices )
{
uint16 beg = 0;
std::vector<uint16> remap;
remap.resize( vertices.size(), 0xffff );
std::vector<SFatVertex> tempVertices( vertices.size() );
std::vector<uint16> tempIndices( indices.size() );
for( size_t i = 0; i < indices.size(); ++i )
{
uint16 ind = indices[i];
if( remap[ind] == 0xffff )
{
remap[ind] = beg++;
}
tempIndices[i] = remap[ind];
tempVertices[remap[ind]] = vertices[ind];
}
vertices = tempVertices;
indices = tempIndices;
uint8 table[256];
uint8 value[256][4];
memset( table, 0, sizeof( table ) );
memset( value, 0, sizeof( value ) );
float matrices = 0.0f;
float clusters = 0.0001f + vertices.size();
std::vector<MatrixAffector> chunks;
std::vector<size_t> marks;
size_t lastChunk = 0;
size_t lastMark = 0;
for( size_t i = 0; i < vertices.size(); i += 4 )
{
uint8 ptr = 0;
uint8 weights[16][4];
uint8 indices[16];
for( size_t j = 0; j < 4 && ( i + j < vertices.size() ); ++j )
{
for( size_t k = 0; k < 4; ++k )
{
uint8 ind = vertices[i + j].indices[k];
value[ind][0] = 0;
value[ind][1] = 0;
value[ind][2] = 0;
value[ind][3] = 0;
table[ind] = 0;
}
}
for( size_t j = 0; j < 4 && ( i + j < vertices.size() ); ++j )
{
for( size_t k = 0; k < 4; ++k )
{
uint8 ind = vertices[i + j].indices[k];
uint8 w = vertices[i + j].weights[k];
table[ind] += w > 0 ? 1 : 0;
value[ind][j] += w;
}
}
for( size_t j = 0; j < 4 && ( i + j < vertices.size() ); ++j )
{
for( size_t k = 0; k < 4; ++k )
{
uint8 ind = vertices[i + j].indices[k];
if( table[ind] > 0 )
{
//printf( "%3d ", ind );
for( size_t l = 0; l < 4; ++l )
{
//printf( "%3d ", value[ind][l] );
weights[ptr][l] = value[ind][l];
}
indices[ptr] = ind;
table[ind] = 0;
++ptr;
//printf( "\n" );
}
}
//printf( "%d matrices \n", ptr );
}
for( size_t j = 0; j < 4 && ( i + j < vertices.size() ); ++j )
{
uint8 w = 0;
for( size_t l = 0; l < ptr; ++l )
{
w += weights[l][j];
}
}
for( size_t l = 0; l < ptr; ++l )
{
AddMatrix( lastMark, chunks, table[l], i, &weights[l][0] );
}
//matrices += ptr;
if( ( i - lastChunk >= CHUNK - 4 ) || ( i + 4 >= vertices.size() ) )
{
marks.push_back( lastMark );
size_t s = chunks.size() - lastMark;
//lastChunk = i;
matrices += 3.0f * 4.0f * s;
//printf( "chunk with %2d vertices and 3x %2d matrices \n", i - lastChunk + 4, s );
lastMark = chunks.size();
lastChunk = i;
}
}
printf( "%d matrix groups in %d chunks \n", chunks.size(), marks.size() );
printf( "%f matrices per vertex \n", matrices / clusters );
}
 
struct FOpen
{
FILE *fp;
239,7 → 403,9
std::vector<uint16> indices;
 
triangles[i]->GetFatVertices( &vertices, &indices );
//re_arrange( indices, indices );
re_arrange( indices, indices );
remap_vertices( vertices, indices );
printf( "%s %i %i\n", triangles[i]->GetEffect()->GetDiffuse()->GetFileName().ptr, vertices.size(), indices.size() );
 
 
/trunk/libps3rsx/tools/tooldxt/compress!!.sh
1,2 → 1,2
make
./tooldxt -dxt1 10 ../../art/licensed/TrollWhite.tga ../../data/troll.dxt1
./tooldxt -dxt3 10 ../../art/licensed/TrollWhite.tga ../../data/troll.dxt3