summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/drivers/dri/i915/i830_vtbl.c2
-rw-r--r--src/mesa/drivers/dri/i915/i915_vtbl.c2
-rw-r--r--src/mesa/drivers/dri/i965/brw_defines.h2
-rw-r--r--src/mesa/drivers/dri/i965/brw_fs_visitor.cpp11
-rw-r--r--src/mesa/drivers/dri/i965/brw_misc_state.c60
-rw-r--r--src/mesa/drivers/dri/i965/brw_structs.h450
-rw-r--r--src/mesa/drivers/dri/i965/brw_vs_state.c2
-rw-r--r--src/mesa/drivers/dri/i965/gen7_wm_state.c11
-rw-r--r--src/mesa/drivers/dri/intel/intel_clear.c1
-rw-r--r--src/mesa/drivers/dri/intel/intel_context.c49
-rw-r--r--src/mesa/drivers/dri/intel/intel_fbo.c51
-rw-r--r--src/mesa/drivers/dri/intel/intel_fbo.h12
-rw-r--r--src/mesa/drivers/dri/intel/intel_pixel_bitmap.c7
-rw-r--r--src/mesa/drivers/dri/intel/intel_regions.c13
-rw-r--r--src/mesa/drivers/dri/intel/intel_screen.c1
-rw-r--r--src/mesa/drivers/dri/intel/intel_tex_copy.c12
-rw-r--r--src/mesa/main/arbprogram.c229
-rw-r--r--src/mesa/main/depthstencil.c322
-rw-r--r--src/mesa/main/depthstencil.h5
-rw-r--r--src/mesa/main/fbobject.c23
-rw-r--r--src/mesa/main/feedback.c2
-rw-r--r--src/mesa/main/formats.c29
-rw-r--r--src/mesa/main/formats.h3
-rw-r--r--src/mesa/main/framebuffer.c10
-rw-r--r--src/mesa/main/image.c18
-rw-r--r--src/mesa/main/mipmap.c20
-rw-r--r--src/mesa/main/mtypes.h2
-rw-r--r--src/mesa/main/pack.c83
-rw-r--r--src/mesa/main/pack.h4
-rw-r--r--src/mesa/main/readpix.c29
-rw-r--r--src/mesa/main/renderbuffer.c3
-rw-r--r--src/mesa/main/samplerobj.c2
-rw-r--r--src/mesa/main/shaderapi.c4
-rw-r--r--src/mesa/main/texenv.c6
-rw-r--r--src/mesa/main/texfetch.c14
-rw-r--r--src/mesa/main/texfetch_tmp.h23
-rw-r--r--src/mesa/main/texformat.c13
-rw-r--r--src/mesa/main/texobj.c2
-rw-r--r--src/mesa/main/texstore.c100
-rw-r--r--src/mesa/main/uniforms.c4
-rw-r--r--src/mesa/program/ir_to_mesa.cpp28
-rw-r--r--src/mesa/state_tracker/st_cb_clear.c6
-rw-r--r--src/mesa/state_tracker/st_cb_drawpixels.c64
-rw-r--r--src/mesa/state_tracker/st_cb_readpixels.c45
-rw-r--r--src/mesa/state_tracker/st_extensions.c11
-rw-r--r--src/mesa/state_tracker/st_format.c54
-rw-r--r--src/mesa/state_tracker/st_manager.c9
-rw-r--r--src/mesa/swrast/s_blit.c3
-rw-r--r--src/mesa/swrast/s_readpix.c2
49 files changed, 1007 insertions, 851 deletions
diff --git a/src/mesa/drivers/dri/i915/i830_vtbl.c b/src/mesa/drivers/dri/i915/i830_vtbl.c
index 584df82b50c..7775e71381f 100644
--- a/src/mesa/drivers/dri/i915/i830_vtbl.c
+++ b/src/mesa/drivers/dri/i915/i830_vtbl.c
@@ -618,11 +618,9 @@ i830_set_draw_region(struct intel_context *intel,
uint32_t draw_x, draw_y;
if (state->draw_region != color_regions[0]) {
- intel_region_release(&state->draw_region);
intel_region_reference(&state->draw_region, color_regions[0]);
}
if (state->depth_region != depth_region) {
- intel_region_release(&state->depth_region);
intel_region_reference(&state->depth_region, depth_region);
}
diff --git a/src/mesa/drivers/dri/i915/i915_vtbl.c b/src/mesa/drivers/dri/i915/i915_vtbl.c
index 9721a1c0e4d..cd7d108222e 100644
--- a/src/mesa/drivers/dri/i915/i915_vtbl.c
+++ b/src/mesa/drivers/dri/i915/i915_vtbl.c
@@ -570,11 +570,9 @@ i915_set_draw_region(struct intel_context *intel,
uint32_t draw_x, draw_y, draw_offset;
if (state->draw_region != color_regions[0]) {
- intel_region_release(&state->draw_region);
intel_region_reference(&state->draw_region, color_regions[0]);
}
if (state->depth_region != depth_region) {
- intel_region_release(&state->depth_region);
intel_region_reference(&state->depth_region, depth_region);
}
diff --git a/src/mesa/drivers/dri/i965/brw_defines.h b/src/mesa/drivers/dri/i965/brw_defines.h
index 6d41b1e69d3..a75171da316 100644
--- a/src/mesa/drivers/dri/i965/brw_defines.h
+++ b/src/mesa/drivers/dri/i965/brw_defines.h
@@ -867,7 +867,7 @@
#define CMD_CONST_BUFFER 0x6002
#define CMD_STATE_BASE_ADDRESS 0x6101
-#define CMD_STATE_INSN_POINTER 0x6102
+#define CMD_STATE_SIP 0x6102
#define CMD_PIPELINE_SELECT_965 0x6104
#define CMD_PIPELINE_SELECT_GM45 0x6904
diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index 9091014976b..cbe5cf428c5 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -1791,7 +1791,8 @@ fs_visitor::emit_fb_writes()
{
this->current_annotation = "FB write header";
GLboolean header_present = GL_TRUE;
- int nr = 2;
+ int base_mrf = 2;
+ int nr = base_mrf;
int reg_width = c->dispatch_width / 8;
if (intel->gen >= 6 &&
@@ -1870,8 +1871,8 @@ fs_visitor::emit_fb_writes()
fs_inst *inst = emit(FS_OPCODE_FB_WRITE);
inst->target = target;
- inst->base_mrf = 2;
- inst->mlen = nr;
+ inst->base_mrf = base_mrf;
+ inst->mlen = nr - base_mrf;
if (target == c->key.nr_color_regions - 1)
inst->eot = true;
inst->header_present = header_present;
@@ -1888,8 +1889,8 @@ fs_visitor::emit_fb_writes()
}
fs_inst *inst = emit(FS_OPCODE_FB_WRITE);
- inst->base_mrf = 2;
- inst->mlen = nr;
+ inst->base_mrf = base_mrf;
+ inst->mlen = nr - base_mrf;
inst->eot = true;
inst->header_present = header_present;
}
diff --git a/src/mesa/drivers/dri/i965/brw_misc_state.c b/src/mesa/drivers/dri/i965/brw_misc_state.c
index 033c77cd321..bc8ef783ef5 100644
--- a/src/mesa/drivers/dri/i965/brw_misc_state.c
+++ b/src/mesa/drivers/dri/i965/brw_misc_state.c
@@ -609,28 +609,17 @@ static void upload_invarient_state( struct brw_context *brw )
if (intel->gen == 6)
intel_emit_post_sync_nonzero_flush(intel);
- {
- /* 0x61040000 Pipeline Select */
- /* PipelineSelect : 0 */
- struct brw_pipeline_select ps;
-
- memset(&ps, 0, sizeof(ps));
- ps.header.opcode = brw->CMD_PIPELINE_SELECT;
- ps.header.pipeline_select = 0;
- BRW_BATCH_STRUCT(brw, &ps);
- }
+ /* Select the 3D pipeline (as opposed to media) */
+ BEGIN_BATCH(1);
+ OUT_BATCH(brw->CMD_PIPELINE_SELECT << 16 | 0);
+ ADVANCE_BATCH();
if (intel->gen < 6) {
- struct brw_global_depth_offset_clamp gdo;
- memset(&gdo, 0, sizeof(gdo));
-
- /* Disable depth offset clamping.
- */
- gdo.header.opcode = _3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP;
- gdo.header.length = sizeof(gdo)/4 - 2;
- gdo.depth_offset_clamp = 0.0;
-
- BRW_BATCH_STRUCT(brw, &gdo);
+ /* Disable depth offset clamping. */
+ BEGIN_BATCH(2);
+ OUT_BATCH(_3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP << 16 | (2 - 2));
+ OUT_BATCH_F(0.0);
+ ADVANCE_BATCH();
}
if (intel->gen >= 6) {
@@ -663,30 +652,15 @@ static void upload_invarient_state( struct brw_context *brw )
}
}
- /* 0x61020000 State Instruction Pointer */
- {
- struct brw_system_instruction_pointer sip;
- memset(&sip, 0, sizeof(sip));
-
- sip.header.opcode = CMD_STATE_INSN_POINTER;
- sip.header.length = 0;
- sip.bits0.pad = 0;
- sip.bits0.system_instruction_pointer = 0;
-
- BRW_BATCH_STRUCT(brw, &sip);
- }
-
-
- {
- struct brw_vf_statistics vfs;
- memset(&vfs, 0, sizeof(vfs));
-
- vfs.opcode = brw->CMD_VF_STATISTICS;
- if (unlikely(INTEL_DEBUG & DEBUG_STATS))
- vfs.statistics_enable = 1;
+ BEGIN_BATCH(2);
+ OUT_BATCH(CMD_STATE_SIP << 16 | (2 - 2));
+ OUT_BATCH(0);
+ ADVANCE_BATCH();
- BRW_BATCH_STRUCT(brw, &vfs);
- }
+ BEGIN_BATCH(1);
+ OUT_BATCH(brw->CMD_VF_STATISTICS << 16 |
+ (unlikely(INTEL_DEBUG & DEBUG_STATS) ? 1 : 0));
+ ADVANCE_BATCH();
}
const struct brw_tracked_state brw_invarient_state = {
diff --git a/src/mesa/drivers/dri/i965/brw_structs.h b/src/mesa/drivers/dri/i965/brw_structs.h
index 7b9cdba4cbf..e1947d5ea64 100644
--- a/src/mesa/drivers/dri/i965/brw_structs.h
+++ b/src/mesa/drivers/dri/i965/brw_structs.h
@@ -40,46 +40,6 @@
/** Number of message register file registers */
#define BRW_MAX_MRF 16
-
-/* Command packets:
- */
-struct header
-{
- GLuint length:16;
- GLuint opcode:16;
-};
-
-
-union header_union
-{
- struct header bits;
- GLuint dword;
-};
-
-struct brw_3d_control
-{
- struct
- {
- GLuint length:8;
- GLuint notify_enable:1;
- GLuint pad:3;
- GLuint wc_flush_enable:1;
- GLuint depth_stall_enable:1;
- GLuint operation:2;
- GLuint opcode:16;
- } header;
-
- struct
- {
- GLuint pad:2;
- GLuint dest_addr_type:1;
- GLuint dest_addr:29;
- } dest;
-
- GLuint dword2;
- GLuint dword3;
-};
-
/* These seem to be passed around as function args, so it works out
* better to keep them as #defines:
*/
@@ -88,314 +48,6 @@ struct brw_3d_control
#define BRW_INHIBIT_FLUSH_RENDER_CACHE 0x4
#define BRW_FLUSH_SNAPSHOT_COUNTERS 0x8
-struct brw_mi_flush
-{
- GLuint flags:4;
- GLuint pad:12;
- GLuint opcode:16;
-};
-
-struct brw_vf_statistics
-{
- GLuint statistics_enable:1;
- GLuint pad:15;
- GLuint opcode:16;
-};
-
-
-
-struct brw_binding_table_pointers
-{
- struct header header;
- GLuint vs;
- GLuint gs;
- GLuint clp;
- GLuint sf;
- GLuint wm;
-};
-
-
-struct brw_blend_constant_color
-{
- struct header header;
- GLfloat blend_constant_color[4];
-};
-
-
-struct brw_depthbuffer
-{
- union header_union header;
-
- union {
- struct {
- GLuint pitch:18;
- GLuint format:3;
- GLuint pad:2;
- GLuint software_tiled_rendering_mode:2;
- GLuint depth_offset_disable:1;
- GLuint tile_walk:1;
- GLuint tiled_surface:1;
- GLuint pad2:1;
- GLuint surface_type:3;
- } bits;
- GLuint dword;
- } dword1;
-
- GLuint dword2_base_addr;
-
- union {
- struct {
- GLuint pad:1;
- GLuint mipmap_layout:1;
- GLuint lod:4;
- GLuint width:13;
- GLuint height:13;
- } bits;
- GLuint dword;
- } dword3;
-
- union {
- struct {
- GLuint pad:10;
- GLuint min_array_element:11;
- GLuint depth:11;
- } bits;
- GLuint dword;
- } dword4;
-};
-
-struct brw_depthbuffer_g4x
-{
- union header_union header;
-
- union {
- struct {
- GLuint pitch:18;
- GLuint format:3;
- GLuint pad:2;
- GLuint software_tiled_rendering_mode:2;
- GLuint depth_offset_disable:1;
- GLuint tile_walk:1;
- GLuint tiled_surface:1;
- GLuint pad2:1;
- GLuint surface_type:3;
- } bits;
- GLuint dword;
- } dword1;
-
- GLuint dword2_base_addr;
-
- union {
- struct {
- GLuint pad:1;
- GLuint mipmap_layout:1;
- GLuint lod:4;
- GLuint width:13;
- GLuint height:13;
- } bits;
- GLuint dword;
- } dword3;
-
- union {
- struct {
- GLuint pad:10;
- GLuint min_array_element:11;
- GLuint depth:11;
- } bits;
- GLuint dword;
- } dword4;
-
- union {
- struct {
- GLuint xoffset:16;
- GLuint yoffset:16;
- } bits;
- GLuint dword;
- } dword5; /* NEW in Integrated Graphics Device */
-};
-
-struct brw_drawrect
-{
- struct header header;
- GLuint xmin:16;
- GLuint ymin:16;
- GLuint xmax:16;
- GLuint ymax:16;
- GLuint xorg:16;
- GLuint yorg:16;
-};
-
-
-
-
-struct brw_global_depth_offset_clamp
-{
- struct header header;
- GLfloat depth_offset_clamp;
-};
-
-struct brw_indexbuffer
-{
- union {
- struct
- {
- GLuint length:8;
- GLuint index_format:2;
- GLuint cut_index_enable:1;
- GLuint pad:5;
- GLuint opcode:16;
- } bits;
- GLuint dword;
-
- } header;
-
- GLuint buffer_start;
- GLuint buffer_end;
-};
-
-/* NEW in Integrated Graphics Device */
-struct brw_aa_line_parameters
-{
- struct header header;
-
- struct {
- GLuint aa_coverage_slope:8;
- GLuint pad0:8;
- GLuint aa_coverage_bias:8;
- GLuint pad1:8;
- } bits0;
-
- struct {
- GLuint aa_coverage_endcap_slope:8;
- GLuint pad0:8;
- GLuint aa_coverage_endcap_bias:8;
- GLuint pad1:8;
- } bits1;
-};
-
-struct brw_line_stipple
-{
- struct header header;
-
- struct
- {
- GLuint pattern:16;
- GLuint pad:16;
- } bits0;
-
- struct
- {
- GLuint repeat_count:9;
- GLuint pad:7;
- GLuint inverse_repeat_count:16;
- } bits1;
-};
-
-
-struct brw_pipelined_state_pointers
-{
- struct header header;
-
- struct {
- GLuint pad:5;
- GLuint offset:27; /* Offset from GENERAL_STATE_BASE */
- } vs;
-
- struct
- {
- GLuint enable:1;
- GLuint pad:4;
- GLuint offset:27; /* Offset from GENERAL_STATE_BASE */
- } gs;
-
- struct
- {
- GLuint enable:1;
- GLuint pad:4;
- GLuint offset:27; /* Offset from GENERAL_STATE_BASE */
- } clp;
-
- struct
- {
- GLuint pad:5;
- GLuint offset:27; /* Offset from GENERAL_STATE_BASE */
- } sf;
-
- struct
- {
- GLuint pad:5;
- GLuint offset:27; /* Offset from GENERAL_STATE_BASE */
- } wm;
-
- struct
- {
- GLuint pad:5;
- GLuint offset:27; /* Offset from GENERAL_STATE_BASE. KW: check me! */
- } cc;
-};
-
-
-struct brw_polygon_stipple_offset
-{
- struct header header;
-
- struct {
- GLuint y_offset:5;
- GLuint pad:3;
- GLuint x_offset:5;
- GLuint pad0:19;
- } bits0;
-};
-
-
-
-struct brw_polygon_stipple
-{
- struct header header;
- GLuint stipple[32];
-};
-
-
-
-struct brw_pipeline_select
-{
- struct
- {
- GLuint pipeline_select:1;
- GLuint pad:15;
- GLuint opcode:16;
- } header;
-};
-
-
-struct brw_pipe_control
-{
- struct
- {
- GLuint length:8;
- GLuint notify_enable:1;
- GLuint texture_cache_flush_enable:1;
- GLuint indirect_state_pointers_disable:1;
- GLuint instruction_state_cache_flush_enable:1;
- GLuint write_cache_flush_enable:1;
- GLuint depth_stall_enable:1;
- GLuint post_sync_operation:2;
-
- GLuint opcode:16;
- } header;
-
- struct
- {
- GLuint pad:2;
- GLuint dest_addr_type:1;
- GLuint dest_addr:29;
- } bits1;
-
- GLuint data0;
- GLuint data1;
-};
-
-
struct brw_urb_fence
{
struct
@@ -428,102 +80,6 @@ struct brw_urb_fence
} bits1;
};
-struct brw_cs_urb_state
-{
- struct header header;
-
- struct
- {
- GLuint nr_urb_entries:3;
- GLuint pad:1;
- GLuint urb_entry_size:5;
- GLuint pad0:23;
- } bits0;
-};
-
-struct brw_constant_buffer
-{
- struct
- {
- GLuint length:8;
- GLuint valid:1;
- GLuint pad:7;
- GLuint opcode:16;
- } header;
-
- struct
- {
- GLuint buffer_length:6;
- GLuint buffer_address:26;
- } bits0;
-};
-
-struct brw_state_base_address
-{
- struct header header;
-
- struct
- {
- GLuint modify_enable:1;
- GLuint pad:4;
- GLuint general_state_address:27;
- } bits0;
-
- struct
- {
- GLuint modify_enable:1;
- GLuint pad:4;
- GLuint surface_state_address:27;
- } bits1;
-
- struct
- {
- GLuint modify_enable:1;
- GLuint pad:4;
- GLuint indirect_object_state_address:27;
- } bits2;
-
- struct
- {
- GLuint modify_enable:1;
- GLuint pad:11;
- GLuint general_state_upper_bound:20;
- } bits3;
-
- struct
- {
- GLuint modify_enable:1;
- GLuint pad:11;
- GLuint indirect_object_state_upper_bound:20;
- } bits4;
-};
-
-struct brw_state_prefetch
-{
- struct header header;
-
- struct
- {
- GLuint prefetch_count:3;
- GLuint pad:3;
- GLuint prefetch_pointer:26;
- } bits0;
-};
-
-struct brw_system_instruction_pointer
-{
- struct header header;
-
- struct
- {
- GLuint pad:4;
- GLuint system_instruction_pointer:28;
- } bits0;
-};
-
-
-
-
/* State structs for the various fixed function units:
*/
@@ -1327,12 +883,6 @@ struct brw_vertex_element_state
#define BRW_VEP_MAX 18
-struct brw_vertex_element_packet {
- struct header header;
- struct brw_vertex_element_state ve[BRW_VEP_MAX]; /* note: less than _TNL_ATTRIB_MAX */
-};
-
-
struct brw_urb_immediate {
GLuint opcode:4;
GLuint offset:6;
diff --git a/src/mesa/drivers/dri/i965/brw_vs_state.c b/src/mesa/drivers/dri/i965/brw_vs_state.c
index d5010a21e80..179ca199b45 100644
--- a/src/mesa/drivers/dri/i965/brw_vs_state.c
+++ b/src/mesa/drivers/dri/i965/brw_vs_state.c
@@ -47,6 +47,7 @@ brw_prepare_vs_unit(struct brw_context *brw)
memset(vs, 0, sizeof(*vs));
/* BRW_NEW_PROGRAM_CACHE | CACHE_NEW_VS_PROG */
+ vs->thread0.grf_reg_count = ALIGN(brw->vs.prog_data->total_grf, 16) / 16 - 1;
vs->thread0.kernel_start_pointer =
brw_program_reloc(brw,
brw->vs.state_offset +
@@ -54,7 +55,6 @@ brw_prepare_vs_unit(struct brw_context *brw)
brw->vs.prog_offset +
(vs->thread0.grf_reg_count << 1)) >> 6;
- vs->thread0.grf_reg_count = ALIGN(brw->vs.prog_data->total_grf, 16) / 16 - 1;
vs->thread1.floating_point_mode = BRW_FLOATING_POINT_NON_IEEE_754;
/* Choosing multiple program flow means that we may get 2-vertex threads,
* which will have the channel mask for dwords 4-7 enabled in the thread,
diff --git a/src/mesa/drivers/dri/i965/gen7_wm_state.c b/src/mesa/drivers/dri/i965/gen7_wm_state.c
index 17f75354f1d..0f5b06cbf48 100644
--- a/src/mesa/drivers/dri/i965/gen7_wm_state.c
+++ b/src/mesa/drivers/dri/i965/gen7_wm_state.c
@@ -138,11 +138,9 @@ upload_wm_state(struct brw_context *brw)
const struct brw_tracked_state gen7_wm_state = {
.dirty = {
- .mesa = (_NEW_LINE | _NEW_POLYGON | _NEW_POLYGONSTIPPLE |
+ .mesa = (_NEW_LINE | _NEW_POLYGON |
_NEW_COLOR | _NEW_BUFFERS),
- .brw = (BRW_NEW_CURBE_OFFSETS |
- BRW_NEW_FRAGMENT_PROGRAM |
- BRW_NEW_NR_WM_SURFACES |
+ .brw = (BRW_NEW_FRAGMENT_PROGRAM |
BRW_NEW_URB_FENCE |
BRW_NEW_BATCH),
.cache = 0,
@@ -240,10 +238,7 @@ upload_ps_state(struct brw_context *brw)
const struct brw_tracked_state gen7_ps_state = {
.dirty = {
- .mesa = (_NEW_LINE |
- _NEW_POLYGON |
- _NEW_POLYGONSTIPPLE |
- _NEW_PROGRAM_CONSTANTS),
+ .mesa = _NEW_PROGRAM_CONSTANTS,
.brw = (BRW_NEW_CURBE_OFFSETS |
BRW_NEW_FRAGMENT_PROGRAM |
BRW_NEW_NR_WM_SURFACES |
diff --git a/src/mesa/drivers/dri/intel/intel_clear.c b/src/mesa/drivers/dri/intel/intel_clear.c
index 5a96232107e..dfca03c14bf 100644
--- a/src/mesa/drivers/dri/intel/intel_clear.c
+++ b/src/mesa/drivers/dri/intel/intel_clear.c
@@ -118,7 +118,6 @@ intelClear(struct gl_context *ctx, GLbitfield mask)
/* HW color buffers (front, back, aux, generic FBO, etc) */
if (colorMask == ~0) {
/* clear all R,G,B,A */
- /* XXX FBO: need to check if colorbuffers are software RBOs! */
blit_mask |= (mask & BUFFER_BITS_COLOR);
}
else {
diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c
index 70aee52bd14..292b7b034ee 100644
--- a/src/mesa/drivers/dri/intel/intel_context.c
+++ b/src/mesa/drivers/dri/intel/intel_context.c
@@ -661,7 +661,7 @@ intelInitContext(struct intel_context *intel,
/* Depth and stencil */
ctx->TextureFormatSupported[MESA_FORMAT_S8_Z24] = GL_TRUE;
- ctx->TextureFormatSupported[MESA_FORMAT_X8_Z24] = intel->has_separate_stencil;
+ ctx->TextureFormatSupported[MESA_FORMAT_X8_Z24] = GL_TRUE;
ctx->TextureFormatSupported[MESA_FORMAT_S8] = intel->has_separate_stencil;
/*
@@ -922,6 +922,8 @@ intelDestroyContext(__DRIcontext * driContextPriv)
/* free the Mesa context */
_mesa_free_context_data(&intel->ctx);
+ _math_matrix_dtr(&intel->ViewportMatrix);
+
FREE(intel);
driContextPriv->driverPrivate = NULL;
}
@@ -1112,7 +1114,6 @@ intel_query_dri2_buffers_no_separate_stencil(struct intel_context *intel,
*
* \see intel_update_renderbuffers()
* \see intel_region_alloc_for_handle()
- * \see intel_renderbuffer_set_region()
*/
static void
intel_process_dri2_buffer_no_separate_stencil(struct intel_context *intel,
@@ -1124,7 +1125,6 @@ intel_process_dri2_buffer_no_separate_stencil(struct intel_context *intel,
assert(!intel->must_use_separate_stencil);
struct gl_framebuffer *fb = drawable->driverPrivate;
- struct intel_region *region = NULL;
struct intel_renderbuffer *depth_rb = NULL;
if (!rb)
@@ -1151,20 +1151,18 @@ intel_process_dri2_buffer_no_separate_stencil(struct intel_context *intel,
if (unlikely(INTEL_DEBUG & DEBUG_DRI)) {
fprintf(stderr, "(reusing depth buffer as stencil)\n");
}
- intel_region_reference(&region, depth_rb->region);
+ intel_region_reference(&rb->region, depth_rb->region);
} else {
- region = intel_region_alloc_for_handle(intel->intelScreen,
- buffer->cpp,
- drawable->w,
- drawable->h,
- buffer->pitch / buffer->cpp,
- buffer->name,
- buffer_name);
+ intel_region_release(&rb->region);
+ rb->region = intel_region_alloc_for_handle(intel->intelScreen,
+ buffer->cpp,
+ drawable->w,
+ drawable->h,
+ buffer->pitch / buffer->cpp,
+ buffer->name,
+ buffer_name);
}
- intel_renderbuffer_set_region(intel, rb, region);
- intel_region_release(&region);
-
if (buffer->attachment == __DRI_BUFFER_DEPTH_STENCIL) {
struct intel_renderbuffer *stencil_rb =
intel_get_renderbuffer(fb, BUFFER_STENCIL);
@@ -1172,10 +1170,10 @@ intel_process_dri2_buffer_no_separate_stencil(struct intel_context *intel,
if (!stencil_rb)
return;
- if (stencil_rb->region && stencil_rb->region->name == buffer->name)
- return;
-
- intel_renderbuffer_set_region(intel, stencil_rb, region);
+ /* The rb passed in is the BUFFER_DEPTH attachment, and we need
+ * to associate this region to BUFFER_STENCIL as well.
+ */
+ intel_region_reference(&stencil_rb->region, rb->region);
}
}
@@ -1300,7 +1298,6 @@ intel_query_dri2_buffers_with_separate_stencil(struct intel_context *intel,
*
* \see intel_update_renderbuffers()
* \see intel_region_alloc_for_handle()
- * \see intel_renderbuffer_set_region()
* \see enum intel_dri2_has_hiz
*/
static void
@@ -1360,9 +1357,9 @@ intel_process_dri2_buffer_with_separate_stencil(struct intel_context *intel,
buffer_name);
if (buffer->attachment == __DRI_BUFFER_HIZ) {
- intel_renderbuffer_set_hiz_region(intel, rb, region);
+ intel_region_reference(&rb->hiz_region, region);
} else {
- intel_renderbuffer_set_region(intel, rb, region);
+ intel_region_reference(&rb->region, region);
}
intel_region_release(&region);
@@ -1511,12 +1508,10 @@ intel_verify_dri2_has_hiz(struct intel_context *intel,
/ depth_stencil_buffer->cpp,
depth_stencil_buffer->name,
"dri2 depth / stencil buffer");
- intel_renderbuffer_set_region(intel,
- intel_get_renderbuffer(fb, BUFFER_DEPTH),
- region);
- intel_renderbuffer_set_region(intel,
- intel_get_renderbuffer(fb, BUFFER_STENCIL),
- region);
+ intel_region_reference(&intel_get_renderbuffer(fb, BUFFER_DEPTH)->region,
+ region);
+ intel_region_reference(&intel_get_renderbuffer(fb, BUFFER_STENCIL)->region,
+ region);
intel_region_release(&region);
}
}
diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c b/src/mesa/drivers/dri/intel/intel_fbo.c
index 90c3909d1d8..1669af2c2a7 100644
--- a/src/mesa/drivers/dri/intel/intel_fbo.c
+++ b/src/mesa/drivers/dri/intel/intel_fbo.c
@@ -70,24 +70,15 @@ intel_new_framebuffer(struct gl_context * ctx, GLuint name)
static void
intel_delete_renderbuffer(struct gl_renderbuffer *rb)
{
- GET_CURRENT_CONTEXT(ctx);
- struct intel_context *intel = intel_context(ctx);
struct intel_renderbuffer *irb = intel_renderbuffer(rb);
ASSERT(irb);
- if (intel && irb->region) {
- intel_region_release(&irb->region);
- }
- if (intel && irb->hiz_region) {
- intel_region_release(&irb->hiz_region);
- }
- if (intel && irb->wrapped_depth) {
- _mesa_reference_renderbuffer(&irb->wrapped_depth, NULL);
- }
- if (intel && irb->wrapped_stencil) {
- _mesa_reference_renderbuffer(&irb->wrapped_stencil, NULL);
- }
+ intel_region_release(&irb->region);
+ intel_region_release(&irb->hiz_region);
+
+ _mesa_reference_renderbuffer(&irb->wrapped_depth, NULL);
+ _mesa_reference_renderbuffer(&irb->wrapped_stencil, NULL);
free(irb);
}
@@ -277,8 +268,6 @@ intel_image_target_renderbuffer_storage(struct gl_context *ctx,
return;
irb = intel_renderbuffer(rb);
- if (irb->region)
- intel_region_release(&irb->region);
intel_region_reference(&irb->region, image->region);
rb->InternalFormat = image->internal_format;
@@ -345,33 +334,6 @@ intel_nop_alloc_storage(struct gl_context * ctx, struct gl_renderbuffer *rb,
return GL_FALSE;
}
-
-void
-intel_renderbuffer_set_region(struct intel_context *intel,
- struct intel_renderbuffer *rb,
- struct intel_region *region)
-{
- struct intel_region *old;
-
- old = rb->region;
- rb->region = NULL;
- intel_region_reference(&rb->region, region);
- intel_region_release(&old);
-}
-
-
-void
-intel_renderbuffer_set_hiz_region(struct intel_context *intel,
- struct intel_renderbuffer *rb,
- struct intel_region *region)
-{
- struct intel_region *old = rb->hiz_region;
- rb->hiz_region = NULL;
- intel_region_reference(&rb->hiz_region, region);
- intel_region_release(&old);
-}
-
-
/**
* Create a new intel_renderbuffer which corresponds to an on-screen window,
* not a user-created renderbuffer.
@@ -572,7 +534,6 @@ intel_update_tex_wrapper_regions(struct intel_context *intel,
/* Point the renderbuffer's region to the texture's region. */
if (irb->region != intel_image->mt->region) {
- intel_region_release(&irb->region);
intel_region_reference(&irb->region, intel_image->mt->region);
}
@@ -592,7 +553,6 @@ intel_update_tex_wrapper_regions(struct intel_context *intel,
/* Point the renderbuffer's hiz region to the texture's hiz region. */
if (irb->hiz_region != intel_image->mt->hiz_region) {
- intel_region_release(&irb->hiz_region);
intel_region_reference(&irb->hiz_region, intel_image->mt->hiz_region);
}
@@ -770,7 +730,6 @@ intel_render_texture(struct gl_context * ctx,
intel_image->mt = new_mt;
intel_renderbuffer_set_draw_offset(irb, intel_image, att->Zoffset);
- intel_region_release(&irb->region);
intel_region_reference(&irb->region, intel_image->mt->region);
}
#endif
diff --git a/src/mesa/drivers/dri/intel/intel_fbo.h b/src/mesa/drivers/dri/intel/intel_fbo.h
index cbf29c86257..f7f99a4f00c 100644
--- a/src/mesa/drivers/dri/intel/intel_fbo.h
+++ b/src/mesa/drivers/dri/intel/intel_fbo.h
@@ -155,18 +155,6 @@ intel_framebuffer_has_hiz(struct gl_framebuffer *fb)
return intel_framebuffer_get_hiz_region(fb) != NULL;
}
-
-extern void
-intel_renderbuffer_set_region(struct intel_context *intel,
- struct intel_renderbuffer *irb,
- struct intel_region *region);
-
-extern void
-intel_renderbuffer_set_hiz_region(struct intel_context *intel,
- struct intel_renderbuffer *rb,
- struct intel_region *region);
-
-
extern struct intel_renderbuffer *
intel_create_renderbuffer(gl_format format);
diff --git a/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c b/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c
index 64c7acce1e9..86d0ef2d748 100644
--- a/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c
+++ b/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c
@@ -175,7 +175,7 @@ do_blit_bitmap( struct gl_context *ctx,
const GLubyte *bitmap )
{
struct intel_context *intel = intel_context(ctx);
- struct intel_region *dst = intel_drawbuf_region(intel);
+ struct intel_region *dst;
struct gl_framebuffer *fb = ctx->DrawBuffer;
GLfloat tmpColor[4];
GLubyte ubcolor[4];
@@ -198,6 +198,9 @@ do_blit_bitmap( struct gl_context *ctx,
return GL_FALSE;
}
+ intel_prepare_render(intel);
+ dst = intel_drawbuf_region(intel);
+
if (!dst)
return GL_FALSE;
@@ -226,8 +229,6 @@ do_blit_bitmap( struct gl_context *ctx,
if (!intel_check_blit_fragment_ops(ctx, tmpColor[3] == 1.0F))
return GL_FALSE;
- intel_prepare_render(intel);
-
/* Clip to buffer bounds and scissor. */
if (!_mesa_clip_to_region(fb->_Xmin, fb->_Ymin,
fb->_Xmax, fb->_Ymax,
diff --git a/src/mesa/drivers/dri/intel/intel_regions.c b/src/mesa/drivers/dri/intel/intel_regions.c
index a4da1ce4fa5..4c4945c7941 100644
--- a/src/mesa/drivers/dri/intel/intel_regions.c
+++ b/src/mesa/drivers/dri/intel/intel_regions.c
@@ -264,12 +264,15 @@ intel_region_alloc_for_handle(struct intel_screen *screen,
void
intel_region_reference(struct intel_region **dst, struct intel_region *src)
{
- if (src)
- _DBG("%s %p %d\n", __FUNCTION__, src, src->refcount);
+ _DBG("%s: %p(%d) -> %p(%d)\n", __FUNCTION__,
+ *dst, *dst ? (*dst)->refcount : 0, src, src ? src->refcount : 0);
- assert(*dst == NULL);
- if (src) {
- src->refcount++;
+ if (src != *dst) {
+ if (*dst)
+ intel_region_release(dst);
+
+ if (src)
+ src->refcount++;
*dst = src;
}
}
diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c
index 2a3a601ddba..bd8d574a29e 100644
--- a/src/mesa/drivers/dri/intel/intel_screen.c
+++ b/src/mesa/drivers/dri/intel/intel_screen.c
@@ -291,7 +291,6 @@ intel_dup_image(__DRIimage *orig_image, void *loaderPrivate)
if (image == NULL)
return NULL;
- image->region = NULL;
intel_region_reference(&image->region, orig_image->region);
if (image->region == NULL) {
FREE(image);
diff --git a/src/mesa/drivers/dri/intel/intel_tex_copy.c b/src/mesa/drivers/dri/intel/intel_tex_copy.c
index eda07a43dee..1a3643da593 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_copy.c
+++ b/src/mesa/drivers/dri/intel/intel_tex_copy.c
@@ -55,15 +55,11 @@ get_teximage_readbuffer(struct intel_context *intel, GLenum internalFormat)
DBG("%s %s\n", __FUNCTION__,
_mesa_lookup_enum_by_nr(internalFormat));
- switch (internalFormat) {
- case GL_DEPTH_COMPONENT:
- case GL_DEPTH_COMPONENT16:
- case GL_DEPTH24_STENCIL8_EXT:
- case GL_DEPTH_STENCIL_EXT:
+ if (_mesa_is_depth_format(internalFormat) ||
+ _mesa_is_depthstencil_format(internalFormat))
return intel_get_renderbuffer(intel->ctx.ReadBuffer, BUFFER_DEPTH);
- default:
- return intel_renderbuffer(intel->ctx.ReadBuffer->_ColorReadBuffer);
- }
+
+ return intel_renderbuffer(intel->ctx.ReadBuffer->_ColorReadBuffer);
}
diff --git a/src/mesa/main/arbprogram.c b/src/mesa/main/arbprogram.c
index 26d781954ed..b83369d9e04 100644
--- a/src/mesa/main/arbprogram.c
+++ b/src/mesa/main/arbprogram.c
@@ -269,6 +269,71 @@ _mesa_IsProgramARB(GLuint id)
return GL_FALSE;
}
+static GLboolean
+get_local_param_pointer(struct gl_context *ctx, const char *func,
+ GLenum target, GLuint index, GLfloat **param)
+{
+ struct gl_program *prog;
+ GLuint maxParams;
+
+ if (target == GL_VERTEX_PROGRAM_ARB
+ && ctx->Extensions.ARB_vertex_program) {
+ prog = &(ctx->VertexProgram.Current->Base);
+ maxParams = ctx->Const.VertexProgram.MaxLocalParams;
+ }
+ else if (target == GL_FRAGMENT_PROGRAM_ARB
+ && ctx->Extensions.ARB_fragment_program) {
+ prog = &(ctx->FragmentProgram.Current->Base);
+ maxParams = ctx->Const.FragmentProgram.MaxLocalParams;
+ }
+ else if (target == GL_FRAGMENT_PROGRAM_NV
+ && ctx->Extensions.NV_fragment_program) {
+ prog = &(ctx->FragmentProgram.Current->Base);
+ maxParams = MAX_NV_FRAGMENT_PROGRAM_PARAMS;
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "%s(target)", func);
+ return GL_FALSE;
+ }
+
+ if (index >= maxParams) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "%s(index)", func);
+ return GL_FALSE;
+ }
+
+ *param = prog->LocalParams[index];
+ return GL_TRUE;
+}
+
+
+static GLboolean
+get_env_param_pointer(struct gl_context *ctx, const char *func,
+ GLenum target, GLuint index, GLfloat **param)
+{
+ if (target == GL_FRAGMENT_PROGRAM_ARB
+ && ctx->Extensions.ARB_fragment_program) {
+ if (index >= ctx->Const.FragmentProgram.MaxEnvParams) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "%s(index)", func);
+ return GL_FALSE;
+ }
+ *param = ctx->FragmentProgram.Parameters[index];
+ return GL_TRUE;
+ }
+ else if (target == GL_VERTEX_PROGRAM_ARB &&
+ (ctx->Extensions.ARB_vertex_program ||
+ ctx->Extensions.NV_vertex_program)) {
+ if (index >= ctx->Const.VertexProgram.MaxEnvParams) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "%s(index)", func);
+ return GL_FALSE;
+ }
+ *param = ctx->VertexProgram.Parameters[index];
+ return GL_TRUE;
+ } else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "%s(target)", func);
+ return GL_FALSE;
+ }
+}
void GLAPIENTRY
_mesa_ProgramStringARB(GLenum target, GLenum format, GLsizei len,
@@ -383,30 +448,16 @@ void GLAPIENTRY
_mesa_ProgramEnvParameter4fARB(GLenum target, GLuint index,
GLfloat x, GLfloat y, GLfloat z, GLfloat w)
{
+ GLfloat *param;
+
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
FLUSH_VERTICES(ctx, _NEW_PROGRAM_CONSTANTS);
- if (target == GL_FRAGMENT_PROGRAM_ARB
- && ctx->Extensions.ARB_fragment_program) {
- if (index >= ctx->Const.FragmentProgram.MaxEnvParams) {
- _mesa_error(ctx, GL_INVALID_VALUE, "glProgramEnvParameter(index)");
- return;
- }
- ASSIGN_4V(ctx->FragmentProgram.Parameters[index], x, y, z, w);
- }
- else if (target == GL_VERTEX_PROGRAM_ARB /* == GL_VERTEX_PROGRAM_NV */
- && (ctx->Extensions.ARB_vertex_program || ctx->Extensions.NV_vertex_program)) {
- if (index >= ctx->Const.VertexProgram.MaxEnvParams) {
- _mesa_error(ctx, GL_INVALID_VALUE, "glProgramEnvParameter(index)");
- return;
- }
- ASSIGN_4V(ctx->VertexProgram.Parameters[index], x, y, z, w);
- }
- else {
- _mesa_error(ctx, GL_INVALID_ENUM, "glProgramEnvParameter(target)");
- return;
+ if (get_env_param_pointer(ctx, "glProgramEnvParameter",
+ target, index, &param)) {
+ ASSIGN_4V(param, x, y, z, w);
}
}
@@ -422,32 +473,16 @@ void GLAPIENTRY
_mesa_ProgramEnvParameter4fvARB(GLenum target, GLuint index,
const GLfloat *params)
{
+ GLfloat *param;
+
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
FLUSH_VERTICES(ctx, _NEW_PROGRAM_CONSTANTS);
- if (target == GL_FRAGMENT_PROGRAM_ARB
- && ctx->Extensions.ARB_fragment_program) {
- if (index >= ctx->Const.FragmentProgram.MaxEnvParams) {
- _mesa_error(ctx, GL_INVALID_VALUE, "glProgramEnvParameter4fv(index)");
- return;
- }
- memcpy(ctx->FragmentProgram.Parameters[index], params,
- 4 * sizeof(GLfloat));
- }
- else if (target == GL_VERTEX_PROGRAM_ARB /* == GL_VERTEX_PROGRAM_NV */
- && (ctx->Extensions.ARB_vertex_program || ctx->Extensions.NV_vertex_program)) {
- if (index >= ctx->Const.VertexProgram.MaxEnvParams) {
- _mesa_error(ctx, GL_INVALID_VALUE, "glProgramEnvParameter4fv(index)");
- return;
- }
- memcpy(ctx->VertexProgram.Parameters[index], params,
- 4 * sizeof(GLfloat));
- }
- else {
- _mesa_error(ctx, GL_INVALID_ENUM, "glProgramEnvParameter4fv(target)");
- return;
+ if (get_env_param_pointer(ctx, "glProgramEnvParameter4fv",
+ target, index, &param)) {
+ memcpy(param, params, 4 * sizeof(GLfloat));
}
}
@@ -496,14 +531,11 @@ _mesa_GetProgramEnvParameterdvARB(GLenum target, GLuint index,
GLdouble *params)
{
GET_CURRENT_CONTEXT(ctx);
- GLfloat fparams[4];
+ GLfloat *fparam;
- _mesa_GetProgramEnvParameterfvARB(target, index, fparams);
- if (ctx->ErrorValue == GL_NO_ERROR) {
- params[0] = fparams[0];
- params[1] = fparams[1];
- params[2] = fparams[2];
- params[3] = fparams[3];
+ if (get_env_param_pointer(ctx, "glGetProgramEnvParameterdv",
+ target, index, &fparam)) {
+ COPY_4V(params, fparam);
}
}
@@ -512,29 +544,15 @@ void GLAPIENTRY
_mesa_GetProgramEnvParameterfvARB(GLenum target, GLuint index,
GLfloat *params)
{
+ GLfloat *param;
+
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
- if (target == GL_FRAGMENT_PROGRAM_ARB
- && ctx->Extensions.ARB_fragment_program) {
- if (index >= ctx->Const.FragmentProgram.MaxEnvParams) {
- _mesa_error(ctx, GL_INVALID_VALUE, "glGetProgramEnvParameter(index)");
- return;
- }
- COPY_4V(params, ctx->FragmentProgram.Parameters[index]);
- }
- else if (target == GL_VERTEX_PROGRAM_ARB
- && ctx->Extensions.ARB_vertex_program) {
- if (index >= ctx->Const.VertexProgram.MaxEnvParams) {
- _mesa_error(ctx, GL_INVALID_VALUE, "glGetProgramEnvParameter(index)");
- return;
- }
- COPY_4V(params, ctx->VertexProgram.Parameters[index]);
- }
- else {
- _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramEnvParameter(target)");
- return;
+ if (get_env_param_pointer(ctx, "glGetProgramEnvParameterfv",
+ target, index, &param)) {
+ COPY_4V(params, param);
}
}
@@ -547,39 +565,16 @@ _mesa_ProgramLocalParameter4fARB(GLenum target, GLuint index,
GLfloat x, GLfloat y, GLfloat z, GLfloat w)
{
GET_CURRENT_CONTEXT(ctx);
- struct gl_program *prog;
+ GLfloat *param;
ASSERT_OUTSIDE_BEGIN_END(ctx);
FLUSH_VERTICES(ctx, _NEW_PROGRAM_CONSTANTS);
- if ((target == GL_FRAGMENT_PROGRAM_NV
- && ctx->Extensions.NV_fragment_program) ||
- (target == GL_FRAGMENT_PROGRAM_ARB
- && ctx->Extensions.ARB_fragment_program)) {
- if (index >= ctx->Const.FragmentProgram.MaxLocalParams) {
- _mesa_error(ctx, GL_INVALID_VALUE, "glProgramLocalParameterARB");
- return;
- }
- prog = &(ctx->FragmentProgram.Current->Base);
- }
- else if (target == GL_VERTEX_PROGRAM_ARB
- && ctx->Extensions.ARB_vertex_program) {
- if (index >= ctx->Const.VertexProgram.MaxLocalParams) {
- _mesa_error(ctx, GL_INVALID_VALUE, "glProgramLocalParameterARB");
- return;
- }
- prog = &(ctx->VertexProgram.Current->Base);
+ if (get_local_param_pointer(ctx, "glProgramLocalParameterARB",
+ target, index, &param)) {
+ ASSERT(index < MAX_PROGRAM_LOCAL_PARAMS);
+ ASSIGN_4V(param, x, y, z, w);
}
- else {
- _mesa_error(ctx, GL_INVALID_ENUM, "glProgramLocalParameterARB");
- return;
- }
-
- ASSERT(index < MAX_PROGRAM_LOCAL_PARAMS);
- prog->LocalParams[index][0] = x;
- prog->LocalParams[index][1] = y;
- prog->LocalParams[index][2] = z;
- prog->LocalParams[index][3] = w;
}
@@ -667,41 +662,14 @@ void GLAPIENTRY
_mesa_GetProgramLocalParameterfvARB(GLenum target, GLuint index,
GLfloat *params)
{
- const struct gl_program *prog;
- GLuint maxParams;
+ GLfloat *param;
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
- if (target == GL_VERTEX_PROGRAM_ARB
- && ctx->Extensions.ARB_vertex_program) {
- prog = &(ctx->VertexProgram.Current->Base);
- maxParams = ctx->Const.VertexProgram.MaxLocalParams;
- }
- else if (target == GL_FRAGMENT_PROGRAM_ARB
- && ctx->Extensions.ARB_fragment_program) {
- prog = &(ctx->FragmentProgram.Current->Base);
- maxParams = ctx->Const.FragmentProgram.MaxLocalParams;
- }
- else if (target == GL_FRAGMENT_PROGRAM_NV
- && ctx->Extensions.NV_fragment_program) {
- prog = &(ctx->FragmentProgram.Current->Base);
- maxParams = MAX_NV_FRAGMENT_PROGRAM_PARAMS;
- }
- else {
- _mesa_error(ctx, GL_INVALID_ENUM,
- "glGetProgramLocalParameterARB(target)");
- return;
- }
-
- if (index >= maxParams) {
- _mesa_error(ctx, GL_INVALID_VALUE,
- "glGetProgramLocalParameterARB(index)");
- return;
+ if (get_local_param_pointer(ctx, "glProgramLocalParameters4fvEXT",
+ target, index, &param)) {
+ COPY_4V(params, param);
}
-
- ASSERT(prog);
- ASSERT(index < MAX_PROGRAM_LOCAL_PARAMS);
- COPY_4V(params, prog->LocalParams[index]);
}
@@ -712,12 +680,13 @@ void GLAPIENTRY
_mesa_GetProgramLocalParameterdvARB(GLenum target, GLuint index,
GLdouble *params)
{
+ GLfloat *param;
GET_CURRENT_CONTEXT(ctx);
- GLfloat floatParams[4];
- ASSIGN_4V(floatParams, 0.0F, 0.0F, 0.0F, 0.0F);
- _mesa_GetProgramLocalParameterfvARB(target, index, floatParams);
- if (ctx->ErrorValue == GL_NO_ERROR) {
- COPY_4V(params, floatParams);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (get_local_param_pointer(ctx, "glProgramLocalParameters4fvEXT",
+ target, index, &param)) {
+ COPY_4V(params, param);
}
}
diff --git a/src/mesa/main/depthstencil.c b/src/mesa/main/depthstencil.c
index ab62c97fe5a..4d0600050ff 100644
--- a/src/mesa/main/depthstencil.c
+++ b/src/mesa/main/depthstencil.c
@@ -393,6 +393,217 @@ _mesa_new_z24_renderbuffer_wrapper(struct gl_context *ctx,
}
+static void
+get_row_z32f(struct gl_context *ctx, struct gl_renderbuffer *z32frb, GLuint count,
+ GLint x, GLint y, void *values)
+{
+ struct gl_renderbuffer *dsrb = z32frb->Wrapped;
+ GLfloat temp[MAX_WIDTH*2];
+ GLfloat *dst = (GLfloat *) values;
+ const GLfloat *src = (const GLfloat *) dsrb->GetPointer(ctx, dsrb, x, y);
+ GLuint i;
+ ASSERT(z32frb->DataType == GL_FLOAT);
+ ASSERT(dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
+ ASSERT(dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8);
+ if (!src) {
+ dsrb->GetRow(ctx, dsrb, count, x, y, temp);
+ src = temp;
+ }
+ for (i = 0; i < count; i++) {
+ dst[i] = src[i*2];
+ }
+}
+
+static void
+get_values_z32f(struct gl_context *ctx, struct gl_renderbuffer *z32frb, GLuint count,
+ const GLint x[], const GLint y[], void *values)
+{
+ struct gl_renderbuffer *dsrb = z32frb->Wrapped;
+ GLfloat temp[MAX_WIDTH*2];
+ GLfloat *dst = (GLfloat *) values;
+ GLuint i;
+ ASSERT(z32frb->DataType == GL_FLOAT);
+ ASSERT(dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
+ ASSERT(dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8);
+ ASSERT(count <= MAX_WIDTH);
+ /* don't bother trying direct access */
+ dsrb->GetValues(ctx, dsrb, count, x, y, temp);
+ for (i = 0; i < count; i++) {
+ dst[i] = temp[i*2];
+ }
+}
+
+static void
+put_row_z32f(struct gl_context *ctx, struct gl_renderbuffer *z32frb, GLuint count,
+ GLint x, GLint y, const void *values, const GLubyte *mask)
+{
+ struct gl_renderbuffer *dsrb = z32frb->Wrapped;
+ const GLfloat *src = (const GLfloat *) values;
+ GLfloat *dst = (GLfloat *) dsrb->GetPointer(ctx, dsrb, x, y);
+ ASSERT(z32frb->DataType == GL_FLOAT);
+ ASSERT(dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
+ ASSERT(dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8);
+ if (dst) {
+ /* direct access */
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ dst[i*2] = src[i];
+ }
+ }
+ }
+ else {
+ /* get, modify, put */
+ GLfloat temp[MAX_WIDTH*2];
+ GLuint i;
+ dsrb->GetRow(ctx, dsrb, count, x, y, temp);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ temp[i*2] = src[i];
+ }
+ }
+ dsrb->PutRow(ctx, dsrb, count, x, y, temp, mask);
+ }
+}
+
+static void
+put_mono_row_z32f(struct gl_context *ctx, struct gl_renderbuffer *z32frb, GLuint count,
+ GLint x, GLint y, const void *value, const GLubyte *mask)
+{
+ struct gl_renderbuffer *dsrb = z32frb->Wrapped;
+ GLfloat *dst = (GLfloat *) dsrb->GetPointer(ctx, dsrb, x, y);
+ ASSERT(z32frb->DataType == GL_FLOAT);
+ ASSERT(dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
+ ASSERT(dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8);
+ if (dst) {
+ /* direct access */
+ GLuint i;
+ const GLfloat val = *(GLfloat*)value;
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ dst[i*2] = val;
+ }
+ }
+ }
+ else {
+ /* get, modify, put */
+ GLfloat temp[MAX_WIDTH*2];
+ GLuint i;
+ const GLfloat val = *(GLfloat *)value;
+ dsrb->GetRow(ctx, dsrb, count, x, y, temp);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ temp[i*2] = val;
+ }
+ }
+ dsrb->PutRow(ctx, dsrb, count, x, y, temp, mask);
+ }
+}
+
+static void
+put_values_z32f(struct gl_context *ctx, struct gl_renderbuffer *z32frb, GLuint count,
+ const GLint x[], const GLint y[],
+ const void *values, const GLubyte *mask)
+{
+ struct gl_renderbuffer *dsrb = z32frb->Wrapped;
+ const GLfloat *src = (const GLfloat *) values;
+ ASSERT(z32frb->DataType == GL_FLOAT);
+ ASSERT(dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
+ ASSERT(dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8);
+ if (dsrb->GetPointer(ctx, dsrb, 0, 0)) {
+ /* direct access */
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ GLfloat *dst = (GLfloat *) dsrb->GetPointer(ctx, dsrb, x[i], y[i]);
+ *dst = src[i];
+ }
+ }
+ }
+ else {
+ /* get, modify, put */
+ GLfloat temp[MAX_WIDTH*2];
+ GLuint i;
+ dsrb->GetValues(ctx, dsrb, count, x, y, temp);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ temp[i*2] = src[i];
+ }
+ }
+ dsrb->PutValues(ctx, dsrb, count, x, y, temp, mask);
+ }
+}
+
+static void
+put_mono_values_z32f(struct gl_context *ctx, struct gl_renderbuffer *z32frb,
+ GLuint count, const GLint x[], const GLint y[],
+ const void *value, const GLubyte *mask)
+{
+ struct gl_renderbuffer *dsrb = z32frb->Wrapped;
+ GLfloat temp[MAX_WIDTH*2];
+ GLuint i;
+ const GLfloat val = *(GLfloat *)value;
+ ASSERT(z32frb->DataType == GL_FLOAT);
+ ASSERT(dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
+ ASSERT(dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8);
+ /* get, modify, put */
+ dsrb->GetValues(ctx, dsrb, count, x, y, temp);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ temp[i*2] = val;
+ }
+ }
+ dsrb->PutValues(ctx, dsrb, count, x, y, temp, mask);
+}
+
+
+/**
+ * Wrap the given GL_DEPTH_STENCIL renderbuffer so that it acts like
+ * a depth renderbuffer.
+ * \return new depth renderbuffer
+ */
+struct gl_renderbuffer *
+_mesa_new_z32f_renderbuffer_wrapper(struct gl_context *ctx,
+ struct gl_renderbuffer *dsrb)
+{
+ struct gl_renderbuffer *z32frb;
+
+ ASSERT(dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8);
+ ASSERT(dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
+
+ z32frb = ctx->Driver.NewRenderbuffer(ctx, 0);
+ if (!z32frb)
+ return NULL;
+
+ /* NOTE: need to do manual refcounting here */
+ z32frb->Wrapped = dsrb;
+ dsrb->RefCount++;
+
+ z32frb->Name = dsrb->Name;
+ z32frb->RefCount = 0;
+ z32frb->Width = dsrb->Width;
+ z32frb->Height = dsrb->Height;
+ z32frb->RowStride = dsrb->RowStride;
+ z32frb->InternalFormat = GL_DEPTH_COMPONENT32F;
+ z32frb->Format = MESA_FORMAT_Z32_FLOAT;
+ z32frb->_BaseFormat = GL_DEPTH_COMPONENT;
+ z32frb->DataType = GL_FLOAT;
+ z32frb->Data = NULL;
+ z32frb->Delete = delete_wrapper;
+ z32frb->AllocStorage = alloc_wrapper_storage;
+ z32frb->GetPointer = nop_get_pointer;
+ z32frb->GetRow = get_row_z32f;
+ z32frb->GetValues = get_values_z32f;
+ z32frb->PutRow = put_row_z32f;
+ z32frb->PutRowRGB = NULL;
+ z32frb->PutMonoRow = put_mono_row_z32f;
+ z32frb->PutValues = put_values_z32f;
+ z32frb->PutMonoValues = put_mono_values_z32f;
+
+ return z32frb;
+}
+
+
/*======================================================================
* Stencil wrapper around depth/stencil renderbuffer
*/
@@ -402,16 +613,22 @@ get_row_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint count,
GLint x, GLint y, void *values)
{
struct gl_renderbuffer *dsrb = s8rb->Wrapped;
- GLuint temp[MAX_WIDTH], i;
+ GLuint temp[MAX_WIDTH*2], i;
GLubyte *dst = (GLubyte *) values;
const GLuint *src = (const GLuint *) dsrb->GetPointer(ctx, dsrb, x, y);
ASSERT(s8rb->DataType == GL_UNSIGNED_BYTE);
- ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT);
+ ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT ||
+ dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
if (!src) {
dsrb->GetRow(ctx, dsrb, count, x, y, temp);
src = temp;
}
- if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+ if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) {
+ for (i = 0; i < count; i++) {
+ dst[i] = src[i*2+1] & 0xff;
+ }
+ }
+ else if (dsrb->Format == MESA_FORMAT_Z24_S8) {
for (i = 0; i < count; i++) {
dst[i] = src[i] & 0xff;
}
@@ -429,14 +646,20 @@ get_values_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint count
const GLint x[], const GLint y[], void *values)
{
struct gl_renderbuffer *dsrb = s8rb->Wrapped;
- GLuint temp[MAX_WIDTH], i;
+ GLuint temp[MAX_WIDTH*2], i;
GLubyte *dst = (GLubyte *) values;
ASSERT(s8rb->DataType == GL_UNSIGNED_BYTE);
- ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT);
+ ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT ||
+ dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
ASSERT(count <= MAX_WIDTH);
/* don't bother trying direct access */
dsrb->GetValues(ctx, dsrb, count, x, y, temp);
- if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+ if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) {
+ for (i = 0; i < count; i++) {
+ dst[i] = temp[i*2+1] & 0xff;
+ }
+ }
+ else if (dsrb->Format == MESA_FORMAT_Z24_S8) {
for (i = 0; i < count; i++) {
dst[i] = temp[i] & 0xff;
}
@@ -457,11 +680,19 @@ put_row_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint count,
const GLubyte *src = (const GLubyte *) values;
GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x, y);
ASSERT(s8rb->DataType == GL_UNSIGNED_BYTE);
- ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT);
+ ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT ||
+ dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
if (dst) {
/* direct access */
GLuint i;
- if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+ if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) {
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ dst[i*2+1] = src[i];
+ }
+ }
+ }
+ else if (dsrb->Format == MESA_FORMAT_Z24_S8) {
for (i = 0; i < count; i++) {
if (!mask || mask[i]) {
dst[i] = (dst[i] & 0xffffff00) | src[i];
@@ -479,9 +710,16 @@ put_row_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint count,
}
else {
/* get, modify, put */
- GLuint temp[MAX_WIDTH], i;
+ GLuint temp[MAX_WIDTH*2], i;
dsrb->GetRow(ctx, dsrb, count, x, y, temp);
- if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+ if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) {
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ temp[i*2+1] = src[i];
+ }
+ }
+ }
+ else if (dsrb->Format == MESA_FORMAT_Z24_S8) {
for (i = 0; i < count; i++) {
if (!mask || mask[i]) {
temp[i] = (temp[i] & 0xffffff00) | src[i];
@@ -508,11 +746,19 @@ put_mono_row_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint cou
const GLubyte val = *((GLubyte *) value);
GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x, y);
ASSERT(s8rb->DataType == GL_UNSIGNED_BYTE);
- ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT);
+ ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT ||
+ dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
if (dst) {
/* direct access */
GLuint i;
- if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+ if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) {
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ dst[i*2+1] = val;
+ }
+ }
+ }
+ else if (dsrb->Format == MESA_FORMAT_Z24_S8) {
for (i = 0; i < count; i++) {
if (!mask || mask[i]) {
dst[i] = (dst[i] & 0xffffff00) | val;
@@ -530,9 +776,16 @@ put_mono_row_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint cou
}
else {
/* get, modify, put */
- GLuint temp[MAX_WIDTH], i;
+ GLuint temp[MAX_WIDTH*2], i;
dsrb->GetRow(ctx, dsrb, count, x, y, temp);
- if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+ if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) {
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ temp[i*2+1] = val;
+ }
+ }
+ }
+ else if (dsrb->Format == MESA_FORMAT_Z24_S8) {
for (i = 0; i < count; i++) {
if (!mask || mask[i]) {
temp[i] = (temp[i] & 0xffffff00) | val;
@@ -559,11 +812,20 @@ put_values_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint count
struct gl_renderbuffer *dsrb = s8rb->Wrapped;
const GLubyte *src = (const GLubyte *) values;
ASSERT(s8rb->DataType == GL_UNSIGNED_BYTE);
- ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT);
+ ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT ||
+ dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
if (dsrb->GetPointer(ctx, dsrb, 0, 0)) {
/* direct access */
GLuint i;
- if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+ if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) {
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x[i], y[i]);
+ dst[1] = src[i];
+ }
+ }
+ }
+ else if (dsrb->Format == MESA_FORMAT_Z24_S8) {
for (i = 0; i < count; i++) {
if (!mask || mask[i]) {
GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x[i], y[i]);
@@ -583,9 +845,16 @@ put_values_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint count
}
else {
/* get, modify, put */
- GLuint temp[MAX_WIDTH], i;
+ GLuint temp[MAX_WIDTH*2], i;
dsrb->GetValues(ctx, dsrb, count, x, y, temp);
- if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+ if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) {
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ temp[i*2+1] = src[i];
+ }
+ }
+ }
+ else if (dsrb->Format == MESA_FORMAT_Z24_S8) {
for (i = 0; i < count; i++) {
if (!mask || mask[i]) {
temp[i] = (temp[i] & 0xffffff00) | src[i];
@@ -610,11 +879,18 @@ put_mono_values_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint
const void *value, const GLubyte *mask)
{
struct gl_renderbuffer *dsrb = s8rb->Wrapped;
- GLuint temp[MAX_WIDTH], i;
+ GLuint temp[MAX_WIDTH*2], i;
const GLubyte val = *((GLubyte *) value);
/* get, modify, put */
dsrb->GetValues(ctx, dsrb, count, x, y, temp);
- if (dsrb->Format == MESA_FORMAT_Z24_S8) {
+ if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) {
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ temp[i*2+1] = val;
+ }
+ }
+ }
+ else if (dsrb->Format == MESA_FORMAT_Z24_S8) {
for (i = 0; i < count; i++) {
if (!mask || mask[i]) {
temp[i] = (temp[i] & 0xffffff00) | val;
@@ -644,8 +920,10 @@ _mesa_new_s8_renderbuffer_wrapper(struct gl_context *ctx, struct gl_renderbuffer
struct gl_renderbuffer *s8rb;
ASSERT(dsrb->Format == MESA_FORMAT_Z24_S8 ||
- dsrb->Format == MESA_FORMAT_S8_Z24);
- ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT);
+ dsrb->Format == MESA_FORMAT_S8_Z24 ||
+ dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8);
+ ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT ||
+ dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
s8rb = ctx->Driver.NewRenderbuffer(ctx, 0);
if (!s8rb)
diff --git a/src/mesa/main/depthstencil.h b/src/mesa/main/depthstencil.h
index ef63c5d7a31..b47a2e482c2 100644
--- a/src/mesa/main/depthstencil.h
+++ b/src/mesa/main/depthstencil.h
@@ -34,6 +34,11 @@ _mesa_new_z24_renderbuffer_wrapper(struct gl_context *ctx,
extern struct gl_renderbuffer *
+_mesa_new_z32f_renderbuffer_wrapper(struct gl_context *ctx,
+ struct gl_renderbuffer *dsrb);
+
+
+extern struct gl_renderbuffer *
_mesa_new_s8_renderbuffer_wrapper(struct gl_context *ctx,
struct gl_renderbuffer *dsrb);
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 8cc3fd49a34..84969360d92 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -1131,6 +1131,16 @@ _mesa_base_fbo_format(struct gl_context *ctx, GLenum internalFormat)
return GL_DEPTH_STENCIL_EXT;
else
return 0;
+ case GL_DEPTH_COMPONENT32F:
+ if (ctx->Extensions.ARB_depth_buffer_float)
+ return GL_DEPTH_COMPONENT;
+ else
+ return 0;
+ case GL_DEPTH32F_STENCIL8:
+ if (ctx->Extensions.ARB_depth_buffer_float)
+ return GL_DEPTH_STENCIL;
+ else
+ return 0;
case GL_RED:
case GL_R8:
case GL_R16:
@@ -2266,6 +2276,15 @@ _mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment,
/* special cases */
*params = GL_INDEX;
}
+ else if (format == MESA_FORMAT_Z32_FLOAT_X24S8) {
+ /* depends on the attachment parameter */
+ if (attachment == GL_STENCIL_ATTACHMENT) {
+ *params = GL_INDEX;
+ }
+ else {
+ *params = GL_FLOAT;
+ }
+ }
else {
*params = _mesa_get_format_datatype(format);
}
@@ -2584,6 +2603,10 @@ _mesa_BlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
}
}
+ if (!mask) {
+ return;
+ }
+
ASSERT(ctx->Driver.BlitFramebuffer);
ctx->Driver.BlitFramebuffer(ctx,
srcX0, srcY0, srcX1, srcY1,
diff --git a/src/mesa/main/feedback.c b/src/mesa/main/feedback.c
index fcb089f1f31..597ec1e3f9a 100644
--- a/src/mesa/main/feedback.c
+++ b/src/mesa/main/feedback.c
@@ -64,7 +64,7 @@ _mesa_FeedbackBuffer( GLsizei size, GLenum type, GLfloat *buffer )
_mesa_error( ctx, GL_INVALID_VALUE, "glFeedbackBuffer(size<0)" );
return;
}
- if (!buffer) {
+ if (!buffer && size > 0) {
_mesa_error( ctx, GL_INVALID_VALUE, "glFeedbackBuffer(buffer==NULL)" );
ctx->Feedback.BufferSize = 0;
return;
diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c
index e88ba43971b..f58b1975672 100644
--- a/src/mesa/main/formats.c
+++ b/src/mesa/main/formats.c
@@ -1091,6 +1091,25 @@ static struct gl_format_info format_info[MESA_FORMAT_COUNT] =
0, 0, 0, 0, 0,
1, 1, 4
},
+ /* ARB_depth_buffer_float */
+ {
+ MESA_FORMAT_Z32_FLOAT, /* Name */
+ "MESA_FORMAT_Z32_FLOAT", /* StrName */
+ GL_DEPTH_COMPONENT, /* BaseFormat */
+ GL_FLOAT, /* DataType */
+ 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
+ 0, 0, 0, 32, 0, /* Lum/Int/Index/Depth/StencilBits */
+ 1, 1, 4 /* BlockWidth/Height,Bytes */
+ },
+ {
+ MESA_FORMAT_Z32_FLOAT_X24S8, /* Name */
+ "MESA_FORMAT_Z32_FLOAT_X24S8", /* StrName */
+ GL_DEPTH_STENCIL, /* BaseFormat */
+ GL_NONE /* XXX */, /* DataType */
+ 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
+ 0, 0, 0, 32, 8, /* Lum/Int/Index/Depth/StencilBits */
+ 1, 1, 8 /* BlockWidth/Height,Bytes */
+ },
};
@@ -1654,6 +1673,16 @@ _mesa_format_to_type_and_comps(gl_format format,
*comps = 1;
return;
+ case MESA_FORMAT_Z32_FLOAT:
+ *datatype = GL_FLOAT;
+ *comps = 1;
+ return;
+
+ case MESA_FORMAT_Z32_FLOAT_X24S8:
+ *datatype = GL_FLOAT_32_UNSIGNED_INT_24_8_REV;
+ *comps = 1;
+ return;
+
case MESA_FORMAT_DUDV8:
*datatype = GL_BYTE;
*comps = 2;
diff --git a/src/mesa/main/formats.h b/src/mesa/main/formats.h
index 0640bbc4af1..5b8c01781a6 100644
--- a/src/mesa/main/formats.h
+++ b/src/mesa/main/formats.h
@@ -209,6 +209,9 @@ typedef enum
MESA_FORMAT_RGB9_E5_FLOAT,
MESA_FORMAT_R11_G11_B10_FLOAT,
+ MESA_FORMAT_Z32_FLOAT,
+ MESA_FORMAT_Z32_FLOAT_X24S8,
+
MESA_FORMAT_COUNT
} gl_format;
diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c
index 66c9bd91096..6e2ce74212e 100644
--- a/src/mesa/main/framebuffer.c
+++ b/src/mesa/main/framebuffer.c
@@ -631,8 +631,14 @@ _mesa_update_depth_buffer(struct gl_context *ctx,
|| fb->_DepthBuffer->Wrapped != depthRb
|| _mesa_get_format_base_format(fb->_DepthBuffer->Format) != GL_DEPTH_COMPONENT) {
/* need to update wrapper */
- struct gl_renderbuffer *wrapper
- = _mesa_new_z24_renderbuffer_wrapper(ctx, depthRb);
+ struct gl_renderbuffer *wrapper;
+
+ if (depthRb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) {
+ wrapper = _mesa_new_z32f_renderbuffer_wrapper(ctx, depthRb);
+ }
+ else {
+ wrapper = _mesa_new_z24_renderbuffer_wrapper(ctx, depthRb);
+ }
_mesa_reference_renderbuffer(&fb->_DepthBuffer, wrapper);
ASSERT(fb->_DepthBuffer->Wrapped == depthRb);
}
diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c
index 6d7bc735887..37127dcb7a2 100644
--- a/src/mesa/main/image.c
+++ b/src/mesa/main/image.c
@@ -84,6 +84,7 @@ _mesa_type_is_packed(GLenum type)
case GL_UNSIGNED_INT_24_8_EXT:
case GL_UNSIGNED_INT_5_9_9_9_REV:
case GL_UNSIGNED_INT_10F_11F_11F_REV:
+ case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
return GL_TRUE;
}
@@ -228,6 +229,8 @@ _mesa_sizeof_packed_type( GLenum type )
return sizeof(GLuint);
case GL_UNSIGNED_INT_10F_11F_11F_REV:
return sizeof(GLuint);
+ case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
+ return 8;
default:
return -1;
}
@@ -379,6 +382,11 @@ _mesa_bytes_per_pixel( GLenum format, GLenum type )
return sizeof(GLuint);
else
return -1;
+ case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
+ if (format == GL_DEPTH_STENCIL)
+ return 8;
+ else
+ return -1;
default:
return -1;
}
@@ -531,8 +539,10 @@ _mesa_is_legal_format_and_type(const struct gl_context *ctx,
else
return GL_FALSE;
case GL_DEPTH_STENCIL_EXT:
- if (ctx->Extensions.EXT_packed_depth_stencil
- && type == GL_UNSIGNED_INT_24_8_EXT)
+ if ((ctx->Extensions.EXT_packed_depth_stencil &&
+ type == GL_UNSIGNED_INT_24_8_EXT) ||
+ (ctx->Extensions.ARB_depth_buffer_float &&
+ type == GL_FLOAT_32_UNSIGNED_INT_24_8_REV))
return GL_TRUE;
else
return GL_FALSE;
@@ -884,6 +894,7 @@ _mesa_is_depth_format(GLenum format)
case GL_DEPTH_COMPONENT16:
case GL_DEPTH_COMPONENT24:
case GL_DEPTH_COMPONENT32:
+ case GL_DEPTH_COMPONENT32F:
return GL_TRUE;
default:
return GL_FALSE;
@@ -931,6 +942,7 @@ _mesa_is_depthstencil_format(GLenum format)
switch (format) {
case GL_DEPTH24_STENCIL8_EXT:
case GL_DEPTH_STENCIL_EXT:
+ case GL_DEPTH32F_STENCIL8:
return GL_TRUE;
default:
return GL_FALSE;
@@ -956,6 +968,8 @@ _mesa_is_depth_or_stencil_format(GLenum format)
case GL_STENCIL_INDEX16_EXT:
case GL_DEPTH_STENCIL_EXT:
case GL_DEPTH24_STENCIL8_EXT:
+ case GL_DEPTH_COMPONENT32F:
+ case GL_DEPTH32F_STENCIL8:
return GL_TRUE;
default:
return GL_FALSE;
diff --git a/src/mesa/main/mipmap.c b/src/mesa/main/mipmap.c
index f2724dbca7e..8a811cb7225 100644
--- a/src/mesa/main/mipmap.c
+++ b/src/mesa/main/mipmap.c
@@ -706,6 +706,17 @@ do_row(GLenum datatype, GLuint comps, GLint srcWidth,
}
}
+ else if (datatype == GL_FLOAT_32_UNSIGNED_INT_24_8_REV && comps == 1) {
+ GLuint i, j, k;
+ const GLfloat *rowA = (const GLfloat *) srcRowA;
+ const GLfloat *rowB = (const GLfloat *) srcRowB;
+ GLfloat *dst = (GLfloat *) dstRow;
+ for (i = j = 0, k = k0; i < (GLuint) dstWidth;
+ i++, j += colStride, k += colStride) {
+ dst[i*2] = (rowA[j*2] + rowA[k*2] + rowB[j*2] + rowB[k*2]) * 0.25F;
+ }
+ }
+
else {
_mesa_problem(NULL, "bad format in do_row()");
}
@@ -1341,6 +1352,15 @@ do_row_3D(GLenum datatype, GLuint comps, GLint srcWidth,
}
}
+ else if (datatype == GL_FLOAT_32_UNSIGNED_INT_24_8_REV && comps == 1) {
+ DECLARE_ROW_POINTERS(GLfloat, 2);
+
+ for (i = j = 0, k = k0; i < (GLuint) dstWidth;
+ i++, j += colStride, k += colStride) {
+ FILTER_F_3D(0);
+ }
+ }
+
else {
_mesa_problem(NULL, "bad format in do_row()");
}
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index f018c75cc6a..b88118366b2 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1856,7 +1856,7 @@ struct gl_program
GLbitfield SystemValuesRead; /**< Bitmask of SYSTEM_VALUE_x inputs used */
GLbitfield InputFlags[MAX_PROGRAM_INPUTS]; /**< PROG_PARAM_BIT_x flags */
GLbitfield OutputFlags[MAX_PROGRAM_OUTPUTS]; /**< PROG_PARAM_BIT_x flags */
- GLbitfield TexturesUsed[MAX_TEXTURE_UNITS]; /**< TEXTURE_x_BIT bitmask */
+ GLbitfield TexturesUsed[MAX_COMBINED_TEXTURE_IMAGE_UNITS]; /**< TEXTURE_x_BIT bitmask */
GLbitfield SamplersUsed; /**< Bitfield of which samplers are used */
GLbitfield ShadowSamplers; /**< Texture units used for shadow sampling. */
diff --git a/src/mesa/main/pack.c b/src/mesa/main/pack.c
index a232a51c355..7de1d05b919 100644
--- a/src/mesa/main/pack.c
+++ b/src/mesa/main/pack.c
@@ -1971,7 +1971,8 @@ extract_uint_indexes(GLuint n, GLuint indexes[],
srcType == GL_INT ||
srcType == GL_UNSIGNED_INT_24_8_EXT ||
srcType == GL_HALF_FLOAT_ARB ||
- srcType == GL_FLOAT);
+ srcType == GL_FLOAT ||
+ srcType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
switch (srcType) {
case GL_BITMAP:
@@ -2142,6 +2143,23 @@ extract_uint_indexes(GLuint n, GLuint indexes[],
}
}
break;
+ case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
+ {
+ GLuint i;
+ const GLuint *s = (const GLuint *) src;
+ if (unpack->SwapBytes) {
+ for (i = 0; i < n; i++) {
+ GLuint value = s[i*2+1];
+ SWAP4BYTE(value);
+ indexes[i] = value & 0xff; /* lower 8 bits */
+ }
+ }
+ else {
+ for (i = 0; i < n; i++)
+ indexes[i] = s[i*2+1] & 0xff; /* lower 8 bits */
+ }
+ }
+ break;
default:
_mesa_problem(NULL, "bad srcType in extract_uint_indexes");
@@ -4412,11 +4430,13 @@ _mesa_unpack_stencil_span( struct gl_context *ctx, GLuint n,
srcType == GL_INT ||
srcType == GL_UNSIGNED_INT_24_8_EXT ||
srcType == GL_HALF_FLOAT_ARB ||
- srcType == GL_FLOAT);
+ srcType == GL_FLOAT ||
+ srcType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
ASSERT(dstType == GL_UNSIGNED_BYTE ||
dstType == GL_UNSIGNED_SHORT ||
- dstType == GL_UNSIGNED_INT);
+ dstType == GL_UNSIGNED_INT ||
+ dstType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
/* only shift and offset apply to stencil */
transferOps &= IMAGE_SHIFT_OFFSET_BIT;
@@ -4488,6 +4508,15 @@ _mesa_unpack_stencil_span( struct gl_context *ctx, GLuint n,
case GL_UNSIGNED_INT:
memcpy(dest, indexes, n * sizeof(GLuint));
break;
+ case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
+ {
+ GLuint *dst = (GLuint *) dest;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i*2+1] = indexes[i] & 0xff; /* lower 8 bits */
+ }
+ }
+ break;
default:
_mesa_problem(ctx, "bad dstType in _mesa_unpack_stencil_span");
}
@@ -4798,6 +4827,20 @@ _mesa_unpack_depth_span( struct gl_context *ctx, GLuint n,
}
}
break;
+ case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
+ {
+ GLuint i;
+ const GLfloat *src = (const GLfloat *)source;
+ for (i = 0; i < n; i++) {
+ GLfloat value = src[i * 2];
+ if (srcPacking->SwapBytes) {
+ SWAP4BYTE(value);
+ }
+ depthValues[i] = value;
+ }
+ needClamp = GL_TRUE;
+ }
+ break;
case GL_FLOAT:
DEPTH_VALUES(GLfloat, 1*);
needClamp = GL_TRUE;
@@ -4874,9 +4917,18 @@ _mesa_unpack_depth_span( struct gl_context *ctx, GLuint n,
zValues[i] = (GLushort) (depthValues[i] * (GLfloat) depthMax);
}
}
+ else if (dstType == GL_FLOAT) {
+ /* Nothing to do. depthValues is pointing to dest. */
+ }
+ else if (dstType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV) {
+ GLfloat *zValues = (GLfloat*) dest;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ zValues[i*2] = depthValues[i];
+ }
+ }
else {
- ASSERT(dstType == GL_FLOAT);
- /*ASSERT(depthMax == 1.0F);*/
+ ASSERT(0);
}
free(depthTemp);
@@ -5004,10 +5056,11 @@ _mesa_pack_depth_span( struct gl_context *ctx, GLuint n, GLvoid *dest,
/**
- * Pack depth and stencil values as GL_DEPTH_STENCIL/GL_UNSIGNED_INT_24_8.
+ * Pack depth and stencil values as GL_DEPTH_STENCIL (GL_UNSIGNED_INT_24_8 etc)
*/
void
-_mesa_pack_depth_stencil_span(struct gl_context *ctx, GLuint n, GLuint *dest,
+_mesa_pack_depth_stencil_span(struct gl_context *ctx,GLuint n,
+ GLenum dstType, GLuint *dest,
const GLfloat *depthVals,
const GLstencil *stencilVals,
const struct gl_pixelstore_attrib *dstPacking)
@@ -5037,9 +5090,19 @@ _mesa_pack_depth_stencil_span(struct gl_context *ctx, GLuint n, GLuint *dest,
stencilVals = stencilCopy;
}
- for (i = 0; i < n; i++) {
- GLuint z = (GLuint) (depthVals[i] * 0xffffff);
- dest[i] = (z << 8) | (stencilVals[i] & 0xff);
+ switch (dstType) {
+ case GL_UNSIGNED_INT_24_8:
+ for (i = 0; i < n; i++) {
+ GLuint z = (GLuint) (depthVals[i] * 0xffffff);
+ dest[i] = (z << 8) | (stencilVals[i] & 0xff);
+ }
+ break;
+ case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
+ for (i = 0; i < n; i++) {
+ ((GLfloat*)dest)[i*2] = depthVals[i];
+ dest[i*2+1] = stencilVals[i] & 0xff;
+ }
+ break;
}
if (dstPacking->SwapBytes) {
diff --git a/src/mesa/main/pack.h b/src/mesa/main/pack.h
index 78238ea5839..00aab409e42 100644
--- a/src/mesa/main/pack.h
+++ b/src/mesa/main/pack.h
@@ -130,8 +130,8 @@ _mesa_pack_depth_span(struct gl_context *ctx, GLuint n, GLvoid *dest,
extern void
-_mesa_pack_depth_stencil_span(struct gl_context *ctx,
- GLuint n, GLuint *dest,
+_mesa_pack_depth_stencil_span(struct gl_context *ctx,GLuint n,
+ GLenum dstType, GLuint *dest,
const GLfloat *depthVals,
const GLstencil *stencilVals,
const struct gl_pixelstore_attrib *dstPacking);
diff --git a/src/mesa/main/readpix.c b/src/mesa/main/readpix.c
index 0331a8ca2fe..84c5b22286a 100644
--- a/src/mesa/main/readpix.c
+++ b/src/mesa/main/readpix.c
@@ -61,6 +61,14 @@ _mesa_error_check_format_type(struct gl_context *ctx, GLenum format,
return GL_TRUE;
}
+ if (ctx->Extensions.ARB_depth_buffer_float
+ && type == GL_FLOAT_32_UNSIGNED_INT_24_8_REV
+ && format != GL_DEPTH_STENCIL_EXT) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "gl%sPixels(format is not GL_DEPTH_STENCIL_EXT)", readDraw);
+ return GL_TRUE;
+ }
+
/* basic combinations test */
if (!_mesa_is_legal_format_and_type(ctx, format, type)) {
_mesa_error(ctx, GL_INVALID_ENUM,
@@ -142,10 +150,23 @@ _mesa_error_check_format_type(struct gl_context *ctx, GLenum format,
}
break;
case GL_DEPTH_STENCIL_EXT:
- if (!ctx->Extensions.EXT_packed_depth_stencil ||
- type != GL_UNSIGNED_INT_24_8_EXT) {
- _mesa_error(ctx, GL_INVALID_ENUM, "gl%sPixels(type)", readDraw);
- return GL_TRUE;
+ /* Check validity of the type first. */
+ switch (type) {
+ case GL_UNSIGNED_INT_24_8_EXT:
+ if (!ctx->Extensions.EXT_packed_depth_stencil) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "gl%sPixels(type)", readDraw);
+ return GL_TRUE;
+ }
+ break;
+ case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
+ if (!ctx->Extensions.ARB_depth_buffer_float) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "gl%sPixels(type)", readDraw);
+ return GL_TRUE;
+ }
+ break;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "gl%sPixels(type)", readDraw);
+ return GL_TRUE;
}
if ((drawing && !_mesa_dest_buffer_exists(ctx, format)) ||
(reading && !_mesa_source_buffer_exists(ctx, format))) {
diff --git a/src/mesa/main/renderbuffer.c b/src/mesa/main/renderbuffer.c
index c36175c60e7..f5b20020d23 100644
--- a/src/mesa/main/renderbuffer.c
+++ b/src/mesa/main/renderbuffer.c
@@ -66,6 +66,9 @@ get_datatype_bytes(struct gl_renderbuffer *rb)
int component_size;
switch (rb->DataType) {
+ case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
+ component_size = 8;
+ break;
case GL_FLOAT:
case GL_UNSIGNED_INT:
case GL_UNSIGNED_INT_24_8_EXT:
diff --git a/src/mesa/main/samplerobj.c b/src/mesa/main/samplerobj.c
index f7774fdd7cb..8f8d87b90e8 100644
--- a/src/mesa/main/samplerobj.c
+++ b/src/mesa/main/samplerobj.c
@@ -251,7 +251,7 @@ _mesa_BindSampler(GLuint unit, GLuint sampler)
struct gl_sampler_object *sampObj;
GET_CURRENT_CONTEXT(ctx);
- if (unit >= ctx->Const.MaxTextureImageUnits) {
+ if (unit >= ctx->Const.MaxCombinedTextureImageUnits) {
_mesa_error(ctx, GL_INVALID_VALUE, "glBindSampler(unit %u)", unit);
return;
}
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index b58e30de9c4..8df25c3f988 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -1032,7 +1032,7 @@ validate_samplers(const struct gl_program *prog, char *errMsg)
"TEXTURE_2D",
"TEXTURE_1D",
};
- GLint targetUsed[MAX_TEXTURE_IMAGE_UNITS];
+ GLint targetUsed[MAX_COMBINED_TEXTURE_IMAGE_UNITS];
GLbitfield samplersUsed = prog->SamplersUsed;
GLuint i;
@@ -1050,7 +1050,7 @@ validate_samplers(const struct gl_program *prog, char *errMsg)
gl_texture_index target;
GLint sampler = _mesa_ffs(samplersUsed) - 1;
assert(sampler >= 0);
- assert(sampler < MAX_TEXTURE_IMAGE_UNITS);
+ assert(sampler < Elements(prog->SamplerUnits));
unit = prog->SamplerUnits[sampler];
target = prog->SamplerTargets[sampler];
if (targetUsed[unit] != -1 && targetUsed[unit] != (int) target) {
diff --git a/src/mesa/main/texenv.c b/src/mesa/main/texenv.c
index 9228e354a4d..c0d0f3779b2 100644
--- a/src/mesa/main/texenv.c
+++ b/src/mesa/main/texenv.c
@@ -419,7 +419,7 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param )
ASSERT_OUTSIDE_BEGIN_END(ctx);
maxUnit = (target == GL_POINT_SPRITE_NV && pname == GL_COORD_REPLACE_NV)
- ? ctx->Const.MaxTextureCoordUnits : ctx->Const.MaxTextureImageUnits;
+ ? ctx->Const.MaxTextureCoordUnits : ctx->Const.MaxCombinedTextureImageUnits;
if (ctx->Texture.CurrentUnit >= maxUnit) {
_mesa_error(ctx, GL_INVALID_OPERATION, "glTexEnvfv(current unit)");
return;
@@ -748,7 +748,7 @@ _mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params )
ASSERT_OUTSIDE_BEGIN_END(ctx);
maxUnit = (target == GL_POINT_SPRITE_NV && pname == GL_COORD_REPLACE_NV)
- ? ctx->Const.MaxTextureCoordUnits : ctx->Const.MaxTextureImageUnits;
+ ? ctx->Const.MaxTextureCoordUnits : ctx->Const.MaxCombinedTextureImageUnits;
if (ctx->Texture.CurrentUnit >= maxUnit) {
_mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexEnvfv(current unit)");
return;
@@ -817,7 +817,7 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params )
ASSERT_OUTSIDE_BEGIN_END(ctx);
maxUnit = (target == GL_POINT_SPRITE_NV && pname == GL_COORD_REPLACE_NV)
- ? ctx->Const.MaxTextureCoordUnits : ctx->Const.MaxTextureImageUnits;
+ ? ctx->Const.MaxTextureCoordUnits : ctx->Const.MaxCombinedTextureImageUnits;
if (ctx->Texture.CurrentUnit >= maxUnit) {
_mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexEnviv(current unit)");
return;
diff --git a/src/mesa/main/texfetch.c b/src/mesa/main/texfetch.c
index 6716ce1b071..72283eb68af 100644
--- a/src/mesa/main/texfetch.c
+++ b/src/mesa/main/texfetch.c
@@ -913,6 +913,20 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
fetch_texel_2d_r11_g11_b10f,
fetch_texel_3d_r11_g11_b10f,
store_texel_r11_g11_b10f
+ },
+ {
+ MESA_FORMAT_Z32_FLOAT,
+ fetch_texel_1d_f_r_f32, /* Reuse the R32F functions. */
+ fetch_texel_2d_f_r_f32,
+ fetch_texel_3d_f_r_f32,
+ store_texel_r_f32
+ },
+ {
+ MESA_FORMAT_Z32_FLOAT_X24S8,
+ fetch_texel_1d_z32f_x24s8,
+ fetch_texel_2d_z32f_x24s8,
+ fetch_texel_3d_z32f_x24s8,
+ store_texel_z32f_x24s8
}
};
diff --git a/src/mesa/main/texfetch_tmp.h b/src/mesa/main/texfetch_tmp.h
index e6fd81d4d57..3b1eedf39bf 100644
--- a/src/mesa/main/texfetch_tmp.h
+++ b/src/mesa/main/texfetch_tmp.h
@@ -2374,6 +2374,29 @@ static void store_texel_r11_g11_b10f(struct gl_texture_image *texImage,
#endif
+/* MESA_FORMAT_Z32_FLOAT_X24S8 ***********************************************/
+
+static void FETCH(z32f_x24s8)(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel)
+{
+ const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 2);
+ texel[RCOMP] = src[0];
+ texel[GCOMP] = 0.0F;
+ texel[BCOMP] = 0.0F;
+ texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_z32f_x24s8(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLfloat *src = (const GLfloat *) texel;
+ GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 2);
+ dst[0] = src[0];
+}
+#endif
+
+
#undef TEXEL_ADDR
#undef DIM
#undef FETCH
diff --git a/src/mesa/main/texformat.c b/src/mesa/main/texformat.c
index 8cbb021d8b0..c919a74e047 100644
--- a/src/mesa/main/texformat.c
+++ b/src/mesa/main/texformat.c
@@ -416,6 +416,19 @@ _mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat,
}
}
+ if (ctx->Extensions.ARB_depth_buffer_float) {
+ switch (internalFormat) {
+ case GL_DEPTH_COMPONENT32F:
+ ASSERT(ctx->TextureFormatSupported[MESA_FORMAT_Z32_FLOAT]);
+ return MESA_FORMAT_Z32_FLOAT;
+ case GL_DEPTH32F_STENCIL8:
+ ASSERT(ctx->TextureFormatSupported[MESA_FORMAT_Z32_FLOAT_X24S8]);
+ return MESA_FORMAT_Z32_FLOAT_X24S8;
+ default:
+ ; /* fallthrough */
+ }
+ }
+
if (ctx->Extensions.ATI_envmap_bumpmap) {
switch (internalFormat) {
case GL_DUDV_ATI:
diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index 565a3a2d8df..0e84b874411 100644
--- a/src/mesa/main/texobj.c
+++ b/src/mesa/main/texobj.c
@@ -899,7 +899,7 @@ unbind_texobj_from_texunits(struct gl_context *ctx,
{
GLuint u, tex;
- for (u = 0; u < MAX_TEXTURE_IMAGE_UNITS; u++) {
+ for (u = 0; u < Elements(ctx->Texture.Unit); u++) {
struct gl_texture_unit *unit = &ctx->Texture.Unit[u];
for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) {
if (texObj == unit->CurrentTex[tex]) {
diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
index 5c925a3d314..6e1e63bdfb0 100644
--- a/src/mesa/main/texstore.c
+++ b/src/mesa/main/texstore.c
@@ -1002,15 +1002,17 @@ memcpy_texture(struct gl_context *ctx,
/**
- * Store a 32-bit integer depth component texture image.
+ * Store a 32-bit integer or float depth component texture image.
*/
static GLboolean
_mesa_texstore_z32(TEXSTORE_PARAMS)
{
const GLuint depthScale = 0xffffffff;
const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
+ const GLenum dstType = _mesa_get_format_datatype(dstFormat);
(void) dims;
- ASSERT(dstFormat == MESA_FORMAT_Z32);
+ ASSERT(dstFormat == MESA_FORMAT_Z32 ||
+ dstFormat == MESA_FORMAT_Z32_FLOAT);
ASSERT(texelBytes == sizeof(GLuint));
if (ctx->Pixel.DepthScale == 1.0f &&
@@ -1018,7 +1020,7 @@ _mesa_texstore_z32(TEXSTORE_PARAMS)
!srcPacking->SwapBytes &&
baseInternalFormat == GL_DEPTH_COMPONENT &&
srcFormat == GL_DEPTH_COMPONENT &&
- srcType == GL_UNSIGNED_INT) {
+ srcType == dstType) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
@@ -1039,7 +1041,7 @@ _mesa_texstore_z32(TEXSTORE_PARAMS)
const GLvoid *src = _mesa_image_address(dims, srcPacking,
srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0);
_mesa_unpack_depth_span(ctx, srcWidth,
- GL_UNSIGNED_INT, (GLuint *) dstRow,
+ dstType, dstRow,
depthScale, srcType, src, srcPacking);
dstRow += dstRowStride;
}
@@ -3303,8 +3305,7 @@ _mesa_texstore_z24_s8(TEXSTORE_PARAMS)
{
const GLuint depthScale = 0xffffff;
const GLint srcRowStride
- = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType)
- / sizeof(GLuint);
+ = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType);
GLint img, row;
ASSERT(dstFormat == MESA_FORMAT_Z24_S8);
@@ -3332,8 +3333,8 @@ _mesa_texstore_z24_s8(TEXSTORE_PARAMS)
+ dstImageOffsets[dstZoffset + img]
+ dstYoffset * dstRowStride / sizeof(GLuint)
+ dstXoffset;
- const GLuint *src
- = (const GLuint *) _mesa_image_address(dims, srcPacking, srcAddr,
+ const GLubyte *src
+ = (const GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr,
srcWidth, srcHeight,
srcFormat, srcType,
img, 0, 0);
@@ -3390,8 +3391,7 @@ _mesa_texstore_s8_z24(TEXSTORE_PARAMS)
{
const GLuint depthScale = 0xffffff;
const GLint srcRowStride
- = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType)
- / sizeof(GLuint);
+ = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType);
GLint img, row;
ASSERT(dstFormat == MESA_FORMAT_S8_Z24);
@@ -3406,8 +3406,8 @@ _mesa_texstore_s8_z24(TEXSTORE_PARAMS)
+ dstImageOffsets[dstZoffset + img]
+ dstYoffset * dstRowStride / sizeof(GLuint)
+ dstXoffset;
- const GLuint *src
- = (const GLuint *) _mesa_image_address(dims, srcPacking, srcAddr,
+ const GLubyte *src
+ = (const GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr,
srcWidth, srcHeight,
srcFormat, srcType,
img, 0, 0);
@@ -3479,8 +3479,7 @@ _mesa_texstore_s8(TEXSTORE_PARAMS)
}
else {
const GLint srcRowStride
- = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType)
- / sizeof(GLuint);
+ = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType);
GLint img, row;
for (img = 0; img < srcDepth; img++) {
@@ -3488,8 +3487,8 @@ _mesa_texstore_s8(TEXSTORE_PARAMS)
+ dstImageOffsets[dstZoffset + img]
+ dstYoffset * dstRowStride / sizeof(GLuint)
+ dstXoffset;
- const GLuint *src
- = (const GLuint *) _mesa_image_address(dims, srcPacking, srcAddr,
+ const GLubyte *src
+ = (const GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr,
srcWidth, srcHeight,
srcFormat, srcType,
img, 0, 0);
@@ -4288,6 +4287,72 @@ _mesa_texstore_r11_g11_b10f(TEXSTORE_PARAMS)
}
+static GLboolean
+_mesa_texstore_z32f_x24s8(TEXSTORE_PARAMS)
+{
+ ASSERT(dstFormat == MESA_FORMAT_Z32_FLOAT_X24S8);
+ ASSERT(srcFormat == GL_DEPTH_STENCIL ||
+ srcFormat == GL_DEPTH_COMPONENT ||
+ srcFormat == GL_STENCIL_INDEX);
+ ASSERT(srcFormat != GL_DEPTH_STENCIL ||
+ srcType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
+
+ if (srcFormat == GL_DEPTH_STENCIL &&
+ ctx->Pixel.DepthScale == 1.0f &&
+ ctx->Pixel.DepthBias == 0.0f &&
+ !srcPacking->SwapBytes) {
+ /* simple path */
+ memcpy_texture(ctx, dims,
+ dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride,
+ dstImageOffsets,
+ srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+ srcAddr, srcPacking);
+ }
+ else if (srcFormat == GL_DEPTH_COMPONENT ||
+ srcFormat == GL_STENCIL_INDEX) {
+ GLint img, row;
+ const GLint srcRowStride
+ = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType)
+ / sizeof(uint64_t);
+
+ /* In case we only upload depth we need to preserve the stencil */
+ for (img = 0; img < srcDepth; img++) {
+ uint64_t *dstRow = (uint64_t *) dstAddr
+ + dstImageOffsets[dstZoffset + img]
+ + dstYoffset * dstRowStride / sizeof(uint64_t)
+ + dstXoffset;
+ const uint64_t *src
+ = (const uint64_t *) _mesa_image_address(dims, srcPacking, srcAddr,
+ srcWidth, srcHeight,
+ srcFormat, srcType,
+ img, 0, 0);
+ for (row = 0; row < srcHeight; row++) {
+ /* The unpack functions with:
+ * dstType = GL_FLOAT_32_UNSIGNED_INT_24_8_REV
+ * only write their own dword, so the other dword (stencil
+ * or depth) is preserved. */
+ if (srcFormat != GL_STENCIL_INDEX)
+ _mesa_unpack_depth_span(ctx, srcWidth,
+ GL_FLOAT_32_UNSIGNED_INT_24_8_REV, /* dst type */
+ dstRow, /* dst addr */
+ 1.0f, srcType, src, srcPacking);
+
+ if (srcFormat != GL_DEPTH_COMPONENT)
+ _mesa_unpack_stencil_span(ctx, srcWidth,
+ GL_FLOAT_32_UNSIGNED_INT_24_8_REV, /* dst type */
+ dstRow, /* dst addr */
+ srcType, src, srcPacking,
+ ctx->_ImageTransferState);
+
+ src += srcRowStride;
+ dstRow += dstRowStride / sizeof(uint64_t);
+ }
+ }
+ }
+ return GL_TRUE;
+}
+
/**
* Table mapping MESA_FORMAT_* to _mesa_texstore_*()
@@ -4422,6 +4487,9 @@ texstore_funcs[MESA_FORMAT_COUNT] =
{ MESA_FORMAT_RGB9_E5_FLOAT, _mesa_texstore_rgb9_e5 },
{ MESA_FORMAT_R11_G11_B10_FLOAT, _mesa_texstore_r11_g11_b10f },
+
+ { MESA_FORMAT_Z32_FLOAT, _mesa_texstore_z32 },
+ { MESA_FORMAT_Z32_FLOAT_X24S8, _mesa_texstore_z32f_x24s8 },
};
diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c
index 1c4fd82baac..dd069a3a4d1 100644
--- a/src/mesa/main/uniforms.c
+++ b/src/mesa/main/uniforms.c
@@ -580,7 +580,7 @@ _mesa_update_shader_textures_used(struct gl_program *prog)
if (prog->SamplersUsed & (1 << s)) {
GLuint unit = prog->SamplerUnits[s];
GLuint tgt = prog->SamplerTargets[s];
- assert(unit < MAX_TEXTURE_IMAGE_UNITS);
+ assert(unit < Elements(prog->TexturesUsed));
assert(tgt < NUM_TEXTURE_TARGETS);
prog->TexturesUsed[unit] |= (1 << tgt);
}
@@ -674,7 +674,7 @@ set_program_uniform(struct gl_context *ctx, struct gl_program *program,
GLuint texUnit = ((GLuint *) values)[i];
/* check that the sampler (tex unit index) is legal */
- if (texUnit >= ctx->Const.MaxTextureImageUnits) {
+ if (texUnit >= ctx->Const.MaxCombinedTextureImageUnits) {
_mesa_error(ctx, GL_INVALID_VALUE,
"glUniform1(invalid sampler/tex unit index for '%s')",
param->Name);
diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index 67adb8f3dcd..738e97ca55c 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -803,48 +803,44 @@ ir_to_mesa_visitor::visit(ir_loop *ir)
ir_dereference_variable *counter = NULL;
if (ir->counter != NULL)
- counter = new(ir) ir_dereference_variable(ir->counter);
+ counter = new(mem_ctx) ir_dereference_variable(ir->counter);
if (ir->from != NULL) {
assert(ir->counter != NULL);
- ir_assignment *a = new(ir) ir_assignment(counter, ir->from, NULL);
+ ir_assignment *a =
+ new(mem_ctx) ir_assignment(counter, ir->from, NULL);
a->accept(this);
- delete a;
}
emit(NULL, OPCODE_BGNLOOP);
if (ir->to) {
ir_expression *e =
- new(ir) ir_expression(ir->cmp, glsl_type::bool_type,
- counter, ir->to);
- ir_if *if_stmt = new(ir) ir_if(e);
+ new(mem_ctx) ir_expression(ir->cmp, glsl_type::bool_type,
+ counter, ir->to);
+ ir_if *if_stmt = new(mem_ctx) ir_if(e);
- ir_loop_jump *brk = new(ir) ir_loop_jump(ir_loop_jump::jump_break);
+ ir_loop_jump *brk =
+ new(mem_ctx) ir_loop_jump(ir_loop_jump::jump_break);
if_stmt->then_instructions.push_tail(brk);
if_stmt->accept(this);
-
- delete if_stmt;
- delete e;
- delete brk;
}
visit_exec_list(&ir->body_instructions, this);
if (ir->increment) {
ir_expression *e =
- new(ir) ir_expression(ir_binop_add, counter->type,
- counter, ir->increment);
+ new(mem_ctx) ir_expression(ir_binop_add, counter->type,
+ counter, ir->increment);
- ir_assignment *a = new(ir) ir_assignment(counter, e, NULL);
+ ir_assignment *a =
+ new(mem_ctx) ir_assignment(counter, e, NULL);
a->accept(this);
- delete a;
- delete e;
}
emit(NULL, OPCODE_ENDLOOP);
diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c
index 181fedd2b99..117000ba716 100644
--- a/src/mesa/state_tracker/st_cb_clear.c
+++ b/src/mesa/state_tracker/st_cb_clear.c
@@ -381,7 +381,8 @@ check_clear_depth_stencil_with_quad(struct gl_context *ctx, struct gl_renderbuff
assert(rb->Format == MESA_FORMAT_S8 ||
rb->Format == MESA_FORMAT_Z24_S8 ||
- rb->Format == MESA_FORMAT_S8_Z24);
+ rb->Format == MESA_FORMAT_S8_Z24 ||
+ rb->Format == MESA_FORMAT_Z32_FLOAT_X24S8);
if (ctx->Scissor.Enabled &&
(ctx->Scissor.X != 0 ||
@@ -436,7 +437,8 @@ check_clear_stencil_with_quad(struct gl_context *ctx, struct gl_renderbuffer *rb
assert(rb->Format == MESA_FORMAT_S8 ||
rb->Format == MESA_FORMAT_Z24_S8 ||
- rb->Format == MESA_FORMAT_S8_Z24);
+ rb->Format == MESA_FORMAT_S8_Z24 ||
+ rb->Format == MESA_FORMAT_Z32_FLOAT_X24S8);
if (maskStencil)
return GL_TRUE;
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c
index d61d7ac22be..dca3324645c 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -812,6 +812,7 @@ draw_stencil_pixels(struct gl_context *ctx, GLint x, GLint y,
for (row = 0; row < height; row++) {
GLubyte sValues[MAX_WIDTH];
GLuint zValues[MAX_WIDTH];
+ GLfloat *zValuesFloat = (GLfloat*)zValues;
GLenum destType = GL_UNSIGNED_BYTE;
const GLvoid *source = _mesa_image_address2d(&clippedUnpack, pixels,
width, height,
@@ -822,7 +823,11 @@ draw_stencil_pixels(struct gl_context *ctx, GLint x, GLint y,
ctx->_ImageTransferState);
if (format == GL_DEPTH_STENCIL) {
- _mesa_unpack_depth_span(ctx, spanWidth, GL_UNSIGNED_INT, zValues,
+ GLenum ztype =
+ pt->resource->format == PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED ?
+ GL_FLOAT : GL_UNSIGNED_INT;
+
+ _mesa_unpack_depth_span(ctx, spanWidth, ztype, zValues,
(1 << 24) - 1, type, source,
&clippedUnpack);
}
@@ -887,6 +892,26 @@ draw_stencil_pixels(struct gl_context *ctx, GLint x, GLint y,
}
}
break;
+ case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED:
+ if (format == GL_DEPTH_STENCIL) {
+ uint *dest = (uint *) (stmap + spanY * pt->stride + spanX*4);
+ GLfloat *destf = (GLfloat*)dest;
+ GLint k;
+ assert(usage == PIPE_TRANSFER_WRITE);
+ for (k = 0; k < spanWidth; k++) {
+ destf[k*2] = zValuesFloat[k];
+ dest[k*2+1] = sValues[k] & 0xff;
+ }
+ }
+ else {
+ uint *dest = (uint *) (stmap + spanY * pt->stride + spanX*4);
+ GLint k;
+ assert(usage == PIPE_TRANSFER_READ_WRITE);
+ for (k = 0; k < spanWidth; k++) {
+ dest[k*2+1] = sValues[k] & 0xff;
+ }
+ }
+ break;
default:
assert(0);
}
@@ -994,14 +1019,23 @@ st_DrawPixels(struct gl_context *ctx, GLint x, GLint y,
GL_NONE, GL_NONE,
PIPE_TEXTURE_2D,
0, PIPE_BIND_SAMPLER_VIEW);
- if (tex_format == PIPE_FORMAT_Z24_UNORM_S8_USCALED)
- stencil_format = PIPE_FORMAT_X24S8_USCALED;
- else if (tex_format == PIPE_FORMAT_S8_USCALED_Z24_UNORM)
- stencil_format = PIPE_FORMAT_S8X24_USCALED;
- else
- stencil_format = PIPE_FORMAT_S8_USCALED;
- if (stencil_format == PIPE_FORMAT_NONE)
- goto stencil_fallback;
+
+ switch (tex_format) {
+ case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
+ stencil_format = PIPE_FORMAT_X24S8_USCALED;
+ break;
+ case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
+ stencil_format = PIPE_FORMAT_S8X24_USCALED;
+ break;
+ case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED:
+ stencil_format = PIPE_FORMAT_X32_S8X24_USCALED;
+ break;
+ case PIPE_FORMAT_S8_USCALED:
+ stencil_format = PIPE_FORMAT_S8_USCALED;
+ break;
+ default:
+ goto stencil_fallback;
+ }
}
/* Mesa state should be up to date by now */
@@ -1188,6 +1222,18 @@ copy_stencil_pixels(struct gl_context *ctx, GLint srcx, GLint srcy,
assert(usage == PIPE_TRANSFER_WRITE);
memcpy(dst, src, width);
break;
+ case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED:
+ {
+ uint *dst4 = (uint *) dst;
+ int j;
+ dst4++;
+ assert(usage == PIPE_TRANSFER_READ_WRITE);
+ for (j = 0; j < width; j++) {
+ *dst4 = src[j] & 0xff;
+ dst4 += 2;
+ }
+ }
+ break;
default:
assert(0);
}
diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c
index 67926e39297..e2b29fe3068 100644
--- a/src/mesa/state_tracker/st_cb_readpixels.c
+++ b/src/mesa/state_tracker/st_cb_readpixels.c
@@ -151,6 +151,24 @@ st_read_stencil_pixels(struct gl_context *ctx, GLint x, GLint y,
}
}
break;
+ case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED:
+ if (format == GL_DEPTH_STENCIL) {
+ const uint *src = (uint *) (stmap + srcY * pt->stride);
+ const GLfloat *srcf = (const GLfloat*)src;
+ GLint k;
+ for (k = 0; k < width; k++) {
+ zValues[k] = srcf[k*2];
+ sValues[k] = src[k*2+1] & 0xff;
+ }
+ }
+ else {
+ const uint *src = (uint *) (stmap + srcY * pt->stride);
+ GLint k;
+ for (k = 0; k < width; k++) {
+ sValues[k] = src[k*2+1] & 0xff;
+ }
+ }
+ break;
default:
assert(0);
}
@@ -159,7 +177,7 @@ st_read_stencil_pixels(struct gl_context *ctx, GLint x, GLint y,
dest = _mesa_image_address2d(packing, pixels, width, height,
format, type, j, 0);
if (format == GL_DEPTH_STENCIL) {
- _mesa_pack_depth_stencil_span(ctx, width, dest,
+ _mesa_pack_depth_stencil_span(ctx, width, type, dest,
zValues, sValues, packing);
}
else {
@@ -568,6 +586,31 @@ st_readpixels(struct gl_context *ctx, GLint x, GLint y, GLsizei width, GLsizei h
dst += dstStride;
}
}
+ else if (pformat == PIPE_FORMAT_Z32_FLOAT) {
+ for (i = 0; i < height; i++) {
+ GLfloat zfloat[MAX_WIDTH];
+ pipe_get_tile_raw(pipe, trans, 0, y, width, 1, zfloat, 0);
+ y += yStep;
+ _mesa_pack_depth_span(ctx, width, dst, type,
+ zfloat, &clippedPacking);
+ dst += dstStride;
+ }
+ }
+ else if (pformat == PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED) {
+ assert(format == GL_DEPTH_COMPONENT);
+ for (i = 0; i < height; i++) {
+ GLfloat zfloat[MAX_WIDTH]; /* Z32 */
+ GLfloat zfloat2[MAX_WIDTH*2]; /* Z32X32 */
+ pipe_get_tile_raw(pipe, trans, 0, y, width, 1, zfloat2, 0);
+ y += yStep;
+ for (j = 0; j < width; j++) {
+ zfloat[j] = zfloat2[j*2];
+ }
+ _mesa_pack_depth_span(ctx, width, dst, type,
+ zfloat, &clippedPacking);
+ dst += dstStride;
+ }
+ }
else {
/* RGBA format */
/* Do a row at a time to flip image data vertically */
diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
index d3aebe526dd..99b231d9706 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -607,4 +607,15 @@ void st_init_extensions(struct st_context *st)
if (screen->get_param(screen, PIPE_CAP_SM3)) {
ctx->Extensions.ARB_shader_texture_lod = GL_TRUE;
}
+
+ if (screen->is_format_supported(screen, PIPE_FORMAT_Z32_FLOAT,
+ PIPE_TEXTURE_2D, 0,
+ PIPE_BIND_DEPTH_STENCIL |
+ PIPE_BIND_SAMPLER_VIEW) &&
+ screen->is_format_supported(screen, PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED,
+ PIPE_TEXTURE_2D, 0,
+ PIPE_BIND_DEPTH_STENCIL |
+ PIPE_BIND_SAMPLER_VIEW)) {
+ ctx->Extensions.ARB_depth_buffer_float = GL_TRUE;
+ }
}
diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c
index fa5d8f5050a..bd4f0860c52 100644
--- a/src/mesa/state_tracker/st_format.c
+++ b/src/mesa/state_tracker/st_format.c
@@ -68,42 +68,70 @@ GLenum
st_format_datatype(enum pipe_format format)
{
const struct util_format_description *desc;
+ int i;
desc = util_format_description(format);
assert(desc);
+ /* Find the first non-VOID channel. */
+ for (i = 0; i < 4; i++) {
+ if (desc->channel[i].type != UTIL_FORMAT_TYPE_VOID) {
+ break;
+ }
+ }
+
if (desc->layout == UTIL_FORMAT_LAYOUT_PLAIN) {
if (format == PIPE_FORMAT_B5G5R5A1_UNORM ||
format == PIPE_FORMAT_B5G6R5_UNORM) {
return GL_UNSIGNED_SHORT;
}
+ else if (format == PIPE_FORMAT_R11G11B10_FLOAT ||
+ format == PIPE_FORMAT_R9G9B9E5_FLOAT) {
+ return GL_FLOAT;
+ }
else if (format == PIPE_FORMAT_Z24_UNORM_S8_USCALED ||
format == PIPE_FORMAT_S8_USCALED_Z24_UNORM ||
format == PIPE_FORMAT_Z24X8_UNORM ||
format == PIPE_FORMAT_X8Z24_UNORM) {
return GL_UNSIGNED_INT_24_8;
}
+ else if (format == PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED) {
+ return GL_FLOAT_32_UNSIGNED_INT_24_8_REV;
+ }
else {
const GLuint size = format_max_bits(format);
+
+ assert(i < 4);
+ if (i == 4)
+ return GL_NONE;
+
if (size == 8) {
- if (desc->channel[0].type == UTIL_FORMAT_TYPE_UNSIGNED)
+ if (desc->channel[i].type == UTIL_FORMAT_TYPE_UNSIGNED)
return GL_UNSIGNED_BYTE;
else
return GL_BYTE;
}
else if (size == 16) {
- if (desc->channel[0].type == UTIL_FORMAT_TYPE_UNSIGNED)
+ if (desc->channel[i].type == UTIL_FORMAT_TYPE_FLOAT)
+ return GL_HALF_FLOAT;
+ if (desc->channel[i].type == UTIL_FORMAT_TYPE_UNSIGNED)
return GL_UNSIGNED_SHORT;
else
return GL_SHORT;
}
- else {
- assert( size <= 32 );
- if (desc->channel[0].type == UTIL_FORMAT_TYPE_UNSIGNED)
+ else if (size <= 32) {
+ if (desc->channel[i].type == UTIL_FORMAT_TYPE_FLOAT)
+ return GL_FLOAT;
+ if (desc->channel[i].type == UTIL_FORMAT_TYPE_UNSIGNED)
return GL_UNSIGNED_INT;
else
return GL_INT;
}
+ else {
+ assert(size == 64);
+ assert(desc->channel[i].type == UTIL_FORMAT_TYPE_FLOAT);
+ return GL_DOUBLE;
+ }
}
}
else if (format == PIPE_FORMAT_UYVY) {
@@ -180,6 +208,10 @@ st_mesa_format_to_pipe_format(gl_format mesaFormat)
return PIPE_FORMAT_Z24X8_UNORM;
case MESA_FORMAT_S8:
return PIPE_FORMAT_S8_USCALED;
+ case MESA_FORMAT_Z32_FLOAT:
+ return PIPE_FORMAT_Z32_FLOAT;
+ case MESA_FORMAT_Z32_FLOAT_X24S8:
+ return PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED;
case MESA_FORMAT_YCBCR:
return PIPE_FORMAT_UYVY;
#if FEATURE_texture_s3tc
@@ -402,6 +434,10 @@ st_pipe_format_to_mesa_format(enum pipe_format format)
return MESA_FORMAT_X8_Z24;
case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
return MESA_FORMAT_S8_Z24;
+ case PIPE_FORMAT_Z32_FLOAT:
+ return MESA_FORMAT_Z32_FLOAT;
+ case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED:
+ return MESA_FORMAT_Z32_FLOAT_X24S8;
case PIPE_FORMAT_UYVY:
return MESA_FORMAT_YCBCR;
@@ -759,6 +795,10 @@ static const struct format_mapping format_map[] = {
{ GL_DEPTH_COMPONENT, 0 },
{ DEFAULT_DEPTH_FORMATS }
},
+ {
+ { GL_DEPTH_COMPONENT32F, 0 },
+ { PIPE_FORMAT_Z32_FLOAT, 0 }
+ },
/* stencil formats */
{
@@ -775,6 +815,10 @@ static const struct format_mapping format_map[] = {
{ GL_DEPTH_STENCIL_EXT, GL_DEPTH24_STENCIL8_EXT, 0 },
{ PIPE_FORMAT_Z24_UNORM_S8_USCALED, PIPE_FORMAT_S8_USCALED_Z24_UNORM, 0 }
},
+ {
+ { GL_DEPTH32F_STENCIL8, 0 },
+ { PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED, 0 }
+ },
/* sRGB formats */
{
diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c
index a8c4b5c3f49..7bd82aae206 100644
--- a/src/mesa/state_tracker/st_manager.c
+++ b/src/mesa/state_tracker/st_manager.c
@@ -918,6 +918,15 @@ st_manager_add_color_renderbuffer(struct st_context *st,
return FALSE;
st_framebuffer_update_attachments(stfb);
+
+ /*
+ * Force a call to the state tracker manager to validate the
+ * new renderbuffer. It might be that there is a window system
+ * renderbuffer available.
+ */
+ if(stfb->iface)
+ stfb->iface_stamp = p_atomic_read(&stfb->iface->stamp) - 1;
+
st_invalidate_state(st->ctx, _NEW_BUFFERS);
return TRUE;
diff --git a/src/mesa/swrast/s_blit.c b/src/mesa/swrast/s_blit.c
index 3516a41bf41..7f53f19eb62 100644
--- a/src/mesa/swrast/s_blit.c
+++ b/src/mesa/swrast/s_blit.c
@@ -568,9 +568,6 @@ _swrast_BlitFramebuffer(struct gl_context *ctx,
};
GLint i;
- if (!ctx->DrawBuffer->_NumColorDrawBuffers)
- return;
-
if (!_mesa_clip_blit(ctx, &srcX0, &srcY0, &srcX1, &srcY1,
&dstX0, &dstY0, &dstX1, &dstY1)) {
return;
diff --git a/src/mesa/swrast/s_readpix.c b/src/mesa/swrast/s_readpix.c
index 214f2ea1aaa..66ca39293a6 100644
--- a/src/mesa/swrast/s_readpix.c
+++ b/src/mesa/swrast/s_readpix.c
@@ -446,7 +446,7 @@ read_depth_stencil_pixels(struct gl_context *ctx,
GLfloat depthVals[MAX_WIDTH];
_swrast_read_depth_span_float(ctx, depthRb, width, x, y + i,
depthVals);
- _mesa_pack_depth_stencil_span(ctx, width, depthStencilDst,
+ _mesa_pack_depth_stencil_span(ctx, width, type, depthStencilDst,
depthVals, stencilVals, packing);
}
}