summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri/i965/brw_draw_upload.c
AgeCommit message (Collapse)AuthorFilesLines
2012-06-26i965: enable ARB_instanced_arrays extensioninstanced_arrays-v2Jordan Justen1-7/+36
Set the step_rate value when drawing to implement ARB_instanced_arrays for gen >= 4. v2: * leave (total_size < 2048) check where it was to only make this check once rather than once for each array. Signed-off-by: Jordan Justen <jordan.l.justen@intel.com> Reviewed-by: Eric Anholt <eric@anholt.net>
2012-05-23i965: add flag to enable cut_indexJordan Justen1-1/+8
When brw->prim_restart.enable_cut_index is set, the cut index will be enabled when uploading index_buffer commands. Signed-off-by: Jordan Justen <jordan.l.justen@intel.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2012-02-29i965: Disable PrimitiveID upload.Kenneth Graunke1-1/+1
We currently don't support gl_PrimitiveID, and I believe asking the hardware to generate it results in vertex cache invalidations. This could result in slowdowns for applications that use gl_InstanceID, which would be counter-productive. Just turn it off for now. Signed-off-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Eric Anholt <eric@anholt.net>
2011-11-29mesa: Make gl_program::InputsRead 64 bits.Mathias Fröhlich1-3/+3
Make gl_program::InputsRead a 64 bits bitfield. Adapt the intel and radeon driver to handle a 64 bits InputsRead value. Signed-off-by: Mathias Froehlich <Mathias.Froehlich@web.de> Reviewed-by: Eric Anholt <eric@anholt.net>
2011-11-11i965: Add support for gl_VertexID and gl_InstanceID.Eric Anholt1-5/+31
The compiler setup for these VF-uploaded attributes looks a little cheesy with mixing system values and real VBO-sourced attributes. It would be nice if we could just compute the ATTR[] map to GRF index up front and use it at visit time instead of using ir->location in the ATTR file. However, we don't know the reg_offset at visit(ir_variable *) time, so we can't do the mapping that early. Fixes piglit vertexid test. Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2011-11-11i965: Replace a should-never-happen fallback with asserts where it matters.Eric Anholt1-11/+15
We only allow 16 vec4s of attributes in our GLSL/ARB_vp programs, and 1 more element will get used for gl_VertexID/gl_InstanceID. So it should never have been possible to hit this fallback, unless there was another bug. If you do hit this, you're probably using gl_VertexID and falling back to swrast won't work for you anyway. This also updates the limits for gen6+. Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2011-11-02i965: Add support for integral vertex attributes.Paul Berry1-4/+65
When a vertex shader input attribute is declared with an integral type (e.g. ivec4), we need to ensure that the generated vertex shader code addresses the vertex attribute register using the proper register type. (Previously, we assumed all vertex shader input attributes were floating-point). In addition, when uploading vertex data that was specified with VertexAttribIPointer, we need to instruct the vertex fetch unit to convert the data to signed or unsigned int, rather than float. And when filling in the implied w=1 on a vector with less than 4 components, we need to fill it in with the integer representation of 1 rather than the floating-point representation of 1. Fixes piglit tests vs-attrib-{ivec4,uvec4}-precision. Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2011-10-29i965: Move index buffer upload to emit() time.Eric Anholt1-2/+2
It's consumed by the brw_emit_index_buffer() code at emit() time. Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Acked-by: Paul Berry <stereotype441@gmail.com>
2011-10-29i965: Do a hack job of merging VB prepare()/emit() together.Eric Anholt1-1/+2
I don't really want to touch this impenetrable code in this series, so just call the one function from the other, since no other atom cares about them. Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Acked-by: Paul Berry <stereotype441@gmail.com>
2011-10-29i965: Remove the validated BO list, now that it's unused.Eric Anholt1-6/+2
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Acked-by: Paul Berry <stereotype441@gmail.com>
2011-10-18intel: Convert from GLboolean to 'bool' from stdbool.h.Kenneth Graunke1-3/+3
I initially produced the patch using this bash command: for file in {intel,i915,i965}/*.{c,cpp,h}; do [ ! -h $file ] && sed -i 's/GLboolean/bool/g' $file && sed -i 's/GL_TRUE/true/g' $file && sed -i 's/GL_FALSE/false/g' $file; done Then I manually added #include <stdbool.h> to fix compilation errors, and converted a few functions back to GLboolean that were used in core Mesa's function pointer table to avoid "incompatible pointer" warnings. Finally, I cleaned up some whitespace issues introduced by the change. Signed-off-by: Kenneth Graunke <kenneth@whitecape.org> Acked-by: Chad Versace <chad@chad-versace.us> Acked-by: Paul Berry <stereotype441@gmail.com>
2011-10-01i965: Make sure to upload the data for a collection of Stride == 0 arrays.Eric Anholt1-1/+18
Commit d631c19db47181129811080bfa772b210d762d4d avoided this problem by forcing the driver to get the min/max index, but that commit was broken, so just fix the driver problem (confusion between "do I need to upload any data?" and "do I need the index bounds in order to upload any data?").
2011-08-23i965: Only map the necessary buffer range in brw_prepare_indicesIan Romanick1-3/+2
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Eric Anholt <eric@anholt.net>
2011-08-23mesa: Eliminate dd_function_table::MapBufferIan Romanick1-1/+5
Replace all calls to dd_function_table::MapBuffer with appropriate calls to dd_function_table::MapBufferRange, then remove all the cruft. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Brian Paul <brianp@vmware.com> Acked-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Eric Anholt <eric@anholt.net>
2011-08-23mesa: Fix incorrect access parameter passed to MapBufferIan Romanick1-3/+1
The code previously passed GL_DYNAMIC_DRAW for the access parameter. By inspection, I believe that all drivers would treat this as GL_READ_WRITE because it's not GL_READ_ONLY and it's not GL_WRITE_ONLY. It appears the i965 code wants GL_WRITE_ONLY (it's about to write a bunch of data in, never read data), while the arrayelt code is GL_READ_ONLY (just dereffed as arguments to CALL_Whatever*v). Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Brian Paul <brianp@vmware.com> Acked-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Eric Anholt <eric@anholt.net> Reviewed-by: Keith Whitwell <keithw@vmware.com>
2011-08-23mesa: Remove target parameter from dd_function_table::MapBufferIan Romanick1-1/+0
No driver used that parameter, and most drivers ended up with a bunch of unused-parameter warnings because it was there. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Brian Paul <brianp@vmware.com> Acked-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Eric Anholt <eric@anholt.net>
2011-08-23mesa: Remove target parameter from dd_function_table::UnmapBufferIan Romanick1-1/+1
No driver used that parameter, and most drivers ended up with a bunch of unused-parameter warnings because it was there. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Brian Paul <brianp@vmware.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Eric Anholt <eric@anholt.net>
2011-07-18i965: Rename CMD_VERTEX_(BUFFER|ELEMENT) to 3DSTATE_VERTEX_...S.Kenneth Graunke1-3/+3
This makes our code use the same names as the documentation. Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
2011-06-18i965: Don't try to continue space before the start of a VBO.Eric Anholt1-0/+2
This loop is trying to see if all the buffers to be uploaded happen to be the same increment from the start of the 3DSTATE_VERTEX_BUFFERS currently loaded in the hardware. However, we might be at a smaller offset than the previous set of VERTEX_BUFFERS, so we can't reuse because that packet made the first entry be its starting offset (you can't access outside the given bounds). Fixes piglit ARB_vertex_buffer_object/elements-negative-offset.
2011-06-18i965: Add missing state flag for vertex elements on current VS program.Eric Anholt1-1/+2
Fixes a missing 3DSTATE_VERTEX_ELEMENTS on topogun.trace.
2011-06-10i965: Add support for GL_FIXED vertex attributes.Eric Anholt1-0/+5
This sadly requires work in the VS to rescale them, because the hardware doesn't support this format natively. Fixes arb_es2_compatibility-fixed-type and gtf/fixed_data_type. Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2011-05-17i965: Set Address Modify Enable in VERTEX_BUFFER on Ivybridge.Kenneth Graunke1-0/+3
Otherwise, Ivybridge seems to ignore the newly supplied data, giving us rubbish for vertices. Signed-off-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Eric Anholt <eric@anholt.net>
2011-04-12Revert "i965: Reinstate max-index paranoia"Chris Wilson1-1/+1
This reverts commit b4cbd2b312d53a50603e2cda925711bc9def4517. It looked like a safe sanity check. It missed the issue of the start of the buffer not being at 0, but even that was not enough to explain why setting the max vertex index caused glyphs to be dropped from the game 'Achron'. Instead, the issue appears to be related to the use of the vertex bias and so we would need to re-emit the max-index every time we adjusted the bias, so re-emitting the relocations and defeating the original optimisation. Reported-and-tested-by: Thomas Jones <thomas.jones@utoronto.ca> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=35163 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-03-11i965: Use ffs() on a 32-bit int value instad of ffsll().Eric Anholt1-1/+1
2011-03-04i965: Fix extending VB packetsChris Wilson1-2/+2
Computation of the delta of this array from the last had a silly little bug and ignored any initial delta==0 causing grief in Nexuiz and friends. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-03-04i965: Align index to type size and flush if the type changesChris Wilson1-7/+14
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-03-04i965: Prevent using a zero sized (or of unknown type) vertex arrayChris Wilson1-5/+6
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-03-01i965: Use negative relocation deltas to minimse vertex uploadsChris Wilson1-7/+14
With relaxed relocation checking in the kernel, we can specify a negative delta (i.e. pointing outside of the target bo) in order to fake a range in a large buffer. We only then need to upload the elements used and adjust the buffer offset such that they correspond with the indices used in the DrawArrays. (Depends on libdrm 0209428b3918c4336018da9293cdcbf7f8fedfb6) Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-03-01i965: Undo 'continuation of vb packets'Chris Wilson1-1/+1
This breaks nexuiz for unknown reason; disable until a true fix can be found.
2011-03-01i965: Fix uploading of shortened vertex packetsChris Wilson1-12/+13
... handle all cases and not just the interleaved upload. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-03-01i965: Upload all vertices usedChris Wilson1-29/+38
... and take advantage of start_vertex_bias to trim to [min_index, max_index] where possible (i.e. when we need to upload all arrays). Fixes half_float_vertex(misc.fillmode.wireframe) Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=34595 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-02-24intel: Reset the buffer offset after releasing reference to packed uploadChris Wilson1-0/+1
Fixes oglc/vbo(basic.bufferdata) Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=34603 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-02-24i965: Unmap the correct pointer after discontiguous uploadChris Wilson1-2/+3
Fixes piglit/fbo-depth-sample-compare: ==14722== Invalid free() / delete / delete[] ==14722== at 0x4C240FD: free (vg_replace_malloc.c:366) ==14722== by 0x84FBBFD: intel_upload_unmap (intel_buffer_objects.c:695) ==14722== by 0x85205BC: brw_prepare_vertices (brw_draw_upload.c:457) ==14722== by 0x852F975: brw_validate_state (brw_state_upload.c:394) ==14722== by 0x851FA24: brw_draw_prims (brw_draw.c:365) ==14722== by 0x85F2221: vbo_exec_vtx_flush (vbo_exec_draw.c:389) ==14722== by 0x85EF443: vbo_exec_FlushVertices_internal (vbo_exec_api.c:543) ==14722== by 0x85EF49B: vbo_exec_FlushVertices (vbo_exec_api.c:973) ==14722== by 0x86D6A16: _mesa_set_enable (enable.c:351) ==14722== by 0x42CAD1: render_to_fbo (in /home/ickle/git/piglit/bin/fbo-depth-sample-compare) ==14722== by 0x42CEE3: piglit_display (in /home/ickle/git/piglit/bin/fbo-depth-sample-compare) ==14722== by 0x42F508: display (in /home/ickle/git/piglit/bin/fbo-depth-sample-compare) ==14722== Address 0xc606310 is 0 bytes after a block of size 18,720 alloc'd ==14722== at 0x4C244E8: malloc (vg_replace_malloc.c:236) ==14722== by 0x85202AB: copy_array_to_vbo_array (brw_draw_upload.c:256) ==14722== by 0x85205BC: brw_prepare_vertices (brw_draw_upload.c:457) ==14722== by 0x852F975: brw_validate_state (brw_state_upload.c:394) ==14722== by 0x851FA24: brw_draw_prims (brw_draw.c:365) ==14722== by 0x85F2221: vbo_exec_vtx_flush (vbo_exec_draw.c:389) ==14722== by 0x85EF443: vbo_exec_FlushVertices_internal (vbo_exec_api.c:543) ==14722== by 0x85EF49B: vbo_exec_FlushVertices (vbo_exec_api.c:973) ==14722== by 0x86D6A16: _mesa_set_enable (enable.c:351) ==14722== by 0x42CAD1: render_to_fbo (in /home/ickle/git/piglit/bin/fbo-depth-sample-compare) ==14722== by 0x42CEE3: piglit_display (in /home/ickle/git/piglit/bin/fbo-depth-sample-compare) ==14722== by 0x42F508: display (in /home/ickle/git/piglit/bin/fbo-depth-sample-compare) Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=34604 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-02-22i965: Trim the interleaved upload to the minimum number of verticesChris Wilson1-1/+5
... should have no impact on a properly formatted draw operation. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-02-22i965: Reinstate max-index paranoiaChris Wilson1-1/+1
Don't trust the applications not to reference beyond the end of the vertex buffers. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-02-22i965: Zero the offset into the vbo when uploading non-interleavedChris Wilson1-0/+1
Fixes regression from 559435d9152acc7162e4e60aae6591c7c6c8274b. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-02-21i965: Fix VB packet reuse when offset for the new buffer isn't stride aligned.Eric Anholt1-1/+1
Fixes regression in scissor-stencil-clear and 5 other tests.
2011-02-21i965: Remove spurious duplicate ADVANCE_BATCHChris Wilson1-1/+0
... a leftover from a bad merge. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-02-21intel: extend current vertex buffersChris Wilson1-18/+53
If the next vertex arrays are a (discontiguous) continuation of the current arrays, such that the new vertices are simply offset from the start of the current vertex buffer definitions we can reuse those defintions and avoid the overhead of relocations and invalidations. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-02-21intel: Use specified alignment for writes into the upload bufferChris Wilson1-7/+9
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-02-21i965: Clean up brw_prepare_vertices()Chris Wilson1-21/+20
Use a temporary glarray variable to replace the numerous input->glarray. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-02-21intel: combine short memcpy using a temporary allocated bufferChris Wilson1-5/+6
Using a temporary buffer for large discontiguous uploads into the common buffer and a single buffered upload is faster than performing the discontiguous copies through a mapping into the GTT. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-02-21i965: upload normal arrays as interleavedChris Wilson1-30/+72
Upload the non-vbo arrays into a single interleaved buffer object, and so need to just emit a single vertex buffer relocation. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-02-21i965: interleaved vboChris Wilson1-12/+27
If the user passed in several arrays interleaved in the same vbo, only emit a single vertex buffer and relocation. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-02-21i965: emit one vb packet per vboChris Wilson1-67/+51
Track reuse of the vertex buffer objects and so minimise the number of vertex buffers used by the hardware (and their relocations). Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-02-21i965: upload transient indices into the same discontiguous bufferChris Wilson1-12/+8
As we now pack the indices into a common upload buffer, we can reuse a single CMD_INDEX_BUFFER packet and translate each invocation with a start vertex offset. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-02-21i965: suppress repeat-emission of identical vertex elementsChris Wilson1-3/+2
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-02-21intel: use pwrite for batchChris Wilson1-0/+5
It's faster. Not only is the memcpy more efficiently performed in the kernel (making up for the system call overhead), but by not using mmap we remove the greater overhead of tracking the vma of every batch. And it means we can read back from the batch buffer without incurring the cost of a uncached read through the GTT. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-02-21intel: Buffered uploadChris Wilson1-1/+1
Rather than performing lots of little writes to update the common bo upon each update, write those into a static buffer and flush that when full (or at the end of the batch). Doing so gives a dramatic performance improvement over and above using mmaped access. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-02-21i965: Combine vb upload buffer with the general upload bufferChris Wilson1-59/+8
Reuse the new common upload buffer for uploading temporary indices and rebuilt vertex arrays. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>