Skip to content

Commit

Permalink
Fragment Shaders.
Browse files Browse the repository at this point in the history
  • Loading branch information
phire committed Nov 15, 2010
1 parent 9a5f289 commit c562b62
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
9 changes: 9 additions & 0 deletions psl1ght/include/rsx/commands.h
Expand Up @@ -91,7 +91,16 @@ typedef struct {
uint32_t data[];
} realityVertexProgram;

typedef struct {
uint32_t offset;
uint32_t size;
uint32_t num_regs;
uint32_t data[];
} realityFragmentProgram;

void realityLoadVertexProgram(gcmContextData *context, realityVertexProgram *prog);
void realityInstallFragmentProgram(gcmContextData *context, realityFragmentProgram *prog, uint32_t *addr);
void realityLoadFragmentProgram(gcmContextData *context, realityFragmentProgram *prog);

#ifdef __cplusplus
}
Expand Down
19 changes: 19 additions & 0 deletions psl1ght/lib/libreality/source/commands.c
@@ -1,6 +1,7 @@
#include <rsx/commands.h>
#include <rsx/nv40.h>
#include <rsx/buffer.h>
#include <rsx/reality.h>

void realitySetClearColor(gcmContextData *context, uint32_t color) {
COMMAND_LENGTH(context, 2);
Expand Down Expand Up @@ -101,6 +102,24 @@ void realityLoadVertexProgram(gcmContextData *context, realityVertexProgram *pro

commandBufferPutCmd1(context, NV30_3D_VP_START_FROM_ID, 0);
commandBufferPutCmd2(context, NV40_3D_VP_ATTRIB_EN, prog->in_reg, prog->out_reg);
}

void realityInstallFragmentProgram(gcmContextData *context, realityFragmentProgram *prog, uint32_t *addr) {
// We don't actually need context, but if we leave it out people will forget.
int i;
for( i = 0; i < prog->size; ++i ) {
addr[i] = (((prog->data[i] >> 16 ) & 0xffff) << 0) |
(((prog->data[i] >> 0 ) & 0xffff) << 16);
}
assert(realityAddressToOffset(addr, &prog->offset) == 0);
}

void realityLoadFragmentProgram(gcmContextData *context, realityFragmentProgram *prog) {
COMMAND_LENGTH(context, 4);
assert(prog->offset != 0);
commandBufferPutCmd1(context, NV30_3D_FP_ACTIVE_PROGRAM,
prog->offset | NV30_3D_FP_ACTIVE_PROGRAM_DMA0);
commandBufferPutCmd1(context, NV30_3D_FP_CONTROL,
prog->num_regs << NV40_3D_FP_CONTROL_TEMP_COUNT__SHIFT);
}

0 comments on commit c562b62

Please sign in to comment.