summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2013-10-02 14:05:04 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2013-10-02 14:49:00 +0200
commit34993cbdfc320f617cb9f756c880db9cbba8084c (patch)
treef484bf8d1ec5f1661b51beda16931900a601ae79
parent468ff9983237c85327e7ddf521bda0e852d82beb (diff)
fb: make mip_cube test cope with npot textures
Make testcase suitable for testing with npot textures. Also add support for RGB565 texture format.
-rw-r--r--native/fb/mip_cube.c24
-rw-r--r--native/lib/dds.c10
2 files changed, 28 insertions, 6 deletions
diff --git a/native/fb/mip_cube.c b/native/fb/mip_cube.c
index b1e6adb..5f262e1 100644
--- a/native/fb/mip_cube.c
+++ b/native/fb/mip_cube.c
@@ -222,6 +222,7 @@ int main(int argc, char **argv)
{
case FMT_A8R8G8B8: tex_format = PIPE_FORMAT_B8G8R8A8_UNORM; break;
case FMT_X8R8G8B8: tex_format = PIPE_FORMAT_B8G8R8X8_UNORM; break;
+ case FMT_R5G6B5: tex_format = PIPE_FORMAT_B5G6R5_UNORM; break;
case FMT_DXT1: tex_format = PIPE_FORMAT_DXT1_RGB; break;
case FMT_DXT3: tex_format = PIPE_FORMAT_DXT3_RGBA; break;
case FMT_DXT5: tex_format = PIPE_FORMAT_DXT5_RGBA; break;
@@ -242,7 +243,28 @@ int main(int argc, char **argv)
for(int ix=0; ix<dds->num_mipmaps; ++ix)
{
printf("%08x: Uploading mipmap %i (%ix%i)\n", dds->slices[0][ix].offset, ix, dds->slices[0][ix].width, dds->slices[0][ix].height);
- etna_pipe_inline_write(pipe, tex_resource, 0, ix, dds->slices[0][ix].data, dds->slices[0][ix].size);
+#if 0
+ for(int y=0; y<dds->slices[0][ix].height; ++y)
+ {
+ for(int x=0; x<dds->slices[0][ix].width; ++x)
+ {
+ uint32_t val = ((uint32_t*)dds->slices[0][ix].data)[y * dds->slices[0][ix].width + x];
+ printf("%c",val != 0xffffffff ? ' ' : '1');
+ }
+ printf("\n");
+ }
+#endif
+ struct pipe_box box;
+ box.x = 0;
+ box.y = 0;
+ box.z = 0;
+ box.width = dds->slices[0][ix].width;
+ box.height = dds->slices[0][ix].height;
+ box.depth = 1;
+
+ pipe->transfer_inline_write(pipe, tex_resource, ix,
+ (PIPE_TRANSFER_WRITE | PIPE_TRANSFER_UNSYNCHRONIZED), &box,
+ dds->slices[0][ix].data, dds->slices[0][ix].stride, dds->slices[0][ix].stride);
}
/* resources */
diff --git a/native/lib/dds.c b/native/lib/dds.c
index 5ae4c26..a3ec71b 100644
--- a/native/lib/dds.c
+++ b/native/lib/dds.c
@@ -36,7 +36,7 @@
#include <stdbool.h>
#include <stdint.h>
-//#define DEBUG
+#define DEBUG
// little-endian, of course
#define DDS_MAGIC 0x20534444
@@ -224,8 +224,6 @@ bool dds_load_file(FILE *f, dds_texture **out)
unsigned int xSize = hdr.dwWidth;
unsigned int ySize = hdr.dwHeight;
- assert( !(xSize & (xSize-1)) );
- assert( !(ySize & (ySize-1)) );
int fmt = find_fmt(&hdr.sPixelFormat);
if(fmt == -1) {
#ifdef DEBUG
@@ -286,8 +284,10 @@ bool dds_load_file(FILE *f, dds_texture **out)
(int)mip->stride);
#endif
offset += size;
- x = (x+1)>>1;
- y = (y+1)>>1;
+ if(x != 1)
+ x = x >> 1;
+ if(y != 1)
+ y = y >> 1;
size = max( li->divSize, x )/li->divSize * max( li->divSize, y )/li->divSize * li->blockBytes;
}
rv->data = malloc(offset);