summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r--src/gallium/auxiliary/cso_cache/cso_context.c8
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_stipple.c30
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_flow.h7
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_init.h7
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_sample.h6
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_tgsi.c2
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_tgsi.h8
-rw-r--r--src/gallium/auxiliary/target-helpers/inline_sw_helper.h12
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_build.c15
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_build.h5
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_dump.c8
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_info.c2
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_sanity.h4
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_strings.c1
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_text.c4
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_text.h4
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_ureg.c12
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_ureg.h8
-rw-r--r--src/gallium/auxiliary/util/u_debug.h8
-rw-r--r--src/gallium/auxiliary/util/u_debug_refcnt.c137
-rw-r--r--src/gallium/auxiliary/util/u_debug_refcnt.h12
-rw-r--r--src/gallium/auxiliary/util/u_dl.h6
-rw-r--r--src/gallium/auxiliary/util/u_draw_quad.h3
-rw-r--r--src/gallium/auxiliary/util/u_helpers.h4
-rw-r--r--src/gallium/auxiliary/util/u_inlines.h10
-rw-r--r--src/gallium/auxiliary/util/u_transfer.c3
-rw-r--r--src/gallium/auxiliary/util/u_transfer.h3
-rw-r--r--src/gallium/auxiliary/util/u_video.h8
-rw-r--r--src/gallium/auxiliary/vl/vl_winsys_dri.c3
29 files changed, 240 insertions, 100 deletions
diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c
index f0013f70472..790e1211898 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.c
+++ b/src/gallium/auxiliary/cso_cache/cso_context.c
@@ -847,7 +847,7 @@ void cso_set_geometry_shader_handle(struct cso_context *ctx, void *handle)
void cso_delete_geometry_shader(struct cso_context *ctx, void *handle)
{
- if (handle == ctx->geometry_shader) {
+ if (handle == ctx->geometry_shader) {
/* unbind before deleting */
ctx->pipe->bind_gs_state(ctx->pipe, NULL);
ctx->geometry_shader = NULL;
@@ -892,7 +892,7 @@ void cso_set_tessctrl_shader_handle(struct cso_context *ctx, void *handle)
void cso_delete_tessctrl_shader(struct cso_context *ctx, void *handle)
{
- if (handle == ctx->tessctrl_shader) {
+ if (handle == ctx->tessctrl_shader) {
/* unbind before deleting */
ctx->pipe->bind_tcs_state(ctx->pipe, NULL);
ctx->tessctrl_shader = NULL;
@@ -937,7 +937,7 @@ void cso_set_tesseval_shader_handle(struct cso_context *ctx, void *handle)
void cso_delete_tesseval_shader(struct cso_context *ctx, void *handle)
{
- if (handle == ctx->tesseval_shader) {
+ if (handle == ctx->tesseval_shader) {
/* unbind before deleting */
ctx->pipe->bind_tes_state(ctx->pipe, NULL);
ctx->tesseval_shader = NULL;
@@ -982,7 +982,7 @@ void cso_set_compute_shader_handle(struct cso_context *ctx, void *handle)
void cso_delete_compute_shader(struct cso_context *ctx, void *handle)
{
- if (handle == ctx->compute_shader) {
+ if (handle == ctx->compute_shader) {
/* unbind before deleting */
ctx->pipe->bind_compute_state(ctx->pipe, NULL);
ctx->compute_shader = NULL;
diff --git a/src/gallium/auxiliary/draw/draw_pipe_stipple.c b/src/gallium/auxiliary/draw/draw_pipe_stipple.c
index dcf05aac1d9..0d39ee4ec47 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_stipple.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_stipple.c
@@ -108,11 +108,11 @@ emit_segment(struct draw_stage *stage, struct prim_header *header,
}
-static inline unsigned
+static inline bool
stipple_test(int counter, ushort pattern, int factor)
{
int b = (counter / factor) & 0xf;
- return (1 << b) & pattern;
+ return !!((1 << b) & pattern);
}
@@ -126,7 +126,7 @@ stipple_line(struct draw_stage *stage, struct prim_header *header)
const float *pos0 = v0->data[pos];
const float *pos1 = v1->data[pos];
float start = 0;
- int state = 0;
+ bool state = 0;
float x0 = pos0[0];
float x1 = pos1[0];
@@ -143,29 +143,29 @@ stipple_line(struct draw_stage *stage, struct prim_header *header)
stipple->counter = 0;
- /* XXX ToDo: intead of iterating pixel-by-pixel, use a look-up table.
+ /* XXX ToDo: instead of iterating pixel-by-pixel, use a look-up table.
*/
for (i = 0; i < length; i++) {
- int result = stipple_test( (int) stipple->counter+i,
- (ushort) stipple->pattern, stipple->factor );
+ bool result = stipple_test((int)stipple->counter + i,
+ (ushort)stipple->pattern, stipple->factor);
if (result != state) {
/* changing from "off" to "on" or vice versa */
- if (state) {
- if (start != i) {
+ if (state) {
+ if (start != i) {
/* finishing an "on" segment */
- emit_segment( stage, header, start / length, i / length );
+ emit_segment(stage, header, start / length, i / length);
}
- }
- else {
+ }
+ else {
/* starting an "on" segment */
- start = (float) i;
- }
- state = result;
+ start = (float)i;
+ }
+ state = result;
}
}
if (state && start < length)
- emit_segment( stage, header, start / length, 1.0 );
+ emit_segment(stage, header, start / length, 1.0);
stipple->counter += length;
}
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_flow.h b/src/gallium/auxiliary/gallivm/lp_bld_flow.h
index 0da849bfe0c..083b0ad9fec 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_flow.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_flow.h
@@ -37,6 +37,9 @@
#include "gallivm/lp_bld.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
struct lp_type;
@@ -198,4 +201,8 @@ lp_build_array_alloca(struct gallivm_state *gallivm,
LLVMValueRef count,
const char *name);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* !LP_BLD_FLOW_H */
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init.h b/src/gallium/auxiliary/gallivm/lp_bld_init.h
index 9e50f88931d..ab44661a271 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_init.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_init.h
@@ -35,6 +35,9 @@
#include "lp_bld.h"
#include <llvm-c/ExecutionEngine.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
struct gallivm_state
{
@@ -82,4 +85,8 @@ void
lp_set_store_alignment(LLVMValueRef Inst,
unsigned Align);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* !LP_BLD_INIT_H */
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.h b/src/gallium/auxiliary/gallivm/lp_bld_sample.h
index a6f0eff42f6..902ae41f960 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_sample.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.h
@@ -42,6 +42,9 @@
#include "gallivm/lp_bld_type.h"
#include "gallivm/lp_bld_swizzle.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
struct pipe_resource;
struct pipe_sampler_view;
@@ -625,5 +628,8 @@ lp_build_minify(struct lp_build_context *bld,
LLVMValueRef level,
boolean lod_scalar);
+#ifdef __cplusplus
+}
+#endif
#endif /* LP_BLD_SAMPLE_H */
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.c
index 1cbe47ca91f..614c6558ede 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.c
@@ -315,7 +315,7 @@ lp_build_tgsi_inst_llvm(
}
}
- if (info->num_dst > 0) {
+ if (info->num_dst > 0 && info->opcode != TGSI_OPCODE_STORE) {
bld_base->emit_store(bld_base, inst, info, emit_data.output);
}
return TRUE;
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
index cc4549778a3..b005d7a0ac1 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
@@ -48,6 +48,10 @@
#include "tgsi/tgsi_scan.h"
#include "tgsi/tgsi_info.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#define LP_CHAN_ALL ~0
#define LP_MAX_INSTRUCTIONS 256
@@ -663,4 +667,8 @@ lp_build_tgsi_llvm(
struct lp_build_tgsi_context * bld_base,
const struct tgsi_token *tokens);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* LP_BLD_TGSI_H */
diff --git a/src/gallium/auxiliary/target-helpers/inline_sw_helper.h b/src/gallium/auxiliary/target-helpers/inline_sw_helper.h
index a9ab16f2b54..5bb77a5bde2 100644
--- a/src/gallium/auxiliary/target-helpers/inline_sw_helper.h
+++ b/src/gallium/auxiliary/target-helpers/inline_sw_helper.h
@@ -6,6 +6,9 @@
#include "util/u_debug.h"
#include "state_tracker/sw_winsys.h"
+#ifdef GALLIUM_SWR
+#include "swr/swr_public.h"
+#endif
/* Helper function to choose and instantiate one of the software rasterizers:
* llvmpipe, softpipe.
@@ -43,10 +46,15 @@ sw_screen_create_named(struct sw_winsys *winsys, const char *driver)
#endif
#if defined(GALLIUM_SOFTPIPE)
- if (screen == NULL)
+ if (screen == NULL && strcmp(driver, "softpipe") == 0)
screen = softpipe_create_screen(winsys);
#endif
+#if defined(GALLIUM_SWR)
+ if (screen == NULL && strcmp(driver, "swr") == 0)
+ screen = swr_create_screen(winsys);
+#endif
+
return screen;
}
@@ -61,6 +69,8 @@ sw_screen_create(struct sw_winsys *winsys)
default_driver = "llvmpipe";
#elif defined(GALLIUM_SOFTPIPE)
default_driver = "softpipe";
+#elif defined(GALLIUM_SWR)
+ default_driver = "swr";
#else
default_driver = "";
#endif
diff --git a/src/gallium/auxiliary/tgsi/tgsi_build.c b/src/gallium/auxiliary/tgsi/tgsi_build.c
index cfe9b92ee1b..e5355f573bb 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_build.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_build.c
@@ -1425,3 +1425,18 @@ tgsi_build_full_property(
return size;
}
+
+struct tgsi_full_src_register
+tgsi_full_src_register_from_dst(const struct tgsi_full_dst_register *dst)
+{
+ struct tgsi_full_src_register src;
+ src.Register = tgsi_default_src_register();
+ src.Register.File = dst->Register.File;
+ src.Register.Indirect = dst->Register.Indirect;
+ src.Register.Dimension = dst->Register.Dimension;
+ src.Register.Index = dst->Register.Index;
+ src.Indirect = dst->Indirect;
+ src.Dimension = dst->Dimension;
+ src.DimIndirect = dst->DimIndirect;
+ return src;
+}
diff --git a/src/gallium/auxiliary/tgsi/tgsi_build.h b/src/gallium/auxiliary/tgsi/tgsi_build.h
index c5127e1855c..34d181ab247 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_build.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_build.h
@@ -30,6 +30,8 @@
struct tgsi_token;
+struct tgsi_full_dst_register;
+struct tgsi_full_src_register;
#if defined __cplusplus
@@ -111,6 +113,9 @@ tgsi_build_full_instruction(
struct tgsi_instruction_predicate
tgsi_default_instruction_predicate(void);
+struct tgsi_full_src_register
+tgsi_full_src_register_from_dst(const struct tgsi_full_dst_register *dst);
+
#if defined __cplusplus
}
#endif
diff --git a/src/gallium/auxiliary/tgsi/tgsi_dump.c b/src/gallium/auxiliary/tgsi/tgsi_dump.c
index f232f3870d1..c8b91bba534 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_dump.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_dump.c
@@ -637,6 +637,14 @@ iter_instruction(
TXT(", ");
ENM(bit, tgsi_memory_names);
}
+ if (inst->Memory.Texture) {
+ TXT( ", " );
+ ENM( inst->Memory.Texture, tgsi_texture_names );
+ }
+ if (inst->Memory.Format) {
+ TXT( ", " );
+ TXT( util_format_name(inst->Memory.Format) );
+ }
}
switch (inst->Instruction.Opcode) {
diff --git a/src/gallium/auxiliary/tgsi/tgsi_info.c b/src/gallium/auxiliary/tgsi/tgsi_info.c
index 70fc4604537..462bd15f01c 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_info.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_info.c
@@ -142,7 +142,7 @@ static const struct tgsi_opcode_info opcode_info[TGSI_OPCODE_LAST] =
{ 0, 0, 0, 0, 0, 1, 0, NONE, "ENDSUB", TGSI_OPCODE_ENDSUB },
{ 1, 1, 1, 0, 0, 0, 0, OTHR, "TXQ_LZ", TGSI_OPCODE_TXQ_LZ },
{ 1, 1, 1, 0, 0, 0, 0, OTHR, "TXQS", TGSI_OPCODE_TXQS },
- { 1, 1, 0, 0, 0, 0, 0, NONE, "RESQ", TGSI_OPCODE_RESQ },
+ { 1, 1, 0, 0, 0, 0, 0, OTHR, "RESQ", TGSI_OPCODE_RESQ },
{ 0, 0, 0, 0, 0, 0, 0, NONE, "", 106 }, /* removed */
{ 0, 0, 0, 0, 0, 0, 0, NONE, "NOP", TGSI_OPCODE_NOP },
{ 1, 2, 0, 0, 0, 0, 0, COMP, "FSEQ", TGSI_OPCODE_FSEQ },
diff --git a/src/gallium/auxiliary/tgsi/tgsi_sanity.h b/src/gallium/auxiliary/tgsi/tgsi_sanity.h
index 1ff7874b8ce..b78d1aba714 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_sanity.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_sanity.h
@@ -28,12 +28,12 @@
#ifndef TGSI_SANITY_H
#define TGSI_SANITY_H
+#include "pipe/p_compiler.h"
+
#if defined __cplusplus
extern "C" {
#endif
-#include "pipe/p_compiler.h"
-
struct tgsi_token;
/* Check the given token stream for errors and common mistakes.
diff --git a/src/gallium/auxiliary/tgsi/tgsi_strings.c b/src/gallium/auxiliary/tgsi/tgsi_strings.c
index b15ae69cf7a..6bd1a2e14d2 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_strings.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_strings.c
@@ -144,6 +144,7 @@ const char *tgsi_property_names[TGSI_PROPERTY_COUNT] =
"TES_POINT_MODE",
"NUM_CLIPDIST_ENABLED",
"NUM_CULLDIST_ENABLED",
+ "FS_EARLY_DEPTH_STENCIL",
};
const char *tgsi_return_type_names[TGSI_RETURN_TYPE_COUNT] =
diff --git a/src/gallium/auxiliary/tgsi/tgsi_text.c b/src/gallium/auxiliary/tgsi/tgsi_text.c
index 91baa01ad8b..77598d2cb79 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_text.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_text.c
@@ -1388,7 +1388,9 @@ static boolean parse_declaration( struct translate_ctx *ctx )
if (str_match_nocase_whole(&cur, "ATOMIC")) {
decl.Declaration.Atomic = 1;
ctx->cur = cur;
- } else if (str_match_nocase_whole(&cur, "SHARED")) {
+ }
+ } else if (file == TGSI_FILE_MEMORY) {
+ if (str_match_nocase_whole(&cur, "SHARED")) {
decl.Declaration.Shared = 1;
ctx->cur = cur;
}
diff --git a/src/gallium/auxiliary/tgsi/tgsi_text.h b/src/gallium/auxiliary/tgsi/tgsi_text.h
index 6a306e6b674..a34565795a9 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_text.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_text.h
@@ -28,12 +28,12 @@
#ifndef TGSI_TEXT_H
#define TGSI_TEXT_H
+#include "pipe/p_compiler.h"
+
#if defined __cplusplus
extern "C" {
#endif
-#include "pipe/p_compiler.h"
-
struct tgsi_token;
boolean
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
index e1a72786476..ab1d03458ef 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
@@ -1242,7 +1242,9 @@ ureg_emit_texture_offset(struct ureg_program *ureg,
void
ureg_emit_memory(struct ureg_program *ureg,
unsigned extended_token,
- unsigned qualifier)
+ unsigned qualifier,
+ unsigned texture,
+ unsigned format)
{
union tgsi_any_token *out, *insn;
@@ -1253,6 +1255,8 @@ ureg_emit_memory(struct ureg_program *ureg,
out[0].value = 0;
out[0].insn_memory.Qualifier = qualifier;
+ out[0].insn_memory.Texture = texture;
+ out[0].insn_memory.Format = format;
}
void
@@ -1413,7 +1417,9 @@ ureg_memory_insn(struct ureg_program *ureg,
unsigned nr_dst,
const struct ureg_src *src,
unsigned nr_src,
- unsigned qualifier)
+ unsigned qualifier,
+ unsigned texture,
+ unsigned format)
{
struct ureg_emit_insn_result insn;
unsigned i;
@@ -1430,7 +1436,7 @@ ureg_memory_insn(struct ureg_program *ureg,
nr_dst,
nr_src);
- ureg_emit_memory(ureg, insn.extended_token, qualifier);
+ ureg_emit_memory(ureg, insn.extended_token, qualifier, texture, format);
for (i = 0; i < nr_dst; i++)
ureg_emit_dst(ureg, dst[i]);
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.h b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
index 6a3b5ddf017..04a62a6e160 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
@@ -541,7 +541,9 @@ ureg_memory_insn(struct ureg_program *ureg,
unsigned nr_dst,
const struct ureg_src *src,
unsigned nr_src,
- unsigned qualifier);
+ unsigned qualifier,
+ unsigned texture,
+ unsigned format);
/***********************************************************************
* Internal instruction helpers, don't call these directly:
@@ -582,7 +584,9 @@ ureg_emit_texture_offset(struct ureg_program *ureg,
void
ureg_emit_memory(struct ureg_program *ureg,
unsigned insn_token,
- unsigned qualifier);
+ unsigned qualifier,
+ unsigned texture,
+ unsigned format);
void
ureg_emit_dst( struct ureg_program *ureg,
diff --git a/src/gallium/auxiliary/util/u_debug.h b/src/gallium/auxiliary/util/u_debug.h
index c2707b402cb..85d0cb64e6c 100644
--- a/src/gallium/auxiliary/util/u_debug.h
+++ b/src/gallium/auxiliary/util/u_debug.h
@@ -39,6 +39,11 @@
#define U_DEBUG_H_
+#if defined(PIPE_OS_HAIKU)
+/* Haiku provides debug_printf in libroot with OS.h */
+#include <OS.h>
+#endif
+
#include "os/os_misc.h"
#include "pipe/p_format.h"
@@ -94,9 +99,6 @@ debug_printf(const char *format, ...)
(void) format; /* silence warning */
#endif
}
-#else /* is Haiku */
-/* Haiku provides debug_printf in libroot with OS.h */
-#include <OS.h>
#endif
diff --git a/src/gallium/auxiliary/util/u_debug_refcnt.c b/src/gallium/auxiliary/util/u_debug_refcnt.c
index 2c3dc986a90..0a4786442fc 100644
--- a/src/gallium/auxiliary/util/u_debug_refcnt.c
+++ b/src/gallium/auxiliary/util/u_debug_refcnt.c
@@ -26,9 +26,14 @@
#if defined(DEBUG)
-/* see http://www.mozilla.org/performance/refcnt-balancer.html for what do with the output
- * on Linux, use tools/addr2line.sh to postprocess it before anything else
- **/
+/**
+ * If the GALLIUM_REFCNT_LOG env var is defined as a filename, gallium
+ * reference counting will be logged to the file.
+ *
+ * See http://www-archive.mozilla.org/performance/refcnt-balancer.html
+ * for what to do with the output on Linux, use tools/addr2line.sh to
+ * postprocess it before anything else.
+ */
#include <stdio.h>
@@ -42,30 +47,41 @@
int debug_refcnt_state;
-FILE* stream;
+static FILE *stream;
-/* TODO: maybe move this serial machinery to a stand-alone module and expose it? */
+/* TODO: maybe move this serial machinery to a stand-alone module and
+ * expose it?
+ */
pipe_static_mutex(serials_mutex);
-static struct util_hash_table* serials_hash;
+static struct util_hash_table *serials_hash;
static unsigned serials_last;
-static unsigned hash_ptr(void* p)
+
+static unsigned
+hash_ptr(void *p)
{
- return (unsigned)(uintptr_t)p;
+ return (unsigned) (uintptr_t) p;
}
-static int compare_ptr(void* a, void* b)
+
+static int
+compare_ptr(void *a, void *b)
{
- if(a == b)
+ if (a == b)
return 0;
- else if(a < b)
+ else if (a < b)
return -1;
else
return 1;
}
-static boolean debug_serial(void* p, unsigned* pserial)
+
+/**
+ * Return a small integer serial number for the given pointer.
+ */
+static boolean
+debug_serial(void *p, unsigned *pserial)
{
unsigned serial;
boolean found = TRUE;
@@ -81,79 +97,99 @@ static boolean debug_serial(void* p, unsigned* pserial)
pipe_mutex_lock(serials_mutex);
if (!serials_hash)
serials_hash = util_hash_table_create(hash_ptr, compare_ptr);
- serial = (unsigned)(uintptr_t)util_hash_table_get(serials_hash, p);
- if(!serial)
- {
- /* time to stop logging... (you'll have a 100 GB logfile at least at this point)
- * TODO: avoid this
+
+ serial = (unsigned) (uintptr_t) util_hash_table_get(serials_hash, p);
+ if (!serial) {
+ /* time to stop logging... (you'll have a 100 GB logfile at least at
+ * this point) TODO: avoid this
*/
serial = ++serials_last;
- if(!serial)
- {
+ if (!serial) {
debug_error("More than 2^32 objects detected, aborting.\n");
os_abort();
}
- util_hash_table_set(serials_hash, p, (void*)(uintptr_t)serial);
+ util_hash_table_set(serials_hash, p, (void *) (uintptr_t) serial);
found = FALSE;
}
pipe_mutex_unlock(serials_mutex);
+
*pserial = serial;
+
return found;
}
-static void debug_serial_delete(void* p)
+
+/**
+ * Free the serial number for the given pointer.
+ */
+static void
+debug_serial_delete(void *p)
{
pipe_mutex_lock(serials_mutex);
util_hash_table_remove(serials_hash, p);
pipe_mutex_unlock(serials_mutex);
}
+
#define STACK_LEN 64
-static void dump_stack(const char* symbols[STACK_LEN])
+static void
+dump_stack(const char *symbols[STACK_LEN])
{
unsigned i;
- for(i = 0; i < STACK_LEN; ++i)
- {
- if(symbols[i])
+ for (i = 0; i < STACK_LEN; ++i) {
+ if (symbols[i])
fprintf(stream, "%s\n", symbols[i]);
}
fprintf(stream, "\n");
}
-void debug_reference_slowpath(const struct pipe_reference* p, debug_reference_descriptor get_desc, int change)
+
+/**
+ * Log a reference count change to the log file (if enabled).
+ * This is called via the pipe_reference() and debug_reference() functions,
+ * basically whenever a reference count is initialized or changed.
+ *
+ * \param p the refcount being changed (the value is not changed here)
+ * \param get_desc a function which will be called to print an object's
+ * name/pointer into a string buffer during logging
+ * \param change the reference count change which must be +/-1 or 0 when
+ * creating the object and initializing the refcount.
+ */
+void
+debug_reference_slowpath(const struct pipe_reference *p,
+ debug_reference_descriptor get_desc, int change)
{
- if(debug_refcnt_state < 0)
+ assert(change >= -1);
+ assert(change <= 1);
+
+ if (debug_refcnt_state < 0)
return;
- if(!debug_refcnt_state)
- {
- const char* filename = debug_get_option("GALLIUM_REFCNT_LOG", NULL);
- if(filename && filename[0])
+ if (!debug_refcnt_state) {
+ const char *filename = debug_get_option("GALLIUM_REFCNT_LOG", NULL);
+ if (filename && filename[0])
stream = fopen(filename, "wt");
- if(stream)
+ if (stream)
debug_refcnt_state = 1;
else
debug_refcnt_state = -1;
}
- if(debug_refcnt_state > 0)
- {
+ if (debug_refcnt_state > 0) {
struct debug_stack_frame frames[STACK_LEN];
- const char* symbols[STACK_LEN];
+ const char *symbols[STACK_LEN];
char buf[1024];
-
unsigned i;
unsigned refcnt = p->count;
unsigned serial;
- boolean existing = debug_serial((void*)p, &serial);
+ boolean existing = debug_serial((void *) p, &serial);
debug_backtrace_capture(frames, 1, STACK_LEN);
- for(i = 0; i < STACK_LEN; ++i)
- {
- if(frames[i].function)
+ for (i = 0; i < STACK_LEN; ++i) {
+ if (frames[i].function)
symbols[i] = debug_symbol_name_cached(frames[i].function);
else
symbols[i] = 0;
@@ -161,30 +197,28 @@ void debug_reference_slowpath(const struct pipe_reference* p, debug_reference_de
get_desc(buf, p);
- if(!existing)
- {
+ if (!existing) {
fprintf(stream, "<%s> %p %u Create\n", buf, (void *) p, serial);
dump_stack(symbols);
- /* this is there to provide a gradual change even if we don't see the initialization */
- for(i = 1; i <= refcnt - change; ++i)
- {
+ /* this is here to provide a gradual change even if we don't see
+ * the initialization
+ */
+ for (i = 1; i <= refcnt - change; ++i) {
fprintf(stream, "<%s> %p %u AddRef %u\n", buf, (void *) p,
serial, i);
dump_stack(symbols);
}
}
- if(change)
- {
+ if (change) {
fprintf(stream, "<%s> %p %u %s %u\n", buf, (void *) p, serial,
change > 0 ? "AddRef" : "Release", refcnt);
dump_stack(symbols);
}
- if(!refcnt)
- {
- debug_serial_delete((void*)p);
+ if (!refcnt) {
+ debug_serial_delete((void *) p);
fprintf(stream, "<%s> %p %u Destroy\n", buf, (void *) p, serial);
dump_stack(symbols);
}
@@ -192,4 +226,5 @@ void debug_reference_slowpath(const struct pipe_reference* p, debug_reference_de
fflush(stream);
}
}
-#endif
+
+#endif /* DEBUG */
diff --git a/src/gallium/auxiliary/util/u_debug_refcnt.h b/src/gallium/auxiliary/util/u_debug_refcnt.h
index 1f9218fec9a..cf047776661 100644
--- a/src/gallium/auxiliary/util/u_debug_refcnt.h
+++ b/src/gallium/auxiliary/util/u_debug_refcnt.h
@@ -40,9 +40,13 @@ typedef void (*debug_reference_descriptor)(char*, const struct pipe_reference*);
extern int debug_refcnt_state;
-void debug_reference_slowpath(const struct pipe_reference* p, debug_reference_descriptor get_desc, int change);
+void
+debug_reference_slowpath(const struct pipe_reference* p,
+ debug_reference_descriptor get_desc, int change);
-static inline void debug_reference(const struct pipe_reference* p, debug_reference_descriptor get_desc, int change)
+static inline void
+debug_reference(const struct pipe_reference* p,
+ debug_reference_descriptor get_desc, int change)
{
if (debug_refcnt_state >= 0)
debug_reference_slowpath(p, get_desc, change);
@@ -50,7 +54,9 @@ static inline void debug_reference(const struct pipe_reference* p, debug_referen
#else
-static inline void debug_reference(const struct pipe_reference* p, debug_reference_descriptor get_desc, int change)
+static inline void
+debug_reference(const struct pipe_reference* p,
+ debug_reference_descriptor get_desc, int change)
{
}
diff --git a/src/gallium/auxiliary/util/u_dl.h b/src/gallium/auxiliary/util/u_dl.h
index 80a00ed6796..d2f4737d42a 100644
--- a/src/gallium/auxiliary/util/u_dl.h
+++ b/src/gallium/auxiliary/util/u_dl.h
@@ -32,6 +32,9 @@
#include "pipe/p_config.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
#if defined(PIPE_OS_WINDOWS)
# define UTIL_DL_EXT ".dll"
@@ -79,5 +82,8 @@ util_dl_close(struct util_dl_library *library);
const char *
util_dl_error(void);
+#ifdef __cplusplus
+}
+#endif
#endif /* U_DL_H_ */
diff --git a/src/gallium/auxiliary/util/u_draw_quad.h b/src/gallium/auxiliary/util/u_draw_quad.h
index b298ef2ae59..6553d5d7b6b 100644
--- a/src/gallium/auxiliary/util/u_draw_quad.h
+++ b/src/gallium/auxiliary/util/u_draw_quad.h
@@ -32,6 +32,7 @@
#include "pipe/p_compiler.h"
#include "pipe/p_context.h"
+#include "util/u_draw.h"
#ifdef __cplusplus
extern "C" {
@@ -40,8 +41,6 @@ extern "C" {
struct pipe_resource;
struct cso_context;
-#include "util/u_draw.h"
-
extern void
util_draw_vertex_buffer(struct pipe_context *pipe, struct cso_context *cso,
struct pipe_resource *vbuf, uint vbuf_slot,
diff --git a/src/gallium/auxiliary/util/u_helpers.h b/src/gallium/auxiliary/util/u_helpers.h
index f25f2807fe5..a9a53e4347a 100644
--- a/src/gallium/auxiliary/util/u_helpers.h
+++ b/src/gallium/auxiliary/util/u_helpers.h
@@ -28,12 +28,12 @@
#ifndef U_HELPERS_H
#define U_HELPERS_H
+#include "pipe/p_state.h"
+
#ifdef __cplusplus
extern "C" {
#endif
-#include "pipe/p_state.h"
-
void util_set_vertex_buffers_mask(struct pipe_vertex_buffer *dst,
uint32_t *enabled_buffers,
const struct pipe_vertex_buffer *src,
diff --git a/src/gallium/auxiliary/util/u_inlines.h b/src/gallium/auxiliary/util/u_inlines.h
index d0812039292..0e80cef0b08 100644
--- a/src/gallium/auxiliary/util/u_inlines.h
+++ b/src/gallium/auxiliary/util/u_inlines.h
@@ -622,6 +622,16 @@ util_copy_constant_buffer(struct pipe_constant_buffer *dst,
}
}
+static inline void
+util_copy_image_view(struct pipe_image_view *dst,
+ const struct pipe_image_view *src)
+{
+ pipe_resource_reference(&dst->resource, src->resource);
+ dst->format = src->format;
+ dst->access = src->access;
+ dst->u = src->u;
+}
+
static inline unsigned
util_max_layer(const struct pipe_resource *r, unsigned level)
{
diff --git a/src/gallium/auxiliary/util/u_transfer.c b/src/gallium/auxiliary/util/u_transfer.c
index adae84bbfab..0610535cd2c 100644
--- a/src/gallium/auxiliary/util/u_transfer.c
+++ b/src/gallium/auxiliary/util/u_transfer.c
@@ -98,7 +98,8 @@ u_resource( struct pipe_resource *res )
boolean u_resource_get_handle_vtbl(struct pipe_screen *screen,
struct pipe_resource *resource,
- struct winsys_handle *handle)
+ struct winsys_handle *handle,
+ unsigned usage)
{
struct u_resource *ur = u_resource(resource);
return ur->vtbl->resource_get_handle(screen, resource, handle);
diff --git a/src/gallium/auxiliary/util/u_transfer.h b/src/gallium/auxiliary/util/u_transfer.h
index 6c25ee0f024..660dc161d33 100644
--- a/src/gallium/auxiliary/util/u_transfer.h
+++ b/src/gallium/auxiliary/util/u_transfer.h
@@ -78,7 +78,8 @@ struct u_resource {
boolean u_resource_get_handle_vtbl(struct pipe_screen *screen,
struct pipe_resource *resource,
- struct winsys_handle *handle);
+ struct winsys_handle *handle,
+ unsigned usage);
void u_resource_destroy_vtbl(struct pipe_screen *screen,
struct pipe_resource *resource);
diff --git a/src/gallium/auxiliary/util/u_video.h b/src/gallium/auxiliary/util/u_video.h
index ddc00216105..9196afc11be 100644
--- a/src/gallium/auxiliary/util/u_video.h
+++ b/src/gallium/auxiliary/util/u_video.h
@@ -28,10 +28,6 @@
#ifndef U_VIDEO_H
#define U_VIDEO_H
-#ifdef __cplusplus
-extern "C" {
-#endif
-
#include "pipe/p_defines.h"
#include "pipe/p_video_enums.h"
@@ -40,6 +36,10 @@ extern "C" {
#include "util/u_debug.h"
#include "util/u_math.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
static inline enum pipe_video_format
u_reduce_video_profile(enum pipe_video_profile profile)
{
diff --git a/src/gallium/auxiliary/vl/vl_winsys_dri.c b/src/gallium/auxiliary/vl/vl_winsys_dri.c
index 758f50d7c23..01365260312 100644
--- a/src/gallium/auxiliary/vl/vl_winsys_dri.c
+++ b/src/gallium/auxiliary/vl/vl_winsys_dri.c
@@ -248,7 +248,8 @@ vl_dri2_screen_texture_from_drawable(struct vl_screen *vscreen, void *drawable)
template.flags = 0;
tex = scrn->base.pscreen->resource_from_handle(scrn->base.pscreen, &template,
- &dri2_handle);
+ &dri2_handle,
+ PIPE_HANDLE_USAGE_READ_WRITE);
free(reply);
return tex;