summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorChih-Wei Huang <cwhuang@linux.org.tw>2016-11-15 16:02:40 +0800
committerChih-Wei Huang <cwhuang@linux.org.tw>2016-11-16 10:46:46 +0800
commitf43ac65d6166f73eb439391b463218d97c65cce9 (patch)
tree0d06ec98e48be80cd924d3f6647a3913f3686ce0 /src/mesa
parent1955a9ca8d71ba5eaff4073bdfff4dee76e1a73a (diff)
parentf2f487ebbb808010528edd69000694bfe525f87b (diff)
downloadexternal_mesa3d-f43ac65d6166f73eb439391b463218d97c65cce9.zip
external_mesa3d-f43ac65d6166f73eb439391b463218d97c65cce9.tar.gz
external_mesa3d-f43ac65d6166f73eb439391b463218d97c65cce9.tar.bz2
Merge remote-tracking branch 'mesa/13.0' into nougat-x86
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/drivers/dri/i965/brw_blorp.c3
-rw-r--r--src/mesa/drivers/dri/i965/brw_fs.cpp6
-rw-r--r--src/mesa/main/shaderobj.c23
-rw-r--r--src/mesa/main/shaderobj.h3
-rw-r--r--src/mesa/program/ir_to_mesa.cpp2
-rw-r--r--src/mesa/state_tracker/st_glsl_to_tgsi.cpp10
-rw-r--r--src/mesa/state_tracker/st_sampler_view.c15
-rw-r--r--src/mesa/state_tracker/st_texture.h9
-rw-r--r--src/mesa/state_tracker/st_vdpau.c20
9 files changed, 52 insertions, 39 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_blorp.c b/src/mesa/drivers/dri/i965/brw_blorp.c
index 9484574..cd2cc76 100644
--- a/src/mesa/drivers/dri/i965/brw_blorp.c
+++ b/src/mesa/drivers/dri/i965/brw_blorp.c
@@ -52,7 +52,8 @@ static void
brw_blorp_upload_shader(struct blorp_context *blorp,
const void *key, uint32_t key_size,
const void *kernel, uint32_t kernel_size,
- const void *prog_data, uint32_t prog_data_size,
+ const struct brw_stage_prog_data *prog_data,
+ uint32_t prog_data_size,
uint32_t *kernel_out, void *prog_data_out)
{
struct brw_context *brw = blorp->driver_ctx;
diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
index 921cc00..afb1057 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -3673,6 +3673,12 @@ lower_fb_write_logical_send(const fs_builder &bld, fs_inst *inst,
*/
setup_color_payload(bld, key, &sources[length], src0_alpha, 1);
length++;
+ } else if (key->replicate_alpha && inst->target != 0) {
+ /* Handle the case when fragment shader doesn't write to draw buffer
+ * zero. No need to call setup_color_payload() for src0_alpha because
+ * alpha value will be undefined.
+ */
+ length++;
}
setup_color_payload(bld, key, &sources[length], color0, components);
diff --git a/src/mesa/main/shaderobj.c b/src/mesa/main/shaderobj.c
index 136ac7b..8fd574e 100644
--- a/src/mesa/main/shaderobj.c
+++ b/src/mesa/main/shaderobj.c
@@ -291,12 +291,18 @@ _mesa_new_shader_program(GLuint name)
* Clear (free) the shader program state that gets produced by linking.
*/
void
-_mesa_clear_shader_program_data(struct gl_shader_program *shProg)
+_mesa_clear_shader_program_data(struct gl_context *ctx,
+ struct gl_shader_program *shProg)
{
- unsigned i;
+ for (gl_shader_stage sh = 0; sh < MESA_SHADER_STAGES; sh++) {
+ if (shProg->_LinkedShaders[sh] != NULL) {
+ _mesa_delete_linked_shader(ctx, shProg->_LinkedShaders[sh]);
+ shProg->_LinkedShaders[sh] = NULL;
+ }
+ }
if (shProg->UniformStorage) {
- for (i = 0; i < shProg->NumUniformStorage; ++i)
+ for (unsigned i = 0; i < shProg->NumUniformStorage; ++i)
_mesa_uniform_detach_all_driver_storage(&shProg->UniformStorage[i]);
ralloc_free(shProg->UniformStorage);
shProg->NumUniformStorage = 0;
@@ -347,11 +353,10 @@ _mesa_free_shader_program_data(struct gl_context *ctx,
struct gl_shader_program *shProg)
{
GLuint i;
- gl_shader_stage sh;
assert(shProg->Type == GL_SHADER_PROGRAM_MESA);
- _mesa_clear_shader_program_data(shProg);
+ _mesa_clear_shader_program_data(ctx, shProg);
if (shProg->AttributeBindings) {
string_to_uint_map_dtor(shProg->AttributeBindings);
@@ -385,14 +390,6 @@ _mesa_free_shader_program_data(struct gl_context *ctx,
shProg->TransformFeedback.VaryingNames = NULL;
shProg->TransformFeedback.NumVarying = 0;
-
- for (sh = 0; sh < MESA_SHADER_STAGES; sh++) {
- if (shProg->_LinkedShaders[sh] != NULL) {
- _mesa_delete_linked_shader(ctx, shProg->_LinkedShaders[sh]);
- shProg->_LinkedShaders[sh] = NULL;
- }
- }
-
free(shProg->Label);
shProg->Label = NULL;
}
diff --git a/src/mesa/main/shaderobj.h b/src/mesa/main/shaderobj.h
index 814a7f1..1249732 100644
--- a/src/mesa/main/shaderobj.h
+++ b/src/mesa/main/shaderobj.h
@@ -99,7 +99,8 @@ extern struct gl_shader_program *
_mesa_new_shader_program(GLuint name);
extern void
-_mesa_clear_shader_program_data(struct gl_shader_program *shProg);
+_mesa_clear_shader_program_data(struct gl_context *ctx,
+ struct gl_shader_program *shProg);
extern void
_mesa_free_shader_program_data(struct gl_context *ctx,
diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index bd65df2..2a29d69 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -3052,7 +3052,7 @@ _mesa_glsl_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
{
unsigned int i;
- _mesa_clear_shader_program_data(prog);
+ _mesa_clear_shader_program_data(ctx, prog);
prog->LinkStatus = GL_TRUE;
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index f376462..c4c08db 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -772,9 +772,9 @@ glsl_to_tgsi_visitor::emit_asm(ir_instruction *ir, unsigned op,
int i = u_bit_scan(&writemask);
- /* before emitting the instruction, see if we have to adjust store
+ /* before emitting the instruction, see if we have to adjust load / store
* address */
- if (i > 1 && inst->op == TGSI_OPCODE_STORE &&
+ if (i > 1 && (inst->op == TGSI_OPCODE_LOAD || inst->op == TGSI_OPCODE_STORE) &&
addr.file == PROGRAM_UNDEFINED) {
/* We have to advance the buffer address by 16 */
addr = get_temp(glsl_type::uint_type);
@@ -782,7 +782,6 @@ glsl_to_tgsi_visitor::emit_asm(ir_instruction *ir, unsigned op,
inst->src[0], st_src_reg_for_int(16));
}
-
/* first time use previous instruction */
if (dinst == NULL) {
dinst = inst;
@@ -802,11 +801,10 @@ glsl_to_tgsi_visitor::emit_asm(ir_instruction *ir, unsigned op,
dinst->dst[j].writemask = (i & 1) ? WRITEMASK_ZW : WRITEMASK_XY;
dinst->dst[j].index = initial_dst_idx[j];
if (i > 1) {
- if (dinst->op == TGSI_OPCODE_STORE) {
+ if (dinst->op == TGSI_OPCODE_LOAD || dinst->op == TGSI_OPCODE_STORE)
dinst->src[0] = addr;
- } else {
+ if (dinst->op != TGSI_OPCODE_STORE)
dinst->dst[j].index++;
- }
}
} else {
/* if we aren't writing to a double, just get the bit of the initial writemask
diff --git a/src/mesa/state_tracker/st_sampler_view.c b/src/mesa/state_tracker/st_sampler_view.c
index 9fe0bfe..2b2fa8b 100644
--- a/src/mesa/state_tracker/st_sampler_view.c
+++ b/src/mesa/state_tracker/st_sampler_view.c
@@ -430,8 +430,12 @@ st_create_texture_sampler_view_from_stobj(struct st_context *st,
templ.u.tex.first_level = stObj->base.MinLevel + stObj->base.BaseLevel;
templ.u.tex.last_level = last_level(stObj);
assert(templ.u.tex.first_level <= templ.u.tex.last_level);
- templ.u.tex.first_layer = stObj->base.MinLayer;
- templ.u.tex.last_layer = last_layer(stObj);
+ if (stObj->layer_override) {
+ templ.u.tex.first_layer = templ.u.tex.last_layer = stObj->layer_override;
+ } else {
+ templ.u.tex.first_layer = stObj->base.MinLayer;
+ templ.u.tex.last_layer = last_layer(stObj);
+ }
assert(templ.u.tex.first_layer <= templ.u.tex.last_layer);
templ.target = gl_target_to_pipe(stObj->base.Target);
}
@@ -478,8 +482,11 @@ st_get_texture_sampler_view_from_stobj(struct st_context *st,
assert(stObj->base.MinLevel + stObj->base.BaseLevel ==
view->u.tex.first_level);
assert(last_level(stObj) == view->u.tex.last_level);
- assert(stObj->base.MinLayer == view->u.tex.first_layer);
- assert(last_layer(stObj) == view->u.tex.last_layer);
+ assert(stObj->layer_override || stObj->base.MinLayer == view->u.tex.first_layer);
+ assert(stObj->layer_override || last_layer(stObj) == view->u.tex.last_layer);
+ assert(!stObj->layer_override ||
+ (stObj->layer_override == view->u.tex.first_layer &&
+ stObj->layer_override == view->u.tex.last_layer));
}
}
else {
diff --git a/src/mesa/state_tracker/st_texture.h b/src/mesa/state_tracker/st_texture.h
index 730843a..0ce7989 100644
--- a/src/mesa/state_tracker/st_texture.h
+++ b/src/mesa/state_tracker/st_texture.h
@@ -108,6 +108,15 @@ struct st_texture_object
*/
enum pipe_format surface_format;
+ /* When non-zero, samplers should use this layer instead of the one
+ * specified by the GL state.
+ *
+ * This is used for VDPAU interop, where imported pipe_resources may be
+ * array textures (containing layers with different fields) even though the
+ * GL state describes one non-array texture per field.
+ */
+ uint layer_override;
+
/** The glsl version of the shader seen during the previous validation */
unsigned prev_glsl_version;
/** The value of the sampler's sRGBDecode state at the previous validation */
diff --git a/src/mesa/state_tracker/st_vdpau.c b/src/mesa/state_tracker/st_vdpau.c
index 7912057..0273815 100644
--- a/src/mesa/state_tracker/st_vdpau.c
+++ b/src/mesa/state_tracker/st_vdpau.c
@@ -189,8 +189,8 @@ st_vdpau_map_surface(struct gl_context *ctx, GLenum target, GLenum access,
struct st_texture_image *stImage = st_texture_image(texImage);
struct pipe_resource *res;
- struct pipe_sampler_view templ, **sampler_view;
mesa_format texFormat;
+ uint layer_override = 0;
if (output) {
res = st_vdpau_output_surface_dma_buf(ctx, vdpSurface);
@@ -201,8 +201,10 @@ st_vdpau_map_surface(struct gl_context *ctx, GLenum target, GLenum access,
} else {
res = st_vdpau_video_surface_dma_buf(ctx, vdpSurface, index);
- if (!res)
+ if (!res) {
res = st_vdpau_video_surface_gallium(ctx, vdpSurface, index);
+ layer_override = index & 1;
+ }
}
if (!res) {
@@ -233,18 +235,8 @@ st_vdpau_map_surface(struct gl_context *ctx, GLenum target, GLenum access,
st_texture_release_all_sampler_views(st, stObj);
pipe_resource_reference(&stImage->pt, res);
- u_sampler_view_default_template(&templ, res, res->format);
- templ.u.tex.first_layer = index & 1;
- templ.u.tex.last_layer = index & 1;
- templ.swizzle_r = GET_SWZ(stObj->base._Swizzle, 0);
- templ.swizzle_g = GET_SWZ(stObj->base._Swizzle, 1);
- templ.swizzle_b = GET_SWZ(stObj->base._Swizzle, 2);
- templ.swizzle_a = GET_SWZ(stObj->base._Swizzle, 3);
-
- sampler_view = st_texture_get_sampler_view(st, stObj);
- *sampler_view = st->pipe->create_sampler_view(st->pipe, res, &templ);
-
stObj->surface_format = res->format;
+ stObj->layer_override = layer_override;
_mesa_dirty_texobj(ctx, texObj);
pipe_resource_reference(&res, NULL);
@@ -264,6 +256,8 @@ st_vdpau_unmap_surface(struct gl_context *ctx, GLenum target, GLenum access,
st_texture_release_all_sampler_views(st, stObj);
pipe_resource_reference(&stImage->pt, NULL);
+ stObj->layer_override = 0;
+
_mesa_dirty_texobj(ctx, texObj);
st_flush(st, NULL, 0);