summaryrefslogtreecommitdiff
path: root/lib/mesa/src/gallium/drivers/r300
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2022-02-24 02:30:08 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2022-02-24 02:30:08 +0000
commit1d35364040c0ffa99133522fa5ab3bd6131d8bf7 (patch)
tree0ea3d9ca4ad10692c6477168b67e98cb50ea6bd3 /lib/mesa/src/gallium/drivers/r300
parentb24b5b9049e889ee4eb39b565bcc8d48bd45ab48 (diff)
Merge Mesa 21.3.7
Diffstat (limited to 'lib/mesa/src/gallium/drivers/r300')
-rw-r--r--lib/mesa/src/gallium/drivers/r300/Android.mk48
-rw-r--r--lib/mesa/src/gallium/drivers/r300/Makefile.sources110
-rw-r--r--lib/mesa/src/gallium/drivers/r300/r300_blit.c2
-rw-r--r--lib/mesa/src/gallium/drivers/r300/r300_context.c4
-rw-r--r--lib/mesa/src/gallium/drivers/r300/r300_context.h2
-rw-r--r--lib/mesa/src/gallium/drivers/r300/r300_emit.c12
-rw-r--r--lib/mesa/src/gallium/drivers/r300/r300_render.c58
-rw-r--r--lib/mesa/src/gallium/drivers/r300/r300_screen.c7
-rw-r--r--lib/mesa/src/gallium/drivers/r300/r300_screen_buffer.c67
-rw-r--r--lib/mesa/src/gallium/drivers/r300/r300_state.c28
-rw-r--r--lib/mesa/src/gallium/drivers/r300/r300_texture.c45
-rw-r--r--lib/mesa/src/gallium/drivers/r300/r300_tgsi_to_rc.c27
12 files changed, 133 insertions, 277 deletions
diff --git a/lib/mesa/src/gallium/drivers/r300/Android.mk b/lib/mesa/src/gallium/drivers/r300/Android.mk
deleted file mode 100644
index 7b1c1055e..000000000
--- a/lib/mesa/src/gallium/drivers/r300/Android.mk
+++ /dev/null
@@ -1,48 +0,0 @@
-# Mesa 3-D graphics library
-#
-# Copyright (C) 2011 Chia-I Wu <olvaffe@gmail.com>
-# Copyright (C) 2011 LunarG Inc.
-#
-# Permission is hereby granted, free of charge, to any person obtaining a
-# copy of this software and associated documentation files (the "Software"),
-# to deal in the Software without restriction, including without limitation
-# the rights to use, copy, modify, merge, publish, distribute, sublicense,
-# and/or sell copies of the Software, and to permit persons to whom the
-# Software is furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included
-# in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-# DEALINGS IN THE SOFTWARE.
-
-LOCAL_PATH := $(call my-dir)
-
-# get C_SOURCES
-include $(LOCAL_PATH)/Makefile.sources
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(C_SOURCES)
-
-LOCAL_C_INCLUDES := \
- $(MESA_TOP)/src/mapi \
- $(MESA_TOP)/src/mesa
-
-
-LOCAL_SHARED_LIBRARIES := libdrm_radeon
-LOCAL_MODULE := libmesa_pipe_r300
-
-include $(GALLIUM_COMMON_MK)
-include $(BUILD_STATIC_LIBRARY)
-
-ifneq ($(HAVE_GALLIUM_R300),)
-GALLIUM_TARGET_DRIVERS += r300
-$(eval GALLIUM_LIBS += $(LOCAL_MODULE) libmesa_winsys_radeon)
-$(eval GALLIUM_SHARED_LIBS += $(LOCAL_SHARED_LIBRARIES))
-endif
diff --git a/lib/mesa/src/gallium/drivers/r300/Makefile.sources b/lib/mesa/src/gallium/drivers/r300/Makefile.sources
deleted file mode 100644
index 1ba6db00d..000000000
--- a/lib/mesa/src/gallium/drivers/r300/Makefile.sources
+++ /dev/null
@@ -1,110 +0,0 @@
-C_SOURCES := \
- r300_blit.c \
- r300_cb.h \
- r300_chipset.c \
- r300_chipset.h \
- r300_context.c \
- r300_context.h \
- r300_cs.h \
- r300_debug.c \
- r300_defines.h \
- r300_emit.c \
- r300_emit.h \
- r300_flush.c \
- r300_fs.c \
- r300_fs.h \
- r300_hyperz.c \
- r300_public.h \
- r300_query.c \
- r300_reg.h \
- r300_render.c \
- r300_render_stencilref.c \
- r300_render_translate.c \
- r300_resource.c \
- r300_screen_buffer.c \
- r300_screen_buffer.h \
- r300_screen.c \
- r300_screen.h \
- r300_shader_semantics.h \
- r300_state.c \
- r300_state_derived.c \
- r300_state_inlines.h \
- r300_texture.c \
- r300_texture_desc.c \
- r300_texture_desc.h \
- r300_texture.h \
- r300_tgsi_to_rc.c \
- r300_tgsi_to_rc.h \
- r300_transfer.c \
- r300_transfer.h \
- r300_vs.c \
- r300_vs_draw.c \
- r300_vs.h \
- \
- compiler/memory_pool.c \
- compiler/memory_pool.h \
- compiler/r300_fragprog.c \
- compiler/r300_fragprog_emit.c \
- compiler/r300_fragprog.h \
- compiler/r300_fragprog_swizzle.c \
- compiler/r300_fragprog_swizzle.h \
- compiler/r3xx_fragprog.c \
- compiler/r3xx_vertprog.c \
- compiler/r3xx_vertprog_dump.c \
- compiler/r500_fragprog.c \
- compiler/r500_fragprog_emit.c \
- compiler/r500_fragprog.h \
- compiler/radeon_code.c \
- compiler/radeon_code.h \
- compiler/radeon_compiler.c \
- compiler/radeon_compiler.h \
- compiler/radeon_compiler_util.c \
- compiler/radeon_compiler_util.h \
- compiler/radeon_dataflow.c \
- compiler/radeon_dataflow_deadcode.c \
- compiler/radeon_dataflow.h \
- compiler/radeon_dataflow_swizzles.c \
- compiler/radeon_emulate_branches.c \
- compiler/radeon_emulate_branches.h \
- compiler/radeon_emulate_loops.c \
- compiler/radeon_emulate_loops.h \
- compiler/radeon_inline_literals.c \
- compiler/radeon_list.c \
- compiler/radeon_list.h \
- compiler/radeon_opcodes.c \
- compiler/radeon_opcodes.h \
- compiler/radeon_optimize.c \
- compiler/radeon_pair_dead_sources.c \
- compiler/radeon_pair_regalloc.c \
- compiler/radeon_pair_schedule.c \
- compiler/radeon_pair_translate.c \
- compiler/radeon_program_alu.c \
- compiler/radeon_program_alu.h \
- compiler/radeon_program.c \
- compiler/radeon_program_constants.h \
- compiler/radeon_program.h \
- compiler/radeon_program_pair.c \
- compiler/radeon_program_pair.h \
- compiler/radeon_program_print.c \
- compiler/radeon_program_tex.c \
- compiler/radeon_program_tex.h \
- compiler/radeon_regalloc.h \
- compiler/radeon_remove_constants.c \
- compiler/radeon_remove_constants.h \
- compiler/radeon_rename_regs.c \
- compiler/radeon_rename_regs.h \
- compiler/radeon_swizzle.h \
- compiler/radeon_variable.c \
- compiler/radeon_variable.h \
- compiler/radeon_vert_fc.c
-
-COMPILER_TESTS_SOURCES := \
- compiler/tests/r300_compiler_tests.c \
- compiler/tests/r300_compiler_tests.h \
- compiler/tests/radeon_compiler_optimize_tests.c \
- compiler/tests/radeon_compiler_regalloc_tests.c \
- compiler/tests/radeon_compiler_util_tests.c \
- compiler/tests/rc_test_helpers.c \
- compiler/tests/rc_test_helpers.h \
- compiler/tests/unit_test.c \
- compiler/tests/unit_test.h
diff --git a/lib/mesa/src/gallium/drivers/r300/r300_blit.c b/lib/mesa/src/gallium/drivers/r300/r300_blit.c
index 738bc53ba..43e204f11 100644
--- a/lib/mesa/src/gallium/drivers/r300/r300_blit.c
+++ b/lib/mesa/src/gallium/drivers/r300/r300_blit.c
@@ -676,7 +676,7 @@ static void r300_resource_copy_region(struct pipe_context *pipe,
util_blitter_blit_generic(r300->blitter, dst_view, &dstbox,
src_view, src_box, src_width0, src_height0,
PIPE_MASK_RGBAZS, PIPE_TEX_FILTER_NEAREST, NULL,
- FALSE);
+ FALSE, FALSE);
r300_blitter_end(r300);
pipe_surface_reference(&dst_view, NULL);
diff --git a/lib/mesa/src/gallium/drivers/r300/r300_context.c b/lib/mesa/src/gallium/drivers/r300/r300_context.c
index db5ad901f..b5a7d10a0 100644
--- a/lib/mesa/src/gallium/drivers/r300/r300_context.c
+++ b/lib/mesa/src/gallium/drivers/r300/r300_context.c
@@ -441,8 +441,8 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
* dummy texture there. */
if (!r300->screen->caps.is_r500) {
struct pipe_resource *tex;
- struct pipe_resource rtempl = {{0}};
- struct pipe_sampler_view vtempl = {{0}};
+ struct pipe_resource rtempl = {0};
+ struct pipe_sampler_view vtempl = {0};
rtempl.target = PIPE_TEXTURE_2D;
rtempl.format = PIPE_FORMAT_I8_UNORM;
diff --git a/lib/mesa/src/gallium/drivers/r300/r300_context.h b/lib/mesa/src/gallium/drivers/r300/r300_context.h
index e7e6f331c..618998090 100644
--- a/lib/mesa/src/gallium/drivers/r300/r300_context.h
+++ b/lib/mesa/src/gallium/drivers/r300/r300_context.h
@@ -389,7 +389,7 @@ struct r300_texture_desc {
struct r300_resource
{
- struct u_resource b;
+ struct pipe_resource b;
/* Winsys buffer backing this resource. */
struct pb_buffer *buf;
diff --git a/lib/mesa/src/gallium/drivers/r300/r300_emit.c b/lib/mesa/src/gallium/drivers/r300/r300_emit.c
index 779c467a1..c91f9851a 100644
--- a/lib/mesa/src/gallium/drivers/r300/r300_emit.c
+++ b/lib/mesa/src/gallium/drivers/r300/r300_emit.c
@@ -142,9 +142,9 @@ static void get_rc_constant_state(
case RC_STATE_R300_TEXSCALE_FACTOR:
tex = r300_resource(texstate->sampler_views[constant->u.State[1]]->base.texture);
/* Add a small number to the texture size to work around rounding errors in hw. */
- vec[0] = tex->b.b.width0 / (tex->tex.width0 + 0.001f);
- vec[1] = tex->b.b.height0 / (tex->tex.height0 + 0.001f);
- vec[2] = tex->b.b.depth0 / (tex->tex.depth0 + 0.001f);
+ vec[0] = tex->b.width0 / (tex->tex.width0 + 0.001f);
+ vec[1] = tex->b.height0 / (tex->tex.height0 + 0.001f);
+ vec[2] = tex->b.depth0 / (tex->tex.depth0 + 0.001f);
vec[3] = 1;
break;
@@ -1325,7 +1325,7 @@ validate:
r300->rws->cs_add_buffer(&r300->cs, tex->buf,
RADEON_USAGE_READWRITE | RADEON_USAGE_SYNCHRONIZED,
r300_surface(fb->cbufs[i])->domain,
- tex->b.b.nr_samples > 1 ?
+ tex->b.nr_samples > 1 ?
RADEON_PRIO_COLOR_BUFFER_MSAA :
RADEON_PRIO_COLOR_BUFFER);
}
@@ -1336,7 +1336,7 @@ validate:
r300->rws->cs_add_buffer(&r300->cs, tex->buf,
RADEON_USAGE_READWRITE | RADEON_USAGE_SYNCHRONIZED,
r300_surface(fb->zsbuf)->domain,
- tex->b.b.nr_samples > 1 ?
+ tex->b.nr_samples > 1 ?
RADEON_PRIO_DEPTH_BUFFER_MSAA :
RADEON_PRIO_DEPTH_BUFFER);
}
@@ -1353,7 +1353,7 @@ validate:
if (r300->textures_state.dirty) {
/* ...textures... */
for (i = 0; i < texstate->count; i++) {
- if (!(texstate->tx_enable & (1 << i))) {
+ if (!(texstate->tx_enable & (1U << i))) {
continue;
}
diff --git a/lib/mesa/src/gallium/drivers/r300/r300_render.c b/lib/mesa/src/gallium/drivers/r300/r300_render.c
index d401853f3..7d6708929 100644
--- a/lib/mesa/src/gallium/drivers/r300/r300_render.c
+++ b/lib/mesa/src/gallium/drivers/r300/r300_render.c
@@ -335,7 +335,7 @@ static boolean immd_is_good_idea(struct r300_context *r300,
static void r300_draw_arrays_immediate(struct r300_context *r300,
const struct pipe_draw_info *info,
- const struct pipe_draw_start_count *draw)
+ const struct pipe_draw_start_count_bias *draw)
{
struct pipe_vertex_element* velem;
struct pipe_vertex_buffer* vbuf;
@@ -499,7 +499,7 @@ static void r300_emit_draw_elements(struct r300_context *r300,
static void r300_draw_elements_immediate(struct r300_context *r300,
const struct pipe_draw_info *info,
- const struct pipe_draw_start_count *draw)
+ const struct pipe_draw_start_count_bias *draw)
{
const uint8_t *ptr1;
const uint16_t *ptr2;
@@ -512,7 +512,7 @@ static void r300_draw_elements_immediate(struct r300_context *r300,
/* 19 dwords for r300_draw_elements_immediate. Give up if the function fails. */
if (!r300_prepare_for_rendering(r300,
PREP_EMIT_STATES | PREP_VALIDATE_VBOS | PREP_EMIT_VARRAYS |
- PREP_INDEXED, NULL, 2+count_dwords, 0, info->index_bias, -1))
+ PREP_INDEXED, NULL, 2+count_dwords, 0, draw->index_bias, -1))
return;
r300_emit_draw_init(r300, info->mode, info->max_index);
@@ -528,13 +528,13 @@ static void r300_draw_elements_immediate(struct r300_context *r300,
OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_INDICES | (draw->count << 16) |
r300_translate_primitive(info->mode));
- if (info->index_bias && !r300->screen->caps.is_r500) {
+ if (draw->index_bias && !r300->screen->caps.is_r500) {
for (i = 0; i < draw->count-1; i += 2)
- OUT_CS(((ptr1[i+1] + info->index_bias) << 16) |
- (ptr1[i] + info->index_bias));
+ OUT_CS(((ptr1[i+1] + draw->index_bias) << 16) |
+ (ptr1[i] + draw->index_bias));
if (draw->count & 1)
- OUT_CS(ptr1[i] + info->index_bias);
+ OUT_CS(ptr1[i] + draw->index_bias);
} else {
for (i = 0; i < draw->count-1; i += 2)
OUT_CS(((ptr1[i+1]) << 16) |
@@ -552,13 +552,13 @@ static void r300_draw_elements_immediate(struct r300_context *r300,
OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_INDICES | (draw->count << 16) |
r300_translate_primitive(info->mode));
- if (info->index_bias && !r300->screen->caps.is_r500) {
+ if (draw->index_bias && !r300->screen->caps.is_r500) {
for (i = 0; i < draw->count-1; i += 2)
- OUT_CS(((ptr2[i+1] + info->index_bias) << 16) |
- (ptr2[i] + info->index_bias));
+ OUT_CS(((ptr2[i+1] + draw->index_bias) << 16) |
+ (ptr2[i] + draw->index_bias));
if (draw->count & 1)
- OUT_CS(ptr2[i] + info->index_bias);
+ OUT_CS(ptr2[i] + draw->index_bias);
} else {
OUT_CS_TABLE(ptr2, count_dwords);
}
@@ -572,9 +572,9 @@ static void r300_draw_elements_immediate(struct r300_context *r300,
R300_VAP_VF_CNTL__INDEX_SIZE_32bit |
r300_translate_primitive(info->mode));
- if (info->index_bias && !r300->screen->caps.is_r500) {
+ if (draw->index_bias && !r300->screen->caps.is_r500) {
for (i = 0; i < draw->count; i++)
- OUT_CS(ptr4[i] + info->index_bias);
+ OUT_CS(ptr4[i] + draw->index_bias);
} else {
OUT_CS_TABLE(ptr4, count_dwords);
}
@@ -585,7 +585,7 @@ static void r300_draw_elements_immediate(struct r300_context *r300,
static void r300_draw_elements(struct r300_context *r300,
const struct pipe_draw_info *info,
- const struct pipe_draw_start_count *draw,
+ const struct pipe_draw_start_count_bias *draw,
int instance_id)
{
struct pipe_resource *indexBuffer =
@@ -600,8 +600,8 @@ static void r300_draw_elements(struct r300_context *r300,
int buffer_offset = 0, index_offset = 0; /* for index bias emulation */
uint16_t indices3[3];
- if (info->index_bias && !r300->screen->caps.is_r500) {
- r300_split_index_bias(r300, info->index_bias, &buffer_offset,
+ if (draw->index_bias && !r300->screen->caps.is_r500) {
+ r300_split_index_bias(r300, draw->index_bias, &buffer_offset,
&index_offset);
}
@@ -635,7 +635,7 @@ static void r300_draw_elements(struct r300_context *r300,
/* 19 dwords for emit_draw_elements. Give up if the function fails. */
if (!r300_prepare_for_rendering(r300,
PREP_EMIT_STATES | PREP_VALIDATE_VBOS | PREP_EMIT_VARRAYS |
- PREP_INDEXED, indexBuffer, 19, buffer_offset, info->index_bias,
+ PREP_INDEXED, indexBuffer, 19, buffer_offset, draw->index_bias,
instance_id))
goto done;
@@ -662,7 +662,7 @@ static void r300_draw_elements(struct r300_context *r300,
if (count) {
if (!r300_prepare_for_rendering(r300,
PREP_VALIDATE_VBOS | PREP_EMIT_VARRAYS | PREP_INDEXED,
- indexBuffer, 19, buffer_offset, info->index_bias,
+ indexBuffer, 19, buffer_offset, draw->index_bias,
instance_id))
goto done;
}
@@ -677,7 +677,7 @@ done:
static void r300_draw_arrays(struct r300_context *r300,
const struct pipe_draw_info *info,
- const struct pipe_draw_start_count *draw,
+ const struct pipe_draw_start_count_bias *draw,
int instance_id)
{
boolean alt_num_verts = r300->screen->caps.is_r500 &&
@@ -719,7 +719,7 @@ static void r300_draw_arrays(struct r300_context *r300,
static void r300_draw_arrays_instanced(struct r300_context *r300,
const struct pipe_draw_info *info,
- const struct pipe_draw_start_count *draw)
+ const struct pipe_draw_start_count_bias *draw)
{
int i;
@@ -729,7 +729,7 @@ static void r300_draw_arrays_instanced(struct r300_context *r300,
static void r300_draw_elements_instanced(struct r300_context *r300,
const struct pipe_draw_info *info,
- const struct pipe_draw_start_count *draw)
+ const struct pipe_draw_start_count_bias *draw)
{
int i;
@@ -788,18 +788,19 @@ static unsigned r300_max_vertex_count(struct r300_context *r300)
static void r300_draw_vbo(struct pipe_context* pipe,
const struct pipe_draw_info *dinfo,
+ unsigned drawid_offset,
const struct pipe_draw_indirect_info *indirect,
- const struct pipe_draw_start_count *draws,
+ const struct pipe_draw_start_count_bias *draws,
unsigned num_draws)
{
if (num_draws > 1) {
- util_draw_multi(pipe, dinfo, indirect, draws, num_draws);
+ util_draw_multi(pipe, dinfo, drawid_offset, indirect, draws, num_draws);
return;
}
struct r300_context* r300 = r300_context(pipe);
struct pipe_draw_info info = *dinfo;
- struct pipe_draw_start_count draw = draws[0];
+ struct pipe_draw_start_count_bias draw = draws[0];
if (r300->skip_rendering ||
!u_trim_pipe_prim(info.mode, &draw.count)) {
@@ -855,17 +856,18 @@ static void r300_draw_vbo(struct pipe_context* pipe,
/* SW TCL elements, using Draw. */
static void r300_swtcl_draw_vbo(struct pipe_context* pipe,
const struct pipe_draw_info *info,
+ unsigned drawid_offset,
const struct pipe_draw_indirect_info *indirect,
- const struct pipe_draw_start_count *draws,
+ const struct pipe_draw_start_count_bias *draws,
unsigned num_draws)
{
if (num_draws > 1) {
- util_draw_multi(pipe, info, indirect, draws, num_draws);
+ util_draw_multi(pipe, info, drawid_offset, indirect, draws, num_draws);
return;
}
struct r300_context* r300 = r300_context(pipe);
- struct pipe_draw_start_count draw = draws[0];
+ struct pipe_draw_start_count_bias draw = draws[0];
if (r300->skip_rendering) {
return;
@@ -884,7 +886,7 @@ static void r300_swtcl_draw_vbo(struct pipe_context* pipe,
r300_update_derived_state(r300);
- draw_vbo(r300->draw, info, NULL, &draw, 1);
+ draw_vbo(r300->draw, info, drawid_offset, NULL, &draw, 1, 0);
draw_flush(r300->draw);
}
diff --git a/lib/mesa/src/gallium/drivers/r300/r300_screen.c b/lib/mesa/src/gallium/drivers/r300/r300_screen.c
index 31878b3f5..bff7a4032 100644
--- a/lib/mesa/src/gallium/drivers/r300/r300_screen.c
+++ b/lib/mesa/src/gallium/drivers/r300/r300_screen.c
@@ -652,6 +652,13 @@ static bool r300_is_format_supported(struct pipe_screen* screen,
}
}
+ if (usage & PIPE_BIND_INDEX_BUFFER) {
+ if (format == PIPE_FORMAT_R8_UINT ||
+ format == PIPE_FORMAT_R16_UINT ||
+ format == PIPE_FORMAT_R32_UINT)
+ retval |= PIPE_BIND_INDEX_BUFFER;
+ }
+
return retval == usage;
}
diff --git a/lib/mesa/src/gallium/drivers/r300/r300_screen_buffer.c b/lib/mesa/src/gallium/drivers/r300/r300_screen_buffer.c
index 741c0107c..9a884e556 100644
--- a/lib/mesa/src/gallium/drivers/r300/r300_screen_buffer.c
+++ b/lib/mesa/src/gallium/drivers/r300/r300_screen_buffer.c
@@ -50,20 +50,35 @@ void r300_upload_index_buffer(struct r300_context *r300,
*start = index_offset / index_size;
}
-static void r300_buffer_destroy(struct pipe_screen *screen,
- struct pipe_resource *buf)
+void r300_resource_destroy(struct pipe_screen *screen,
+ struct pipe_resource *buf)
{
- struct r300_resource *rbuf = r300_resource(buf);
-
- align_free(rbuf->malloced_buffer);
-
- if (rbuf->buf)
- pb_reference(&rbuf->buf, NULL);
-
- FREE(rbuf);
+ if (buf->target == PIPE_BUFFER) {
+ struct r300_resource *rbuf = r300_resource(buf);
+
+ align_free(rbuf->malloced_buffer);
+
+ if (rbuf->buf)
+ pb_reference(&rbuf->buf, NULL);
+
+ FREE(rbuf);
+ } else {
+ struct r300_screen *rscreen = r300_screen(screen);
+ struct r300_resource* tex = (struct r300_resource*)buf;
+
+ if (tex->tex.cmask_dwords) {
+ mtx_lock(&rscreen->cmask_mutex);
+ if (buf == rscreen->cmask_resource) {
+ rscreen->cmask_resource = NULL;
+ }
+ mtx_unlock(&rscreen->cmask_mutex);
+ }
+ pb_reference(&tex->buf, NULL);
+ FREE(tex);
+ }
}
-static void *
+void *
r300_buffer_transfer_map( struct pipe_context *context,
struct pipe_resource *resource,
unsigned level,
@@ -101,7 +116,7 @@ r300_buffer_transfer_map( struct pipe_context *context,
struct pb_buffer *new_buf;
/* Create a new one in the same pipe_resource. */
- new_buf = r300->rws->buffer_create(r300->rws, rbuf->b.b.width0,
+ new_buf = r300->rws->buffer_create(r300->rws, rbuf->b.width0,
R300_BUFFER_ALIGNMENT,
rbuf->domain,
RADEON_FLAG_NO_INTERPROCESS_SHARING);
@@ -112,7 +127,7 @@ r300_buffer_transfer_map( struct pipe_context *context,
/* We changed the buffer, now we need to bind it where the old one was bound. */
for (i = 0; i < r300->nr_vertex_buffers; i++) {
- if (r300->vertex_buffer[i].buffer.resource == &rbuf->b.b) {
+ if (r300->vertex_buffer[i].buffer.resource == &rbuf->b) {
r300->vertex_arrays_dirty = TRUE;
break;
}
@@ -138,23 +153,14 @@ r300_buffer_transfer_map( struct pipe_context *context,
return map + box->x;
}
-static void r300_buffer_transfer_unmap( struct pipe_context *pipe,
- struct pipe_transfer *transfer )
+void r300_buffer_transfer_unmap( struct pipe_context *pipe,
+ struct pipe_transfer *transfer )
{
struct r300_context *r300 = r300_context(pipe);
slab_free(&r300->pool_transfers, transfer);
}
-static const struct u_resource_vtbl r300_buffer_vtbl =
-{
- NULL, /* get_handle */
- r300_buffer_destroy, /* resource_destroy */
- r300_buffer_transfer_map, /* transfer_map */
- NULL, /* transfer_flush_region */
- r300_buffer_transfer_unmap, /* transfer_unmap */
-};
-
struct pipe_resource *r300_buffer_create(struct pipe_screen *screen,
const struct pipe_resource *templ)
{
@@ -163,10 +169,9 @@ struct pipe_resource *r300_buffer_create(struct pipe_screen *screen,
rbuf = MALLOC_STRUCT(r300_resource);
- rbuf->b.b = *templ;
- rbuf->b.vtbl = &r300_buffer_vtbl;
- pipe_reference_init(&rbuf->b.b.reference, 1);
- rbuf->b.b.screen = screen;
+ rbuf->b = *templ;
+ pipe_reference_init(&rbuf->b.reference, 1);
+ rbuf->b.screen = screen;
rbuf->domain = RADEON_DOMAIN_GTT;
rbuf->buf = NULL;
rbuf->malloced_buffer = NULL;
@@ -178,11 +183,11 @@ struct pipe_resource *r300_buffer_create(struct pipe_screen *screen,
if (templ->bind & PIPE_BIND_CONSTANT_BUFFER ||
(!r300screen->caps.has_tcl && !(templ->bind & PIPE_BIND_CUSTOM))) {
rbuf->malloced_buffer = align_malloc(templ->width0, 64);
- return &rbuf->b.b;
+ return &rbuf->b;
}
rbuf->buf =
- r300screen->rws->buffer_create(r300screen->rws, rbuf->b.b.width0,
+ r300screen->rws->buffer_create(r300screen->rws, rbuf->b.width0,
R300_BUFFER_ALIGNMENT,
rbuf->domain,
RADEON_FLAG_NO_INTERPROCESS_SHARING);
@@ -190,5 +195,5 @@ struct pipe_resource *r300_buffer_create(struct pipe_screen *screen,
FREE(rbuf);
return NULL;
}
- return &rbuf->b.b;
+ return &rbuf->b;
}
diff --git a/lib/mesa/src/gallium/drivers/r300/r300_state.c b/lib/mesa/src/gallium/drivers/r300/r300_state.c
index 3501c0b86..07299bb0b 100644
--- a/lib/mesa/src/gallium/drivers/r300/r300_state.c
+++ b/lib/mesa/src/gallium/drivers/r300/r300_state.c
@@ -1519,6 +1519,7 @@ static void r300_set_sampler_views(struct pipe_context* pipe,
enum pipe_shader_type shader,
unsigned start, unsigned count,
unsigned unbind_num_trailing_slots,
+ bool take_ownership,
struct pipe_sampler_view** views)
{
struct r300_context* r300 = r300_context(pipe);
@@ -1529,13 +1530,16 @@ static void r300_set_sampler_views(struct pipe_context* pipe,
unsigned tex_units = r300->screen->caps.num_tex_units;
boolean dirty_tex = FALSE;
- if (shader != PIPE_SHADER_FRAGMENT)
- return;
-
assert(start == 0); /* non-zero not handled yet */
- if (count > tex_units) {
- return;
+ if (shader != PIPE_SHADER_FRAGMENT || count > tex_units) {
+ if (take_ownership) {
+ for (unsigned i = 0; i < count; i++) {
+ struct pipe_sampler_view *view = views[i];
+ pipe_sampler_view_reference(&view, NULL);
+ }
+ }
+ return;
}
/* Calculate the real number of views. */
@@ -1545,9 +1549,15 @@ static void r300_set_sampler_views(struct pipe_context* pipe,
}
for (i = 0; i < count; i++) {
- pipe_sampler_view_reference(
- (struct pipe_sampler_view**)&state->sampler_views[i],
- views[i]);
+ if (take_ownership) {
+ pipe_sampler_view_reference(
+ (struct pipe_sampler_view**)&state->sampler_views[i], NULL);
+ state->sampler_views[i] = (struct r300_sampler_view*)views[i];
+ } else {
+ pipe_sampler_view_reference(
+ (struct pipe_sampler_view**)&state->sampler_views[i],
+ views[i]);
+ }
if (!views[i]) {
continue;
@@ -1811,7 +1821,7 @@ static void r300_vertex_psc(struct r300_vertex_element_state *velems)
if (i & 1) {
vstream->vap_prog_stream_cntl[i >> 1] |= type << 16;
- vstream->vap_prog_stream_cntl_ext[i >> 1] |= swizzle << 16;
+ vstream->vap_prog_stream_cntl_ext[i >> 1] |= (uint32_t)swizzle << 16;
} else {
vstream->vap_prog_stream_cntl[i >> 1] |= type;
vstream->vap_prog_stream_cntl_ext[i >> 1] |= swizzle;
diff --git a/lib/mesa/src/gallium/drivers/r300/r300_texture.c b/lib/mesa/src/gallium/drivers/r300/r300_texture.c
index b04c34967..843443bfb 100644
--- a/lib/mesa/src/gallium/drivers/r300/r300_texture.c
+++ b/lib/mesa/src/gallium/drivers/r300/r300_texture.c
@@ -911,7 +911,7 @@ void r300_texture_setup_format_state(struct r300_screen *screen,
unsigned height0_override,
struct r300_texture_format_state *out)
{
- struct pipe_resource *pt = &tex->b.b;
+ struct pipe_resource *pt = &tex->b;
struct r300_texture_desc *desc = &tex->tex;
boolean is_r500 = screen->caps.is_r500;
unsigned width, height, depth;
@@ -1021,23 +1021,6 @@ static void r300_texture_setup_fb_state(struct r300_surface *surf)
}
}
-static void r300_texture_destroy(struct pipe_screen *screen,
- struct pipe_resource* texture)
-{
- struct r300_screen *rscreen = r300_screen(screen);
- struct r300_resource* tex = (struct r300_resource*)texture;
-
- if (tex->tex.cmask_dwords) {
- mtx_lock(&rscreen->cmask_mutex);
- if (texture == rscreen->cmask_resource) {
- rscreen->cmask_resource = NULL;
- }
- mtx_unlock(&rscreen->cmask_mutex);
- }
- pb_reference(&tex->buf, NULL);
- FREE(tex);
-}
-
bool r300_resource_get_handle(struct pipe_screen* screen,
struct pipe_context *ctx,
struct pipe_resource *texture,
@@ -1057,15 +1040,6 @@ bool r300_resource_get_handle(struct pipe_screen* screen,
return rws->buffer_get_handle(rws, tex->buf, whandle);
}
-static const struct u_resource_vtbl r300_texture_vtbl =
-{
- NULL, /* get_handle */
- r300_texture_destroy, /* resource_destroy */
- r300_texture_transfer_map, /* transfer_map */
- NULL, /* transfer_flush_region */
- r300_texture_transfer_unmap, /* transfer_unmap */
-};
-
/* The common texture constructor. */
static struct r300_resource*
r300_texture_create_object(struct r300_screen *rscreen,
@@ -1084,12 +1058,11 @@ r300_texture_create_object(struct r300_screen *rscreen,
goto fail;
}
- pipe_reference_init(&tex->b.b.reference, 1);
- tex->b.b.screen = &rscreen->screen;
- tex->b.b.usage = base->usage;
- tex->b.b.bind = base->bind;
- tex->b.b.flags = base->flags;
- tex->b.vtbl = &r300_texture_vtbl;
+ pipe_reference_init(&tex->b.reference, 1);
+ tex->b.screen = &rscreen->screen;
+ tex->b.usage = base->usage;
+ tex->b.bind = base->bind;
+ tex->b.flags = base->flags;
tex->tex.microtile = microtile;
tex->tex.macrotile[0] = macrotile;
tex->tex.stride_in_bytes_override = stride_in_bytes_override;
@@ -1219,8 +1192,6 @@ struct pipe_resource *r300_texture_from_handle(struct pipe_screen *screen,
whandle->stride, buffer);
}
-/* Not required to implement u_resource_vtbl, consider moving to another file:
- */
struct pipe_surface* r300_create_surface_custom(struct pipe_context * ctx,
struct pipe_resource* texture,
const struct pipe_surface *surf_tmpl,
@@ -1263,7 +1234,7 @@ struct pipe_surface* r300_create_surface_custom(struct pipe_context * ctx,
/* Height must be aligned to the size of a tile. */
tile_height = r300_get_pixel_alignment(surface->base.format,
- tex->b.b.nr_samples,
+ tex->b.nr_samples,
tex->tex.microtile,
tex->tex.macrotile[level],
DIM_HEIGHT, 0);
@@ -1305,8 +1276,6 @@ struct pipe_surface* r300_create_surface(struct pipe_context * ctx,
texture->height0);
}
-/* Not required to implement u_resource_vtbl, consider moving to another file:
- */
void r300_surface_destroy(struct pipe_context *ctx, struct pipe_surface* s)
{
pipe_resource_reference(&s->texture, NULL);
diff --git a/lib/mesa/src/gallium/drivers/r300/r300_tgsi_to_rc.c b/lib/mesa/src/gallium/drivers/r300/r300_tgsi_to_rc.c
index 7217dd09a..fbc827afc 100644
--- a/lib/mesa/src/gallium/drivers/r300/r300_tgsi_to_rc.c
+++ b/lib/mesa/src/gallium/drivers/r300/r300_tgsi_to_rc.c
@@ -225,17 +225,38 @@ static void transform_texture(struct rc_instruction * dst, struct tgsi_instructi
case TGSI_TEXTURE_SHADOW1D:
dst->U.I.TexSrcTarget = RC_TEXTURE_1D;
dst->U.I.TexShadow = 1;
- *shadowSamplers |= 1 << dst->U.I.TexSrcUnit;
+ *shadowSamplers |= 1U << dst->U.I.TexSrcUnit;
break;
case TGSI_TEXTURE_SHADOW2D:
dst->U.I.TexSrcTarget = RC_TEXTURE_2D;
dst->U.I.TexShadow = 1;
- *shadowSamplers |= 1 << dst->U.I.TexSrcUnit;
+ *shadowSamplers |= 1U << dst->U.I.TexSrcUnit;
break;
case TGSI_TEXTURE_SHADOWRECT:
dst->U.I.TexSrcTarget = RC_TEXTURE_RECT;
dst->U.I.TexShadow = 1;
- *shadowSamplers |= 1 << dst->U.I.TexSrcUnit;
+ *shadowSamplers |= 1U << dst->U.I.TexSrcUnit;
+ break;
+ case TGSI_TEXTURE_1D_ARRAY:
+ dst->U.I.TexSrcTarget = RC_TEXTURE_1D_ARRAY;
+ break;
+ case TGSI_TEXTURE_2D_ARRAY:
+ dst->U.I.TexSrcTarget = RC_TEXTURE_2D_ARRAY;
+ break;
+ case TGSI_TEXTURE_SHADOW1D_ARRAY:
+ dst->U.I.TexSrcTarget = RC_TEXTURE_1D_ARRAY;
+ dst->U.I.TexShadow = 1;
+ *shadowSamplers |= 1U << dst->U.I.TexSrcUnit;
+ break;
+ case TGSI_TEXTURE_SHADOW2D_ARRAY:
+ dst->U.I.TexSrcTarget = RC_TEXTURE_2D_ARRAY;
+ dst->U.I.TexShadow = 1;
+ *shadowSamplers |= 1U << dst->U.I.TexSrcUnit;
+ break;
+ case TGSI_TEXTURE_SHADOWCUBE:
+ dst->U.I.TexSrcTarget = RC_TEXTURE_CUBE;
+ dst->U.I.TexShadow = 1;
+ *shadowSamplers |= 1U << dst->U.I.TexSrcUnit;
break;
}
dst->U.I.TexSwizzle = RC_SWIZZLE_XYZW;