summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/util/u_gen_mipmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/auxiliary/util/u_gen_mipmap.c')
-rw-r--r--src/gallium/auxiliary/util/u_gen_mipmap.c290
1 files changed, 133 insertions, 157 deletions
diff --git a/src/gallium/auxiliary/util/u_gen_mipmap.c b/src/gallium/auxiliary/util/u_gen_mipmap.c
index 2b4cdab..b32ad1c 100644
--- a/src/gallium/auxiliary/util/u_gen_mipmap.c
+++ b/src/gallium/auxiliary/util/u_gen_mipmap.c
@@ -35,10 +35,11 @@
#include "pipe/p_context.h"
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
#include "pipe/p_shader_tokens.h"
+#include "pipe/p_state.h"
#include "util/u_memory.h"
#include "util/u_draw_quad.h"
@@ -61,10 +62,7 @@ struct gen_mipmap_state
struct pipe_depth_stencil_alpha_state depthstencil;
struct pipe_rasterizer_state rasterizer;
struct pipe_sampler_state sampler;
- struct pipe_viewport_state viewport;
- struct pipe_shader_state vert_shader;
- struct pipe_shader_state frag_shader;
void *vs;
void *fs;
@@ -78,15 +76,15 @@ struct gen_mipmap_state
enum dtype
{
- UBYTE,
- UBYTE_3_3_2,
- USHORT,
- USHORT_4_4_4_4,
- USHORT_5_6_5,
- USHORT_1_5_5_5_REV,
- UINT,
- FLOAT,
- HALF_FLOAT
+ DTYPE_UBYTE,
+ DTYPE_UBYTE_3_3_2,
+ DTYPE_USHORT,
+ DTYPE_USHORT_4_4_4_4,
+ DTYPE_USHORT_5_6_5,
+ DTYPE_USHORT_1_5_5_5_REV,
+ DTYPE_UINT,
+ DTYPE_FLOAT,
+ DTYPE_HALF_FLOAT
};
@@ -194,7 +192,7 @@ do_row(enum dtype datatype, uint comps, int srcWidth,
assert(srcWidth == dstWidth || srcWidth == 2 * dstWidth);
*/
- if (datatype == UBYTE && comps == 4) {
+ if (datatype == DTYPE_UBYTE && comps == 4) {
uint i, j, k;
const ubyte(*rowA)[4] = (const ubyte(*)[4]) srcRowA;
const ubyte(*rowB)[4] = (const ubyte(*)[4]) srcRowB;
@@ -207,7 +205,7 @@ do_row(enum dtype datatype, uint comps, int srcWidth,
dst[i][3] = (rowA[j][3] + rowA[k][3] + rowB[j][3] + rowB[k][3]) / 4;
}
}
- else if (datatype == UBYTE && comps == 3) {
+ else if (datatype == DTYPE_UBYTE && comps == 3) {
uint i, j, k;
const ubyte(*rowA)[3] = (const ubyte(*)[3]) srcRowA;
const ubyte(*rowB)[3] = (const ubyte(*)[3]) srcRowB;
@@ -219,7 +217,7 @@ do_row(enum dtype datatype, uint comps, int srcWidth,
dst[i][2] = (rowA[j][2] + rowA[k][2] + rowB[j][2] + rowB[k][2]) / 4;
}
}
- else if (datatype == UBYTE && comps == 2) {
+ else if (datatype == DTYPE_UBYTE && comps == 2) {
uint i, j, k;
const ubyte(*rowA)[2] = (const ubyte(*)[2]) srcRowA;
const ubyte(*rowB)[2] = (const ubyte(*)[2]) srcRowB;
@@ -230,7 +228,7 @@ do_row(enum dtype datatype, uint comps, int srcWidth,
dst[i][1] = (rowA[j][1] + rowA[k][1] + rowB[j][1] + rowB[k][1]) >> 2;
}
}
- else if (datatype == UBYTE && comps == 1) {
+ else if (datatype == DTYPE_UBYTE && comps == 1) {
uint i, j, k;
const ubyte *rowA = (const ubyte *) srcRowA;
const ubyte *rowB = (const ubyte *) srcRowB;
@@ -241,7 +239,7 @@ do_row(enum dtype datatype, uint comps, int srcWidth,
}
}
- else if (datatype == USHORT && comps == 4) {
+ else if (datatype == DTYPE_USHORT && comps == 4) {
uint i, j, k;
const ushort(*rowA)[4] = (const ushort(*)[4]) srcRowA;
const ushort(*rowB)[4] = (const ushort(*)[4]) srcRowB;
@@ -254,7 +252,7 @@ do_row(enum dtype datatype, uint comps, int srcWidth,
dst[i][3] = (rowA[j][3] + rowA[k][3] + rowB[j][3] + rowB[k][3]) / 4;
}
}
- else if (datatype == USHORT && comps == 3) {
+ else if (datatype == DTYPE_USHORT && comps == 3) {
uint i, j, k;
const ushort(*rowA)[3] = (const ushort(*)[3]) srcRowA;
const ushort(*rowB)[3] = (const ushort(*)[3]) srcRowB;
@@ -266,7 +264,7 @@ do_row(enum dtype datatype, uint comps, int srcWidth,
dst[i][2] = (rowA[j][2] + rowA[k][2] + rowB[j][2] + rowB[k][2]) / 4;
}
}
- else if (datatype == USHORT && comps == 2) {
+ else if (datatype == DTYPE_USHORT && comps == 2) {
uint i, j, k;
const ushort(*rowA)[2] = (const ushort(*)[2]) srcRowA;
const ushort(*rowB)[2] = (const ushort(*)[2]) srcRowB;
@@ -277,7 +275,7 @@ do_row(enum dtype datatype, uint comps, int srcWidth,
dst[i][1] = (rowA[j][1] + rowA[k][1] + rowB[j][1] + rowB[k][1]) / 4;
}
}
- else if (datatype == USHORT && comps == 1) {
+ else if (datatype == DTYPE_USHORT && comps == 1) {
uint i, j, k;
const ushort *rowA = (const ushort *) srcRowA;
const ushort *rowB = (const ushort *) srcRowB;
@@ -288,7 +286,7 @@ do_row(enum dtype datatype, uint comps, int srcWidth,
}
}
- else if (datatype == FLOAT && comps == 4) {
+ else if (datatype == DTYPE_FLOAT && comps == 4) {
uint i, j, k;
const float(*rowA)[4] = (const float(*)[4]) srcRowA;
const float(*rowB)[4] = (const float(*)[4]) srcRowB;
@@ -305,7 +303,7 @@ do_row(enum dtype datatype, uint comps, int srcWidth,
rowB[j][3] + rowB[k][3]) * 0.25F;
}
}
- else if (datatype == FLOAT && comps == 3) {
+ else if (datatype == DTYPE_FLOAT && comps == 3) {
uint i, j, k;
const float(*rowA)[3] = (const float(*)[3]) srcRowA;
const float(*rowB)[3] = (const float(*)[3]) srcRowB;
@@ -320,7 +318,7 @@ do_row(enum dtype datatype, uint comps, int srcWidth,
rowB[j][2] + rowB[k][2]) * 0.25F;
}
}
- else if (datatype == FLOAT && comps == 2) {
+ else if (datatype == DTYPE_FLOAT && comps == 2) {
uint i, j, k;
const float(*rowA)[2] = (const float(*)[2]) srcRowA;
const float(*rowB)[2] = (const float(*)[2]) srcRowB;
@@ -333,7 +331,7 @@ do_row(enum dtype datatype, uint comps, int srcWidth,
rowB[j][1] + rowB[k][1]) * 0.25F;
}
}
- else if (datatype == FLOAT && comps == 1) {
+ else if (datatype == DTYPE_FLOAT && comps == 1) {
uint i, j, k;
const float *rowA = (const float *) srcRowA;
const float *rowB = (const float *) srcRowB;
@@ -345,7 +343,7 @@ do_row(enum dtype datatype, uint comps, int srcWidth,
}
#if 0
- else if (datatype == HALF_FLOAT && comps == 4) {
+ else if (datatype == HALF_DTYPE_FLOAT && comps == 4) {
uint i, j, k, comp;
const half_float(*rowA)[4] = (const half_float(*)[4]) srcRowA;
const half_float(*rowB)[4] = (const half_float(*)[4]) srcRowB;
@@ -362,7 +360,7 @@ do_row(enum dtype datatype, uint comps, int srcWidth,
}
}
}
- else if (datatype == HALF_FLOAT && comps == 3) {
+ else if (datatype == DTYPE_HALF_FLOAT && comps == 3) {
uint i, j, k, comp;
const half_float(*rowA)[3] = (const half_float(*)[3]) srcRowA;
const half_float(*rowB)[3] = (const half_float(*)[3]) srcRowB;
@@ -379,7 +377,7 @@ do_row(enum dtype datatype, uint comps, int srcWidth,
}
}
}
- else if (datatype == HALF_FLOAT && comps == 2) {
+ else if (datatype == DTYPE_HALF_FLOAT && comps == 2) {
uint i, j, k, comp;
const half_float(*rowA)[2] = (const half_float(*)[2]) srcRowA;
const half_float(*rowB)[2] = (const half_float(*)[2]) srcRowB;
@@ -396,7 +394,7 @@ do_row(enum dtype datatype, uint comps, int srcWidth,
}
}
}
- else if (datatype == HALF_FLOAT && comps == 1) {
+ else if (datatype == DTYPE_HALF_FLOAT && comps == 1) {
uint i, j, k;
const half_float *rowA = (const half_float *) srcRowA;
const half_float *rowB = (const half_float *) srcRowB;
@@ -413,7 +411,7 @@ do_row(enum dtype datatype, uint comps, int srcWidth,
}
#endif
- else if (datatype == UINT && comps == 1) {
+ else if (datatype == DTYPE_UINT && comps == 1) {
uint i, j, k;
const uint *rowA = (const uint *) srcRowA;
const uint *rowB = (const uint *) srcRowB;
@@ -424,7 +422,7 @@ do_row(enum dtype datatype, uint comps, int srcWidth,
}
}
- else if (datatype == USHORT_5_6_5 && comps == 3) {
+ else if (datatype == DTYPE_USHORT_5_6_5 && comps == 3) {
uint i, j, k;
const ushort *rowA = (const ushort *) srcRowA;
const ushort *rowB = (const ushort *) srcRowB;
@@ -449,7 +447,7 @@ do_row(enum dtype datatype, uint comps, int srcWidth,
dst[i] = (blue << 11) | (green << 5) | red;
}
}
- else if (datatype == USHORT_4_4_4_4 && comps == 4) {
+ else if (datatype == DTYPE_USHORT_4_4_4_4 && comps == 4) {
uint i, j, k;
const ushort *rowA = (const ushort *) srcRowA;
const ushort *rowB = (const ushort *) srcRowB;
@@ -479,7 +477,7 @@ do_row(enum dtype datatype, uint comps, int srcWidth,
dst[i] = (alpha << 12) | (blue << 8) | (green << 4) | red;
}
}
- else if (datatype == USHORT_1_5_5_5_REV && comps == 4) {
+ else if (datatype == DTYPE_USHORT_1_5_5_5_REV && comps == 4) {
uint i, j, k;
const ushort *rowA = (const ushort *) srcRowA;
const ushort *rowB = (const ushort *) srcRowB;
@@ -509,7 +507,7 @@ do_row(enum dtype datatype, uint comps, int srcWidth,
dst[i] = (alpha << 15) | (blue << 10) | (green << 5) | red;
}
}
- else if (datatype == UBYTE_3_3_2 && comps == 3) {
+ else if (datatype == DTYPE_UBYTE_3_3_2 && comps == 3) {
uint i, j, k;
const ubyte *rowA = (const ubyte *) srcRowA;
const ubyte *rowB = (const ubyte *) srcRowB;
@@ -570,7 +568,7 @@ do_row_3D(enum dtype datatype, uint comps, int srcWidth,
assert(comps >= 1);
assert(comps <= 4);
- if ((datatype == UBYTE) && (comps == 4)) {
+ if ((datatype == DTYPE_UBYTE) && (comps == 4)) {
DECLARE_ROW_POINTERS(ubyte, 4);
for (i = j = 0, k = k0; i < (uint) dstWidth;
@@ -581,7 +579,7 @@ do_row_3D(enum dtype datatype, uint comps, int srcWidth,
FILTER_3D(3);
}
}
- else if ((datatype == UBYTE) && (comps == 3)) {
+ else if ((datatype == DTYPE_UBYTE) && (comps == 3)) {
DECLARE_ROW_POINTERS(ubyte, 3);
for (i = j = 0, k = k0; i < (uint) dstWidth;
@@ -591,7 +589,7 @@ do_row_3D(enum dtype datatype, uint comps, int srcWidth,
FILTER_3D(2);
}
}
- else if ((datatype == UBYTE) && (comps == 2)) {
+ else if ((datatype == DTYPE_UBYTE) && (comps == 2)) {
DECLARE_ROW_POINTERS(ubyte, 2);
for (i = j = 0, k = k0; i < (uint) dstWidth;
@@ -600,7 +598,7 @@ do_row_3D(enum dtype datatype, uint comps, int srcWidth,
FILTER_3D(1);
}
}
- else if ((datatype == UBYTE) && (comps == 1)) {
+ else if ((datatype == DTYPE_UBYTE) && (comps == 1)) {
DECLARE_ROW_POINTERS(ubyte, 1);
for (i = j = 0, k = k0; i < (uint) dstWidth;
@@ -608,7 +606,7 @@ do_row_3D(enum dtype datatype, uint comps, int srcWidth,
FILTER_3D(0);
}
}
- else if ((datatype == USHORT) && (comps == 4)) {
+ else if ((datatype == DTYPE_USHORT) && (comps == 4)) {
DECLARE_ROW_POINTERS(ushort, 4);
for (i = j = 0, k = k0; i < (uint) dstWidth;
@@ -619,7 +617,7 @@ do_row_3D(enum dtype datatype, uint comps, int srcWidth,
FILTER_3D(3);
}
}
- else if ((datatype == USHORT) && (comps == 3)) {
+ else if ((datatype == DTYPE_USHORT) && (comps == 3)) {
DECLARE_ROW_POINTERS(ushort, 3);
for (i = j = 0, k = k0; i < (uint) dstWidth;
@@ -629,7 +627,7 @@ do_row_3D(enum dtype datatype, uint comps, int srcWidth,
FILTER_3D(2);
}
}
- else if ((datatype == USHORT) && (comps == 2)) {
+ else if ((datatype == DTYPE_USHORT) && (comps == 2)) {
DECLARE_ROW_POINTERS(ushort, 2);
for (i = j = 0, k = k0; i < (uint) dstWidth;
@@ -638,7 +636,7 @@ do_row_3D(enum dtype datatype, uint comps, int srcWidth,
FILTER_3D(1);
}
}
- else if ((datatype == USHORT) && (comps == 1)) {
+ else if ((datatype == DTYPE_USHORT) && (comps == 1)) {
DECLARE_ROW_POINTERS(ushort, 1);
for (i = j = 0, k = k0; i < (uint) dstWidth;
@@ -646,7 +644,7 @@ do_row_3D(enum dtype datatype, uint comps, int srcWidth,
FILTER_3D(0);
}
}
- else if ((datatype == FLOAT) && (comps == 4)) {
+ else if ((datatype == DTYPE_FLOAT) && (comps == 4)) {
DECLARE_ROW_POINTERS(float, 4);
for (i = j = 0, k = k0; i < (uint) dstWidth;
@@ -657,7 +655,7 @@ do_row_3D(enum dtype datatype, uint comps, int srcWidth,
FILTER_F_3D(3);
}
}
- else if ((datatype == FLOAT) && (comps == 3)) {
+ else if ((datatype == DTYPE_FLOAT) && (comps == 3)) {
DECLARE_ROW_POINTERS(float, 3);
for (i = j = 0, k = k0; i < (uint) dstWidth;
@@ -667,7 +665,7 @@ do_row_3D(enum dtype datatype, uint comps, int srcWidth,
FILTER_F_3D(2);
}
}
- else if ((datatype == FLOAT) && (comps == 2)) {
+ else if ((datatype == DTYPE_FLOAT) && (comps == 2)) {
DECLARE_ROW_POINTERS(float, 2);
for (i = j = 0, k = k0; i < (uint) dstWidth;
@@ -676,7 +674,7 @@ do_row_3D(enum dtype datatype, uint comps, int srcWidth,
FILTER_F_3D(1);
}
}
- else if ((datatype == FLOAT) && (comps == 1)) {
+ else if ((datatype == DTYPE_FLOAT) && (comps == 1)) {
DECLARE_ROW_POINTERS(float, 1);
for (i = j = 0, k = k0; i < (uint) dstWidth;
@@ -684,7 +682,7 @@ do_row_3D(enum dtype datatype, uint comps, int srcWidth,
FILTER_F_3D(0);
}
}
- else if ((datatype == HALF_FLOAT) && (comps == 4)) {
+ else if ((datatype == DTYPE_HALF_FLOAT) && (comps == 4)) {
DECLARE_ROW_POINTERS(half_float, 4);
for (i = j = 0, k = k0; i < (uint) dstWidth;
@@ -695,7 +693,7 @@ do_row_3D(enum dtype datatype, uint comps, int srcWidth,
FILTER_HF_3D(3);
}
}
- else if ((datatype == HALF_FLOAT) && (comps == 3)) {
+ else if ((datatype == DTYPE_HALF_FLOAT) && (comps == 3)) {
DECLARE_ROW_POINTERS(half_float, 4);
for (i = j = 0, k = k0; i < (uint) dstWidth;
@@ -705,7 +703,7 @@ do_row_3D(enum dtype datatype, uint comps, int srcWidth,
FILTER_HF_3D(2);
}
}
- else if ((datatype == HALF_FLOAT) && (comps == 2)) {
+ else if ((datatype == DTYPE_HALF_FLOAT) && (comps == 2)) {
DECLARE_ROW_POINTERS(half_float, 4);
for (i = j = 0, k = k0; i < (uint) dstWidth;
@@ -714,7 +712,7 @@ do_row_3D(enum dtype datatype, uint comps, int srcWidth,
FILTER_HF_3D(1);
}
}
- else if ((datatype == HALF_FLOAT) && (comps == 1)) {
+ else if ((datatype == DTYPE_HALF_FLOAT) && (comps == 1)) {
DECLARE_ROW_POINTERS(half_float, 4);
for (i = j = 0, k = k0; i < (uint) dstWidth;
@@ -722,7 +720,7 @@ do_row_3D(enum dtype datatype, uint comps, int srcWidth,
FILTER_HF_3D(0);
}
}
- else if ((datatype == UINT) && (comps == 1)) {
+ else if ((datatype == DTYPE_UINT) && (comps == 1)) {
const uint *rowA = (const uint *) srcRowA;
const uint *rowB = (const uint *) srcRowB;
const uint *rowC = (const uint *) srcRowC;
@@ -738,7 +736,7 @@ do_row_3D(enum dtype datatype, uint comps, int srcWidth,
dst[i] = (float)((double) tmp * 0.125);
}
}
- else if ((datatype == USHORT_5_6_5) && (comps == 3)) {
+ else if ((datatype == DTYPE_USHORT_5_6_5) && (comps == 3)) {
DECLARE_ROW_POINTERS0(ushort);
for (i = j = 0, k = k0; i < (uint) dstWidth;
@@ -776,7 +774,7 @@ do_row_3D(enum dtype datatype, uint comps, int srcWidth,
dst[i] = (b << 11) | (g << 5) | r;
}
}
- else if ((datatype == USHORT_4_4_4_4) && (comps == 4)) {
+ else if ((datatype == DTYPE_USHORT_4_4_4_4) && (comps == 4)) {
DECLARE_ROW_POINTERS0(ushort);
for (i = j = 0, k = k0; i < (uint) dstWidth;
@@ -825,7 +823,7 @@ do_row_3D(enum dtype datatype, uint comps, int srcWidth,
dst[i] = (a << 12) | (b << 8) | (g << 4) | r;
}
}
- else if ((datatype == USHORT_1_5_5_5_REV) && (comps == 4)) {
+ else if ((datatype == DTYPE_USHORT_1_5_5_5_REV) && (comps == 4)) {
DECLARE_ROW_POINTERS0(ushort);
for (i = j = 0, k = k0; i < (uint) dstWidth;
@@ -874,7 +872,7 @@ do_row_3D(enum dtype datatype, uint comps, int srcWidth,
dst[i] = (a << 15) | (b << 10) | (g << 5) | r;
}
}
- else if ((datatype == UBYTE_3_3_2) && (comps == 3)) {
+ else if ((datatype == DTYPE_UBYTE_3_3_2) && (comps == 3)) {
DECLARE_ROW_POINTERS0(ushort);
for (i = j = 0, k = k0; i < (uint) dstWidth;
@@ -928,34 +926,34 @@ format_to_type_comps(enum pipe_format pformat,
case PIPE_FORMAT_X8R8G8B8_UNORM:
case PIPE_FORMAT_B8G8R8A8_UNORM:
case PIPE_FORMAT_B8G8R8X8_UNORM:
- *datatype = UBYTE;
+ *datatype = DTYPE_UBYTE;
*comps = 4;
return;
case PIPE_FORMAT_A1R5G5B5_UNORM:
- *datatype = USHORT_1_5_5_5_REV;
+ *datatype = DTYPE_USHORT_1_5_5_5_REV;
*comps = 4;
return;
case PIPE_FORMAT_A4R4G4B4_UNORM:
- *datatype = USHORT_4_4_4_4;
+ *datatype = DTYPE_USHORT_4_4_4_4;
*comps = 4;
return;
case PIPE_FORMAT_R5G6B5_UNORM:
- *datatype = USHORT_5_6_5;
+ *datatype = DTYPE_USHORT_5_6_5;
*comps = 3;
return;
case PIPE_FORMAT_L8_UNORM:
case PIPE_FORMAT_A8_UNORM:
case PIPE_FORMAT_I8_UNORM:
- *datatype = UBYTE;
+ *datatype = DTYPE_UBYTE;
*comps = 1;
return;
case PIPE_FORMAT_A8L8_UNORM:
- *datatype = UBYTE;
+ *datatype = DTYPE_UBYTE;
*comps = 2;
return;
default:
assert(0);
- *datatype = UBYTE;
+ *datatype = DTYPE_UBYTE;
*comps = 0;
break;
}
@@ -1116,31 +1114,30 @@ make_1d_mipmap(struct gen_mipmap_state *ctx,
for (dstLevel = baseLevel + 1; dstLevel <= lastLevel; dstLevel++) {
const uint srcLevel = dstLevel - 1;
- struct pipe_surface *srcSurf, *dstSurf;
+ struct pipe_transfer *srcTrans, *dstTrans;
void *srcMap, *dstMap;
- srcSurf = screen->get_tex_surface(screen, pt, face, srcLevel, zslice,
- PIPE_BUFFER_USAGE_CPU_READ);
-
- dstSurf = screen->get_tex_surface(screen, pt, face, dstLevel, zslice,
- PIPE_BUFFER_USAGE_CPU_WRITE);
-
- srcMap = ((ubyte *) pipe_surface_map(srcSurf,
- PIPE_BUFFER_USAGE_CPU_READ)
- + srcSurf->offset);
- dstMap = ((ubyte *) pipe_surface_map(dstSurf,
- PIPE_BUFFER_USAGE_CPU_WRITE)
- + dstSurf->offset);
+ srcTrans = screen->get_tex_transfer(screen, pt, face, srcLevel, zslice,
+ PIPE_TRANSFER_READ, 0, 0,
+ pt->width[srcLevel],
+ pt->height[srcLevel]);
+ dstTrans = screen->get_tex_transfer(screen, pt, face, dstLevel, zslice,
+ PIPE_TRANSFER_WRITE, 0, 0,
+ pt->width[dstLevel],
+ pt->height[dstLevel]);
+
+ srcMap = (ubyte *) screen->transfer_map(screen, srcTrans);
+ dstMap = (ubyte *) screen->transfer_map(screen, dstTrans);
reduce_1d(pt->format,
- srcSurf->width, srcMap,
- dstSurf->width, dstMap);
+ srcTrans->width, srcMap,
+ dstTrans->width, dstMap);
- pipe_surface_unmap(srcSurf);
- pipe_surface_unmap(dstSurf);
+ screen->transfer_unmap(screen, srcTrans);
+ screen->transfer_unmap(screen, dstTrans);
- pipe_surface_reference(&srcSurf, NULL);
- pipe_surface_reference(&dstSurf, NULL);
+ screen->tex_transfer_destroy(srcTrans);
+ screen->tex_transfer_destroy(dstTrans);
}
}
@@ -1160,32 +1157,32 @@ make_2d_mipmap(struct gen_mipmap_state *ctx,
for (dstLevel = baseLevel + 1; dstLevel <= lastLevel; dstLevel++) {
const uint srcLevel = dstLevel - 1;
- struct pipe_surface *srcSurf, *dstSurf;
+ struct pipe_transfer *srcTrans, *dstTrans;
ubyte *srcMap, *dstMap;
- srcSurf = screen->get_tex_surface(screen, pt, face, srcLevel, zslice,
- PIPE_BUFFER_USAGE_CPU_READ);
- dstSurf = screen->get_tex_surface(screen, pt, face, dstLevel, zslice,
- PIPE_BUFFER_USAGE_CPU_WRITE);
-
- srcMap = ((ubyte *) pipe_surface_map(srcSurf,
- PIPE_BUFFER_USAGE_CPU_READ)
- + srcSurf->offset);
- dstMap = ((ubyte *) pipe_surface_map(dstSurf,
- PIPE_BUFFER_USAGE_CPU_WRITE)
- + dstSurf->offset);
+ srcTrans = screen->get_tex_transfer(screen, pt, face, srcLevel, zslice,
+ PIPE_TRANSFER_READ, 0, 0,
+ pt->width[srcLevel],
+ pt->height[srcLevel]);
+ dstTrans = screen->get_tex_transfer(screen, pt, face, dstLevel, zslice,
+ PIPE_TRANSFER_WRITE, 0, 0,
+ pt->width[dstLevel],
+ pt->height[dstLevel]);
+
+ srcMap = (ubyte *) screen->transfer_map(screen, srcTrans);
+ dstMap = (ubyte *) screen->transfer_map(screen, dstTrans);
reduce_2d(pt->format,
- srcSurf->width, srcSurf->height,
- srcSurf->stride, srcMap,
- dstSurf->width, dstSurf->height,
- dstSurf->stride, dstMap);
+ srcTrans->width, srcTrans->height,
+ srcTrans->stride, srcMap,
+ dstTrans->width, dstTrans->height,
+ dstTrans->stride, dstMap);
- pipe_surface_unmap(srcSurf);
- pipe_surface_unmap(dstSurf);
+ screen->transfer_unmap(screen, srcTrans);
+ screen->transfer_unmap(screen, dstTrans);
- pipe_surface_reference(&srcSurf, NULL);
- pipe_surface_reference(&dstSurf, NULL);
+ screen->tex_transfer_destroy(srcTrans);
+ screen->tex_transfer_destroy(dstTrans);
}
}
@@ -1195,6 +1192,7 @@ make_3d_mipmap(struct gen_mipmap_state *ctx,
struct pipe_texture *pt,
uint face, uint baseLevel, uint lastLevel)
{
+#if 0
struct pipe_context *pipe = ctx->pipe;
struct pipe_screen *screen = pipe->screen;
uint dstLevel, zslice = 0;
@@ -1204,37 +1202,36 @@ make_3d_mipmap(struct gen_mipmap_state *ctx,
for (dstLevel = baseLevel + 1; dstLevel <= lastLevel; dstLevel++) {
const uint srcLevel = dstLevel - 1;
- struct pipe_surface *srcSurf, *dstSurf;
+ struct pipe_transfer *srcTrans, *dstTrans;
ubyte *srcMap, *dstMap;
- srcSurf = screen->get_tex_surface(screen, pt, face, srcLevel, zslice,
- PIPE_BUFFER_USAGE_CPU_READ);
- dstSurf = screen->get_tex_surface(screen, pt, face, dstLevel, zslice,
- PIPE_BUFFER_USAGE_CPU_WRITE);
-
- srcMap = ((ubyte *) pipe_surface_map(srcSurf,
- PIPE_BUFFER_USAGE_CPU_READ)
- + srcSurf->offset);
- dstMap = ((ubyte *) pipe_surface_map(dstSurf,
- PIPE_BUFFER_USAGE_CPU_WRITE)
- + dstSurf->offset);
+ srcTrans = screen->get_tex_transfer(screen, pt, face, srcLevel, zslice,
+ PIPE_TRANSFER_READ, 0, 0,
+ pt->width[srcLevel],
+ pt->height[srcLevel]);
+ dstTrans = screen->get_tex_transfer(screen, pt, face, dstLevel, zslice,
+ PIPE_TRANSFER_WRITE, 0, 0,
+ pt->width[dstLevel],
+ pt->height[dstLevel]);
+
+ srcMap = (ubyte *) screen->transfer_map(screen, srcTrans);
+ dstMap = (ubyte *) screen->transfer_map(screen, dstTrans);
-#if 0
reduce_3d(pt->format,
- srcSurf->width, srcSurf->height,
- srcSurf->stride, srcMap,
- dstSurf->width, dstSurf->height,
- dstSurf->stride, dstMap);
-#else
- (void) reduce_3d;
-#endif
+ srcTrans->width, srcTrans->height,
+ srcTrans->stride, srcMap,
+ dstTrans->width, dstTrans->height,
+ dstTrans->stride, dstMap);
- pipe_surface_unmap(srcSurf);
- pipe_surface_unmap(dstSurf);
+ screen->transfer_unmap(screen, srcTrans);
+ screen->transfer_unmap(screen, dstTrans);
- pipe_surface_reference(&srcSurf, NULL);
- pipe_surface_reference(&dstSurf, NULL);
+ screen->tex_transfer_destroy(srcTrans);
+ screen->tex_transfer_destroy(dstTrans);
}
+#else
+ (void) reduce_3d;
+#endif
}
@@ -1294,8 +1291,7 @@ util_create_gen_mipmap(struct pipe_context *pipe,
memset(&ctx->rasterizer, 0, sizeof(ctx->rasterizer));
ctx->rasterizer.front_winding = PIPE_WINDING_CW;
ctx->rasterizer.cull_mode = PIPE_WINDING_NONE;
- ctx->rasterizer.bypass_clipping = 1;
- /*ctx->rasterizer.bypass_vs = 1;*/
+ ctx->rasterizer.bypass_vs_clip_and_viewport = 1;
ctx->rasterizer.gl_rasterization_rules = 1;
/* sampler state */
@@ -1306,28 +1302,19 @@ util_create_gen_mipmap(struct pipe_context *pipe,
ctx->sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NEAREST;
ctx->sampler.normalized_coords = 1;
- /* viewport state (identity, verts are in wincoords) */
- ctx->viewport.scale[0] = 1.0;
- ctx->viewport.scale[1] = 1.0;
- ctx->viewport.scale[2] = 1.0;
- ctx->viewport.scale[3] = 1.0;
- ctx->viewport.translate[0] = 0.0;
- ctx->viewport.translate[1] = 0.0;
- ctx->viewport.translate[2] = 0.0;
- ctx->viewport.translate[3] = 0.0;
-
- /* vertex shader */
+ /* vertex shader - still needed to specify mapping from fragment
+ * shader input semantics to vertex elements
+ */
{
const uint semantic_names[] = { TGSI_SEMANTIC_POSITION,
TGSI_SEMANTIC_GENERIC };
const uint semantic_indexes[] = { 0, 0 };
ctx->vs = util_make_vertex_passthrough_shader(pipe, 2, semantic_names,
- semantic_indexes,
- &ctx->vert_shader);
+ semantic_indexes);
}
/* fragment shader */
- ctx->fs = util_make_fragment_tex_shader(pipe, &ctx->frag_shader);
+ ctx->fs = util_make_fragment_tex_shader(pipe);
/* vertex data that doesn't change */
for (i = 0; i < 4; i++) {
@@ -1369,7 +1356,6 @@ get_next_slot(struct gen_mipmap_state *ctx)
static unsigned
set_vertex_data(struct gen_mipmap_state *ctx, float width, float height)
{
- void *buf;
unsigned offset;
ctx->vertices[0][0][0] = 0.0f; /*x*/
@@ -1394,12 +1380,8 @@ set_vertex_data(struct gen_mipmap_state *ctx, float width, float height)
offset = get_next_slot( ctx );
- buf = pipe_buffer_map(ctx->pipe->screen, ctx->vbuf,
- PIPE_BUFFER_USAGE_CPU_WRITE);
-
- memcpy((char *)buf + offset, ctx->vertices, sizeof(ctx->vertices));
-
- pipe_buffer_unmap(ctx->pipe->screen, ctx->vbuf);
+ pipe_buffer_write(ctx->pipe->screen, ctx->vbuf,
+ offset, sizeof(ctx->vertices), ctx->vertices);
return offset;
}
@@ -1417,10 +1399,7 @@ util_destroy_gen_mipmap(struct gen_mipmap_state *ctx)
pipe->delete_vs_state(pipe, ctx->vs);
pipe->delete_fs_state(pipe, ctx->fs);
- FREE((void*) ctx->vert_shader.tokens);
- FREE((void*) ctx->frag_shader.tokens);
-
- pipe_buffer_reference(pipe->screen, &ctx->vbuf, NULL);
+ pipe_buffer_reference(&ctx->vbuf, NULL);
FREE(ctx);
}
@@ -1432,7 +1411,7 @@ util_destroy_gen_mipmap(struct gen_mipmap_state *ctx)
*/
void util_gen_mipmap_flush( struct gen_mipmap_state *ctx )
{
- pipe_buffer_reference(ctx->pipe->screen, &ctx->vbuf, NULL);
+ pipe_buffer_reference(&ctx->vbuf, NULL);
ctx->vbuf_slot = 0;
}
@@ -1476,13 +1455,11 @@ util_gen_mipmap(struct gen_mipmap_state *ctx,
cso_save_framebuffer(ctx->cso);
cso_save_fragment_shader(ctx->cso);
cso_save_vertex_shader(ctx->cso);
- cso_save_viewport(ctx->cso);
/* bind our state */
cso_set_blend(ctx->cso, &ctx->blend);
cso_set_depth_stencil_alpha(ctx->cso, &ctx->depthstencil);
cso_set_rasterizer(ctx->cso, &ctx->rasterizer);
- cso_set_viewport(ctx->cso, &ctx->viewport);
cso_set_fragment_shader_handle(ctx->cso, ctx->fs);
cso_set_vertex_shader_handle(ctx->cso, ctx->vs);
@@ -1528,7 +1505,7 @@ util_gen_mipmap(struct gen_mipmap_state *ctx,
cso_set_sampler_textures(ctx->cso, 1, &pt);
- /* quad coords in window coords (bypassing clipping, viewport mapping) */
+ /* quad coords in window coords (bypassing vs, clip and viewport) */
offset = set_vertex_data(ctx,
(float) pt->width[dstLevel],
(float) pt->height[dstLevel]);
@@ -1555,5 +1532,4 @@ util_gen_mipmap(struct gen_mipmap_state *ctx,
cso_restore_framebuffer(ctx->cso);
cso_restore_fragment_shader(ctx->cso);
cso_restore_vertex_shader(ctx->cso);
- cso_restore_viewport(ctx->cso);
}