aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/state_tracker
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/mesa/state_tracker')
-rw-r--r--mesalib/src/mesa/state_tracker/st_atom_sampler.c4
-rw-r--r--mesalib/src/mesa/state_tracker/st_atom_texture.c4
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c23
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_readpixels.c33
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_texture.c9
-rw-r--r--mesalib/src/mesa/state_tracker/st_texture.h15
6 files changed, 40 insertions, 48 deletions
diff --git a/mesalib/src/mesa/state_tracker/st_atom_sampler.c b/mesalib/src/mesa/state_tracker/st_atom_sampler.c
index cb1817970..80e6cb02c 100644
--- a/mesalib/src/mesa/state_tracker/st_atom_sampler.c
+++ b/mesalib/src/mesa/state_tracker/st_atom_sampler.c
@@ -33,6 +33,8 @@
#include "main/macros.h"
+#include "main/mtypes.h"
+#include "main/samplerobj.h"
#include "st_context.h"
#include "st_cb_texture.h"
@@ -154,7 +156,7 @@ update_samplers(struct st_context *st)
teximg = texobj->Image[0][texobj->BaseLevel];
- msamp = st_get_mesa_sampler(st->ctx, texUnit);
+ msamp = _mesa_get_samplerobj(st->ctx, texUnit);
sampler->wrap_s = gl_wrap_xlate(msamp->WrapS);
sampler->wrap_t = gl_wrap_xlate(msamp->WrapT);
diff --git a/mesalib/src/mesa/state_tracker/st_atom_texture.c b/mesalib/src/mesa/state_tracker/st_atom_texture.c
index 4277a24b0..fb532644f 100644
--- a/mesalib/src/mesa/state_tracker/st_atom_texture.c
+++ b/mesalib/src/mesa/state_tracker/st_atom_texture.c
@@ -33,6 +33,8 @@
#include "main/macros.h"
+#include "main/mtypes.h"
+#include "main/samplerobj.h"
#include "program/prog_instruction.h"
#include "st_context.h"
@@ -209,7 +211,7 @@ update_textures(struct st_context *st)
else
texUnit = vprog->Base.SamplerUnits[su];
- samp = st_get_mesa_sampler(st->ctx, texUnit);
+ samp = _mesa_get_samplerobj(st->ctx, texUnit);
texObj = st->ctx->Texture.Unit[texUnit]._Current;
diff --git a/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c b/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c
index 953cb446e..06573d9ad 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c
@@ -408,9 +408,7 @@ st_copy_buffer_subdata(struct gl_context *ctx,
struct pipe_context *pipe = st_context(ctx)->pipe;
struct st_buffer_object *srcObj = st_buffer_object(src);
struct st_buffer_object *dstObj = st_buffer_object(dst);
- struct pipe_transfer *src_transfer;
- struct pipe_transfer *dst_transfer;
- ubyte *srcPtr, *dstPtr;
+ struct pipe_box box;
if(!size)
return;
@@ -419,23 +417,10 @@ st_copy_buffer_subdata(struct gl_context *ctx,
assert(!src->Pointer);
assert(!dst->Pointer);
- srcPtr = (ubyte *) pipe_buffer_map_range(pipe,
- srcObj->buffer,
- readOffset, size,
- PIPE_TRANSFER_READ,
- &src_transfer);
+ u_box_1d(readOffset, size, &box);
- dstPtr = (ubyte *) pipe_buffer_map_range(pipe,
- dstObj->buffer,
- writeOffset, size,
- PIPE_TRANSFER_WRITE,
- &dst_transfer);
-
- if (srcPtr && dstPtr)
- memcpy(dstPtr + writeOffset, srcPtr + readOffset, size);
-
- pipe_buffer_unmap(pipe, src_transfer);
- pipe_buffer_unmap(pipe, dst_transfer);
+ pipe->resource_copy_region(pipe, dstObj->buffer, 0, writeOffset, 0, 0,
+ srcObj->buffer, 0, &box);
}
diff --git a/mesalib/src/mesa/state_tracker/st_cb_readpixels.c b/mesalib/src/mesa/state_tracker/st_cb_readpixels.c
index 08f53054d..2c2da42c4 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_readpixels.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_readpixels.c
@@ -198,6 +198,7 @@ st_fast_readpixels(struct gl_context *ctx, struct st_renderbuffer *strb,
const struct gl_pixelstore_attrib *pack,
GLvoid *dest)
{
+ GLubyte alphaORoperand;
enum combination {
A8R8G8B8_UNORM_TO_RGBA_UBYTE,
A8R8G8B8_UNORM_TO_RGB_UBYTE,
@@ -208,20 +209,26 @@ st_fast_readpixels(struct gl_context *ctx, struct st_renderbuffer *strb,
if (ctx->_ImageTransferState)
return GL_FALSE;
- if (strb->format == PIPE_FORMAT_B8G8R8A8_UNORM &&
- format == GL_RGBA && type == GL_UNSIGNED_BYTE) {
+ if (strb->format == PIPE_FORMAT_B8G8R8A8_UNORM) {
+ alphaORoperand = 0;
+ }
+ else if (strb->format == PIPE_FORMAT_B8G8R8X8_UNORM ) {
+ alphaORoperand = 0xff;
+ }
+ else {
+ return GL_FALSE;
+ }
+
+ if (format == GL_RGBA && type == GL_UNSIGNED_BYTE) {
combo = A8R8G8B8_UNORM_TO_RGBA_UBYTE;
}
- else if (strb->format == PIPE_FORMAT_B8G8R8A8_UNORM &&
- format == GL_RGB && type == GL_UNSIGNED_BYTE) {
+ else if (format == GL_RGB && type == GL_UNSIGNED_BYTE) {
combo = A8R8G8B8_UNORM_TO_RGB_UBYTE;
}
- else if (strb->format == PIPE_FORMAT_B8G8R8A8_UNORM &&
- format == GL_BGRA && type == GL_UNSIGNED_INT_8_8_8_8_REV) {
+ else if (format == GL_BGRA && type == GL_UNSIGNED_INT_8_8_8_8_REV) {
combo = A8R8G8B8_UNORM_TO_BGRA_UINT;
}
- else if (strb->format == PIPE_FORMAT_B8G8R8A8_UNORM &&
- format == GL_RGBA && type == GL_UNSIGNED_INT_8_8_8_8) {
+ else if (format == GL_RGBA && type == GL_UNSIGNED_INT_8_8_8_8) {
combo = A8R8G8B8_UNORM_TO_RGBA_UINT;
}
else {
@@ -283,7 +290,7 @@ st_fast_readpixels(struct gl_context *ctx, struct st_renderbuffer *strb,
dst[col*4+0] = (pixel >> 16) & 0xff;
dst[col*4+1] = (pixel >> 8) & 0xff;
dst[col*4+2] = (pixel >> 0) & 0xff;
- dst[col*4+3] = (pixel >> 24) & 0xff;
+ dst[col*4+3] = ((pixel >> 24) & 0xff) | alphaORoperand;
}
dst += dstStride;
y += dy;
@@ -306,6 +313,12 @@ st_fast_readpixels(struct gl_context *ctx, struct st_renderbuffer *strb,
for (row = 0; row < height; row++) {
const GLubyte *src = map + y * trans->stride;
memcpy(dst, src, 4 * width);
+ if (alphaORoperand) {
+ assert(alphaORoperand == 0xff);
+ for (col = 0; col < width; col++) {
+ dst[col*4+3] = 0xff;
+ }
+ }
dst += dstStride;
y += dy;
}
@@ -315,7 +328,7 @@ st_fast_readpixels(struct gl_context *ctx, struct st_renderbuffer *strb,
const GLubyte *src = map + y * trans->stride;
for (col = 0; col < width; col++) {
GLuint pixel = ((GLuint *) src)[col];
- dst[col*4+0] = (pixel >> 24) & 0xff;
+ dst[col*4+0] = ((pixel >> 24) & 0xff) | alphaORoperand;
dst[col*4+1] = (pixel >> 0) & 0xff;
dst[col*4+2] = (pixel >> 8) & 0xff;
dst[col*4+3] = (pixel >> 16) & 0xff;
diff --git a/mesalib/src/mesa/state_tracker/st_cb_texture.c b/mesalib/src/mesa/state_tracker/st_cb_texture.c
index 0dc61bba9..74f9449b7 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_texture.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_texture.c
@@ -1686,7 +1686,7 @@ copy_image_data_to_texture(struct st_context *st,
/* debug checks */
{
const struct gl_texture_image *dstImage =
- stObj->base.Image[stImage->face][stImage->level];
+ stObj->base.Image[stImage->face][dstLevel];
assert(dstImage);
assert(dstImage->Width == stImage->base.Width);
assert(dstImage->Height == stImage->base.Height);
@@ -1843,7 +1843,12 @@ st_finalize_texture(struct gl_context *ctx,
/* Need to import images in main memory or held in other textures.
*/
if (stImage && stObj->pt != stImage->pt) {
- copy_image_data_to_texture(st, stObj, level, stImage);
+ if (level == 0 || (stImage->base.Width == u_minify(stObj->width0, level) &&
+ stImage->base.Height == u_minify(stObj->height0, level) &&
+ stImage->base.Depth == u_minify(stObj->depth0, level))) {
+ /* src image fits expected dest mipmap level size */
+ copy_image_data_to_texture(st, stObj, level, stImage);
+ }
}
}
}
diff --git a/mesalib/src/mesa/state_tracker/st_texture.h b/mesalib/src/mesa/state_tracker/st_texture.h
index 5c7216e60..b25f16410 100644
--- a/mesalib/src/mesa/state_tracker/st_texture.h
+++ b/mesalib/src/mesa/state_tracker/st_texture.h
@@ -163,21 +163,6 @@ st_get_texture_sampler_view(struct st_texture_object *stObj,
}
-/**
- * Get pointer to the active sampler object for the given texture unit.
- * This will either be a user-defined sampler object or the texture
- * object's own sampler state.
- */
-static INLINE struct gl_sampler_object *
-st_get_mesa_sampler(const struct gl_context *ctx, GLuint unit)
-{
- if (ctx->Texture.Unit[unit].Sampler)
- return ctx->Texture.Unit[unit].Sampler;
- else
- return &ctx->Texture.Unit[unit]._Current->Sampler;
-}
-
-
extern struct pipe_resource *
st_texture_create(struct st_context *st,
enum pipe_texture_target target,