rename argb -> rgba
This commit is contained in:
parent
089b126523
commit
23cafcdb23
@ -1018,7 +1018,7 @@ int main()
|
|||||||
assert(texturebuffer_ptr != MAP_FAILED);
|
assert(texturebuffer_ptr != MAP_FAILED);
|
||||||
|
|
||||||
// copy texture
|
// copy texture
|
||||||
void * texture_buf = read_file("../texture/butterfly_1024x1024_argb8888.data");
|
void * texture_buf = read_file("../texture/butterfly_1024x1024_rgba8888.data");
|
||||||
assert(texture_buf != NULL);
|
assert(texture_buf != NULL);
|
||||||
|
|
||||||
for (int i = 0; i < texture_size / 4; i++) {
|
for (int i = 0; i < texture_size / 4; i++) {
|
||||||
|
|||||||
@ -1105,7 +1105,7 @@ int main()
|
|||||||
assert(texturebuffer_ptr != MAP_FAILED);
|
assert(texturebuffer_ptr != MAP_FAILED);
|
||||||
|
|
||||||
// copy texture
|
// copy texture
|
||||||
void * texture_buf = read_file("../texture/butterfly_1024x1024_argb8888.data");
|
void * texture_buf = read_file("../texture/butterfly_1024x1024_rgba8888.data");
|
||||||
assert(texture_buf != NULL);
|
assert(texture_buf != NULL);
|
||||||
|
|
||||||
for (int i = 0; i < texture_size / 4; i++) {
|
for (int i = 0; i < texture_size / 4; i++) {
|
||||||
|
|||||||
@ -1126,7 +1126,7 @@ int main()
|
|||||||
assert(texturebuffer_ptr != MAP_FAILED);
|
assert(texturebuffer_ptr != MAP_FAILED);
|
||||||
|
|
||||||
// copy texture
|
// copy texture
|
||||||
void * texture_buf = read_file("../texture/butterfly_1024x1024_argb8888.data");
|
void * texture_buf = read_file("../texture/butterfly_1024x1024_rgba8888.data");
|
||||||
assert(texture_buf != NULL);
|
assert(texture_buf != NULL);
|
||||||
|
|
||||||
for (int i = 0; i < texture_size / 4; i++) {
|
for (int i = 0; i < texture_size / 4; i++) {
|
||||||
|
|||||||
@ -1188,7 +1188,7 @@ int main()
|
|||||||
assert(texturebuffer_ptr != MAP_FAILED);
|
assert(texturebuffer_ptr != MAP_FAILED);
|
||||||
|
|
||||||
// copy texture
|
// copy texture
|
||||||
void * texture_buf = read_file("../texture/butterfly_1024x1024_argb8888.data");
|
void * texture_buf = read_file("../texture/butterfly_1024x1024_rgba8888.data");
|
||||||
assert(texture_buf != NULL);
|
assert(texture_buf != NULL);
|
||||||
|
|
||||||
for (int i = 0; i < texture_size / 4; i++) {
|
for (int i = 0; i < texture_size / 4; i++) {
|
||||||
|
|||||||
@ -646,7 +646,7 @@ int main()
|
|||||||
assert(texturebuffer_ptr != MAP_FAILED);
|
assert(texturebuffer_ptr != MAP_FAILED);
|
||||||
|
|
||||||
// copy texture
|
// copy texture
|
||||||
void * texture_buf = read_file("../texture/butterfly_1024x1024_argb8888.data");
|
void * texture_buf = read_file("../texture/butterfly_1024x1024_rgba8888.data");
|
||||||
assert(texture_buf != NULL);
|
assert(texture_buf != NULL);
|
||||||
|
|
||||||
for (int i = 0; i < texture_size / 4; i++) {
|
for (int i = 0; i < texture_size / 4; i++) {
|
||||||
|
|||||||
@ -663,7 +663,7 @@ int main()
|
|||||||
assert(texturebuffer_ptr != MAP_FAILED);
|
assert(texturebuffer_ptr != MAP_FAILED);
|
||||||
|
|
||||||
// copy texture
|
// copy texture
|
||||||
void * texture_buf = read_file("../texture/butterfly_128x128_argb8888.data");
|
void * texture_buf = read_file("../texture/butterfly_128x128_rgba8888.data");
|
||||||
assert(texture_buf != NULL);
|
assert(texture_buf != NULL);
|
||||||
|
|
||||||
for (int i = 0; i < texture_size / 4; i++) {
|
for (int i = 0; i < texture_size / 4; i++) {
|
||||||
|
|||||||
@ -707,7 +707,7 @@ int main()
|
|||||||
intermediate_handle[1] = create_colorbuffer(fd, texture_size, NULL);
|
intermediate_handle[1] = create_colorbuffer(fd, texture_size, NULL);
|
||||||
|
|
||||||
{
|
{
|
||||||
void * texture_buf = read_file("../texture/butterfly_1024x1024_argb8888.data");
|
void * texture_buf = read_file("../texture/butterfly_1024x1024_rgba8888.data");
|
||||||
assert(texture_buf != NULL);
|
assert(texture_buf != NULL);
|
||||||
for (int i = 0; i < texture_size / 4; i++) {
|
for (int i = 0; i < texture_size / 4; i++) {
|
||||||
((uint32_t*)texturebuffer_ptr)[i] = ((uint32_t*)texture_buf)[i];
|
((uint32_t*)texturebuffer_ptr)[i] = ((uint32_t*)texture_buf)[i];
|
||||||
|
|||||||
@ -765,7 +765,7 @@ int main()
|
|||||||
assert(texturebuffer_ptr != MAP_FAILED);
|
assert(texturebuffer_ptr != MAP_FAILED);
|
||||||
|
|
||||||
// copy texture
|
// copy texture
|
||||||
void * texture_buf = read_file("../texture/butterfly_1024x1024_argb8888.data");
|
void * texture_buf = read_file("../texture/butterfly_1024x1024_rgba8888.data");
|
||||||
assert(texture_buf != NULL);
|
assert(texture_buf != NULL);
|
||||||
|
|
||||||
for (int i = 0; i < texture_size / 4; i++) {
|
for (int i = 0; i < texture_size / 4; i++) {
|
||||||
|
|||||||
@ -935,7 +935,7 @@ int main()
|
|||||||
assert(texturebuffer_ptr != MAP_FAILED);
|
assert(texturebuffer_ptr != MAP_FAILED);
|
||||||
|
|
||||||
// copy texture
|
// copy texture
|
||||||
void * texture_buf = read_file("../texture/butterfly_1024x1024_argb8888.data");
|
void * texture_buf = read_file("../texture/butterfly_1024x1024_rgba8888.data");
|
||||||
assert(texture_buf != NULL);
|
assert(texture_buf != NULL);
|
||||||
|
|
||||||
for (int i = 0; i < texture_size / 4; i++) {
|
for (int i = 0; i < texture_size / 4; i++) {
|
||||||
|
|||||||
@ -991,7 +991,7 @@ int main()
|
|||||||
assert(texturebuffer_ptr != MAP_FAILED);
|
assert(texturebuffer_ptr != MAP_FAILED);
|
||||||
|
|
||||||
// copy texture
|
// copy texture
|
||||||
void * texture_buf = read_file("../texture/butterfly_1024x1024_argb8888.data");
|
void * texture_buf = read_file("../texture/butterfly_1024x1024_rgba8888.data");
|
||||||
assert(texture_buf != NULL);
|
assert(texture_buf != NULL);
|
||||||
|
|
||||||
for (int i = 0; i < texture_size / 4; i++) {
|
for (int i = 0; i < texture_size / 4; i++) {
|
||||||
|
|||||||
@ -981,7 +981,7 @@ int main()
|
|||||||
assert(texturebuffer_ptr != MAP_FAILED);
|
assert(texturebuffer_ptr != MAP_FAILED);
|
||||||
|
|
||||||
// copy texture
|
// copy texture
|
||||||
void * texture_buf = read_file("../texture/butterfly_1024x1024_argb8888.data");
|
void * texture_buf = read_file("../texture/butterfly_1024x1024_rgba8888.data");
|
||||||
assert(texture_buf != NULL);
|
assert(texture_buf != NULL);
|
||||||
|
|
||||||
for (int i = 0; i < texture_size / 4; i++) {
|
for (int i = 0; i < texture_size / 4; i++) {
|
||||||
|
|||||||
@ -1040,7 +1040,7 @@ int main()
|
|||||||
assert(texturebuffer_ptr != MAP_FAILED);
|
assert(texturebuffer_ptr != MAP_FAILED);
|
||||||
|
|
||||||
// copy texture
|
// copy texture
|
||||||
void * texture_buf = read_file("../texture/butterfly_1024x1024_argb8888.data");
|
void * texture_buf = read_file("../texture/butterfly_1024x1024_rgba8888.data");
|
||||||
assert(texture_buf != NULL);
|
assert(texture_buf != NULL);
|
||||||
|
|
||||||
for (int i = 0; i < texture_size / 4; i++) {
|
for (int i = 0; i < texture_size / 4; i++) {
|
||||||
|
|||||||
@ -981,7 +981,7 @@ int main()
|
|||||||
assert(texturebuffer_ptr != MAP_FAILED);
|
assert(texturebuffer_ptr != MAP_FAILED);
|
||||||
|
|
||||||
// copy texture
|
// copy texture
|
||||||
void * texture_buf = read_file("../texture/butterfly_1024x1024_argb8888.data");
|
void * texture_buf = read_file("../texture/butterfly_1024x1024_rgba8888.data");
|
||||||
assert(texture_buf != NULL);
|
assert(texture_buf != NULL);
|
||||||
|
|
||||||
for (int i = 0; i < texture_size / 4; i++) {
|
for (int i = 0; i < texture_size / 4; i++) {
|
||||||
|
|||||||
@ -990,7 +990,7 @@ int main()
|
|||||||
assert(texturebuffer_ptr != MAP_FAILED);
|
assert(texturebuffer_ptr != MAP_FAILED);
|
||||||
|
|
||||||
// copy texture
|
// copy texture
|
||||||
void * texture_buf = read_file("../texture/butterfly_1024x1024_argb8888.data");
|
void * texture_buf = read_file("../texture/butterfly_1024x1024_rgba8888.data");
|
||||||
assert(texture_buf != NULL);
|
assert(texture_buf != NULL);
|
||||||
|
|
||||||
for (int i = 0; i < texture_size / 4; i++) {
|
for (int i = 0; i < texture_size / 4; i++) {
|
||||||
|
|||||||
@ -996,7 +996,7 @@ int main()
|
|||||||
assert(texturebuffer_ptr != MAP_FAILED);
|
assert(texturebuffer_ptr != MAP_FAILED);
|
||||||
|
|
||||||
// copy texture
|
// copy texture
|
||||||
void * texture_buf = read_file("../texture/butterfly_1024x1024_argb8888.data");
|
void * texture_buf = read_file("../texture/butterfly_1024x1024_rgba8888.data");
|
||||||
assert(texture_buf != NULL);
|
assert(texture_buf != NULL);
|
||||||
|
|
||||||
for (int i = 0; i < texture_size / 4; i++) {
|
for (int i = 0; i < texture_size / 4; i++) {
|
||||||
|
|||||||
@ -699,10 +699,10 @@ int main()
|
|||||||
|
|
||||||
const int texture_size = 1024 * 1024 * 4;
|
const int texture_size = 1024 * 1024 * 4;
|
||||||
texturebuffer_handle[0] = load_texture(fd,
|
texturebuffer_handle[0] = load_texture(fd,
|
||||||
"../texture/butterfly_1024x1024_argb8888.data",
|
"../texture/butterfly_1024x1024_rgba8888.data",
|
||||||
texture_size);
|
texture_size);
|
||||||
texturebuffer_handle[1] = load_texture(fd,
|
texturebuffer_handle[1] = load_texture(fd,
|
||||||
"../texture/bird_1024x1024_argb8888.data",
|
"../texture/bird_1024x1024_rgba8888.data",
|
||||||
texture_size);
|
texture_size);
|
||||||
|
|
||||||
{ // clear colorbuffer
|
{ // clear colorbuffer
|
||||||
|
|||||||
@ -972,7 +972,7 @@ int main()
|
|||||||
assert(texturebuffer_ptr != MAP_FAILED);
|
assert(texturebuffer_ptr != MAP_FAILED);
|
||||||
|
|
||||||
// copy texture
|
// copy texture
|
||||||
void * texture_buf = read_file("../texture/butterfly_1024x1024_argb8888.data");
|
void * texture_buf = read_file("../texture/butterfly_1024x1024_rgba8888.data");
|
||||||
assert(texture_buf != NULL);
|
assert(texture_buf != NULL);
|
||||||
|
|
||||||
for (int i = 0; i < texture_size / 4; i++) {
|
for (int i = 0; i < texture_size / 4; i++) {
|
||||||
|
|||||||
@ -55,7 +55,7 @@ def validate_swizzle(token):
|
|||||||
return tuple(swizzles[c] for c in token.lexeme)
|
return tuple(swizzles[c] for c in token.lexeme)
|
||||||
|
|
||||||
def validate_mask_swizzle(token) -> tuple[AlphaMask, RGBMask]:
|
def validate_mask_swizzle(token) -> tuple[AlphaMask, RGBMask]:
|
||||||
argb_masks = OrderedDict([
|
rgba_masks = OrderedDict([
|
||||||
(b"none" , (AlphaMask.NONE, RGBMask.NONE)),
|
(b"none" , (AlphaMask.NONE, RGBMask.NONE)),
|
||||||
(b"r" , (AlphaMask.NONE, RGBMask.R)),
|
(b"r" , (AlphaMask.NONE, RGBMask.R)),
|
||||||
(b"g" , (AlphaMask.NONE, RGBMask.G)),
|
(b"g" , (AlphaMask.NONE, RGBMask.G)),
|
||||||
@ -72,9 +72,9 @@ def validate_mask_swizzle(token) -> tuple[AlphaMask, RGBMask]:
|
|||||||
(b"gba" , (AlphaMask.A, RGBMask.GB)),
|
(b"gba" , (AlphaMask.A, RGBMask.GB)),
|
||||||
(b"rgba" , (AlphaMask.A, RGBMask.RGB)),
|
(b"rgba" , (AlphaMask.A, RGBMask.RGB)),
|
||||||
])
|
])
|
||||||
if token.lexeme not in argb_masks:
|
if token.lexeme not in rgba_masks:
|
||||||
raise ValidatorError("invalid destination mask", token)
|
raise ValidatorError("invalid destination mask", token)
|
||||||
return argb_masks[token.lexeme]
|
return rgba_masks[token.lexeme]
|
||||||
|
|
||||||
def validate_masks(ins_ast: parser.TEXInstruction):
|
def validate_masks(ins_ast: parser.TEXInstruction):
|
||||||
addresses = set()
|
addresses = set()
|
||||||
|
|||||||
115
src/float_colorbuffer.cpp
Normal file
115
src/float_colorbuffer.cpp
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
#include <assert.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
|
||||||
|
#include "r500/3d_registers.h"
|
||||||
|
#include "r500/3d_registers_undocumented.h"
|
||||||
|
#include "r500/3d_registers_bits.h"
|
||||||
|
#include "r500/indirect_buffer.h"
|
||||||
|
#include "r500/shader.h"
|
||||||
|
#include "r500/display_controller.h"
|
||||||
|
|
||||||
|
#include "drm/buffer.h"
|
||||||
|
#include "drm/drm.h"
|
||||||
|
|
||||||
|
#include "math/float_types.hpp"
|
||||||
|
#include "math/transform.hpp"
|
||||||
|
#include "math/constants.hpp"
|
||||||
|
|
||||||
|
#include "../model/model2.h"
|
||||||
|
#include "../model/plane.h"
|
||||||
|
|
||||||
|
#define CLEAR_SHADER 0
|
||||||
|
#define PLANE_SHADER 1
|
||||||
|
#define PARTICLE_SHADER 2
|
||||||
|
#define TEXTURE_TILE_SHADER 3
|
||||||
|
|
||||||
|
const char * vertex_shader_paths[] = {
|
||||||
|
"clear.vs.bin",
|
||||||
|
};
|
||||||
|
const int vertex_shader_paths_length = (sizeof (vertex_shader_paths)) / (sizeof (vertex_shader_paths[0]));
|
||||||
|
const char * fragment_shader_paths[] = {
|
||||||
|
"clear.fs.bin",
|
||||||
|
};
|
||||||
|
const int fragment_shader_paths_length = (sizeof (fragment_shader_paths)) / (sizeof (fragment_shader_paths[0]));
|
||||||
|
|
||||||
|
#define PARTICLE_TEXTURE 0
|
||||||
|
|
||||||
|
const char * textures[] = {
|
||||||
|
"../texture/particle_32x32_rgba8888.data",
|
||||||
|
};
|
||||||
|
const int textures_length = (sizeof (textures)) / (sizeof (textures[0]));
|
||||||
|
|
||||||
|
struct shaders {
|
||||||
|
struct shader_offset * vertex;
|
||||||
|
struct shader_offset * fragment;
|
||||||
|
int vertex_length;
|
||||||
|
int fragment_length;
|
||||||
|
};
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
struct shaders shaders = {
|
||||||
|
.vertex = load_shaders(vertex_shader_paths, vertex_shader_paths_length),
|
||||||
|
.fragment = load_shaders(fragment_shader_paths, fragment_shader_paths_length),
|
||||||
|
.vertex_length = vertex_shader_paths_length,
|
||||||
|
.fragment_length = fragment_shader_paths_length,
|
||||||
|
};
|
||||||
|
|
||||||
|
void * rmmio = map_pci_resource2();
|
||||||
|
|
||||||
|
int fd = open("/dev/dri/card0", O_RDWR | O_CLOEXEC);
|
||||||
|
assert(fd != -1);
|
||||||
|
|
||||||
|
const int colorbuffer_size = 1600 * 1200 * 4;
|
||||||
|
int colorbuffer_handle[2];
|
||||||
|
int zbuffer_handle;
|
||||||
|
int * texturebuffer_handle;
|
||||||
|
int flush_handle;
|
||||||
|
|
||||||
|
void * colorbuffer_ptr[2];
|
||||||
|
void * zbuffer_ptr;
|
||||||
|
|
||||||
|
// colorbuffer
|
||||||
|
colorbuffer_handle[0] = create_buffer(fd, colorbuffer_size, &colorbuffer_ptr[0]);
|
||||||
|
colorbuffer_handle[1] = create_buffer(fd, colorbuffer_size, &colorbuffer_ptr[1]);
|
||||||
|
zbuffer_handle = create_buffer(fd, colorbuffer_size, &zbuffer_ptr);
|
||||||
|
flush_handle = create_flush_buffer(fd);
|
||||||
|
texturebuffer_handle = load_textures(fd, textures, textures_length);
|
||||||
|
|
||||||
|
fprintf(stderr, "colorbuffer handle[0] %d\n", colorbuffer_handle[0]);
|
||||||
|
fprintf(stderr, "colorbuffer handle[1] %d\n", colorbuffer_handle[1]);
|
||||||
|
fprintf(stderr, "zbuffer handle %d\n", zbuffer_handle);
|
||||||
|
|
||||||
|
int colorbuffer_ix = 0;
|
||||||
|
float theta = PI * 0.5;
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
int ib_dwords = indirect_buffer(shaders, theta);
|
||||||
|
|
||||||
|
drm_radeon_cs(fd,
|
||||||
|
colorbuffer_handle[colorbuffer_ix],
|
||||||
|
zbuffer_handle,
|
||||||
|
flush_handle,
|
||||||
|
texturebuffer_handle,
|
||||||
|
textures_length,
|
||||||
|
ib_dwords);
|
||||||
|
|
||||||
|
primary_surface_address(rmmio, colorbuffer_ix);
|
||||||
|
|
||||||
|
// next state
|
||||||
|
theta += 0.01f;
|
||||||
|
colorbuffer_ix = (colorbuffer_ix + 1) & 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
@ -545,7 +545,7 @@ int indirect_buffer(shaders& shaders,
|
|||||||
}
|
}
|
||||||
|
|
||||||
const char * textures[] = {
|
const char * textures[] = {
|
||||||
"../texture/butterfly_1024x1024_argb8888.data",
|
"../texture/butterfly_1024x1024_rgba8888.data",
|
||||||
};
|
};
|
||||||
const int textures_length = (sizeof (textures)) / (sizeof (textures[0]));
|
const int textures_length = (sizeof (textures)) / (sizeof (textures[0]));
|
||||||
|
|
||||||
|
|||||||
@ -722,7 +722,7 @@ int _tile_texture(const shaders& shaders,
|
|||||||
}
|
}
|
||||||
|
|
||||||
const char * textures[] = {
|
const char * textures[] = {
|
||||||
"../texture/butterfly_1024x1024_argb8888.data",
|
"../texture/butterfly_1024x1024_rgba8888.data",
|
||||||
};
|
};
|
||||||
const int textures_length = (sizeof (textures)) / (sizeof (textures[0]));
|
const int textures_length = (sizeof (textures)) / (sizeof (textures[0]));
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user