Re: [Mesa-dev] [PATCH] gallium: add bits for clipping points as tris (d3d-style)
On Fri, 10 Jan 2014 03:57:45 +0100 srol...@vmware.com wrote: > From: Roland Scheidegger > > OpenGL does whole-point clipping, that is a large point is either fully > clipped or fully unclipped (the latter means it may extend beyond the > viewport as long as the center is inside the viewport). d3d9 (d3d10 has > no large points) however requires points to be clipped after they are > expanded to a rectangle. (Note some IHVs are known to ignore GL rules at > least with some hw/drivers.) > > Hence add a rasterizer bit indicating which way points should be clipped > (some drivers probably will always ignore this), and add the draw interaction > this requires. Drivers wanting to support this and using draw must support > large points on their own as draw doesn't implement vp clipping on the > expanded points (it potentially could but the complexity doesn't seem > warranted), and the driver needs to do viewport scissoring on such points. Is there any possibility of this being exposed to user-space? With that hat on, it would have been useful to me several times in the past. Perhaps whoever was Mesa's ARB contact could propose an extension? I know nothing about how that happens, just would like this functionality. - Lauri ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] GPU lockup CP stall when calling clBuildProgram on Cayman&In-Reply-To=
I have been digging into this, and I was wrong it occurred at clBuildProgram (was just the logs printing was deferred - sorry). Using gdb, I have been able to see that the crash occurs inside the call pipe_semaphore_signal(&ws->cs_queued); Here is the calling stack just before the hang: (gdb) bt #0 radeon_drm_ws_queue_cs (ws=0x60b2e0, cs=0x77f6a010) at radeon_drm_winsys.c:555 #1 0x7293a7e8 in radeon_drm_cs_flush (rcs=0x77f6a010, flags=2, cs_trace_id=0) at radeon_drm_cs.c:567 #2 0x72950f6d in r600_context_flush (ctx=0x6251d0, flags=2) at r600_hw_context.c:356 #3 0x72951f3b in r600_flush (ctx=0x6251d0, flags=0) at r600_pipe.c:88 #4 0x72952056 in r600_flush_gfx_ring (ctx=0x6251d0, flags=0) at r600_pipe.c:120 #5 0x72952034 in r600_flush_from_st (ctx=0x6251d0, fence=0x7fffb390, flags=0) at r600_pipe.c:115 #6 0x76c0718a in clover::command_queue::flush (this=0x642000) at core/queue.cpp:48 #7 0x76c182f2 in clover::hard_event::wait (this=0xaca350) at core/event.cpp:124 #8 0x76c60811 in clFinish (d_q=0x642008) at api/event.cpp:268 #9 0x0040136c in main (argc=1, argv=0x7fffdd58) at hello_world.c:193 If I run line 563 pipe_semaphore_signal(&ws->cs_queued) the system hang. (gdb) print *cs $2 = {base = {cdw = 384, buf = 0x77f6a028, ring_type = RING_GFX}, csc1 = {buf = {3221301248, 2147483648, 2147483648, 3221243392, 1040, 3221383168, 768, 2, 1073741824, 3221383168, 772, 0, 0, 3221317632, 867, 256, 3221317888, 659, 0, 3221317888, 213, 15, 3221317888, 512, 0, 3221317632, 1088, 0, 3221317632, 1103, 4, 3221645568, 576, 0, 0, 0, 0, 0, 0, 3221514496, 583, 0, 0, 0, 0, 3222104320, 644, 0 , 3221383424, 741, 0, 0, 3221383424, 685, 0, 0, 3221317632, 645, 7, 3221317888, 682, 196671, 3221383424, 757, 1985229328, 4275878552, 3221383424, 570, 0, 0, 3221317888, 572, 4294967295, 3221383424, 256, 4294967295, 0, 3221319424, 0, 0, 3221317888, 10, 0, 3221317888, 439, 0, 3221448960, 688, 0, 0, 0, 3221317888, 128, 0, 3221317888, 131, 65535, 3221383424, 180, 0, 1065353216, 3221317888, 140, 2863311530, 3221317888, 518, 1087, 3221317888, 520, 0, 3221514496, 762, 1065353216, 1065353216, 1065353216, 1065353216, 3221383424, 144, 0, 1073758208, 3221383424, 12, 0, 1073758208, 3221317888, 530, 0, 3221317888, 537, 0, 3221317888, 554, 0, 3222300928, 80, 0 , 3222300928, 96, 0 , 3221317888, 714, 0, 3221317888, 4, 0, 3221317888, 141, 0, 3221317888, 434, 0, 3221383424, 441, 0, 0, 3221317888, 725, 0, 3221318656, 0, 16781311, 3221318656, 32, 16781311, 3221301248, 2147483648, 2147483648, 3221243392, 1031, 3221383168, 768, 2, 1073741824...}, fd = 8, cs = {num_chunks = 3, cs_id = 0, chunks = 140737353588864, gart_limit = 0, vram_limit = 0}, chunks = {{chunk_id = 2, length_dw = 384, chunk_data = 140737353523240}, {chunk_id = 1, length_dw = 16, chunk_data = 6452160}, {chunk_id = 3, length_dw = 2, chunk_data = 14073735358}}, chunk_array = {140737353588816, 140737353588832, 140737353588848}, flags = {1, 0}, cs_trace_id = 0, nrelocs = 512, crelocs = 4, validated_crelocs = 0, relocs_bo = 0x642c30, relocs = 0x6273c0, is_handle_added = '\000' , "\001\001\001\001", '\000' , reloc_indices_hashlist = {0 , 2, 1, 3, 0 }, used_vram = 65640, used_gart = 1}, csc2 = {buf = {0 }, fd = 8, cs = {num_chunks = 0, cs_id = 0, chunks = 140737353657120, gart_limit = 0, vram_limit = 0}, chunks = {{chunk_id = 2, length_dw = 0, chunk_data = 140737353591496}, {chunk_id = 1, length_dw = 0, chunk_data = 6472608}, {chunk_id = 3, length_dw = 2, chunk_data = 140737353657144}}, chunk_array = {140737353657072, 140737353657088, 140737353657104}, flags = {0, 0}, cs_trace_id = 0, nrelocs = 512, crelocs = 0, validated_crelocs = 0, relocs_bo = 0x62b390, relocs = 0x62c3a0, is_handle_added = '\000' , reloc_indices_hashlist = {0 }, used_vram = 0, used_gart = 0}, csc = 0x77f7aac8, cst = 0x77f6a028, ws = 0x60b2e0, flush_cs = 0x729520c6 , flush_data = 0x6251d0, flush_completed = {mutex = {__data = {__lock = 0, __count = 0, __owner = 0, __nusers = 0, __kind = 0, __spins = 0, __list = {__prev = 0x0, __next = 0x0}}, __size = '\000' , __align = 0}, cond = {__data = {__lock = 0, __futex = 0, __total_seq = 0, __wakeup_seq = 0, __woken_seq = 0, __mutex = 0x0, __nwaiters = 0, __broadcast_seq = 0}, __size = '\000' , __align = 0}, counter = 0}, trace_buf = 0x0} (gdb) (gdb) print *ws $3 = {base = {reference = {count = 1}, screen = 0x0, destroy = 0x7294381e , query_info = 0x7294395d , buffer_create = 0x729385f6 , buffer_get_cs_handle = 0x729385dc , buffer_map = 0x7293789c , buffer_unmap = 0x72937ad5 , buffer_is_busy = 0x72936ca3 , buffer_wait = 0x72936c27 , buffer_get_tiling = 0x729382c8 , buffer_set_tiling = 0x7293843e , buffer_from_handle = 0x72938701 , buffer_get_handle = 0x72938c9f , buffer_get_virtual_address = 0x72938e10 , cs_create = 0x729395bc , cs_destroy = 0x7293a854 , c
Re: [Mesa-dev] [PATCH] gallium: add bits for clipping points as tris (d3d-style)
On Fri, Jan 10, 2014 at 10:33 AM, Lauri Kasanen wrote: > On Fri, 10 Jan 2014 03:57:45 +0100 > srol...@vmware.com wrote: > >> From: Roland Scheidegger >> >> OpenGL does whole-point clipping, that is a large point is either fully >> clipped or fully unclipped (the latter means it may extend beyond the >> viewport as long as the center is inside the viewport). d3d9 (d3d10 has >> no large points) however requires points to be clipped after they are >> expanded to a rectangle. (Note some IHVs are known to ignore GL rules at >> least with some hw/drivers.) >> >> Hence add a rasterizer bit indicating which way points should be clipped >> (some drivers probably will always ignore this), and add the draw interaction >> this requires. Drivers wanting to support this and using draw must support >> large points on their own as draw doesn't implement vp clipping on the >> expanded points (it potentially could but the complexity doesn't seem >> warranted), and the driver needs to do viewport scissoring on such points. > > Is there any possibility of this being exposed to user-space? With that > hat on, it would have been useful to me several times in the past. > > Perhaps whoever was Mesa's ARB contact could propose an extension? I > know nothing about how that happens, just would like this functionality. IIRC there were some draft by NVIDIA discussed in Khronos OpenGL ES meetings 6-7 years ago, but I don't think it ever resulted in a released extension spec. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/2] mesa: Add extra null check in _mesa_GenerateMipmap()
Signed-off-by: Juha-Pekka Heikkila --- src/mesa/main/fbobject.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index 2892784..6b88e7d 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -3024,6 +3024,12 @@ _mesa_GenerateMipmap(GLenum target) texObj = _mesa_get_current_tex_object(ctx, target); + if (!texObj) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGenerateMipmap(current_tex_object=null)"); + return; + } + if (texObj->BaseLevel >= texObj->MaxLevel) { /* nothing to do */ return; -- 1.8.1.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/2] glsl: Fix memcpy size in ir_constant
ir_constant::ir_constant(const struct glsl_type, const ir_constant_data *) was copying too much memory. Signed-off-by: Juha-Pekka Heikkila --- src/glsl/ir.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp index ba6903d..83feb49 100644 --- a/src/glsl/ir.cpp +++ b/src/glsl/ir.cpp @@ -622,7 +622,7 @@ ir_constant::ir_constant(const struct glsl_type *type, this->ir_type = ir_type_constant; this->type = type; - memcpy(& this->value, data, sizeof(this->value)); + memcpy(& this->value, data, type->std140_size(false)); } ir_constant::ir_constant(float f, unsigned vector_elements) -- 1.8.1.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 1/2] loader: refactor duplicated code into loader util lib
On Thu, Jan 9, 2014 at 10:36 PM, Eric Anholt wrote: > Rob Clark writes: > >> From: Rob Clark >> >> All the various window system integration layers duplicate roughly the >> same code for figuring out device and driver name, pci-id's, etc. Which >> is sad. So extract it out into a loader util lib. > > Thanks for tackling this. It had been (low) on my list for a while. cool, thanks for having a look >> static int >> droid_open_device(void) >> { >> @@ -773,7 +672,7 @@ dri2_initialize_android(_EGLDriver *drv, _EGLDisplay >> *dpy) >>goto cleanup_display; >> } > > forgot loader_set_logger here. Do we want to just move that to > egl_dri2.c instead of each platform_*? fwiw, default logger (if you don't call loader_set_logger()) is just printf. So in theory the ones that don't call loader_set_logger() either had no logging before or were just using printf. Hmm.. but that probably shouldn't be the case for the 'droid loader, so maybe I screwed that up. (disclaimer: the android loader in particular, I have no idea how to build/test.. so this one probably is the most likely one that I would have screwed up :-P) >> - dri2_dpy->driver_name = (char *) droid_get_driver_name(dri2_dpy->fd); >> + dri2_dpy->driver_name = loader_get_driver_for_fd(dri2_dpy->fd, 0); >> if (dri2_dpy->driver_name == NULL) { >>err = "DRI2: failed to get driver name"; >>goto cleanup_device; > > >> diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader.h >> b/src/gallium/auxiliary/pipe-loader/pipe_loader.h >> index 444bdf1..e915c63 100644 >> --- a/src/gallium/auxiliary/pipe-loader/pipe_loader.h >> +++ b/src/gallium/auxiliary/pipe-loader/pipe_loader.h >> @@ -44,6 +44,7 @@ struct pipe_screen; >> enum pipe_loader_device_type { >> PIPE_LOADER_DEVICE_SOFTWARE, >> PIPE_LOADER_DEVICE_PCI, >> + PIPE_LOADER_DEVICE_PLATFORM, >> NUM_PIPE_LOADER_DEVICE_TYPES >> }; >> > >> diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c >> b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c >> index 927fb24..fda0ab1 100644 >> --- a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c >> +++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c >> @@ -190,17 +117,22 @@ boolean >> pipe_loader_drm_probe_fd(struct pipe_loader_device **dev, int fd) >> { >> struct pipe_loader_drm_device *ddev = >> CALLOC_STRUCT(pipe_loader_drm_device); >> - >> - ddev->base.type = PIPE_LOADER_DEVICE_PCI; >> + int vendor_id, chip_id; >> + >> + if (loader_get_pci_id_for_fd(fd, &vendor_id, &chip_id)) { >> + ddev->base.type = PIPE_LOADER_DEVICE_PCI; >> + ddev->base.u.pci.vendor_id = vendor_id; >> + ddev->base.u.pci.chip_id = chip_id; >> + } else { >> + ddev->base.type = PIPE_LOADER_DEVICE_PLATFORM; >> + } >> ddev->base.ops = &pipe_loader_drm_ops; >> ddev->fd = fd; >> >> pipe_loader_drm_x_auth(fd); >> >> - if (!find_drm_pci_id(ddev)) >> - goto fail; >> - >> - if (!find_drm_driver_name(ddev)) >> + ddev->base.driver_name = loader_get_driver_for_fd(fd, _LOADER_GALLIUM); >> + if (!ddev->base.driver_name) >>goto fail; >> >> *dev = &ddev->base; >> diff --git a/src/gallium/state_trackers/clover/core/device.cpp >> b/src/gallium/state_trackers/clover/core/device.cpp >> index e5e429a..76a49d0 100644 >> --- a/src/gallium/state_trackers/clover/core/device.cpp >> +++ b/src/gallium/state_trackers/clover/core/device.cpp >> @@ -63,6 +63,7 @@ device::type() const { >> case PIPE_LOADER_DEVICE_SOFTWARE: >>return CL_DEVICE_TYPE_CPU; >> case PIPE_LOADER_DEVICE_PCI: >> + case PIPE_LOADER_DEVICE_PLATFORM: >>return CL_DEVICE_TYPE_GPU; >> default: >>assert(0); >> @@ -74,6 +75,7 @@ cl_uint >> device::vendor_id() const { >> switch (ldev->type) { >> case PIPE_LOADER_DEVICE_SOFTWARE: >> + case PIPE_LOADER_DEVICE_PLATFORM: >>return 0; >> case PIPE_LOADER_DEVICE_PCI: >>return ldev->u.pci.vendor_id; > > These hunks look unrelated to the refactor and should be in a separate > commit enabling non-pci devices. I think I ended up including these in the first patch just because I needed some value to use in pipe_loader_drm_probe_fd() if loader_get_pci_id_for_fd() failed. I suppose what I could do is move the addition of new enum value into a patch that comes before this one. >> diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c >> index b4b97ac..c13930c 100644 >> --- a/src/gbm/backends/dri/gbm_dri.c >> +++ b/src/gbm/backends/dri/gbm_dri.c >> @@ -44,6 +44,7 @@ >> #include "gbm_driint.h" >> >> #include "gbmint.h" >> +#include "loader.h" >> >> /* For importing wl_buffer */ >> #if HAVE_WAYLAND_PLATFORM >> @@ -270,7 +271,7 @@ dri_screen_create(struct gbm_dri_device *dri) >> const __DRIextension **extensions; >> int ret = 0; >> >> - dri->base.driver_name = dri_fd_get_driver_name(dri->base.base.fd); >> + dri->base.driver_name = loader_get_driver_for_fd(dri->base.base.fd, 0)
Re: [Mesa-dev] [PATCH 05/30] glsl/linker: Refactor in preparation for adding more shader stages.
On 9 January 2014 22:17, Chris Forbes wrote: > This is a nice cleanup; I like that this brings both writes to > prog->LastClipDistanceArraySize together -- but it looks like the > behavior changes slightly. > > Previously, if there was no VS and no GS, then we would never write > prog->LastClipDistanceArraySize. Now we'll read an old junk value > (potentially from a previous linking of the same program object with > different shaders attached) from prog->Vert.ClipDistanceArraySize > (since we never called validate_vertex_shader_executable) -- but we'll > never end up actually using it, since it's only used for transform > feedback of gl_ClipDistance. > Yeah, that's a good point. I agree that it's completely benign, but I think I could have made things clearer. I've changed it to this: if (num_shaders[MESA_SHADER_GEOMETRY] > 0) prog->LastClipDistanceArraySize = prog->Geom.ClipDistanceArraySize; else if (num_shaders[MESA_SHADER_VERTEX] > 0) prog->LastClipDistanceArraySize = prog->Vert.ClipDistanceArraySize; else prog->LastClipDistanceArraySize = 0; /* Not used */ ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 11/30] mesa: Change redundant code into loops in shaderapi.c.
On 9 January 2014 20:03, Chris Forbes wrote: > This is a slightly odd construction (although copied from the existing > code): > > > + if ((shProg == NULL) || (shProg->_LinkedShaders[stage] == NULL)) > > +shProg = NULL; > You're right. This would be much better as: if ((shProg != NULL) && (shProg->_LinkedShaders[stage] == NULL)) shProg = NULL; I'll update it in a follow-up patch. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 19/30] mesa/cs: Handle compute shaders in _mesa_use_program().
On 9 January 2014 22:32, Chris Forbes wrote: > Minor nit, but could CS be done after the ordered pipeline stages, for > consistency? > Sure, no problem. In fact, I just realized that if I change the "type" parameter of use_shader_program to gl_shader_stage, I can call it in a loop. I'll do that in a follow-up patch. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 10/30] mesa: Remove ad-hoc arrays of gl_shader_program.
On 01/09/2014 07:19 PM, Paul Berry wrote: Now that we have a ctx->Shader.CurrentProgram array, we can just use it directly. --- src/mesa/main/context.c | 6 +- src/mesa/state_tracker/st_draw.c| 6 +- src/mesa/state_tracker/st_program.c | 6 +- 3 files changed, 3 insertions(+), 15 deletions(-) For patches 1 - 12: Reviewed-by: Brian Paul More nice clean-ups! ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 21/30] mesa/cs: Implement MAX_COMPUTE_WORK_GROUP_SIZE constant.
On 01/09/2014 07:19 PM, Paul Berry wrote: --- src/glsl/builtin_variables.cpp | 27 +++ src/glsl/glsl_parser_extras.cpp | 4 src/glsl/glsl_parser_extras.h | 3 +++ src/glsl/main.cpp | 3 +++ src/glsl/standalone_scaffolding.cpp | 3 +++ src/mesa/main/context.c | 5 + src/mesa/main/get.c | 8 src/mesa/main/mtypes.h | 3 +++ 8 files changed, 56 insertions(+) diff --git a/src/glsl/builtin_variables.cpp b/src/glsl/builtin_variables.cpp index 17ae087..171bf08 100644 --- a/src/glsl/builtin_variables.cpp +++ b/src/glsl/builtin_variables.cpp @@ -390,6 +390,7 @@ private: enum ir_variable_mode mode, int slot); ir_variable *add_uniform(const glsl_type *type, const char *name); ir_variable *add_const(const char *name, int value); + ir_variable *add_const_ivec3(const char *name, int x, int y, int z); void add_varying(int slot, const glsl_type *type, const char *name, const char *name_as_gs_input); @@ -530,6 +531,25 @@ builtin_variable_generator::add_const(const char *name, int value) } +ir_variable * +builtin_variable_generator::add_const_ivec3(const char *name, int x, int y, +int z) +{ + ir_variable *const var = add_variable(name, glsl_type::ivec3_type, + ir_var_auto, -1); + ir_constant_data data; + memset(&data, 0, sizeof(data)); + data.i[0] = x; + data.i[1] = y; + data.i[2] = z; + var->constant_value = new(var) ir_constant(glsl_type::ivec3_type, &data); + var->constant_initializer = + new(var) ir_constant(glsl_type::ivec3_type, &data); + var->data.has_initializer = true; + return var; +} + + void builtin_variable_generator::generate_constants() { @@ -660,6 +680,13 @@ builtin_variable_generator::generate_constants() add_const("gl_MaxTessControlAtomicCounters", 0); add_const("gl_MaxTessEvaluationAtomicCounters", 0); } + + if (state->is_version(430, 0) || state->ARB_compute_shader_enable) { + add_const_ivec3("gl_MaxComputeWorkGroupSize", + state->Const.MaxComputeWorkGroupSize[0], + state->Const.MaxComputeWorkGroupSize[1], + state->Const.MaxComputeWorkGroupSize[2]); + } } diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp index 33a43c5..8524fc6 100644 --- a/src/glsl/glsl_parser_extras.cpp +++ b/src/glsl/glsl_parser_extras.cpp @@ -123,6 +123,10 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *_ctx, this->Const.MaxCombinedAtomicCounters = ctx->Const.MaxCombinedAtomicCounters; this->Const.MaxAtomicBufferBindings = ctx->Const.MaxAtomicBufferBindings; + /* Compute shader constants */ + for (unsigned i = 0; i < Elements(this->Const.MaxComputeWorkGroupSize); i++) + this->Const.MaxComputeWorkGroupSize[i] = ctx->Const.MaxComputeWorkGroupSize[i]; + this->current_function = NULL; this->toplevel_ir = NULL; this->found_return = false; diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h index 468707c..be34fd9 100644 --- a/src/glsl/glsl_parser_extras.h +++ b/src/glsl/glsl_parser_extras.h @@ -250,6 +250,9 @@ struct _mesa_glsl_parse_state { unsigned MaxFragmentAtomicCounters; unsigned MaxCombinedAtomicCounters; unsigned MaxAtomicBufferBindings; + + /* ARB_compute_shader */ + unsigned MaxComputeWorkGroupSize[3]; } Const; /** diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp index 864c929..bb2054f 100644 --- a/src/glsl/main.cpp +++ b/src/glsl/main.cpp @@ -50,6 +50,9 @@ initialize_context(struct gl_context *ctx, gl_api api) */ ctx->Const.GLSLVersion = glsl_version; ctx->Extensions.ARB_ES3_compatibility = true; + ctx->Const.MaxComputeWorkGroupSize[0] = 1024; + ctx->Const.MaxComputeWorkGroupSize[1] = 1024; + ctx->Const.MaxComputeWorkGroupSize[2] = 64; ctx->Const.Program[MESA_SHADER_COMPUTE].MaxTextureImageUnits = 16; ctx->Const.Program[MESA_SHADER_COMPUTE].MaxUniformComponents = 1024; ctx->Const.Program[MESA_SHADER_COMPUTE].MaxInputComponents = 0; /* not used */ diff --git a/src/glsl/standalone_scaffolding.cpp b/src/glsl/standalone_scaffolding.cpp index ab92da8..e8eb529 100644 --- a/src/glsl/standalone_scaffolding.cpp +++ b/src/glsl/standalone_scaffolding.cpp @@ -140,6 +140,9 @@ void initialize_context_to_defaults(struct gl_context *ctx, gl_api api) ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxInputComponents = 32; ctx->Const.MaxDrawBuffers = 1; + ctx->Const.MaxComputeWorkGroupSize[0] = 1024; + ctx->Const.MaxComputeWorkGroupSize[1] = 1024; + ctx->Const.MaxComputeWorkGroupSize[2] = 64; ctx->Const.Program[MESA_SHADER_COMPUTE].MaxTextureImageUnits = 16; ctx->Const.Program[MESA_SHADER_COMPUTE].MaxUniformComponents
Re: [Mesa-dev] [PATCH] gallium: add bits for clipping points as tris (d3d-style)
Am 10.01.2014 12:04, schrieb Erik Faye-Lund: > On Fri, Jan 10, 2014 at 10:33 AM, Lauri Kasanen wrote: >> On Fri, 10 Jan 2014 03:57:45 +0100 >> srol...@vmware.com wrote: >> >>> From: Roland Scheidegger >>> >>> OpenGL does whole-point clipping, that is a large point is either fully >>> clipped or fully unclipped (the latter means it may extend beyond the >>> viewport as long as the center is inside the viewport). d3d9 (d3d10 has >>> no large points) however requires points to be clipped after they are >>> expanded to a rectangle. (Note some IHVs are known to ignore GL rules at >>> least with some hw/drivers.) >>> >>> Hence add a rasterizer bit indicating which way points should be clipped >>> (some drivers probably will always ignore this), and add the draw >>> interaction >>> this requires. Drivers wanting to support this and using draw must support >>> large points on their own as draw doesn't implement vp clipping on the >>> expanded points (it potentially could but the complexity doesn't seem >>> warranted), and the driver needs to do viewport scissoring on such points. >> >> Is there any possibility of this being exposed to user-space? With that >> hat on, it would have been useful to me several times in the past. >> >> Perhaps whoever was Mesa's ARB contact could propose an extension? I >> know nothing about how that happens, just would like this functionality. > > IIRC there were some draft by NVIDIA discussed in Khronos OpenGL ES > meetings 6-7 years ago, but I don't think it ever resulted in a > released extension spec > I think the spec would actually be a bit messy, as it means you have to convert points essentially to tris before before rasterization (before clipping in fact), so it doesn't really fit into "normal" pipeline. The llvmpipe implementation (which is only in a private branch as it can't be merged easily to master due to needing fake viewport scissoring) of course doesn't do this (points rasterization is way easier than tris) but just pretends like it does. It is worth noting d3d10 got rid of the problem entirely (for large points you have to explicitly convert your points to tris in the gs). Also, even if we had such an extension, drivers need to implement this. I don't know if all hw can easily do that, though at least some nvidia cards with blob will always follow d3d9 behavior (but I have no idea if the hw couldn't do GL behavior or nvidia just thought the d3d9 behavior is more useful anyway). (Not saying I'd object such an extension just rather it's out of the scope of this patch as we just need it for d3d9.) Roland ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 2/2] dri: set yInverted default to GL_TRUE
For both patches, Reviewed-by: Chad Versace ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 06/16] i965/fs: Assert that var < num_vars.
Patches 1-6 Reviewed-by: Jordan Justen On Thu, Dec 19, 2013 at 1:40 PM, Matt Turner wrote: > Helped to track down a problem in a version of the next commit. > --- > src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp > b/src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp > index a29767d..a2d88aa 100644 > --- a/src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp > +++ b/src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp > @@ -57,6 +57,7 @@ fs_live_variables::setup_one_read(bblock_t *block, fs_inst > *inst, >int ip, fs_reg reg) > { > int var = var_from_vgrf[reg.reg] + reg.reg_offset; > + assert(var < num_vars); > > /* In most cases, a register can be written over safely by the > * same instruction that is its last use. For a single > @@ -106,6 +107,7 @@ fs_live_variables::setup_one_write(bblock_t *block, > fs_inst *inst, > int ip, fs_reg reg) > { > int var = var_from_vgrf[reg.reg] + reg.reg_offset; > + assert(var < num_vars); > > start[var] = MIN2(start[var], ip); > end[var] = MAX2(end[var], ip); > -- > 1.8.3.2 > > ___ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 16/16] i965/fs: Print the maximum register pressure.
On Thu, Dec 19, 2013 at 1:40 PM, Matt Turner wrote: > --- > src/mesa/drivers/dri/i965/brw_fs.cpp | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp > b/src/mesa/drivers/dri/i965/brw_fs.cpp > index 606e21a..e1edd0f 100644 > --- a/src/mesa/drivers/dri/i965/brw_fs.cpp > +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp > @@ -2947,13 +2947,15 @@ fs_visitor::dump_instructions() > { > calculate_register_pressure(); > > - int ip = 0; > + int ip = 0, max_pressure = 0; > foreach_list(node, &this->instructions) { >backend_instruction *inst = (backend_instruction *)node; > + max_pressure = MAX2(max_pressure, regs_live_at_ip[ip]); >printf("{%3d} %4d: ", regs_live_at_ip[ip], ip); >dump_instruction(inst); >++ip; > } > + printf("Maximum %3d registers live at once.\n", max_pressure); How about "Max number of live registers: %3d\n" or "Maximum of %3d registers simultaneously live.\n"? Patches 14, 15 (w/Ken's improved commit message) and 16 Reviewed-by: Jordan Justen ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 7/7] c11: Make TIME_UTC a conditional macro.
On Thu, Jan 09, 2014 at 11:32:10AM -0800, Jose Fonseca wrote: > This series is pretty much what I proposed several months ago, rebased on top > of master, with minor if any tweaks. > > Still to do is remove the deprecated abstractions (which now are mere > wrappers of the c11 ones). > > That said, this series is already useful as is, not only because of > the code de-duplication, but also because the Windows conditional var > implemention in master is poll-based so performs quite badly, in > particular llvmpipe with many threads. Which is fixed here. > > IMHO the rest can be done as time permits... > > Jose This series looks good to me. But I'd like to see patch 7 squashed into patch 2 to prevent possible build failures during bisects. I like how this series opens up opportunities for additional cleanups. In particular, we can now begin to remove the threading wrappers in src/egl/main. I'm not familiar with C11's thread headers, so patch 2 is Acked-by: Chad Versace Patches 3-7 are: Reviewed-by: Chad Versace ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [Bug 70410] egl-static/Makefile: linking fails with llvm >= 3.4
https://bugs.freedesktop.org/show_bug.cgi?id=70410 Kai changed: What|Removed |Added CC||k...@dev.carbon-project.org --- Comment #17 from Kai --- I've tested attachment 91725 and it works with LLVM 3.5 (r198682) in a clean build enviroment (LLVM packages for Debian from llvm.org/apt). I couldn't use attachment 91764, since apparently the patch from attachment 91751 hasn't landed in LLVM's tree yet (at least not before r198682). You can have my Tested-by: Kai Wasserbäch for attachment 91725. Stack: LLVM: SVN:trunk/r198682 Mesa: Git:master/532b1fecd9 libdrm: 2.4.50-1 (Debian package) -- You are receiving this mail because: You are the assignee for the bug. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] mesa: use _mesa_shader_stage_to_string() to generate file extension
Signed-off-by: Emil Velikov --- Hi Paul, Here is another small cleanup inspired by your work. Not entirely sure that the last hunk is correct though. Cheers, Emil --- src/mesa/program/prog_print.c | 26 +- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/src/mesa/program/prog_print.c b/src/mesa/program/prog_print.c index 9391e99..4962401 100644 --- a/src/mesa/program/prog_print.c +++ b/src/mesa/program/prog_print.c @@ -31,6 +31,7 @@ #include /* for PRIx64 macro */ +#include "glsl_parser_extras.h" #include "main/glheader.h" #include "main/context.h" #include "main/imports.h" @@ -1005,23 +1006,11 @@ _mesa_print_parameter_list(const struct gl_program_parameter_list *list) void _mesa_write_shader_to_file(const struct gl_shader *shader) { - const char *type = ""; char filename[100]; FILE *f; - switch (shader->Stage) { - case MESA_SHADER_FRAGMENT: - type = "frag"; - break; - case MESA_SHADER_VERTEX: - type = "vert"; - break; - case MESA_SHADER_GEOMETRY: - type = "geom"; - break; - } - - _mesa_snprintf(filename, sizeof(filename), "shader_%u.%s", shader->Name, type); + _mesa_snprintf(filename, sizeof(filename), "shader_%u.%.4s", shader->Name, + _mesa_shader_stage_to_string(shader->Stage)); f = fopen(filename, "w"); if (!f) { fprintf(stderr, "Unable to open %s for writing\n", filename); @@ -1062,16 +1051,11 @@ void _mesa_append_uniforms_to_file(const struct gl_shader *shader) { const struct gl_program *const prog = shader->Program; - const char *type; char filename[100]; FILE *f; - if (shader->Stage == MESA_SHADER_FRAGMENT) - type = "frag"; - else - type = "vert"; - - _mesa_snprintf(filename, sizeof(filename), "shader_%u.%s", shader->Name, type); + _mesa_snprintf(filename, sizeof(filename), "shader_%u.%.4s", shader->Name, + _mesa_shader_stage_to_string(shader->Stage)); f = fopen(filename, "a"); /* append */ if (!f) { fprintf(stderr, "Unable to open %s for appending\n", filename); -- 1.8.5.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] Plans for 10.0.3 release
On Thu, Jan 09, 2014 at 01:07:58PM -0800, Carl Worth wrote: > Hi folks, > > I just released Mesa 10.0.2 (a bit late) and followed it by immediately > working through my queue of commits nominated for the stable branch, > which I've just pushed out. > > Since the code for 10.0.2 was done and pushed a week ago, my current > plan is to release 10.0.2 just one week from now, (to get back to a > schedule of a stable release every two weeks). > > The state of the queue looks pretty good right now. There are still a > handful of patches from early December that have not landed on master > yet. I imagine he's waiting for review on those. > > Then, there are two recent, larger series from Aaron and Chad. For each > of these series, there has been some discussion and both authors are > planning to come back with a version 2 of their series in response to > review. Carl, my series is now on master. I sent the series separately to mesa-stable on Thursday as a single squashed patch that cleanly applies to 10.0. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] nouveau: add framebuffer validation callback
Fixes assertions when trying to attach textures to fbs with formats not supported by the render engines. See https://bugs.freedesktop.org/show_bug.cgi?id=73459 Signed-off-by: Ilia Mirkin --- In a perfect world I'd have separate callbacks for depth and color, but given the list of supported values, I don't think this matters. Also I used st_validate_framebuffer as a template, but I don't know if there can actually be many attachments. Should MaxColorAttachments be set to 1? I think it's set to 8 right now. And there's also an odd nouveau_validate_framebuffer thing in nouveau_context.c, but I think that's related to actually rendering/invalidating the fb displayed to the screen. src/mesa/drivers/dri/nouveau/nouveau_driver.h | 1 + src/mesa/drivers/dri/nouveau/nouveau_fbo.c| 38 +++ src/mesa/drivers/dri/nouveau/nv04_context.c | 14 ++ src/mesa/drivers/dri/nouveau/nv10_context.c | 16 +++ src/mesa/drivers/dri/nouveau/nv20_context.c | 16 +++ 5 files changed, 85 insertions(+) diff --git a/src/mesa/drivers/dri/nouveau/nouveau_driver.h b/src/mesa/drivers/dri/nouveau/nouveau_driver.h index e03b2c1..84953da 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_driver.h +++ b/src/mesa/drivers/dri/nouveau/nouveau_driver.h @@ -60,6 +60,7 @@ struct nouveau_driver { struct nouveau_surface *dst, unsigned mask, unsigned value, int dx, int dy, int w, int h); + bool (*is_rt_format_supported)(gl_format format); nouveau_state_func *emit; int num_emit; diff --git a/src/mesa/drivers/dri/nouveau/nouveau_fbo.c b/src/mesa/drivers/dri/nouveau/nouveau_fbo.c index 25543e4..fba0d52 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_fbo.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_fbo.c @@ -268,6 +268,43 @@ nouveau_finish_render_texture(struct gl_context *ctx, texture_dirty(rb->TexImage->TexObject); } +static void +nouveau_framebuffer_validate(struct gl_context *ctx, +struct gl_framebuffer *fb) +{ + const struct nouveau_driver *drv = context_drv(ctx); + int i, count = 0; + + for (i = 0; i < ctx->Const.MaxColorAttachments; i++) { + struct gl_renderbuffer_attachment *rba = + &fb->Attachment[BUFFER_COLOR0 + i]; + if (rba->Type == GL_NONE) + continue; + + count++; + if (rba->Type != GL_TEXTURE) + continue; + + if (!drv->is_rt_format_supported( + rba->Renderbuffer->TexImage->TexFormat)) + goto err; + } + if (count > 1) + goto err; + + if (fb->Attachment[BUFFER_DEPTH].Type == GL_TEXTURE) { + struct gl_texture_image *ti = + fb->Attachment[BUFFER_DEPTH].Renderbuffer->TexImage; + if (!drv->is_rt_format_supported(ti->TexFormat)) + goto err; + } + + return; +err: + fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT; + return; +} + void nouveau_fbo_functions_init(struct dd_function_table *functions) { @@ -279,4 +316,5 @@ nouveau_fbo_functions_init(struct dd_function_table *functions) functions->FramebufferRenderbuffer = nouveau_framebuffer_renderbuffer; functions->RenderTexture = nouveau_render_texture; functions->FinishRenderTexture = nouveau_finish_render_texture; + functions->ValidateFramebuffer = nouveau_framebuffer_validate; } diff --git a/src/mesa/drivers/dri/nouveau/nv04_context.c b/src/mesa/drivers/dri/nouveau/nv04_context.c index c198c03..665cadd 100644 --- a/src/mesa/drivers/dri/nouveau/nv04_context.c +++ b/src/mesa/drivers/dri/nouveau/nv04_context.c @@ -199,11 +199,25 @@ fail: return NULL; } +static bool +nv04_is_rt_format_supported(gl_format format) +{ + switch (format) { + case MESA_FORMAT_XRGB: + case MESA_FORMAT_ARGB: + case MESA_FORMAT_RGB565: + return true; + default: + return false; + } +} + const struct nouveau_driver nv04_driver = { .context_create = nv04_context_create, .context_destroy = nv04_context_destroy, .surface_copy = nv04_surface_copy, .surface_fill = nv04_surface_fill, + .is_rt_format_supported = nv04_is_rt_format_supported, .emit = (nouveau_state_func[]) { nv04_defer_control, nouveau_emit_nothing, diff --git a/src/mesa/drivers/dri/nouveau/nv10_context.c b/src/mesa/drivers/dri/nouveau/nv10_context.c index 1918f12..9c5cfcb 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_context.c +++ b/src/mesa/drivers/dri/nouveau/nv10_context.c @@ -492,11 +492,27 @@ fail: return NULL; } +static bool +nv10_is_rt_format_supported(gl_format format) +{ + switch (format) { + case MESA_F
Re: [Mesa-dev] [PATCH 07/16] i965/fs: Support coalescing registers of size > 1.
On Thu, Dec 19, 2013 at 1:40 PM, Matt Turner wrote: > total instructions in shared programs: 1550048 -> 1549880 (-0.01%) > instructions in affected programs: 1896 -> 1728 (-8.86%) > --- > src/mesa/drivers/dri/i965/brw_fs.cpp | 80 > ++-- > 1 file changed, 58 insertions(+), 22 deletions(-) > > diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp > b/src/mesa/drivers/dri/i965/brw_fs.cpp > index 1a16f4e..39041e3 100644 > --- a/src/mesa/drivers/dri/i965/brw_fs.cpp > +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp > @@ -2265,6 +2265,12 @@ fs_visitor::register_coalesce() > > calculate_live_intervals(); > > + int src_size = 0; > + int channels_remaining = 0; > + int reg_from = -1, reg_to = -1; > + int reg_to_offset[MAX_SAMPLER_MESSAGE_SIZE]; > + fs_inst *mov[MAX_SAMPLER_MESSAGE_SIZE]; > + > foreach_list_safe(node, &this->instructions) { >fs_inst *inst = (fs_inst *)node; > > @@ -2276,11 +2282,14 @@ fs_visitor::register_coalesce() > inst->src[0].abs || > inst->src[0].smear != -1 || > inst->dst.file != GRF || > - inst->dst.type != inst->src[0].type || > - virtual_grf_sizes[inst->src[0].reg] != 1) { > + inst->dst.type != inst->src[0].type) { > continue; >} > > + if (virtual_grf_sizes[inst->src[0].reg] > > + virtual_grf_sizes[inst->dst.reg]) > + continue; Why isn't this != rather than >? >int var_from = live_intervals->var_from_reg(&inst->src[0]); >int var_to = live_intervals->var_from_reg(&inst->dst); > > @@ -2288,31 +2297,58 @@ fs_visitor::register_coalesce() >!inst->dst.equals(inst->src[0])) > continue; > > - int reg_from = inst->src[0].reg; > - assert(inst->src[0].reg_offset == 0); > - int reg_to = inst->dst.reg; > - int reg_to_offset = inst->dst.reg_offset; > + if (reg_from != inst->src[0].reg) { > + reg_from = inst->src[0].reg; > + > + src_size = virtual_grf_sizes[inst->src[0].reg]; > + assert(src_size <= MAX_SAMPLER_MESSAGE_SIZE); > + > + channels_remaining = src_size; > + memset(mov, 0, sizeof(mov)); > + > + reg_to = inst->dst.reg; > + } > + > + if (reg_to != inst->dst.reg) > + continue; > + > + const int offset = inst->src[0].reg_offset; > + reg_to_offset[offset] = inst->dst.reg_offset; > + mov[offset] = inst; > + channels_remaining--; > + > + if (channels_remaining) > + continue; > + > + for (int i = 0; i < src_size; i++) { > + if (mov[i]) > +mov[i]->remove(); > + } > >foreach_list(node, &this->instructions) { > fs_inst *scan_inst = (fs_inst *)node; > > -if (scan_inst->dst.file == GRF && > -scan_inst->dst.reg == reg_from) { > - scan_inst->dst.reg = reg_to; > - scan_inst->dst.reg_offset = reg_to_offset; > -} > -for (int i = 0; i < 3; i++) { > - if (scan_inst->src[i].file == GRF && > - scan_inst->src[i].reg == reg_from) { > - scan_inst->src[i].reg = reg_to; > - scan_inst->src[i].reg_offset = reg_to_offset; > - } > -} > - } > + for (int i = 0; i < src_size; i++) { > +if (mov[i]) { Shouldn't this always be taken? > + if (scan_inst->dst.file == GRF && > + scan_inst->dst.reg == reg_from && > + scan_inst->dst.reg_offset == i) { > + scan_inst->dst.reg = reg_to; > + scan_inst->dst.reg_offset = reg_to_offset[i]; > + } > + for (int j = 0; j < 3; j++) { > + if (scan_inst->src[j].file == GRF && > + scan_inst->src[j].reg == reg_from && > + scan_inst->src[j].reg_offset == i) { > + scan_inst->src[j].reg = reg_to; > + scan_inst->src[j].reg_offset = reg_to_offset[i]; > + } > + } > > - inst->remove(); > - progress = true; > - continue; > + progress = true; > +} > + } > + } Couldn't we assign progress = true here instead? Ie, outside 2 of the 3 nested for loops. > } > > if (progress) > -- > 1.8.3.2 > > ___ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 12/30] mesa: Change redundant code into loops in texstate.c.
On 01/09/2014 06:19 PM, Paul Berry wrote: > This is possible now that ctx->Shader.CurrentProgram is an array. > --- > src/mesa/main/texstate.c | 75 > +++- > 1 file changed, 29 insertions(+), 46 deletions(-) > > diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c > index b9c76da..905a9d5 100644 > --- a/src/mesa/main/texstate.c > +++ b/src/mesa/main/texstate.c > @@ -526,27 +526,20 @@ static void > update_texture_state( struct gl_context *ctx ) > { > GLuint unit; > - struct gl_program *fprog = NULL; > - struct gl_program *vprog = NULL; > - struct gl_program *gprog = NULL; > + struct gl_program *prog[MESA_SHADER_STAGES]; > GLbitfield enabledFragUnits = 0x0; > - > - if (ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX] && > - ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX]->LinkStatus) { > - vprog = > ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX]->_LinkedShaders[MESA_SHADER_VERTEX]->Program; > - } > - > - if (ctx->Shader.CurrentProgram[MESA_SHADER_GEOMETRY] && > - ctx->Shader.CurrentProgram[MESA_SHADER_GEOMETRY]->LinkStatus) { > - gprog = > ctx->Shader.CurrentProgram[MESA_SHADER_GEOMETRY]->_LinkedShaders[MESA_SHADER_GEOMETRY]->Program; > - } > - > - if (ctx->Shader.CurrentProgram[MESA_SHADER_FRAGMENT] && > - ctx->Shader.CurrentProgram[MESA_SHADER_FRAGMENT]->LinkStatus) { > - fprog = > ctx->Shader.CurrentProgram[MESA_SHADER_FRAGMENT]->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program; > - } > - else if (ctx->FragmentProgram._Enabled) { > - fprog = &ctx->FragmentProgram.Current->Base; > + int i; > + > + for (i = 0; i < MESA_SHADER_STAGES; i++) { > + if (ctx->Shader.CurrentProgram[i] && > + ctx->Shader.CurrentProgram[i]->LinkStatus) { > + prog[i] = ctx->Shader.CurrentProgram[i]->_LinkedShaders[i]->Program; > + } else { > + if (i == MESA_SHADER_FRAGMENT && ctx->FragmentProgram._Enabled) > +prog[i] = &ctx->FragmentProgram.Current->Base; > + else > +prog[i] = NULL; > + } > } > > /* TODO: only set this if there are actual changes */ > @@ -562,9 +555,7 @@ update_texture_state( struct gl_context *ctx ) > */ > for (unit = 0; unit < ctx->Const.MaxCombinedTextureImageUnits; unit++) { >struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; > - GLbitfield enabledVertTargets = 0x0; > - GLbitfield enabledFragTargets = 0x0; > - GLbitfield enabledGeomTargets = 0x0; > + GLbitfield enabledTargetsByStage[MESA_SHADER_STAGES]; >GLbitfield enabledTargets = 0x0; >GLuint texIndex; > > @@ -574,25 +565,16 @@ update_texture_state( struct gl_context *ctx ) > * by a fragment program/program. When multiple flags are set, we'll > * settle on the one with highest priority (see below). > */ > - if (vprog) { > - enabledVertTargets |= vprog->TexturesUsed[unit]; > + for (i = 0; i < MESA_SHADER_STAGES; i++) { > + if (prog[i]) > +enabledTargetsByStage[i] = prog[i]->TexturesUsed[unit]; > + else if (i == MESA_SHADER_FRAGMENT) > +enabledTargetsByStage[i] = texUnit->Enabled; > + else > +enabledTargetsByStage[i] = 0; > + enabledTargets |= enabledTargetsByStage[i]; This doesn't look equivalent. Previously, enabled{Vert,Frag,Geom}Targets would accumulate bits over every iteration through units. Now, enabledTargetsByStage only reflects the most recent unit. enabledTargets still accumulates properly, but you use enabledTargetsByStage below, so I think it needs to as well. You just need to use |= in both places, like the old code. Also, I just want to say - this code is absurdly confusing. Always has been. I don't envy you having to touch it. :) >} > > - if (gprog) { > - enabledGeomTargets |= gprog->TexturesUsed[unit]; > - } > - > - if (fprog) { > - enabledFragTargets |= fprog->TexturesUsed[unit]; > - } > - else { > - /* fixed-function fragment program */ > - enabledFragTargets |= texUnit->Enabled; > - } > - > - enabledTargets = enabledVertTargets | enabledFragTargets | > - enabledGeomTargets; > - >texUnit->_ReallyEnabled = 0x0; > >if (enabledTargets == 0x0) { > @@ -624,7 +606,7 @@ update_texture_state( struct gl_context *ctx ) >} > >if (!texUnit->_ReallyEnabled) { > - if (fprog) { > + if (prog[MESA_SHADER_FRAGMENT]) { > /* If we get here it means the shader is expecting a texture > * object, but there isn't one (or it's incomplete). Use the > * fallback texture. > @@ -654,25 +636,26 @@ update_texture_state( struct gl_context *ctx ) > >ctx->Texture._EnabledUnits |= (1 << unit); > > - if (enabledFragTargets) > + if (enabledTargetsByStage[MESA_SHADER_FRAGMENT]) >
[Mesa-dev] [PATCH] mesa: Set the correct error in _mesa_BeginConditionalRender
From: Ian Romanick Piglit was recently changed to expect the correct error code (piglit commit 271b998), so it started failing on Mesa. This corrects that failing and adds some spec quotations to justify the errrors set. The code was rearranged a little bit to match the order listed in the spec. Signed-off-by: Ian Romanick --- src/mesa/main/condrender.c | 41 ++--- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/src/mesa/main/condrender.c b/src/mesa/main/condrender.c index 2632f7a..0ad1e5c2 100644 --- a/src/mesa/main/condrender.c +++ b/src/mesa/main/condrender.c @@ -40,17 +40,38 @@ void GLAPIENTRY _mesa_BeginConditionalRender(GLuint queryId, GLenum mode) { - struct gl_query_object *q; + struct gl_query_object *q = NULL; GET_CURRENT_CONTEXT(ctx); - if (!ctx->Extensions.NV_conditional_render || ctx->Query.CondRenderQuery || - queryId == 0) { + /* Section 2.14 (Conditional Rendering) of the OpenGL 3.0 spec says: +* +* "If BeginConditionalRender is called while conditional rendering is +* in progress, or if EndConditionalRender is called while conditional +* rendering is not in progress, the error INVALID_OPERATION is +* generated." +*/ + if (!ctx->Extensions.NV_conditional_render || ctx->Query.CondRenderQuery) { _mesa_error(ctx, GL_INVALID_OPERATION, "glBeginConditionalRender()"); return; } ASSERT(ctx->Query.CondRenderMode == GL_NONE); + /* Section 2.14 (Conditional Rendering) of the OpenGL 3.0 spec says: +* +* "The error INVALID_VALUE is generated if is not the name of an +* existing query object query." +*/ + if (queryId != 0) + q = _mesa_lookup_query_object(ctx, queryId); + + if (!q) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glBeginConditionalRender(bad queryId=%u)", queryId); + return; + } + ASSERT(q->Id == queryId); + switch (mode) { case GL_QUERY_WAIT: case GL_QUERY_NO_WAIT: @@ -64,14 +85,12 @@ _mesa_BeginConditionalRender(GLuint queryId, GLenum mode) return; } - q = _mesa_lookup_query_object(ctx, queryId); - if (!q) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glBeginConditionalRender(bad queryId=%u)", queryId); - return; - } - ASSERT(q->Id == queryId); - + /* Section 2.14 (Conditional Rendering) of the OpenGL 3.0 spec says: +* +* "The error INVALID_OPERATION is generated if is the name of a +* query object with a target other than SAMPLES_PASSED, or is the +* name of a query currently in progress." +*/ if ((q->Target != GL_SAMPLES_PASSED && q->Target != GL_ANY_SAMPLES_PASSED && q->Target != GL_ANY_SAMPLES_PASSED_CONSERVATIVE) || q->Active) { -- 1.8.1.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 1/2] loader: refactor duplicated code into loader util lib
On Fri, Jan 10, 2014 at 08:14:19AM -0500, Rob Clark wrote: > On Thu, Jan 9, 2014 at 10:36 PM, Eric Anholt wrote: > > Rob Clark writes: > > > >> From: Rob Clark > >> static int > >> droid_open_device(void) > >> { > >> @@ -773,7 +672,7 @@ dri2_initialize_android(_EGLDriver *drv, _EGLDisplay > >> *dpy) > >>goto cleanup_display; > >> } > > > > forgot loader_set_logger here. Do we want to just move that to > > egl_dri2.c instead of each platform_*? > > fwiw, default logger (if you don't call loader_set_logger()) is just > printf. So in theory the ones that don't call loader_set_logger() > either had no logging before or were just using printf. Hmm.. but > that probably shouldn't be the case for the 'droid loader, so maybe I > screwed that up. FYI, in Android, the logging system uses the Android logging library, which emits its output to a shared system log. If you log anything with printf in Android, it does to /dev/null. So, the Android loader is likely broken now, but I don't have the resources to test it either. +Adria and Juha, who work on Android and may want to check this series. > (disclaimer: the android loader in particular, I have no idea how to > build/test.. so this one probably is the most likely one that I would > have screwed up :-P) ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 07/16] i965/fs: Support coalescing registers of size > 1.
On Fri, Jan 10, 2014 at 11:12 AM, Jordan Justen wrote: > On Thu, Dec 19, 2013 at 1:40 PM, Matt Turner wrote: >> total instructions in shared programs: 1550048 -> 1549880 (-0.01%) >> instructions in affected programs: 1896 -> 1728 (-8.86%) >> --- >> src/mesa/drivers/dri/i965/brw_fs.cpp | 80 >> ++-- >> 1 file changed, 58 insertions(+), 22 deletions(-) >> >> diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp >> b/src/mesa/drivers/dri/i965/brw_fs.cpp >> index 1a16f4e..39041e3 100644 >> --- a/src/mesa/drivers/dri/i965/brw_fs.cpp >> +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp >> @@ -2265,6 +2265,12 @@ fs_visitor::register_coalesce() >> >> calculate_live_intervals(); >> >> + int src_size = 0; >> + int channels_remaining = 0; >> + int reg_from = -1, reg_to = -1; >> + int reg_to_offset[MAX_SAMPLER_MESSAGE_SIZE]; >> + fs_inst *mov[MAX_SAMPLER_MESSAGE_SIZE]; >> + >> foreach_list_safe(node, &this->instructions) { >>fs_inst *inst = (fs_inst *)node; >> >> @@ -2276,11 +2282,14 @@ fs_visitor::register_coalesce() >> inst->src[0].abs || >> inst->src[0].smear != -1 || >> inst->dst.file != GRF || >> - inst->dst.type != inst->src[0].type || >> - virtual_grf_sizes[inst->src[0].reg] != 1) { >> + inst->dst.type != inst->src[0].type) { >> continue; >>} >> >> + if (virtual_grf_sizes[inst->src[0].reg] > >> + virtual_grf_sizes[inst->dst.reg]) >> + continue; > > Why isn't this != rather than >? > >>int var_from = live_intervals->var_from_reg(&inst->src[0]); >>int var_to = live_intervals->var_from_reg(&inst->dst); >> >> @@ -2288,31 +2297,58 @@ fs_visitor::register_coalesce() >>!inst->dst.equals(inst->src[0])) >> continue; >> >> - int reg_from = inst->src[0].reg; >> - assert(inst->src[0].reg_offset == 0); >> - int reg_to = inst->dst.reg; >> - int reg_to_offset = inst->dst.reg_offset; >> + if (reg_from != inst->src[0].reg) { >> + reg_from = inst->src[0].reg; >> + >> + src_size = virtual_grf_sizes[inst->src[0].reg]; >> + assert(src_size <= MAX_SAMPLER_MESSAGE_SIZE); >> + >> + channels_remaining = src_size; >> + memset(mov, 0, sizeof(mov)); >> + >> + reg_to = inst->dst.reg; >> + } >> + >> + if (reg_to != inst->dst.reg) >> + continue; >> + >> + const int offset = inst->src[0].reg_offset; >> + reg_to_offset[offset] = inst->dst.reg_offset; >> + mov[offset] = inst; >> + channels_remaining--; >> + >> + if (channels_remaining) >> + continue; >> + >> + for (int i = 0; i < src_size; i++) { >> + if (mov[i]) >> +mov[i]->remove(); >> + } >> >>foreach_list(node, &this->instructions) { >> fs_inst *scan_inst = (fs_inst *)node; >> >> -if (scan_inst->dst.file == GRF && >> -scan_inst->dst.reg == reg_from) { >> - scan_inst->dst.reg = reg_to; >> - scan_inst->dst.reg_offset = reg_to_offset; >> -} >> -for (int i = 0; i < 3; i++) { >> - if (scan_inst->src[i].file == GRF && >> - scan_inst->src[i].reg == reg_from) { >> - scan_inst->src[i].reg = reg_to; >> - scan_inst->src[i].reg_offset = reg_to_offset; >> - } >> -} >> - } >> + for (int i = 0; i < src_size; i++) { >> +if (mov[i]) { > > Shouldn't this always be taken? The next patch seems to invalidate this question. >> + if (scan_inst->dst.file == GRF && >> + scan_inst->dst.reg == reg_from && >> + scan_inst->dst.reg_offset == i) { >> + scan_inst->dst.reg = reg_to; >> + scan_inst->dst.reg_offset = reg_to_offset[i]; >> + } >> + for (int j = 0; j < 3; j++) { >> + if (scan_inst->src[j].file == GRF && >> + scan_inst->src[j].reg == reg_from && >> + scan_inst->src[j].reg_offset == i) { >> + scan_inst->src[j].reg = reg_to; >> + scan_inst->src[j].reg_offset = reg_to_offset[i]; >> + } >> + } >> >> - inst->remove(); >> - progress = true; >> - continue; >> + progress = true; >> +} >> + } >> + } > > Couldn't we assign progress = true here instead? Ie, outside 2 of the > 3 nested for loops. The next patch seems to invalidate this question too. >> } >> >> if (progress) >> -- >> 1.8.3.2 >> >> ___ >> mesa-dev mailing list >> mesa-dev@lists.freedesktop.org >> http://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] mesa: fix GL_COLOR_SUM enum for drivers without ARB_vertex_program
Commit c13970808 (mesa: GL_EXT_secondary_color is not optional) changed CHECK_EXTENSION2(EXT_secondary_color, ARB_vetex_program, cap) to CHECK_EXTENSION(ARB_vertex_program, cap) However CHECK_EXTENSION2 checks that either extension is available, not both. Remove the extension check entirely since the intent was for it to always be enabled. Signed-off-by: Ilia Mirkin Cc: 9.2 10.0 --- Someone mentioned that nouveau (dri) was getting errors with glDisable(GL_COLOR_SUM), even though the driver should have had support for it. src/mesa/main/enable.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c index bb4a23c..fca3068 100644 --- a/src/mesa/main/enable.c +++ b/src/mesa/main/enable.c @@ -762,7 +762,6 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) case GL_COLOR_SUM_EXT: if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; - CHECK_EXTENSION(ARB_vertex_program, cap); if (ctx->Fog.ColorSumEnabled == state) return; FLUSH_VERTICES(ctx, _NEW_FOG); @@ -1443,7 +1442,6 @@ _mesa_IsEnabled( GLenum cap ) case GL_COLOR_SUM_EXT: if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; - CHECK_EXTENSION(ARB_vertex_program); return ctx->Fog.ColorSumEnabled; /* GL_ARB_multisample */ -- 1.8.3.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] mesa: Set the correct error in _mesa_BeginConditionalRender
Reviewed-by: Matt Turner ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 03/10] i965: Create a helper function for emitting PIPE_CONTROL flushes.
On 01/08/2014 04:27 PM, Chris Forbes wrote: >> + OUT_BATCH(0); >> + ADVANCE_BATCH(); >> + } else { >> + BEGIN_BATCH(4); >> + OUT_BATCH(_3DSTATE_PIPE_CONTROL | flags | (4 - 2)); > > If the PRM is to believed, then ILK has two of its flag bits in dw1 > [Stall at scoreboard, and the nonfunctional depth cache flush > inhibit]; it looks as if we never try to actually use stall at > scoreboard pre-Gen6 though, so this works. > > > Patches 1-3 are > > Reviewed-by: Chris Forbes Oh yeah...I don't think we ever use those bits on ILK. Not sure whether the PRM is to be believed or not. It's probably right. Suggestions? I could try to add defines for those flags and make it actually work, but...kind of loathe to do that. I could also add a comment saying that it's technically wrong for ILK... --Ken ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 03/10] i965: Create a helper function for emitting PIPE_CONTROL flushes.
On 01/09/2014 07:52 PM, Eric Anholt wrote: > Kenneth Graunke writes: > >> These days, we need to emit PIPE_CONTROL flushes all over the place. >> Being able to do that via a single function call seems convenient. >> >> Broadwell will also increase the length of these packets by 1; with the >> refactoring, we should have to do this in substantially fewer places. >> >> Signed-off-by: Kenneth Graunke > >> diff --git a/src/mesa/drivers/dri/i965/intel_batchbuffer.c >> b/src/mesa/drivers/dri/i965/intel_batchbuffer.c >> index d9b6c15..d2f0e90 100644 >> --- a/src/mesa/drivers/dri/i965/intel_batchbuffer.c >> +++ b/src/mesa/drivers/dri/i965/intel_batchbuffer.c >> @@ -475,6 +475,32 @@ emit: >> } >> >> /** >> + * Emit a PIPE_CONTROL with various flushing flags. >> + * >> + * The caller is responsible for deciding what flags are appropriate for the >> + * given generation. >> + */ >> +void >> +brw_emit_pipe_control_flush(struct brw_context *brw, uint32_t flags) >> +{ >> + if (brw->gen >= 6) { >> + BEGIN_BATCH(4); >> + OUT_BATCH(_3DSTATE_PIPE_CONTROL | (4 - 2)); >> + OUT_BATCH(flags); >> + OUT_BATCH(0); >> + OUT_BATCH(0); >> + ADVANCE_BATCH(); >> + } else { >> + BEGIN_BATCH(4); >> + OUT_BATCH(_3DSTATE_PIPE_CONTROL | flags | (4 - 2)); >> + OUT_BATCH(0); >> + OUT_BATCH(0); >> + OUT_BATCH(0); >> + ADVANCE_BATCH(); >> + } >> +} >> + >> +/** >> * Restriction [DevSNB, DevIVB]: >> * >> * Prior to changing Depth/Stencil Buffer state (i.e. any combination of >> @@ -491,26 +517,9 @@ intel_emit_depth_stall_flushes(struct brw_context *brw) >> { >> assert(brw->gen >= 6 && brw->gen <= 7); >> >> - BEGIN_BATCH(4); >> - OUT_BATCH(_3DSTATE_PIPE_CONTROL | (4 - 2)); >> - OUT_BATCH(PIPE_CONTROL_DEPTH_STALL); >> - OUT_BATCH(0); /* address */ >> - OUT_BATCH(0); /* write data */ >> - ADVANCE_BATCH() >> - >> - BEGIN_BATCH(4); >> - OUT_BATCH(_3DSTATE_PIPE_CONTROL | (4 - 2)); >> - OUT_BATCH(PIPE_CONTROL_DEPTH_CACHE_FLUSH); >> - OUT_BATCH(0); /* address */ >> - OUT_BATCH(0); /* write data */ >> - ADVANCE_BATCH(); >> - >> - BEGIN_BATCH(4); >> - OUT_BATCH(_3DSTATE_PIPE_CONTROL | (4 - 2)); >> - OUT_BATCH(PIPE_CONTROL_DEPTH_STALL); >> - OUT_BATCH(0); /* address */ >> - OUT_BATCH(0); /* write data */ >> - ADVANCE_BATCH(); >> + brw_emit_pipe_control_flush(brw, PIPE_CONTROL_DEPTH_STALL); >> + brw_emit_pipe_control_flush(brw, PIPE_CONTROL_DEPTH_CACHE_FLUSH); >> + brw_emit_pipe_control_flush(brw, PIPE_CONTROL_DEPTH_STALL); >> } >> >> /** >> @@ -608,13 +617,8 @@ intel_emit_post_sync_nonzero_flush(struct brw_context >> *brw) >> if (!brw->batch.need_workaround_flush) >>return; >> >> - BEGIN_BATCH(4); >> - OUT_BATCH(_3DSTATE_PIPE_CONTROL | (4 - 2)); >> - OUT_BATCH(PIPE_CONTROL_CS_STALL | >> - PIPE_CONTROL_STALL_AT_SCOREBOARD); >> - OUT_BATCH(0); /* address */ >> - OUT_BATCH(0); /* write data */ >> - ADVANCE_BATCH(); >> + brw_emit_pipe_control_flush(brw, PIPE_CONTROL_CS_STALL | >> + PIPE_CONTROL_STALL_AT_SCOREBOARD); >> >> BEGIN_BATCH(4); >> OUT_BATCH(_3DSTATE_PIPE_CONTROL | (4 - 2)); >> @@ -636,46 +640,22 @@ intel_emit_post_sync_nonzero_flush(struct brw_context >> *brw) >> void >> intel_batchbuffer_emit_mi_flush(struct brw_context *brw) >> { >> - if (brw->gen >= 6) { >> - if (brw->batch.ring == BLT_RING) { >> - BEGIN_BATCH_BLT(4); >> - OUT_BATCH(MI_FLUSH_DW); >> - OUT_BATCH(0); >> - OUT_BATCH(0); >> - OUT_BATCH(0); >> - ADVANCE_BATCH(); >> - } else { >> - if (brw->gen == 6) { >> -/* Hardware workaround: SNB B-Spec says: >> - * >> - * [Dev-SNB{W/A}]: Before a PIPE_CONTROL with Write Cache >> - * Flush Enable =1, a PIPE_CONTROL with any non-zero >> - * post-sync-op is required. >> - */ >> -intel_emit_post_sync_nonzero_flush(brw); >> - } >> - >> - BEGIN_BATCH(4); >> - OUT_BATCH(_3DSTATE_PIPE_CONTROL | (4 - 2)); >> - OUT_BATCH(PIPE_CONTROL_INSTRUCTION_FLUSH | >> - PIPE_CONTROL_WRITE_FLUSH | >> - PIPE_CONTROL_DEPTH_CACHE_FLUSH | >> - PIPE_CONTROL_VF_CACHE_INVALIDATE | >> - PIPE_CONTROL_TC_FLUSH | >> - PIPE_CONTROL_NO_WRITE | >> - PIPE_CONTROL_CS_STALL); >> - OUT_BATCH(0); /* write address */ >> - OUT_BATCH(0); /* write data */ >> - ADVANCE_BATCH(); >> - } >> - } else { >> - BEGIN_BATCH(4); >> - OUT_BATCH(_3DSTATE_PIPE_CONTROL | (4 - 2) | >> -PIPE_CONTROL_WRITE_FLUSH | >> -PIPE_CONTROL_NO_WRITE); >> - OUT_BATCH(0); /* write address */ >> - OUT_BATCH(0); /* write data */ >> - OUT_BATCH(0); /* write data */ >> + if (unlikely(brw->batch.ring == BLT_RING) && brw->gen >= 6) { >> + BEGIN_BATCH_BLT(4); >> + OUT_BATCH(MI_FLUSH_DW); >> + OUT_BATCH(0); >> + OUT_BATCH(0); >> +
Re: [Mesa-dev] [PATCH 07/16] i965/fs: Support coalescing registers of size > 1.
On Fri, Jan 10, 2014 at 11:12 AM, Jordan Justen wrote: > On Thu, Dec 19, 2013 at 1:40 PM, Matt Turner wrote: >> total instructions in shared programs: 1550048 -> 1549880 (-0.01%) >> instructions in affected programs: 1896 -> 1728 (-8.86%) >> --- >> src/mesa/drivers/dri/i965/brw_fs.cpp | 80 >> ++-- >> 1 file changed, 58 insertions(+), 22 deletions(-) >> >> diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp >> b/src/mesa/drivers/dri/i965/brw_fs.cpp >> index 1a16f4e..39041e3 100644 >> --- a/src/mesa/drivers/dri/i965/brw_fs.cpp >> +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp >> @@ -2265,6 +2265,12 @@ fs_visitor::register_coalesce() >> >> calculate_live_intervals(); >> >> + int src_size = 0; >> + int channels_remaining = 0; >> + int reg_from = -1, reg_to = -1; >> + int reg_to_offset[MAX_SAMPLER_MESSAGE_SIZE]; >> + fs_inst *mov[MAX_SAMPLER_MESSAGE_SIZE]; >> + >> foreach_list_safe(node, &this->instructions) { >>fs_inst *inst = (fs_inst *)node; >> >> @@ -2276,11 +2282,14 @@ fs_visitor::register_coalesce() >> inst->src[0].abs || >> inst->src[0].smear != -1 || >> inst->dst.file != GRF || >> - inst->dst.type != inst->src[0].type || >> - virtual_grf_sizes[inst->src[0].reg] != 1) { >> + inst->dst.type != inst->src[0].type) { >> continue; >>} >> >> + if (virtual_grf_sizes[inst->src[0].reg] > >> + virtual_grf_sizes[inst->dst.reg]) >> + continue; > > Why isn't this != rather than >? Because coalescing a size=1 register into part of a size>1 is okay. >>int var_from = live_intervals->var_from_reg(&inst->src[0]); >>int var_to = live_intervals->var_from_reg(&inst->dst); >> >> @@ -2288,31 +2297,58 @@ fs_visitor::register_coalesce() >>!inst->dst.equals(inst->src[0])) >> continue; >> >> - int reg_from = inst->src[0].reg; >> - assert(inst->src[0].reg_offset == 0); >> - int reg_to = inst->dst.reg; >> - int reg_to_offset = inst->dst.reg_offset; >> + if (reg_from != inst->src[0].reg) { >> + reg_from = inst->src[0].reg; >> + >> + src_size = virtual_grf_sizes[inst->src[0].reg]; >> + assert(src_size <= MAX_SAMPLER_MESSAGE_SIZE); >> + >> + channels_remaining = src_size; >> + memset(mov, 0, sizeof(mov)); >> + >> + reg_to = inst->dst.reg; >> + } >> + >> + if (reg_to != inst->dst.reg) >> + continue; >> + >> + const int offset = inst->src[0].reg_offset; >> + reg_to_offset[offset] = inst->dst.reg_offset; >> + mov[offset] = inst; >> + channels_remaining--; >> + >> + if (channels_remaining) >> + continue; >> + >> + for (int i = 0; i < src_size; i++) { >> + if (mov[i]) >> +mov[i]->remove(); >> + } >> >>foreach_list(node, &this->instructions) { >> fs_inst *scan_inst = (fs_inst *)node; >> >> -if (scan_inst->dst.file == GRF && >> -scan_inst->dst.reg == reg_from) { >> - scan_inst->dst.reg = reg_to; >> - scan_inst->dst.reg_offset = reg_to_offset; >> -} >> -for (int i = 0; i < 3; i++) { >> - if (scan_inst->src[i].file == GRF && >> - scan_inst->src[i].reg == reg_from) { >> - scan_inst->src[i].reg = reg_to; >> - scan_inst->src[i].reg_offset = reg_to_offset; >> - } >> -} >> - } >> + for (int i = 0; i < src_size; i++) { >> +if (mov[i]) { > > Shouldn't this always be taken? > >> + if (scan_inst->dst.file == GRF && >> + scan_inst->dst.reg == reg_from && >> + scan_inst->dst.reg_offset == i) { >> + scan_inst->dst.reg = reg_to; >> + scan_inst->dst.reg_offset = reg_to_offset[i]; >> + } >> + for (int j = 0; j < 3; j++) { >> + if (scan_inst->src[j].file == GRF && >> + scan_inst->src[j].reg == reg_from && >> + scan_inst->src[j].reg_offset == i) { >> + scan_inst->src[j].reg = reg_to; >> + scan_inst->src[j].reg_offset = reg_to_offset[i]; >> + } >> + } >> >> - inst->remove(); >> - progress = true; >> - continue; >> + progress = true; >> +} >> + } >> + } > > Couldn't we assign progress = true here instead? Ie, outside 2 of the > 3 nested for loops. I think made this patch a little more confusing that necessary so that the next one was much easier to follow. At least, I'm pretty sure. :) ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 12/30] mesa: Change redundant code into loops in texstate.c.
On 10 January 2014 11:41, Kenneth Graunke wrote: > On 01/09/2014 06:19 PM, Paul Berry wrote: > > This is possible now that ctx->Shader.CurrentProgram is an array. > > --- > > src/mesa/main/texstate.c | 75 > +++- > > 1 file changed, 29 insertions(+), 46 deletions(-) > > > > diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c > > index b9c76da..905a9d5 100644 > > --- a/src/mesa/main/texstate.c > > +++ b/src/mesa/main/texstate.c > > @@ -526,27 +526,20 @@ static void > > update_texture_state( struct gl_context *ctx ) > > { > > GLuint unit; > > - struct gl_program *fprog = NULL; > > - struct gl_program *vprog = NULL; > > - struct gl_program *gprog = NULL; > > + struct gl_program *prog[MESA_SHADER_STAGES]; > > GLbitfield enabledFragUnits = 0x0; > > - > > - if (ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX] && > > - ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX]->LinkStatus) { > > - vprog = > ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX]->_LinkedShaders[MESA_SHADER_VERTEX]->Program; > > - } > > - > > - if (ctx->Shader.CurrentProgram[MESA_SHADER_GEOMETRY] && > > - ctx->Shader.CurrentProgram[MESA_SHADER_GEOMETRY]->LinkStatus) { > > - gprog = > ctx->Shader.CurrentProgram[MESA_SHADER_GEOMETRY]->_LinkedShaders[MESA_SHADER_GEOMETRY]->Program; > > - } > > - > > - if (ctx->Shader.CurrentProgram[MESA_SHADER_FRAGMENT] && > > - ctx->Shader.CurrentProgram[MESA_SHADER_FRAGMENT]->LinkStatus) { > > - fprog = > ctx->Shader.CurrentProgram[MESA_SHADER_FRAGMENT]->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program; > > - } > > - else if (ctx->FragmentProgram._Enabled) { > > - fprog = &ctx->FragmentProgram.Current->Base; > > + int i; > > + > > + for (i = 0; i < MESA_SHADER_STAGES; i++) { > > + if (ctx->Shader.CurrentProgram[i] && > > + ctx->Shader.CurrentProgram[i]->LinkStatus) { > > + prog[i] = > ctx->Shader.CurrentProgram[i]->_LinkedShaders[i]->Program; > > + } else { > > + if (i == MESA_SHADER_FRAGMENT && ctx->FragmentProgram._Enabled) > > +prog[i] = &ctx->FragmentProgram.Current->Base; > > + else > > +prog[i] = NULL; > > + } > > } > > > > /* TODO: only set this if there are actual changes */ > > @@ -562,9 +555,7 @@ update_texture_state( struct gl_context *ctx ) > > */ > > for (unit = 0; unit < ctx->Const.MaxCombinedTextureImageUnits; > unit++) { > >struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; > > - GLbitfield enabledVertTargets = 0x0; > > - GLbitfield enabledFragTargets = 0x0; > > - GLbitfield enabledGeomTargets = 0x0; > > + GLbitfield enabledTargetsByStage[MESA_SHADER_STAGES]; > >GLbitfield enabledTargets = 0x0; > >GLuint texIndex; > > > > @@ -574,25 +565,16 @@ update_texture_state( struct gl_context *ctx ) > > * by a fragment program/program. When multiple flags are set, > we'll > > * settle on the one with highest priority (see below). > > */ > > - if (vprog) { > > - enabledVertTargets |= vprog->TexturesUsed[unit]; > > + for (i = 0; i < MESA_SHADER_STAGES; i++) { > > + if (prog[i]) > > +enabledTargetsByStage[i] = prog[i]->TexturesUsed[unit]; > > + else if (i == MESA_SHADER_FRAGMENT) > > +enabledTargetsByStage[i] = texUnit->Enabled; > > + else > > +enabledTargetsByStage[i] = 0; > > + enabledTargets |= enabledTargetsByStage[i]; > > This doesn't look equivalent. Previously, > enabled{Vert,Frag,Geom}Targets would accumulate bits over every > iteration through units. Now, enabledTargetsByStage only reflects the > most recent unit. > > enabledTargets still accumulates properly, but you use > enabledTargetsByStage below, so I think it needs to as well. > > You just need to use |= in both places, like the old code. > It's definitely possible that I got something wrong in this patch--I didn't completely grok what the code was doing and instead strived to just preserve the existing semantics. But I'm pretty sure I got the enabledTargetsByStage part right. Here's what the code used to look like--the enabled{Vert,Frag,Geom}Targets variables were all reset to 0 every time through the loop: for (unit = 0; unit < ctx->Const.MaxCombinedTextureImageUnits; unit++) { struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; GLbitfield enabledVertTargets = 0x0; GLbitfield enabledFragTargets = 0x0; GLbitfield enabledGeomTargets = 0x0; GLbitfield enabledTargets = 0x0; GLuint texIndex; /* Get the bitmask of texture target enables. * enableBits will be a mask of the TEXTURE_*_BIT flags indicating * which texture targets are enabled (fixed function) or referenced * by a fragment program/program. When multiple flags are set, we'll * settle on the one with highest priority (see below).
Re: [Mesa-dev] [PATCH 09/16] i965/fs: Calculate interference better in register_coalesce.
On Wed, Dec 25, 2013 at 2:11 AM, Pohjolainen, Topi wrote: > On Thu, Dec 19, 2013 at 01:40:23PM -0800, Matt Turner wrote: >> Previously we simply considered two registers whose live ranges >> overlapped to interfere. Cases such as >> >>set A -- >>... | >>mov B, A --| >>... | B | A >>use B --| >>... | >>use A -- >> >> would be considered to interfere, even though B is an unmodified copy of >> A whose live range fit wholly inside that of A. >> >> If no writes to A or B occur between the mov B, A and the use of B then >> we can safely coalesce them. >> >> Instead of removing MOV instructions, we make them NOPs and remove them >> at once after the main pass is finished in order to avoid recomputing >> live intervals (which are needed to perform the previous step). >> >> total instructions in shared programs: 1543768 -> 1513077 (-1.99%) >> instructions in affected programs: 951563 -> 920872 (-3.23%) >> GAINED:46 >> LOST: 22 >> --- >> src/mesa/drivers/dri/i965/brw_fs.cpp | 69 >> >> 1 file changed, 62 insertions(+), 7 deletions(-) >> >> diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp >> b/src/mesa/drivers/dri/i965/brw_fs.cpp >> index e4ac0a5..ad56b87 100644 >> --- a/src/mesa/drivers/dri/i965/brw_fs.cpp >> +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp >> @@ -2273,7 +2273,7 @@ fs_visitor::register_coalesce() >> int last_use[MAX_SAMPLER_MESSAGE_SIZE]; >> int next_ip = 0; >> >> - foreach_list_safe(node, &this->instructions) { >> + foreach_list(node, &this->instructions) { >>fs_inst *inst = (fs_inst *)node; >> >>int ip = next_ip; >> @@ -2299,8 +2299,39 @@ fs_visitor::register_coalesce() >>int var_to = live_intervals->var_from_reg(&inst->dst); >> >>if (live_intervals->vars_interfere(var_from, var_to) && >> - !inst->dst.equals(inst->src[0])) >> - continue; >> + !inst->dst.equals(inst->src[0])) { >> + >> + if (live_intervals->end[var_to] > live_intervals->end[var_from]) >> +continue; > > Just checking if I understood things correctly and trying to fill in the caps > that I cannot figure out myself: Is the check for the start implicit from > somewhere else? This has to apply as well, right? > > if (live_intervals->start[var_to] < > live_intervals->start[var_from]) >continue; We know that the live ranges of (A) var_from and (B) var_to interfere because of the ->vars_interfere() call above. If the end of B's live range is after the end of A's range, then we know two things: - the start of B's live range must be in A's live range (since we already know the two ranges interfere, this is the only remaining possibility) - the interference isn't of the form we're looking for (where B is entirely inside A) That's pretty tricky and it took me a while to recreate what I was thinking when I wrote the code, so let me know if this makes sense to you. :) I think I'll put an explanatory comment there for good measure. >> + >> + bool overwritten = false; >> + int scan_ip = -1; >> + >> + foreach_list(n, &this->instructions) { >> + fs_inst *scan_inst = (fs_inst *)n; >> +scan_ip++; >> + >> +if (scan_inst->is_control_flow()) { >> + overwritten = true; >> + break; >> +} > > Instructions are scanned from the very beginning of the program, and hence we > are also scanning for instructions that correspond to control flow changes > (i.e., jumps) before either of the start of live intervals of 'var_to' and > 'var_from' (in fact if I'm not mistakan above, this should read "before live > interval of 'var_from'"). > > And if any such instruction is found the consideration for any coalescing is > dropped. Isn't it enough to scan for control flow changes only after the start > of the live interval of 'var_from'? (It has been a while since I've been > thinking any of this sort of things and I'm easily missing things. But had to > ask.) I'm not sure because of DO instructions that mark the beginning of a loop -- if our live ranges are in a loop we probably need to think some more about how we can coalesce registers.. I think we can improve this later though, because I've seen a lot of shaders with loops that contain MOVs that could be removed if register coalescing were a bit smarter. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 05/10] i965: Use Global GTT for Sandybridge post-sync non-zero workaround.
On 01/09/2014 10:03 PM, Eric Anholt wrote: > Eric Anholt writes: > >> Kenneth Graunke writes: >> >>> The kernel doesn't even set up the aliasing PPGTT on Sandybridge, so any >>> writes marked as PPGTT will likely just get dropped on the floor. >> >> The hardware bug is that writes not marked as GTT are still looked up in >> the GTT anyway. >> >> The kernel does set up the PPGTT, which is how we found we needed to put >> in the kernel workaround based on DOMAIN_INSTRUCTION (of binding the >> target buffer to the gtt as well as the ppgtt, since the writes landed >> in the wrong place) >> >> I don't think this patch will change anything, but it seems reasonable >> if the commit message is updated. > > Actually, thinking about it more, I'd rather not explicitly use global > GTT, unless the function is also renamed to > gen6_emit_post_sync_nonzero_workaround, since now this function on > non-gen6 would reference GTT memory in its instruction, but the kernel > wouldn't put anything in the GTT. > > (I'd rather just leave the workaround as is, myself). Okay, sounds like this is unnecessary. But...the next patch (helper function for writes) causes this to use PIPE_CONTROL_GLOBAL_GTT_WRITE on SNB only, and PPGTT on Gen7+. Part of the rationale for this patch was to change the SNB-specific behavior as a separate bisectable commit from the refactor. But I guess this patch does it universally, which is a bit different. I'm fine with dropping this patch. Is that what you'd like? ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 1/2] st/mesa: simplify shader limit initialization code
On Thu, Jan 9, 2014 at 8:21 PM, Brian Paul wrote: > Make use of the new gl_constants::Program[] array. > --- > src/mesa/state_tracker/st_extensions.c | 31 > > src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 20 +- > src/mesa/state_tracker/st_program.h| 18 > 3 files changed, 28 insertions(+), 41 deletions(-) > > diff --git a/src/mesa/state_tracker/st_extensions.c > b/src/mesa/state_tracker/st_extensions.c > index c17601a..cc63b36 100644 > --- a/src/mesa/state_tracker/st_extensions.c > +++ b/src/mesa/state_tracker/st_extensions.c > @@ -38,6 +38,8 @@ > #include "st_context.h" > #include "st_extensions.h" > #include "st_format.h" > +#include "st_program.h" > + > > static unsigned _min(unsigned a, unsigned b) > { > @@ -68,8 +70,8 @@ void st_init_limits(struct st_context *st) > { > struct pipe_screen *screen = st->pipe->screen; > struct gl_constants *c = &st->ctx->Const; > - unsigned sh; > boolean can_ubo = TRUE; > + int i; > > c->MaxTextureLevels >= _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS), > @@ -149,27 +151,12 @@ void st_init_limits(struct st_context *st) >can_ubo = FALSE; > } > > - for (sh = 0; sh < PIPE_SHADER_TYPES; ++sh) { > - struct gl_shader_compiler_options *options; > - struct gl_program_constants *pc; > - > - switch (sh) { > - case PIPE_SHADER_FRAGMENT: > - pc = &c->Program[MESA_SHADER_FRAGMENT]; > - options = &st->ctx->ShaderCompilerOptions[MESA_SHADER_FRAGMENT]; > - break; > - case PIPE_SHADER_VERTEX: > - pc = &c->Program[MESA_SHADER_VERTEX]; > - options = &st->ctx->ShaderCompilerOptions[MESA_SHADER_VERTEX]; > - break; > - case PIPE_SHADER_GEOMETRY: > - pc = &c->Program[MESA_SHADER_GEOMETRY]; > - options = &st->ctx->ShaderCompilerOptions[MESA_SHADER_GEOMETRY]; > - break; > - default: > - /* compute shader, etc. */ > - continue; > - } > + /* Note: we only loop over the currently supported gallium shader types */ > + for (i = MESA_SHADER_VERTEX; i <= MESA_SHADER_FRAGMENT; i++) { The MESA_SHADER_xxx numbers are ordered in the same way they appear in the pipeline, so tessellation shaders will be before MESA_SHADER_FRAGMENT. In other words, the comment in the code is not true and st_shader_stage_to_ptarget should be more robust to handle unsupported shader types. Marek ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 13/16] i965/fs: Add a saturation propagation optimization pass.
On Thu, Dec 26, 2013 at 5:54 AM, Pohjolainen, Topi wrote: > On Thu, Dec 19, 2013 at 01:40:27PM -0800, Matt Turner wrote: >> Transforms, for example, >> >> mul vgrf3, vgrf2, vgrf1 >> mov.sat vgrf4, vgrf3 >> >> into >> >> mul.sat vgrf3, vgrf2, vgrf1 >> mov vgrf4, vgrf3 >> >> which gives register_coalescing an opportunity to remove the MOV >> instruction. >> >> total instructions in shared programs: 1512588 -> 1501297 (-0.75%) >> instructions in affected programs: 723097 -> 711806 (-1.56%) >> GAINED:0 >> LOST: 4 >> --- >> src/mesa/drivers/dri/i965/Makefile.sources | 1 + >> src/mesa/drivers/dri/i965/brw_fs.cpp | 1 + >> src/mesa/drivers/dri/i965/brw_fs.h | 1 + >> .../dri/i965/brw_fs_saturate_propagation.cpp | 102 >> + >> 4 files changed, 105 insertions(+) >> create mode 100644 src/mesa/drivers/dri/i965/brw_fs_saturate_propagation.cpp >> >> diff --git a/src/mesa/drivers/dri/i965/Makefile.sources >> b/src/mesa/drivers/dri/i965/Makefile.sources >> index 36d8261..3f901da 100644 >> --- a/src/mesa/drivers/dri/i965/Makefile.sources >> +++ b/src/mesa/drivers/dri/i965/Makefile.sources >> @@ -62,6 +62,7 @@ i965_FILES = \ >> brw_fs_live_variables.cpp \ >> brw_fs_peephole_predicated_break.cpp \ >> brw_fs_reg_allocate.cpp \ >> + brw_fs_saturate_propagation.cpp \ >> brw_fs_sel_peephole.cpp \ >> brw_fs_value_numbering.cpp \ >> brw_fs_vector_splitting.cpp \ >> diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp >> b/src/mesa/drivers/dri/i965/brw_fs.cpp >> index 08837da..12b6d4a 100644 >> --- a/src/mesa/drivers/dri/i965/brw_fs.cpp >> +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp >> @@ -3304,6 +3304,7 @@ fs_visitor::run() >> progress = opt_peephole_sel() || progress; >> progress = dead_control_flow_eliminate(this) || progress; >> vn_progress = opt_value_numbering(); >> + progress = opt_saturate_propagation() || progress; >> progress = register_coalesce() || progress; >>progress = compute_to_mrf() || progress; >> >> diff --git a/src/mesa/drivers/dri/i965/brw_fs.h >> b/src/mesa/drivers/dri/i965/brw_fs.h >> index 75de18e..07360ae 100644 >> --- a/src/mesa/drivers/dri/i965/brw_fs.h >> +++ b/src/mesa/drivers/dri/i965/brw_fs.h >> @@ -368,6 +368,7 @@ public: >> void try_replace_with_sel(); >> bool opt_peephole_sel(); >> bool opt_peephole_predicated_break(); >> + bool opt_saturate_propagation(); >> void emit_bool_to_cond_code(ir_rvalue *condition); >> void emit_if_gen6(ir_if *ir); >> void emit_unspill(fs_inst *inst, fs_reg reg, uint32_t spill_offset, >> diff --git a/src/mesa/drivers/dri/i965/brw_fs_saturate_propagation.cpp >> b/src/mesa/drivers/dri/i965/brw_fs_saturate_propagation.cpp >> new file mode 100644 >> index 000..91a1338 >> --- /dev/null >> +++ b/src/mesa/drivers/dri/i965/brw_fs_saturate_propagation.cpp >> @@ -0,0 +1,102 @@ >> +/* >> + * Copyright © 2013 Intel Corporation >> + * >> + * Permission is hereby granted, free of charge, to any person obtaining a >> + * copy of this software and associated documentation files (the >> "Software"), >> + * to deal in the Software without restriction, including without limitation >> + * the rights to use, copy, modify, merge, publish, distribute, sublicense, >> + * and/or sell copies of the Software, and to permit persons to whom the >> + * Software is furnished to do so, subject to the following conditions: >> + * >> + * The above copyright notice and this permission notice (including the next >> + * paragraph) shall be included in all copies or substantial portions of the >> + * Software. >> + * >> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS >> OR >> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, >> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL >> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR >> OTHER >> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING >> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER >> DEALINGS >> + * IN THE SOFTWARE. >> + */ >> + >> +#include "brw_fs.h" >> +#include "brw_fs_live_variables.h" >> +#include "brw_cfg.h" >> + >> +/** @file brw_fs_saturate_propagation.cpp >> + */ >> + >> +static bool >> +opt_saturate_propagation_local(fs_visitor *v, bblock_t *block) >> +{ >> + bool progress = false; >> + int ip = block->start_ip; >> + >> + for (fs_inst *inst = (fs_inst *)block->start; >> +inst != block->end->next; >> +inst = (fs_inst *) inst->next) { >> + ip++; >> + >> + if (inst->opcode != BRW_OPCODE_MOV || >> + inst->dst.file != GRF || >> + !inst->saturate) >> + continue; >> + >> + int src_var = v->live_intervals->var_from_reg(&inst->src[0]); >> + int src_en
Re: [Mesa-dev] [PATCH 2/2] st/mesa: remove _min(), _maxf(), _clamp()
I guess we should make MIN2 and friends inline functions to prevent evaluating its parameters multiple times. For example, MIN2(get_param(), Y) calls get_param() twice. It's not very important in this case though. Reviewed-by: Marek Olšák Marek On Thu, Jan 9, 2014 at 8:21 PM, Brian Paul wrote: > Just use the existing MIN2, MAX2 and CLAMP macros. > --- > src/mesa/state_tracker/st_extensions.c | 80 > ++-- > 1 file changed, 34 insertions(+), 46 deletions(-) > > diff --git a/src/mesa/state_tracker/st_extensions.c > b/src/mesa/state_tracker/st_extensions.c > index cc63b36..faf0e77 100644 > --- a/src/mesa/state_tracker/st_extensions.c > +++ b/src/mesa/state_tracker/st_extensions.c > @@ -41,26 +41,6 @@ > #include "st_program.h" > > > -static unsigned _min(unsigned a, unsigned b) > -{ > - return (a < b) ? a : b; > -} > - > -static float _maxf(float a, float b) > -{ > - return (a > b) ? a : b; > -} > - > -static int _clamp(int a, int min, int max) > -{ > - if (a < min) > - return min; > - else if (a > max) > - return max; > - else > - return a; > -} > - > > /** > * Query driver to get implementation limits. > @@ -74,25 +54,25 @@ void st_init_limits(struct st_context *st) > int i; > > c->MaxTextureLevels > - = _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS), > + = MIN2(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS), > MAX_TEXTURE_LEVELS); > > c->Max3DTextureLevels > - = _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_3D_LEVELS), > + = MIN2(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_3D_LEVELS), > MAX_3D_TEXTURE_LEVELS); > > c->MaxCubeTextureLevels > - = _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS), > + = MIN2(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS), > MAX_CUBE_TEXTURE_LEVELS); > > c->MaxTextureRectSize > - = _min(1 << (c->MaxTextureLevels - 1), MAX_TEXTURE_RECT_SIZE); > + = MIN2(1 << (c->MaxTextureLevels - 1), MAX_TEXTURE_RECT_SIZE); > > c->MaxArrayTextureLayers >= screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS); > > c->MaxCombinedTextureImageUnits > - = _min(screen->get_param(screen, PIPE_CAP_MAX_COMBINED_SAMPLERS), > + = MIN2(screen->get_param(screen, PIPE_CAP_MAX_COMBINED_SAMPLERS), > MAX_COMBINED_TEXTURE_IMAGE_UNITS); > > /* Define max viewport size and max renderbuffer size in terms of > @@ -104,26 +84,27 @@ void st_init_limits(struct st_context *st) > c->MaxRenderbufferSize = c->MaxTextureRectSize; > > c->MaxDrawBuffers = c->MaxColorAttachments = > - _clamp(screen->get_param(screen, PIPE_CAP_MAX_RENDER_TARGETS), > + CLAMP(screen->get_param(screen, PIPE_CAP_MAX_RENDER_TARGETS), > 1, MAX_DRAW_BUFFERS); > > - c->MaxDualSourceDrawBuffers > - = _clamp(screen->get_param(screen, > PIPE_CAP_MAX_DUAL_SOURCE_RENDER_TARGETS), > - 0, MAX_DRAW_BUFFERS); > + c->MaxDualSourceDrawBuffers = > + CLAMP(screen->get_param(screen, > + PIPE_CAP_MAX_DUAL_SOURCE_RENDER_TARGETS), > +0, MAX_DRAW_BUFFERS); > > c->MaxLineWidth > - = _maxf(1.0f, screen->get_paramf(screen, > - PIPE_CAPF_MAX_LINE_WIDTH)); > + = MAX2(1.0f, screen->get_paramf(screen, > + PIPE_CAPF_MAX_LINE_WIDTH)); > c->MaxLineWidthAA > - = _maxf(1.0f, screen->get_paramf(screen, > - PIPE_CAPF_MAX_LINE_WIDTH_AA)); > + = MAX2(1.0f, screen->get_paramf(screen, > + PIPE_CAPF_MAX_LINE_WIDTH_AA)); > > c->MaxPointSize > - = _maxf(1.0f, screen->get_paramf(screen, > - PIPE_CAPF_MAX_POINT_WIDTH)); > + = MAX2(1.0f, screen->get_paramf(screen, > + PIPE_CAPF_MAX_POINT_WIDTH)); > c->MaxPointSizeAA > - = _maxf(1.0f, screen->get_paramf(screen, > - PIPE_CAPF_MAX_POINT_WIDTH_AA)); > + = MAX2(1.0f, screen->get_paramf(screen, > + PIPE_CAPF_MAX_POINT_WIDTH_AA)); > /* called after _mesa_create_context/_mesa_init_point, fix default user > * settable max point size up > */ > @@ -135,7 +116,7 @@ void st_init_limits(struct st_context *st) > c->MinPointSizeAA = 0.0f; > > c->MaxTextureMaxAnisotropy > - = _maxf(2.0f, screen->get_paramf(screen, > + = MAX2(2.0f, screen->get_paramf(screen, > PIPE_CAPF_MAX_TEXTURE_ANISOTROPY)); > > c->MaxTextureLodBias > @@ -159,7 +140,7 @@ void st_init_limits(struct st_context *st) >struct gl_program_constants *pc = &c->Program[i]; > >pc->MaxTextureImageUnits = > - _min(screen->get_shader_param(screen, sh, > + MIN2(screen->get_shader_par
Re: [Mesa-dev] [PATCH 1/2] st/mesa: simplify shader limit initialization code
On 01/10/2014 03:50 PM, Marek Olšák wrote: On Thu, Jan 9, 2014 at 8:21 PM, Brian Paul wrote: Make use of the new gl_constants::Program[] array. --- src/mesa/state_tracker/st_extensions.c | 31 src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 20 +- src/mesa/state_tracker/st_program.h| 18 3 files changed, 28 insertions(+), 41 deletions(-) diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c index c17601a..cc63b36 100644 --- a/src/mesa/state_tracker/st_extensions.c +++ b/src/mesa/state_tracker/st_extensions.c @@ -38,6 +38,8 @@ #include "st_context.h" #include "st_extensions.h" #include "st_format.h" +#include "st_program.h" + static unsigned _min(unsigned a, unsigned b) { @@ -68,8 +70,8 @@ void st_init_limits(struct st_context *st) { struct pipe_screen *screen = st->pipe->screen; struct gl_constants *c = &st->ctx->Const; - unsigned sh; boolean can_ubo = TRUE; + int i; c->MaxTextureLevels = _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS), @@ -149,27 +151,12 @@ void st_init_limits(struct st_context *st) can_ubo = FALSE; } - for (sh = 0; sh < PIPE_SHADER_TYPES; ++sh) { - struct gl_shader_compiler_options *options; - struct gl_program_constants *pc; - - switch (sh) { - case PIPE_SHADER_FRAGMENT: - pc = &c->Program[MESA_SHADER_FRAGMENT]; - options = &st->ctx->ShaderCompilerOptions[MESA_SHADER_FRAGMENT]; - break; - case PIPE_SHADER_VERTEX: - pc = &c->Program[MESA_SHADER_VERTEX]; - options = &st->ctx->ShaderCompilerOptions[MESA_SHADER_VERTEX]; - break; - case PIPE_SHADER_GEOMETRY: - pc = &c->Program[MESA_SHADER_GEOMETRY]; - options = &st->ctx->ShaderCompilerOptions[MESA_SHADER_GEOMETRY]; - break; - default: - /* compute shader, etc. */ - continue; - } + /* Note: we only loop over the currently supported gallium shader types */ + for (i = MESA_SHADER_VERTEX; i <= MESA_SHADER_FRAGMENT; i++) { The MESA_SHADER_xxx numbers are ordered in the same way they appear in the pipeline, so tessellation shaders will be before MESA_SHADER_FRAGMENT. In other words, the comment in the code is not true and st_shader_stage_to_ptarget should be more robust to handle unsupported shader types. Ah, I was thinking tessellation shaders came before the vertex shader, but they don't. I'll respin this someday. -Brian ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 2/2] st/mesa: remove _min(), _maxf(), _clamp()
On 01/10/2014 03:59 PM, Marek Olšák wrote: I guess we should make MIN2 and friends inline functions to prevent evaluating its parameters multiple times. But MIN2, MAX2, etc. are used for uint, int and float. For example, MIN2(get_param(), Y) calls get_param() twice. It's not very important in this case though. Hmm, I didn't even think of that. I'm tempted to leave it as-is now and simply add a comment about why the inline funcs are used instead of the macros. -Brian ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 08/10] i965: Introduce an OUT_RELOC64 macro.
On 01/09/2014 09:31 PM, Eric Anholt wrote: > Kenneth Graunke writes: > >> On 12/13/2013 09:28 AM, Daniel Vetter wrote: >>> On Thu, Dec 12, 2013 at 01:26:40AM -0800, Kenneth Graunke wrote: Broadwell uses 48-bit addresses. The first DWord is the low 32 bits, and the second DWord is the high 16 bits. Since individual buffers shouldn't be larger than 4GB in size, any offsets into those buffers (buffer->offset + delta) should fit in the low 32 bits. So I believe we can simply emit 0 for the high 16-bits, and drm_intel_bo_emit_reloc() should patch it up. Signed-off-by: Kenneth Graunke --- src/mesa/drivers/dri/i965/intel_batchbuffer.h | 5 + 1 file changed, 5 insertions(+) diff --git a/src/mesa/drivers/dri/i965/intel_batchbuffer.h b/src/mesa/drivers/dri/i965/intel_batchbuffer.h index 159f928..128eed9 100644 --- a/src/mesa/drivers/dri/i965/intel_batchbuffer.h +++ b/src/mesa/drivers/dri/i965/intel_batchbuffer.h @@ -178,6 +178,11 @@ void intel_batchbuffer_cached_advance(struct brw_context *brw); read_domains, write_domain, delta); \ } while (0) +/* Handle 48-bit address relocations for Gen8+ */ +#define OUT_RELOC64(buf, read_domains, write_domain, delta) \ + OUT_RELOC(buf, read_domains, write_domain, delta); \ + OUT_BATCH(0); >>> >>> Please not. The presumed_offset that libdrm uses is 64bits, and you need >>> to emit the full presumed address (and correctly shifted). Atm the kernel >>> never gives you a presumed reloc offset with the high bits set so it >>> doesn't matter. But I'd prefer if we don't need to make this opt-in >>> behaviour once we enable address spaces with more than 4G. >>> >>> i-g-t gets away with the cheap hack since we're allowed to break igt. >>> Let me check ddx and libva whether I've lost this fight already ... >>> -Daniel >> >> I'm more than happy to do the right thing, I just don't know what that >> is. I don't see any uint64_t values in the interface we use at all: >> >> OUT_RELOC becomes >>ret = drm_intel_bo_emit_reloc(brw->batch.bo, 4*brw->batch.used, >> buffer, delta, >> read_domains, write_domain); > > The libdrm ABI is a disaster. bo->offset is a long, so we're keeping 32 > bits of the kernel's returned value on 32 bit userspace, and 64 bits on > 64 bit userspace. This means that on 32-bit we'll write in an > expected-incorrect offset in the presumed offset for a >4g-located BO, > which the kernel will map and fix up at exec time. On 64-bit, your > patch would write an expected-incorrect 32-bit value into the batch, but > libdrm would tell the kernel the full expected 64 bit value in the > presumed_offset field, and you'll get brokenness for >4g buffers. > > So, I think you do need a drm_intel_bo_emit_reloc64 that returns a > uint64_t value that the kernel wrote into the presumed offset, which you > then plug into your batchbuffer. > > (In other news, while thinking about this, there are some obscure races > with buffer migration due to presumed_offset being read at a separate > time from when we look up bo->offset to actually write the offset into > the batch, in the presence of context sharing in GL). I'd really like to land this patch as-is, since I need it to land the rest of my Broadwell code. I would update the commit message to note that it's broken for >4G currently. Then, I could write the new libdrm API and send out a separate series which fixes OUT_RELOC64 to work for >4G. Keep in mind that Mesa doesn't actually advertise Broadwell support (i.e. recognize the PCI IDs) yet. This would need to be fixed before we actually turn it on. --Ken ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 4/5] glsl: Vectorize multiple scalar assignments
On Thu, Jan 9, 2014 at 11:28 AM, Ian Romanick wrote: > On 01/08/2014 12:43 PM, Matt Turner wrote: >> +/** >> + * \file opt_vectorize.cpp >> + * >> + * Combines scalar assignments of the same expression (modulo swizzle) to >> + * multiple channels of the same variable into a single vectorized >> expression >> + * and assignment. >> + * >> + * Many generated shaders contain scalarized code. That is, they contain >> + * >> + * r1.x = log2(v0.x); >> + * r1.y = log2(v0.y); >> + * r1.z = log2(v0.z); >> + * >> + * rather than >> + * >> + * r1.xyz = log2(v0.xyz); >> + * >> + * We look for consecutive assignments of the same expression (modulo >> swizzle) >> + * to each channel of the same variable. >> + * >> + * For instance, we want to convert these three scalar operations >> + * >> + * (assign (x) (var_ref r1) (expression float log2 (swiz x (var_ref v0 >> + * (assign (y) (var_ref r1) (expression float log2 (swiz y (var_ref v0 >> + * (assign (z) (var_ref r1) (expression float log2 (swiz z (var_ref v0 >> + * >> + * into a single vector operation >> + * >> + * (assign (xyz) (var_ref r1) (expression vec3 log2 (swiz xyz (var_ref >> v0 > > I think it's worth adding a note that this pass only attempts to combine > assignments that are sequential. That comment block already says that: + * We look for consecutive assignments of the same expression (modulo swizzle) + * to each channel of the same variable. I'll change the first comment to use the word consecutive. > The above example gets fully > vectorized, but this sequence would not: > > (assign (x) (var_ref r1) (expression float log2 (swiz x (var_ref v0 > (assign (x) (var_ref r2) (expression float log2 (swiz y (var_ref v0 > (assign (y) (var_ref r1) (expression float log2 (swiz z (var_ref v0 > (assign (y) (var_ref r2) (expression float log2 (swiz w (var_ref v0 > > I think this will also break on code like > > (assign (x) (var_ref r1) (expression float log2 (swiz w (var_ref r1 > (assign (y) (var_ref r1) (expression float log2 (swiz z (var_ref r1 > # r1.xy have different values now. > (assign (z) (var_ref r1) (expression float log2 (swiz y (var_ref r1 > (assign (w) (var_ref r1) (expression float log2 (swiz x (var_ref r1 > > Maybe just skip assignments where the LHS also appears in the RHS for > now? Or does the check write_mask_matches_swizzle take care of this? It won't break because the code rejects expressions that contain swizzles that don't match the LHS's write mask. See the call to write_mask_matches_swizzle(). The good thing about this is that we can combine expressions that use the LHS, like (assign (x) (var_ref r1) (expression float log2 (swiz x (var_ref r1 (assign (y) (var_ref r1) (expression float log2 (swiz y (var_ref r1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 07/16] i965/fs: Support coalescing registers of size > 1.
Patches 7 & 8 Reviewed-by: Jordan Justen On Fri, Jan 10, 2014 at 1:41 PM, Matt Turner wrote: > On Fri, Jan 10, 2014 at 11:12 AM, Jordan Justen wrote: >> On Thu, Dec 19, 2013 at 1:40 PM, Matt Turner wrote: >>> total instructions in shared programs: 1550048 -> 1549880 (-0.01%) >>> instructions in affected programs: 1896 -> 1728 (-8.86%) >>> --- >>> src/mesa/drivers/dri/i965/brw_fs.cpp | 80 >>> ++-- >>> 1 file changed, 58 insertions(+), 22 deletions(-) >>> >>> diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp >>> b/src/mesa/drivers/dri/i965/brw_fs.cpp >>> index 1a16f4e..39041e3 100644 >>> --- a/src/mesa/drivers/dri/i965/brw_fs.cpp >>> +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp >>> @@ -2265,6 +2265,12 @@ fs_visitor::register_coalesce() >>> >>> calculate_live_intervals(); >>> >>> + int src_size = 0; >>> + int channels_remaining = 0; >>> + int reg_from = -1, reg_to = -1; >>> + int reg_to_offset[MAX_SAMPLER_MESSAGE_SIZE]; >>> + fs_inst *mov[MAX_SAMPLER_MESSAGE_SIZE]; >>> + >>> foreach_list_safe(node, &this->instructions) { >>>fs_inst *inst = (fs_inst *)node; >>> >>> @@ -2276,11 +2282,14 @@ fs_visitor::register_coalesce() >>> inst->src[0].abs || >>> inst->src[0].smear != -1 || >>> inst->dst.file != GRF || >>> - inst->dst.type != inst->src[0].type || >>> - virtual_grf_sizes[inst->src[0].reg] != 1) { >>> + inst->dst.type != inst->src[0].type) { >>> continue; >>>} >>> >>> + if (virtual_grf_sizes[inst->src[0].reg] > >>> + virtual_grf_sizes[inst->dst.reg]) >>> + continue; >> >> Why isn't this != rather than >? > > Because coalescing a size=1 register into part of a size>1 is okay. > >>>int var_from = live_intervals->var_from_reg(&inst->src[0]); >>>int var_to = live_intervals->var_from_reg(&inst->dst); >>> >>> @@ -2288,31 +2297,58 @@ fs_visitor::register_coalesce() >>>!inst->dst.equals(inst->src[0])) >>> continue; >>> >>> - int reg_from = inst->src[0].reg; >>> - assert(inst->src[0].reg_offset == 0); >>> - int reg_to = inst->dst.reg; >>> - int reg_to_offset = inst->dst.reg_offset; >>> + if (reg_from != inst->src[0].reg) { >>> + reg_from = inst->src[0].reg; >>> + >>> + src_size = virtual_grf_sizes[inst->src[0].reg]; >>> + assert(src_size <= MAX_SAMPLER_MESSAGE_SIZE); >>> + >>> + channels_remaining = src_size; >>> + memset(mov, 0, sizeof(mov)); >>> + >>> + reg_to = inst->dst.reg; >>> + } >>> + >>> + if (reg_to != inst->dst.reg) >>> + continue; >>> + >>> + const int offset = inst->src[0].reg_offset; >>> + reg_to_offset[offset] = inst->dst.reg_offset; >>> + mov[offset] = inst; >>> + channels_remaining--; >>> + >>> + if (channels_remaining) >>> + continue; >>> + >>> + for (int i = 0; i < src_size; i++) { >>> + if (mov[i]) >>> +mov[i]->remove(); >>> + } >>> >>>foreach_list(node, &this->instructions) { >>> fs_inst *scan_inst = (fs_inst *)node; >>> >>> -if (scan_inst->dst.file == GRF && >>> -scan_inst->dst.reg == reg_from) { >>> - scan_inst->dst.reg = reg_to; >>> - scan_inst->dst.reg_offset = reg_to_offset; >>> -} >>> -for (int i = 0; i < 3; i++) { >>> - if (scan_inst->src[i].file == GRF && >>> - scan_inst->src[i].reg == reg_from) { >>> - scan_inst->src[i].reg = reg_to; >>> - scan_inst->src[i].reg_offset = reg_to_offset; >>> - } >>> -} >>> - } >>> + for (int i = 0; i < src_size; i++) { >>> +if (mov[i]) { >> >> Shouldn't this always be taken? >> >>> + if (scan_inst->dst.file == GRF && >>> + scan_inst->dst.reg == reg_from && >>> + scan_inst->dst.reg_offset == i) { >>> + scan_inst->dst.reg = reg_to; >>> + scan_inst->dst.reg_offset = reg_to_offset[i]; >>> + } >>> + for (int j = 0; j < 3; j++) { >>> + if (scan_inst->src[j].file == GRF && >>> + scan_inst->src[j].reg == reg_from && >>> + scan_inst->src[j].reg_offset == i) { >>> + scan_inst->src[j].reg = reg_to; >>> + scan_inst->src[j].reg_offset = reg_to_offset[i]; >>> + } >>> + } >>> >>> - inst->remove(); >>> - progress = true; >>> - continue; >>> + progress = true; >>> +} >>> + } >>> + } >> >> Couldn't we assign progress = true here instead? Ie, outside 2 of the >> 3 nested for loops. > > I think made this patch a little more confusing that necessary so that > the next one was much easier to follow. At least, I'm pretty sure. :) ___ mesa-
[Mesa-dev] [PATCH 0/3 v2] More valgrind fixes
v2: Dropped r200 patch Moved gfx/dma cleanup to r600_common_context_cleanup Fixed comment style in one of the patches Aaron Watry (3): radeon: Move gfx/dma cs cleanup to r600_common_context_cleanup st/dri: prevent leak of dri option default values mesa/main: Free ctx->DrawIndirectBuffer during teardown src/gallium/drivers/r600/r600_pipe.c | 7 --- src/gallium/drivers/radeon/r600_pipe_common.c | 7 +++ src/gallium/state_trackers/dri/common/dri_screen.c | 6 ++ src/mesa/main/bufferobj.c | 2 ++ 4 files changed, 15 insertions(+), 7 deletions(-) ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 3/3] mesa/main: Free ctx->DrawIndirectBuffer during teardown
ctx->DrawIndirectBuffer wasn't being free'd in _mesa_free_buffer_objects With this patch, "valgrind --leak-check=full glxgears" on evergreen (CEDAR) now shows: LEAK SUMMARY: definitely lost: 0 bytes in 0 blocks indirectly lost: 0 bytes in 0 blocks possibly lost: 0 bytes in 0 blocks still reachable: 70,228 bytes in 651 blocks suppressed: 0 bytes in 0 blocks CC: "10.0" Reviewed-by: Brian Paul Reviewed-by: Marek Olšák --- src/mesa/main/bufferobj.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index a3d8f24..9336759 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -871,6 +871,8 @@ _mesa_free_buffer_objects( struct gl_context *ctx ) _mesa_reference_buffer_object(ctx, &ctx->UniformBuffer, NULL); + _mesa_reference_buffer_object(ctx, &ctx->DrawIndirectBuffer, NULL); + for (i = 0; i < MAX_COMBINED_UNIFORM_BUFFERS; i++) { _mesa_reference_buffer_object(ctx, &ctx->UniformBufferBindings[i].BufferObject, -- 1.8.3.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/3] radeon: Move gfx/dma cs cleanup to r600_common_context_cleanup
The radeonsi code was not cleaning up either of these items leading to leaked memory. v2: Move cleanup to r600_common_context_cleanup instead of duplicating the logic for SI CC: "10.0" --- src/gallium/drivers/r600/r600_pipe.c | 7 --- src/gallium/drivers/radeon/r600_pipe_common.c | 7 +++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/gallium/drivers/r600/r600_pipe.c b/src/gallium/drivers/r600/r600_pipe.c index 74e007b..e7d5862 100644 --- a/src/gallium/drivers/r600/r600_pipe.c +++ b/src/gallium/drivers/r600/r600_pipe.c @@ -185,13 +185,6 @@ static void r600_destroy_context(struct pipe_context *context) r600_release_command_buffer(&rctx->start_cs_cmd); - if (rctx->b.rings.gfx.cs) { - rctx->b.ws->cs_destroy(rctx->b.rings.gfx.cs); - } - if (rctx->b.rings.dma.cs) { - rctx->b.ws->cs_destroy(rctx->b.rings.dma.cs); - } - FREE(rctx->start_compute_cs_cmd.buf); r600_common_context_cleanup(&rctx->b); diff --git a/src/gallium/drivers/radeon/r600_pipe_common.c b/src/gallium/drivers/radeon/r600_pipe_common.c index 28921be..07bf383 100644 --- a/src/gallium/drivers/radeon/r600_pipe_common.c +++ b/src/gallium/drivers/radeon/r600_pipe_common.c @@ -250,6 +250,13 @@ bool r600_common_context_init(struct r600_common_context *rctx, void r600_common_context_cleanup(struct r600_common_context *rctx) { + if (rctx->rings.gfx.cs) { + rctx->ws->cs_destroy(rctx->rings.gfx.cs); + } + if (rctx->rings.dma.cs) { + rctx->ws->cs_destroy(rctx->rings.dma.cs); + } + if (rctx->uploader) { u_upload_destroy(rctx->uploader); } -- 1.8.3.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/3] st/dri: prevent leak of dri option default values
v2: Change comment style CC: "10.0" Reviewed-by: Marek Olšák --- src/gallium/state_trackers/dri/common/dri_screen.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/src/gallium/state_trackers/dri/common/dri_screen.c b/src/gallium/state_trackers/dri/common/dri_screen.c index 7410dbe..b338f64 100644 --- a/src/gallium/state_trackers/dri/common/dri_screen.c +++ b/src/gallium/state_trackers/dri/common/dri_screen.c @@ -360,6 +360,12 @@ dri_destroy_option_cache(struct dri_screen * screen) } free(screen->optionCache.values); + + /* Default values are copied to screen->optionCache->values in +* initOptionCache. The info field, however, is a pointer copy, so don't free +* that twice. +*/ + free(screen->optionCacheDefaults.values); } void -- 1.8.3.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] Plans for 10.0.3 release
On Thu, Jan 9, 2014 at 3:07 PM, Carl Worth wrote: > Hi folks, > > I just released Mesa 10.0.2 (a bit late) and followed it by immediately > working through my queue of commits nominated for the stable branch, > which I've just pushed out. > > Since the code for 10.0.2 was done and pushed a week ago, my current > plan is to release 10.0.2 just one week from now, (to get back to a > schedule of a stable release every two weeks). > > The state of the queue looks pretty good right now. There are still a > handful of patches from early December that have not landed on master > yet. I imagine he's waiting for review on those. > > Then, there are two recent, larger series from Aaron and Chad. For each > of these series, there has been some discussion and both authors are > planning to come back with a version 2 of their series in response to > review. I just sent v2 of my series to mesa-dev a few minutes ago (dropping one of them from v2). 2 of the 3 have prior reviewed-by tags, so hopefully I can commit the series in the next few days (depending on how many people work or indulge their hobby over the weekend). --Aaron > > I do want to say that I really enjoy how smooth that stable-release > management has been. That's thanks to all of the developers doing such > high-quality work. I've not yet encountered a nominated patch that I > needed to reject due to a regression or a patch which failed to meet the > release-branch criteria. So thanks to all for your attention to > detail. I really appreciate it. > > -Carl > > -- > carl.d.wo...@intel.com ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 09/16] i965/fs: Calculate interference better in register_coalesce.
On Thu, Dec 19, 2013 at 1:40 PM, Matt Turner wrote: > Previously we simply considered two registers whose live ranges > overlapped to interfere. Cases such as > >set A -- >... | >mov B, A --| >... | B | A >use B --| >... | >use A -- > > would be considered to interfere, even though B is an unmodified copy of > A whose live range fit wholly inside that of A. > > If no writes to A or B occur between the mov B, A and the use of B then > we can safely coalesce them. > > Instead of removing MOV instructions, we make them NOPs and remove them > at once after the main pass is finished in order to avoid recomputing > live intervals (which are needed to perform the previous step). > > total instructions in shared programs: 1543768 -> 1513077 (-1.99%) > instructions in affected programs: 951563 -> 920872 (-3.23%) > GAINED:46 > LOST: 22 > --- > src/mesa/drivers/dri/i965/brw_fs.cpp | 69 > > 1 file changed, 62 insertions(+), 7 deletions(-) > > diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp > b/src/mesa/drivers/dri/i965/brw_fs.cpp > index e4ac0a5..ad56b87 100644 > --- a/src/mesa/drivers/dri/i965/brw_fs.cpp > +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp > @@ -2273,7 +2273,7 @@ fs_visitor::register_coalesce() > int last_use[MAX_SAMPLER_MESSAGE_SIZE]; > int next_ip = 0; > > - foreach_list_safe(node, &this->instructions) { > + foreach_list(node, &this->instructions) { >fs_inst *inst = (fs_inst *)node; > >int ip = next_ip; > @@ -2299,8 +2299,39 @@ fs_visitor::register_coalesce() >int var_to = live_intervals->var_from_reg(&inst->dst); > >if (live_intervals->vars_interfere(var_from, var_to) && > - !inst->dst.equals(inst->src[0])) > - continue; > + !inst->dst.equals(inst->src[0])) { > + > + if (live_intervals->end[var_to] > live_intervals->end[var_from]) > +continue; > + > + bool overwritten = false; > + int scan_ip = -1; > + > + foreach_list(n, &this->instructions) { > + fs_inst *scan_inst = (fs_inst *)n; > +scan_ip++; > + > +if (scan_inst->is_control_flow()) { > + overwritten = true; > + break; > +} > + > +if (scan_ip <= live_intervals->start[var_to]) > + continue; > + > +if (scan_ip > live_intervals->end[var_to]) > + break; > + > +if (scan_inst->dst.equals(inst->dst) || > +scan_inst->dst.equals(inst->src[0])) { > + overwritten = true; > + break; > +} > + } > + > + if (overwritten) > +continue; > + } > >if (reg_from != inst->src[0].reg) { > reg_from = inst->src[0].reg; > @@ -2342,9 +2373,18 @@ fs_visitor::register_coalesce() >if (live_channels_remaining) > continue; > > + bool removed = false; >for (int i = 0; i < src_size; i++) { > - if (mov[i]) > -mov[i]->remove(); > + if (mov[i]) { > +removed = true; > + > +mov[i]->opcode = BRW_OPCODE_NOP; > +mov[i]->conditional_mod = BRW_CONDITIONAL_NONE; Is conditional_mod == BRW_CONDITIONAL_NONE something we should look for before considering coalescing a mov? > +mov[i]->dst = reg_undef; > +mov[i]->src[0] = reg_undef; > +mov[i]->src[1] = reg_undef; > +mov[i]->src[2] = reg_undef; > + } >} > >foreach_list(node, &this->instructions) { > @@ -2366,11 +2406,26 @@ fs_visitor::register_coalesce() > scan_inst->src[j].reg_offset = reg_to_offset[i]; >} > } > - > - progress = true; > } > } >} > + > + if (removed) { > + live_intervals->start[var_to] = MIN2(live_intervals->start[var_to], > + > live_intervals->start[var_from]); > + live_intervals->end[var_to] = MAX2(live_intervals->end[var_to], > +live_intervals->end[var_from]); > + reg_from = -1; Do you think these are what lead to the lost programs? I haven't been able to determine why they are needed starting with this patch... -Jordan > + } > + } > + > + foreach_list_safe(node, &this->instructions) { > + fs_inst *inst = (fs_inst *)node; > + > + if (inst->opcode == BRW_OPCODE_NOP) { > + inst->remove(); > + progress = true; > + } > } > > if (progress) > -- > 1.8.3.2 > > ___ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/mesa-dev _
Re: [Mesa-dev] [PATCH] i965: Use sample barycentric coordinates with per sample shading
On Thu, Jan 9, 2014 at 4:34 PM, Chris Forbes wrote: > Hi Anuj, > > There's one fiddly interaction that I don't think this handles quite > right, although I think it does conform. > > Suppose we have this fragment shader: > >#version 330 >#extension ARB_gpu_shader5: require > >sample in vec4 a; >in vec4 b; > >... > > Then `b` is being evaluated at the sample position as well. This is > allowed by my reading of the spec, but probably not what the author > expected. Good catch. > > From the ARB_gpu_shader5 spec, emphasis mine: > > (11) Should we support per-sample interpolation of attributes? If so, > how? > > RESOLVED. Yes. When multisample rasterization is enabled, qualifying > one or more fragment shader inputs with "sample" will force per-sample > interpolation of those attributes. If the same shader includes other > fragment inputs not qualified with sample, those attributes _may_ be > interpolated per-pixel (i.e., all samples get the same values, likely > evaluated at the pixel center). > > What do you think? I agree with your interpretation. Spec seems to be flexible about it. I'll check what NVIDIA does in this case. This should be easy to fix if we need to. > > -- Chris ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 07/40] mesa: Add new constants related to GL_ARB_viewport_array
From: Ian Romanick These limits will be queryable by GL_MAX_VIEWPORTS, GL_VIEWPORT_SUBPIXEL_BITS, and GL_VIEWPORT_BOUNDS_RANGE. Drivers that actually implement the extension must set values for these constants that comply with the minimum-maximums from the spec. Most of these changes were part of other patches. They were separated out because it make reordering of later patches easier. Also, MaxViewports wasn't set by that patch, and I completely overlooked it in review. It's now obvious that it's set. :) v2 (idr): Split these changes out from the original patches. Keep MaxViewportWidth and MaxViewportHeight as GLuint. Signed-off-by: Ian Romanick --- src/mesa/main/config.h | 3 +++ src/mesa/main/context.c | 6 ++ src/mesa/main/mtypes.h | 6 ++ 3 files changed, 15 insertions(+) diff --git a/src/mesa/main/config.h b/src/mesa/main/config.h index 22bbfa0..a6401f7 100644 --- a/src/mesa/main/config.h +++ b/src/mesa/main/config.h @@ -137,6 +137,9 @@ #define MAX_VIEWPORT_WIDTH 16384 #define MAX_VIEWPORT_HEIGHT 16384 +/** Maximun number of viewports supported with ARB_viewport_array */ +#define MAX_VIEWPORTS 16 + /** Maxmimum size for CVA. May be overridden by the drivers. */ #define MAX_ARRAY_LOCK_SIZE 3000 diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 0b8fb94..538322e 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -588,6 +588,12 @@ _mesa_init_constants(struct gl_context *ctx) ctx->Const.MaxViewportWidth = MAX_VIEWPORT_WIDTH; ctx->Const.MaxViewportHeight = MAX_VIEWPORT_HEIGHT; + /* Driver must override these values if ARB_viewport_array is supported. */ + ctx->Const.MaxViewports = 1; + ctx->Const.ViewportSubpixelBits = 0; + ctx->Const.ViewportBounds.Min = 0; + ctx->Const.ViewportBounds.Max = 0; + /** GL_ARB_uniform_buffer_object */ ctx->Const.MaxCombinedUniformBlocks = 36; ctx->Const.MaxUniformBufferBindings = 36; diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index c4bb099..6e2f6f7 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -3133,6 +3133,12 @@ struct gl_constants GLfloat MaxSpotExponent; /**< GL_NV_light_max_exponent */ GLuint MaxViewportWidth, MaxViewportHeight; + GLuint MaxViewports; /**< GL_ARB_viewport_array */ + GLuint ViewportSubpixelBits; /**< GL_ARB_viewport_array */ + struct { + GLfloat Min; + GLfloat Max; + } ViewportBounds; /**< GL_ARB_viewport_array */ struct gl_program_constants Program[MESA_SHADER_STAGES]; GLuint MaxProgramMatrices; -- 1.8.1.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 35/40] i965: Consider all scissor rectangles in noop_scissor
From: Ian Romanick v2: Use '& 1' instead of '& i'. Noticed by Ken. Signed-off-by: Ian Romanick --- src/mesa/drivers/dri/i965/brw_clear.c | 14 ++ 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_clear.c b/src/mesa/drivers/dri/i965/brw_clear.c index 58fd612..19bde0f 100644 --- a/src/mesa/drivers/dri/i965/brw_clear.c +++ b/src/mesa/drivers/dri/i965/brw_clear.c @@ -83,10 +83,16 @@ debug_mask(const char *name, GLbitfield mask) static bool noop_scissor(struct gl_context *ctx, struct gl_framebuffer *fb) { - return ctx->Scissor.ScissorArray[0].X <= 0 && - ctx->Scissor.ScissorArray[0].Y <= 0 && - ctx->Scissor.ScissorArray[0].Width >= fb->Width && - ctx->Scissor.ScissorArray[0].Height >= fb->Height; + for (unsigned i = 0; i < ctx->Const.MaxViewports; i++) { + if (((ctx->Scissor.EnableFlags >> i) & 1) && + (ctx->Scissor.ScissorArray[i].X > 0 || + ctx->Scissor.ScissorArray[i].Y > 0 || + ctx->Scissor.ScissorArray[i].Width < fb->Width || + ctx->Scissor.ScissorArray[i].Height < fb->Height)) + return false; + } + + return true; } /** -- 1.8.1.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 27/40] mesa: Add new viewport and depth-range entry points for GL_ARB_viewport_array
From: Courtney Goeltzenleuchter v2 (idr): Use set_viewport_no_notify / set_depth_range_no_notify (and manually notify the driver) instead of calling _mesa_set_viewporti / _mesa_set_depthrangei. Refactor bodies of _mesa_ViewportIndexed and _mesa_ViewportIndexedv into a shared function. Remove spurious CLAMP calls in _mesa_DepthRangeArrayv and _mesa_DepthRangeIndexed. v3 (idr): Add some missing return-statements after calls to _mesa_error. v4 (idr): Only perform the ViewportBounds.Min / ViewportBounds.Max clamping in set_viewport_no_notify if GL_ARB_viewport_array is enabled. Otherwise the driver may not have set ViewportBounds, and the clamping will do bad things. Signed-off-by: Ian Romanick --- src/mesa/main/viewport.c | 164 +++ src/mesa/main/viewport.h | 14 2 files changed, 178 insertions(+) diff --git a/src/mesa/main/viewport.c b/src/mesa/main/viewport.c index 3cd171e..a9e1adc 100644 --- a/src/mesa/main/viewport.c +++ b/src/mesa/main/viewport.c @@ -43,6 +43,21 @@ set_viewport_no_notify(struct gl_context *ctx, unsigned idx, width = MIN2(width, (GLfloat) ctx->Const.MaxViewportWidth); height = MIN2(height, (GLfloat) ctx->Const.MaxViewportHeight); + /* The GL_ARB_viewport_array spec says: +* +* "The location of the viewport's bottom-left corner, given by (x,y), +* are clamped to be within the implementation-dependent viewport +* bounds range. The viewport bounds range [min, max] tuple may be +* determined by calling GetFloatv with the symbolic constant +* VIEWPORT_BOUNDS_RANGE (see section 6.1)." +*/ + if (ctx->Extensions.ARB_viewport_array) { + x = CLAMP(x, +ctx->Const.ViewportBounds.Min, ctx->Const.ViewportBounds.Max); + y = CLAMP(y, +ctx->Const.ViewportBounds.Min, ctx->Const.ViewportBounds.Max); + } + ctx->ViewportArray[idx].X = x; ctx->ViewportArray[idx].Width = width; ctx->ViewportArray[idx].Y = y; @@ -65,6 +80,15 @@ set_viewport_no_notify(struct gl_context *ctx, unsigned idx, #endif } +struct gl_viewport_inputs { + GLfloat X, Y;/**< position */ + GLfloat Width, Height; /**< size */ +}; + +struct gl_depthrange_inputs { + GLdouble Near, Far; /**< Depth buffer range */ +}; + /** * Set the viewport. * \sa Called via glViewport() or display list execution. @@ -135,6 +159,85 @@ _mesa_set_viewport(struct gl_context *ctx, unsigned idx, GLfloat x, GLfloat y, } } +void GLAPIENTRY +_mesa_ViewportArrayv(GLuint first, GLsizei count, const GLfloat *v) +{ + int i; + const struct gl_viewport_inputs *const p = (struct gl_viewport_inputs *) v; + GET_CURRENT_CONTEXT(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glViewportArrayv %d %d\n", first, count); + + if ((first + count) > ctx->Const.MaxViewports) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glViewportArrayv: first (%d) + count (%d) > MaxViewports " + "(%d)", + first, count, ctx->Const.MaxViewports); + return; + } + + /* Verify width & height */ + for (i = 0; i < count; i++) { + if (p[i].Width < 0 || p[i].Height < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glViewportArrayv: index (%d) width or height < 0 " + "(%f, %f)", + i + first, p[i].Width, p[i].Height); + return; + } + } + + for (i = 0; i < count; i++) + set_viewport_no_notify(ctx, i + first, + p[i].X, p[i].Y, + p[i].Width, p[i].Height); + + if (ctx->Driver.Viewport) + ctx->Driver.Viewport(ctx); +} + +static void +ViewportIndexedf(GLuint index, GLfloat x, GLfloat y, + GLfloat w, GLfloat h, const char *function) +{ + GET_CURRENT_CONTEXT(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "%s(%d, %f, %f, %f, %f)\n", + function, index, x, y, w, h); + + if (index >= ctx->Const.MaxViewports) { + _mesa_error(ctx, GL_INVALID_VALUE, + "%s: index (%d) >= MaxViewports (%d)", + function, index, ctx->Const.MaxViewports); + return; + } + + /* Verify width & height */ + if (w < 0 || h < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, + "%s: index (%d) width or height < 0 (%f, %f)", + function, index, w, h); + return; + } + + _mesa_set_viewport(ctx, index, x, y, w, h); +} + +void GLAPIENTRY +_mesa_ViewportIndexedf(GLuint index, GLfloat x, GLfloat y, + GLfloat w, GLfloat h) +{ + ViewportIndexedf(index, x, y, w, h, "glViewportIndexedf"); +} + +void GLAPIENTRY +_mesa_ViewportIndexedfv(GLuint index, const GLfloat *v) +{ + ViewportIndexedf(index, v[0], v[1], v[2], v[3], "glViewportIndexedfv"); +} + static void set_depth_range_no_notify(struct gl_context *ctx, unsigned idx,
[Mesa-dev] [PATCH 13/40] mesa: Refactor depth range setting even more
From: Ian Romanick Create an internal function that just writes data into the depth range. In future patches this will see more use because we only want to call dd_function_table::DepthRange once after setting all of the depth ranges instead of once per depth range. Signed-off-by: Ian Romanick --- src/mesa/main/viewport.c | 57 src/mesa/main/viewport.h | 3 +++ 2 files changed, 41 insertions(+), 19 deletions(-) diff --git a/src/mesa/main/viewport.c b/src/mesa/main/viewport.c index d4b0393..2c81af7 100644 --- a/src/mesa/main/viewport.c +++ b/src/mesa/main/viewport.c @@ -108,6 +108,43 @@ _mesa_set_viewport(struct gl_context *ctx, unsigned idx, GLint x, GLint y, } } +static void +set_depth_range_no_notify(struct gl_context *ctx, unsigned idx, + GLclampd nearval, GLclampd farval) +{ + if (ctx->ViewportArray[idx].Near == nearval && + ctx->ViewportArray[idx].Far == farval) + return; + + ctx->ViewportArray[idx].Near = CLAMP(nearval, 0.0, 1.0); + ctx->ViewportArray[idx].Far = CLAMP(farval, 0.0, 1.0); + ctx->NewState |= _NEW_VIEWPORT; + +#if 1 + /* XXX remove this someday. Currently the DRI drivers rely on +* the WindowMap matrix being up to date in the driver's Viewport +* and DepthRange functions. +*/ + _math_matrix_viewport(&ctx->ViewportArray[idx]._WindowMap, + ctx->ViewportArray[idx].X, + ctx->ViewportArray[idx].Y, + ctx->ViewportArray[idx].Width, + ctx->ViewportArray[idx].Height, + ctx->ViewportArray[idx].Near, + ctx->ViewportArray[idx].Far, + ctx->DrawBuffer->_DepthMaxF); +#endif +} + +void +_mesa_set_depth_range(struct gl_context *ctx, unsigned idx, + GLclampd nearval, GLclampd farval) +{ + set_depth_range_no_notify(ctx, idx, nearval, farval); + + if (ctx->Driver.DepthRange) + ctx->Driver.DepthRange(ctx); +} /** * Called by glDepthRange @@ -127,25 +164,7 @@ _mesa_DepthRange(GLclampd nearval, GLclampd farval) if (MESA_VERBOSE&VERBOSE_API) _mesa_debug(ctx, "glDepthRange %f %f\n", nearval, farval); - if (ctx->ViewportArray[0].Near == nearval && - ctx->ViewportArray[0].Far == farval) - return; - - ctx->ViewportArray[0].Near = CLAMP(nearval, 0.0, 1.0); - ctx->ViewportArray[0].Far = CLAMP(farval, 0.0, 1.0); - ctx->NewState |= _NEW_VIEWPORT; - -#if 1 - /* XXX remove this someday. Currently the DRI drivers rely on -* the WindowMap matrix being up to date in the driver's Viewport -* and DepthRange functions. -*/ - _math_matrix_viewport(&ctx->ViewportArray[0]._WindowMap, - ctx->ViewportArray[0].X, ctx->ViewportArray[0].Y, - ctx->ViewportArray[0].Width, ctx->ViewportArray[0].Height, - ctx->ViewportArray[0].Near, ctx->ViewportArray[0].Far, - ctx->DrawBuffer->_DepthMaxF); -#endif + set_depth_range_no_notify(ctx, 0, nearval, farval); if (ctx->Driver.DepthRange) { ctx->Driver.DepthRange(ctx); diff --git a/src/mesa/main/viewport.h b/src/mesa/main/viewport.h index b4eb521..44bca1b 100644 --- a/src/mesa/main/viewport.h +++ b/src/mesa/main/viewport.h @@ -46,6 +46,9 @@ _mesa_DepthRange(GLclampd nearval, GLclampd farval); extern void GLAPIENTRY _mesa_DepthRangef(GLclampf nearval, GLclampf farval); +extern void +_mesa_set_depth_range(struct gl_context *ctx, unsigned idx, + GLclampd nearval, GLclampd farval); extern void _mesa_init_viewport(struct gl_context *ctx); -- 1.8.1.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 10/40] mesa: Update viewport state for viewport_array
From: Courtney Goeltzenleuchter Include DepthRange as well since it's state is lumped together with viewport state. Updates all the drivers that reference Viewport state in gl_context. v2 (idr): Rebase fixes. Also, don't have meta call _mesa_Viewport. We don't want the extra validation overhead, and meta will only ever need to change viewport 0 (while _mesa_Viewport updates all of them). v3 (idr): Remove spurious casts to float in _mesa_DepthRange. gl_viewport_attrib::Near and gl_viewport_attrib::Far are double now, just like nearval and farval. As result, the casts aren't just unnecessary, they're wrong. Signed-off-by: Ian Romanick --- src/mesa/drivers/common/meta.c | 28 ++--- src/mesa/drivers/dri/i915/i915_state.c | 24 ++-- src/mesa/drivers/dri/i965/brw_cc.c | 4 +- src/mesa/drivers/dri/i965/brw_clip_state.c | 12 +++--- src/mesa/drivers/dri/i965/brw_sf_state.c| 2 +- src/mesa/drivers/dri/i965/gen6_clip_state.c | 8 ++-- src/mesa/drivers/dri/i965/gen6_viewport_state.c | 6 +-- src/mesa/drivers/dri/i965/gen7_viewport_state.c | 6 +-- src/mesa/drivers/dri/nouveau/nouveau_util.h | 4 +- src/mesa/drivers/dri/nouveau/nv10_state_fb.c| 2 +- src/mesa/drivers/dri/r200/r200_state.c | 4 +- src/mesa/drivers/dri/radeon/radeon_state.c | 4 +- src/mesa/main/attrib.c | 5 ++- src/mesa/main/context.c | 21 ++ src/mesa/main/get.c | 16 ++-- src/mesa/main/get_hash_params.py| 2 +- src/mesa/main/mtypes.h | 8 ++-- src/mesa/main/rastpos.c | 4 +- src/mesa/main/state.c | 17 src/mesa/main/viewport.c| 52 - src/mesa/math/m_matrix.c| 9 +++-- src/mesa/math/m_matrix.h| 4 +- src/mesa/program/prog_statevars.c | 7 ++-- src/mesa/state_tracker/st_atom_viewport.c | 12 +++--- src/mesa/swrast/s_context.c | 8 ++-- src/mesa/swrast/s_depth.c | 10 ++--- src/mesa/swrast_setup/ss_context.c | 4 +- src/mesa/tnl/t_rasterpos.c | 16 28 files changed, 158 insertions(+), 141 deletions(-) diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c index 173b45c..9b2f7d0 100644 --- a/src/mesa/drivers/common/meta.c +++ b/src/mesa/drivers/common/meta.c @@ -737,21 +737,21 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state) if (state & MESA_META_VIEWPORT) { /* save viewport state */ - save->ViewportX = ctx->Viewport.X; - save->ViewportY = ctx->Viewport.Y; - save->ViewportW = ctx->Viewport.Width; - save->ViewportH = ctx->Viewport.Height; + save->ViewportX = ctx->ViewportArray[0].X; + save->ViewportY = ctx->ViewportArray[0].Y; + save->ViewportW = ctx->ViewportArray[0].Width; + save->ViewportH = ctx->ViewportArray[0].Height; /* set viewport to match window size */ - if (ctx->Viewport.X != 0 || - ctx->Viewport.Y != 0 || - ctx->Viewport.Width != ctx->DrawBuffer->Width || - ctx->Viewport.Height != ctx->DrawBuffer->Height) { + if (ctx->ViewportArray[0].X != 0 || + ctx->ViewportArray[0].Y != 0 || + ctx->ViewportArray[0].Width != ctx->DrawBuffer->Width || + ctx->ViewportArray[0].Height != ctx->DrawBuffer->Height) { _mesa_set_viewport(ctx, 0, 0, ctx->DrawBuffer->Width, ctx->DrawBuffer->Height); } /* save depth range state */ - save->DepthNear = ctx->Viewport.Near; - save->DepthFar = ctx->Viewport.Far; + save->DepthNear = ctx->ViewportArray[0].Near; + save->DepthFar = ctx->ViewportArray[0].Far; /* set depth range to default */ _mesa_DepthRange(0.0, 1.0); } @@ -1089,10 +1089,10 @@ _mesa_meta_end(struct gl_context *ctx) } if (state & MESA_META_VIEWPORT) { - if (save->ViewportX != ctx->Viewport.X || - save->ViewportY != ctx->Viewport.Y || - save->ViewportW != ctx->Viewport.Width || - save->ViewportH != ctx->Viewport.Height) { + if (save->ViewportX != ctx->ViewportArray[0].X || + save->ViewportY != ctx->ViewportArray[0].Y || + save->ViewportW != ctx->ViewportArray[0].Width || + save->ViewportH != ctx->ViewportArray[0].Height) { _mesa_set_viewport(ctx, save->ViewportX, save->ViewportY, save->ViewportW, save->ViewportH); } diff --git a/src/mesa/drivers/dri/i915/i915_state.c b/src/mesa/drivers/dri/i915/i915_state.c index 1cc1d5d..d3646fe 100644 --- a/src/mesa/drivers/dri/i915/i915_state.c +++ b/src/mesa/drivers/dri/i915/i915_state.c @@ -404,21 +404,21 @@ intelCalcViewport(struct gl_context * ctx)
[Mesa-dev] [PATCH 03/40] mesa: Eliminate parameters to dd_function_table::Viewport
From: Ian Romanick No driver uses them. They will just be annoying in future patches. Signed-off-by: Ian Romanick --- src/mesa/drivers/dri/i915/intel_context.c | 15 ++- src/mesa/drivers/dri/i965/brw_context.c| 7 +-- src/mesa/drivers/dri/r200/r200_state.c | 8 +--- src/mesa/drivers/dri/radeon/radeon_state.c | 8 +--- src/mesa/drivers/dri/swrast/swrast.c | 6 +- src/mesa/drivers/windows/gdi/wmesa.c | 4 +--- src/mesa/drivers/x11/xm_dd.c | 6 +- src/mesa/main/dd.h | 2 +- src/mesa/main/viewport.c | 2 +- src/mesa/state_tracker/st_cb_viewport.c| 3 +-- 10 files changed, 11 insertions(+), 50 deletions(-) diff --git a/src/mesa/drivers/dri/i915/intel_context.c b/src/mesa/drivers/dri/i915/intel_context.c index ac5d4ff..e076396 100644 --- a/src/mesa/drivers/dri/i915/intel_context.c +++ b/src/mesa/drivers/dri/i915/intel_context.c @@ -271,17 +271,11 @@ intel_prepare_render(struct intel_context *intel) } static void -intel_noninvalidate_viewport(struct gl_context *ctx, GLint x, GLint y, - GLsizei w, GLsizei h) +intel_noninvalidate_viewport(struct gl_context *ctx) { struct intel_context *intel = intel_context(ctx); __DRIcontext *driContext = intel->driContext; -(void) x; -(void) y; -(void) w; -(void) h; - intelCalcViewport(ctx); if (_mesa_is_winsys_fbo(ctx->DrawBuffer)) { @@ -291,13 +285,8 @@ intel_noninvalidate_viewport(struct gl_context *ctx, GLint x, GLint y, } static void -intel_viewport(struct gl_context *ctx, GLint x, GLint y, GLsizei w, GLsizei h) +intel_viewport(struct gl_context *ctx) { -(void) x; -(void) y; -(void) w; -(void) h; - intelCalcViewport(ctx); } diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index 1b42751..6821029 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -134,16 +134,11 @@ intelGetString(struct gl_context * ctx, GLenum name) } static void -intel_viewport(struct gl_context *ctx, GLint x, GLint y, GLsizei w, GLsizei h) +intel_viewport(struct gl_context *ctx) { struct brw_context *brw = brw_context(ctx); __DRIcontext *driContext = brw->driContext; - (void) x; - (void) y; - (void) w; - (void) h; - if (_mesa_is_winsys_fbo(ctx->DrawBuffer)) { dri2InvalidateDrawable(driContext->driDrawablePriv); dri2InvalidateDrawable(driContext->driReadablePriv); diff --git a/src/mesa/drivers/dri/r200/r200_state.c b/src/mesa/drivers/dri/r200/r200_state.c index b4ef7cf..0522287 100644 --- a/src/mesa/drivers/dri/r200/r200_state.c +++ b/src/mesa/drivers/dri/r200/r200_state.c @@ -1600,14 +1600,8 @@ void r200_vtbl_update_scissor( struct gl_context *ctx ) } -static void r200Viewport( struct gl_context *ctx, GLint x, GLint y, - GLsizei width, GLsizei height ) +static void r200Viewport(struct gl_context *ctx) { - (void) x; - (void) y; - (void) width; - (void) height; - /* Don't pipeline viewport changes, conflict with window offset * setting below. Could apply deltas to rescue pipelined viewport * values, or keep the originals hanging around. diff --git a/src/mesa/drivers/dri/radeon/radeon_state.c b/src/mesa/drivers/dri/radeon/radeon_state.c index 843a5a6..160f396 100644 --- a/src/mesa/drivers/dri/radeon/radeon_state.c +++ b/src/mesa/drivers/dri/radeon/radeon_state.c @@ -1383,14 +1383,8 @@ void radeonUpdateWindow( struct gl_context *ctx ) } -static void radeonViewport( struct gl_context *ctx, GLint x, GLint y, - GLsizei width, GLsizei height ) +static void radeonViewport(struct gl_context *ctx) { - (void) x; - (void) y; - (void) width; - (void) height; - /* Don't pipeline viewport changes, conflict with window offset * setting below. Could apply deltas to rescue pipelined viewport * values, or keep the originals hanging around. diff --git a/src/mesa/drivers/dri/swrast/swrast.c b/src/mesa/drivers/dri/swrast/swrast.c index 79a2740..30e6805 100644 --- a/src/mesa/drivers/dri/swrast/swrast.c +++ b/src/mesa/drivers/dri/swrast/swrast.c @@ -618,15 +618,11 @@ update_state( struct gl_context *ctx, GLuint new_state ) } static void -viewport(struct gl_context *ctx, GLint x, GLint y, GLsizei w, GLsizei h) +viewport(struct gl_context *ctx) { struct gl_framebuffer *draw = ctx->WinSysDrawBuffer; struct gl_framebuffer *read = ctx->WinSysReadBuffer; -(void) x; -(void) y; -(void) w; -(void) h; swrast_check_and_update_window_size(ctx, draw); swrast_check_and_update_window_size(ctx, read); } diff --git a/src/mesa/drivers/windows/gdi/wmesa.c b/src/mesa/drivers/windows/gdi/wmesa.c index d6eb823..c1a9c28 100644 --- a/src/mesa/drivers/windows/gdi/wmesa.c +++ b/src/mesa/drivers/windows/gdi/wmesa.c @@ -484,9 +484,7 @@ wme
[Mesa-dev] [PATCH 26/40] mesa: Add new scissor entry points for GL_ARB_viewport_array
From: Courtney Goeltzenleuchter v2 (idr): Use set_scissor_no_notify (and manually notify the driver) instead of calling _mesa_set_scissori. Refactory bodies of _mesa_ScissorIndexed and _mesa_ScissorIndexedv into a shared function. Perform parameter validation in the same order in all three functions. Pull MaxViewports comparison fix (in _mesa_ScissorArrayv) from the next patch to this patch. Signed-off-by: Ian Romanick --- src/mesa/main/scissor.c | 93 + src/mesa/main/scissor.h | 8 + 2 files changed, 101 insertions(+) diff --git a/src/mesa/main/scissor.c b/src/mesa/main/scissor.c index 9caac2e..14c8e8a 100644 --- a/src/mesa/main/scissor.c +++ b/src/mesa/main/scissor.c @@ -114,6 +114,99 @@ _mesa_set_scissor(struct gl_context *ctx, unsigned idx, ctx->Driver.Scissor(ctx); } +/** + * Define count scissor boxes starting at index. + * + * \param index index of first scissor records to set + * \param count number of scissor records to set + * \param x, y pointer to array of struct gl_scissor_rects + * + * \sa glScissorArrayv(). + * + * Verifies the parameters and call set_scissor_no_notify to do the work. + */ +void GLAPIENTRY +_mesa_ScissorArrayv(GLuint first, GLsizei count, const GLint *v) +{ + int i; + struct gl_scissor_rect *p = (struct gl_scissor_rect *) v; + GET_CURRENT_CONTEXT(ctx); + + if ((first + count) > ctx->Const.MaxViewports) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glScissorArrayv: first (%d) + count (%d) >= MaxViewports (%d)", + first, count, ctx->Const.MaxViewports); + return; + } + + /* Verify width & height */ + for (i = 0; i < count; i++) { + if (p[i].Width < 0 || p[i].Height < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glScissorArrayv: index (%d) width or height < 0 (%d, %d)", + i, p[i].Width, p[i].Height); + } + } + + for (i = 0; i < count; i++) + set_scissor_no_notify(ctx, i + first, +p[i].X, p[i].Y, p[i].Width, p[i].Height); + + if (ctx->Driver.Scissor) + ctx->Driver.Scissor(ctx); +} + +/** + * Define the scissor box. + * + * \param index index of scissor records to set + * \param x, y coordinates of the scissor box lower-left corner. + * \param width width of the scissor box. + * \param height height of the scissor box. + * + * Verifies the parameters call set_scissor_no_notify to do the work. + */ +static void +ScissorIndexed(GLuint index, GLint left, GLint bottom, + GLsizei width, GLsizei height, const char *function) +{ + GET_CURRENT_CONTEXT(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "%s(%d, %d, %d, %d, %d)\n", + function, index, left, bottom, width, height); + + if (index >= ctx->Const.MaxViewports) { + _mesa_error(ctx, GL_INVALID_VALUE, + "%s: index (%d) >= MaxViewports (%d)", + function, index, ctx->Const.MaxViewports); + return; + } + + if (width < 0 || height < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, + "%s: index (%d) width or height < 0 (%d, %d)", + function, index, width, height); + } + + set_scissor_no_notify(ctx, index, left, bottom, width, height); + + if (ctx->Driver.Scissor) + ctx->Driver.Scissor(ctx); +} + +void GLAPIENTRY +_mesa_ScissorIndexed(GLuint index, GLint left, GLint bottom, + GLsizei width, GLsizei height) +{ + ScissorIndexed(index, left, bottom, width, height, "glScissorIndexd"); +} + +void GLAPIENTRY +_mesa_ScissorIndexedv(GLuint index, const GLint *v) +{ + ScissorIndexed(index, v[0], v[1], v[2], v[3], "glScissorIndexdv"); +} /** * Initialize the context's scissor state. diff --git a/src/mesa/main/scissor.h b/src/mesa/main/scissor.h index 5726a00..5f9a994 100644 --- a/src/mesa/main/scissor.h +++ b/src/mesa/main/scissor.h @@ -34,6 +34,14 @@ struct gl_context; extern void GLAPIENTRY _mesa_Scissor( GLint x, GLint y, GLsizei width, GLsizei height ); +extern void GLAPIENTRY +_mesa_ScissorArrayv(GLuint first, GLsizei count, const GLint * v); + +extern void GLAPIENTRY +_mesa_ScissorIndexed(GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); + +extern void GLAPIENTRY +_mesa_ScissorIndexedv(GLuint index, const GLint * v); extern void _mesa_set_scissor(struct gl_context *ctx, unsigned idx, -- 1.8.1.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 04/40] mesa: Eliminate parameters to dd_function_table::DepthRange
From: Ian Romanick No driver uses them. They will just be annoying in future patches. Signed-off-by: Ian Romanick --- src/mesa/drivers/dri/i915/i830_state.c | 2 +- src/mesa/drivers/dri/i915/i915_state.c | 2 +- src/mesa/drivers/dri/r200/r200_state.c | 3 +-- src/mesa/drivers/dri/radeon/radeon_common.c | 4 +--- src/mesa/drivers/dri/radeon/radeon_state.c | 3 +-- src/mesa/main/dd.h | 2 +- src/mesa/main/viewport.c| 2 +- 7 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/mesa/drivers/dri/i915/i830_state.c b/src/mesa/drivers/dri/i915/i830_state.c index bbf0cef..cf85058 100644 --- a/src/mesa/drivers/dri/i915/i830_state.c +++ b/src/mesa/drivers/dri/i915/i830_state.c @@ -453,7 +453,7 @@ i830DepthMask(struct gl_context * ctx, GLboolean flag) /** Called from ctx->Driver.DepthRange() */ static void -i830DepthRange(struct gl_context * ctx, GLclampd nearval, GLclampd farval) +i830DepthRange(struct gl_context *ctx) { intelCalcViewport(ctx); } diff --git a/src/mesa/drivers/dri/i915/i915_state.c b/src/mesa/drivers/dri/i915/i915_state.c index fedafec..f867f12 100644 --- a/src/mesa/drivers/dri/i915/i915_state.c +++ b/src/mesa/drivers/dri/i915/i915_state.c @@ -426,7 +426,7 @@ intelCalcViewport(struct gl_context * ctx) /** Called from ctx->Driver.DepthRange() */ static void -i915DepthRange(struct gl_context * ctx, GLclampd nearval, GLclampd farval) +i915DepthRange(struct gl_context *ctx) { intelCalcViewport(ctx); } diff --git a/src/mesa/drivers/dri/r200/r200_state.c b/src/mesa/drivers/dri/r200/r200_state.c index 0522287..4a7d694 100644 --- a/src/mesa/drivers/dri/r200/r200_state.c +++ b/src/mesa/drivers/dri/r200/r200_state.c @@ -1611,8 +1611,7 @@ static void r200Viewport(struct gl_context *ctx) radeon_viewport(ctx); } -static void r200DepthRange( struct gl_context *ctx, GLclampd nearval, - GLclampd farval ) +static void r200DepthRange(struct gl_context *ctx) { r200UpdateWindow( ctx ); } diff --git a/src/mesa/drivers/dri/radeon/radeon_common.c b/src/mesa/drivers/dri/radeon/radeon_common.c index d083e5b..a5d363f 100644 --- a/src/mesa/drivers/dri/radeon/radeon_common.c +++ b/src/mesa/drivers/dri/radeon/radeon_common.c @@ -325,9 +325,7 @@ void radeon_draw_buffer(struct gl_context *ctx, struct gl_framebuffer *fb) radeon->NewGLState |= _NEW_SCISSOR; if (ctx->Driver.DepthRange) - ctx->Driver.DepthRange(ctx, - ctx->Viewport.Near, - ctx->Viewport.Far); + ctx->Driver.DepthRange(ctx); /* Update culling direction which changes depending on the * orientation of the buffer: diff --git a/src/mesa/drivers/dri/radeon/radeon_state.c b/src/mesa/drivers/dri/radeon/radeon_state.c index 160f396..09386d9 100644 --- a/src/mesa/drivers/dri/radeon/radeon_state.c +++ b/src/mesa/drivers/dri/radeon/radeon_state.c @@ -1394,8 +1394,7 @@ static void radeonViewport(struct gl_context *ctx) radeon_viewport(ctx); } -static void radeonDepthRange( struct gl_context *ctx, GLclampd nearval, - GLclampd farval ) +static void radeonDepthRange(struct gl_context *ctx) { radeonUpdateWindow( ctx ); } diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h index f438278..c8537b7 100644 --- a/src/mesa/main/dd.h +++ b/src/mesa/main/dd.h @@ -484,7 +484,7 @@ struct dd_function_table { /** Enable or disable writing into the depth buffer */ void (*DepthMask)(struct gl_context *ctx, GLboolean flag); /** Specify mapping of depth values from NDC to window coordinates */ - void (*DepthRange)(struct gl_context *ctx, GLclampd nearval, GLclampd farval); + void (*DepthRange)(struct gl_context *ctx); /** Specify the current buffer for writing */ void (*DrawBuffer)( struct gl_context *ctx, GLenum buffer ); /** Specify the buffers for writing for fragment programs*/ diff --git a/src/mesa/main/viewport.c b/src/mesa/main/viewport.c index 7ea1d5f..3aaab2d 100644 --- a/src/mesa/main/viewport.c +++ b/src/mesa/main/viewport.c @@ -143,7 +143,7 @@ _mesa_DepthRange(GLclampd nearval, GLclampd farval) #endif if (ctx->Driver.DepthRange) { - ctx->Driver.DepthRange(ctx, nearval, farval); + ctx->Driver.DepthRange(ctx); } } -- 1.8.1.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 01/40] i915: Remove spurious calls to DepthRange
From: Ian Romanick For both i830 and i915, the driver DepthRange function just calls intelCalcViewport. Signed-off-by: Ian Romanick Cc: Eric Anholt --- src/mesa/drivers/dri/i915/i830_vtbl.c | 6 +- src/mesa/drivers/dri/i915/i915_vtbl.c | 5 + 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/mesa/drivers/dri/i915/i830_vtbl.c b/src/mesa/drivers/dri/i915/i830_vtbl.c index f988a83..f8749a5 100644 --- a/src/mesa/drivers/dri/i915/i830_vtbl.c +++ b/src/mesa/drivers/dri/i915/i830_vtbl.c @@ -832,16 +832,12 @@ i830_update_draw_buffer(struct intel_context *intel) fb->_NumColorDrawBuffers); intel->NewGLState |= _NEW_BUFFERS; - /* update viewport since it depends on window size */ - intelCalcViewport(ctx); - /* Set state we know depends on drawable parameters: */ + intelCalcViewport(ctx); ctx->Driver.Scissor(ctx, ctx->Scissor.X, ctx->Scissor.Y, ctx->Scissor.Width, ctx->Scissor.Height); - ctx->Driver.DepthRange(ctx, ctx->Viewport.Near, ctx->Viewport.Far); - /* Update culling direction which changes depending on the * orientation of the buffer: */ diff --git a/src/mesa/drivers/dri/i915/i915_vtbl.c b/src/mesa/drivers/dri/i915/i915_vtbl.c index 3368fe4..755d322 100644 --- a/src/mesa/drivers/dri/i915/i915_vtbl.c +++ b/src/mesa/drivers/dri/i915/i915_vtbl.c @@ -806,14 +806,11 @@ i915_update_draw_buffer(struct intel_context *intel) fb->_NumColorDrawBuffers); intel->NewGLState |= _NEW_BUFFERS; - /* update viewport since it depends on window size */ - intelCalcViewport(ctx); - /* Set state we know depends on drawable parameters: */ + intelCalcViewport(ctx); ctx->Driver.Scissor(ctx, ctx->Scissor.X, ctx->Scissor.Y, ctx->Scissor.Width, ctx->Scissor.Height); - ctx->Driver.DepthRange(ctx, ctx->Viewport.Near, ctx->Viewport.Far); /* Update culling direction which changes depending on the * orientation of the buffer: -- 1.8.1.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 18/40] mesa: Restore all the scissor rectangles in _mesa_PopAttrib
From: Ian Romanick Signed-off-by: Ian Romanick --- src/mesa/main/attrib.c | 16 ++-- 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c index f55433e..db659ad 100644 --- a/src/mesa/main/attrib.c +++ b/src/mesa/main/attrib.c @@ -1269,15 +1269,19 @@ _mesa_PopAttrib(void) break; case GL_SCISSOR_BIT: { + unsigned i; const struct gl_scissor_attrib *scissor; scissor = (const struct gl_scissor_attrib *) attr->data; - _mesa_set_scissor(ctx, 0, - scissor->ScissorArray[0].X, - scissor->ScissorArray[0].Y, - scissor->ScissorArray[0].Width, - scissor->ScissorArray[0].Height); - _mesa_set_enable(ctx, GL_SCISSOR_TEST, scissor->EnableFlags & 1); + for (i = 0; i < ctx->Const.MaxViewports; i++) { + _mesa_set_scissor(ctx, i, +scissor->ScissorArray[i].X, +scissor->ScissorArray[i].Y, +scissor->ScissorArray[i].Width, +scissor->ScissorArray[i].Height); + _mesa_set_enablei(ctx, GL_SCISSOR_TEST, i, +(scissor->EnableFlags >> i) & 1); + } } break; case GL_STENCIL_BUFFER_BIT: -- 1.8.1.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 09/40] mesa: Move parameter validation from _mesa_set_viewport to _mesa_Viewport
From: Ian Romanick Internal callers should do the right thing. Signed-off-by: Ian Romanick --- src/mesa/main/viewport.c | 19 ++- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/mesa/main/viewport.c b/src/mesa/main/viewport.c index 3aaab2d..3bc89ab 100644 --- a/src/mesa/main/viewport.c +++ b/src/mesa/main/viewport.c @@ -47,6 +47,16 @@ _mesa_Viewport(GLint x, GLint y, GLsizei width, GLsizei height) { GET_CURRENT_CONTEXT(ctx); FLUSH_VERTICES(ctx, 0); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glViewport %d %d %d %d\n", x, y, width, height); + + if (width < 0 || height < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glViewport(%d, %d, %d, %d)", x, y, width, height); + return; + } + _mesa_set_viewport(ctx, x, y, width, height); } @@ -64,15 +74,6 @@ void _mesa_set_viewport(struct gl_context *ctx, GLint x, GLint y, GLsizei width, GLsizei height) { - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glViewport %d %d %d %d\n", x, y, width, height); - - if (width < 0 || height < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glViewport(%d, %d, %d, %d)", x, y, width, height); - return; - } - /* clamp width and height to the implementation dependent range */ width = MIN2(width, (GLsizei) ctx->Const.MaxViewportWidth); height = MIN2(height, (GLsizei) ctx->Const.MaxViewportHeight); -- 1.8.1.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 14/40] mesa: Refactor viewport setting even more
From: Ian Romanick Create an internal function that just writes data into the viewport. In future patches this will see more use because we only want to call dd_function_table::Viewport once after setting all of the viewport instead of once per viewport. Signed-off-by: Ian Romanick --- src/mesa/main/viewport.c | 63 +--- 1 file changed, 38 insertions(+), 25 deletions(-) diff --git a/src/mesa/main/viewport.c b/src/mesa/main/viewport.c index 2c81af7..ac891c8 100644 --- a/src/mesa/main/viewport.c +++ b/src/mesa/main/viewport.c @@ -34,6 +34,35 @@ #include "mtypes.h" #include "viewport.h" +static void +set_viewport_no_notify(struct gl_context *ctx, unsigned idx, GLint x, GLint y, + GLsizei width, GLsizei height) +{ + /* clamp width and height to the implementation dependent range */ + width = MIN2(width, (GLsizei) ctx->Const.MaxViewportWidth); + height = MIN2(height, (GLsizei) ctx->Const.MaxViewportHeight); + + ctx->ViewportArray[idx].X = x; + ctx->ViewportArray[idx].Width = width; + ctx->ViewportArray[idx].Y = y; + ctx->ViewportArray[idx].Height = height; + ctx->NewState |= _NEW_VIEWPORT; + +#if 1 + /* XXX remove this someday. Currently the DRI drivers rely on +* the WindowMap matrix being up to date in the driver's Viewport +* and DepthRange functions. +*/ + _math_matrix_viewport(&ctx->ViewportArray[idx]._WindowMap, + ctx->ViewportArray[idx].X, + ctx->ViewportArray[idx].Y, + ctx->ViewportArray[idx].Width, + ctx->ViewportArray[idx].Height, + ctx->ViewportArray[idx].Near, + ctx->ViewportArray[idx].Far, + ctx->DrawBuffer->_DepthMaxF); +#endif +} /** * Set the viewport. @@ -57,7 +86,14 @@ _mesa_Viewport(GLint x, GLint y, GLsizei width, GLsizei height) return; } - _mesa_set_viewport(ctx, 0, x, y, width, height); + set_viewport_no_notify(ctx, 0, x, y, width, height); + + if (ctx->Driver.Viewport) { + /* Many drivers will use this call to check for window size changes + * and reallocate the z/stencil/accum/etc buffers if needed. + */ + ctx->Driver.Viewport(ctx); + } } @@ -75,30 +111,7 @@ void _mesa_set_viewport(struct gl_context *ctx, unsigned idx, GLint x, GLint y, GLsizei width, GLsizei height) { - /* clamp width and height to the implementation dependent range */ - width = MIN2(width, (GLsizei) ctx->Const.MaxViewportWidth); - height = MIN2(height, (GLsizei) ctx->Const.MaxViewportHeight); - - ctx->ViewportArray[idx].X = x; - ctx->ViewportArray[idx].Width = width; - ctx->ViewportArray[idx].Y = y; - ctx->ViewportArray[idx].Height = height; - ctx->NewState |= _NEW_VIEWPORT; - -#if 1 - /* XXX remove this someday. Currently the DRI drivers rely on -* the WindowMap matrix being up to date in the driver's Viewport -* and DepthRange functions. -*/ - _math_matrix_viewport(&ctx->ViewportArray[idx]._WindowMap, - ctx->ViewportArray[idx].X, - ctx->ViewportArray[idx].Y, - ctx->ViewportArray[idx].Width, - ctx->ViewportArray[idx].Height, - ctx->ViewportArray[idx].Near, - ctx->ViewportArray[idx].Far, - ctx->DrawBuffer->_DepthMaxF); -#endif + set_viewport_no_notify(ctx, idx, x, y, width, height); if (ctx->Driver.Viewport) { /* Many drivers will use this call to check for window size changes -- 1.8.1.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 05/40] mesa: Eliminate parameters to dd_function_table::Scissor
From: Ian Romanick The i830 and i915 drivers used them, but they didn't really need to. They will just be annoying in future patches. Signed-off-by: Ian Romanick --- src/mesa/drivers/common/driverfuncs.c | 3 +-- src/mesa/drivers/dri/i915/i830_state.c | 22 -- src/mesa/drivers/dri/i915/i830_vtbl.c | 3 +-- src/mesa/drivers/dri/i915/i915_state.c | 22 -- src/mesa/drivers/dri/i915/i915_vtbl.c | 3 +-- src/mesa/drivers/dri/radeon/radeon_common.c | 2 +- src/mesa/drivers/dri/radeon/radeon_common.h | 2 +- src/mesa/main/dd.h | 2 +- src/mesa/main/scissor.c | 2 +- 9 files changed, 31 insertions(+), 30 deletions(-) diff --git a/src/mesa/drivers/common/driverfuncs.c b/src/mesa/drivers/common/driverfuncs.c index f185688..e8dcb24 100644 --- a/src/mesa/drivers/common/driverfuncs.c +++ b/src/mesa/drivers/common/driverfuncs.c @@ -302,8 +302,7 @@ _mesa_init_driver_state(struct gl_context *ctx) ctx->Driver.LogicOpcode(ctx, ctx->Color.LogicOp); ctx->Driver.PointSize(ctx, ctx->Point.Size); ctx->Driver.PolygonStipple(ctx, (const GLubyte *) ctx->PolygonStipple); - ctx->Driver.Scissor(ctx, ctx->Scissor.X, ctx->Scissor.Y, - ctx->Scissor.Width, ctx->Scissor.Height); + ctx->Driver.Scissor(ctx); ctx->Driver.ShadeModel(ctx, ctx->Light.ShadeModel); ctx->Driver.StencilFuncSeparate(ctx, GL_FRONT, ctx->Stencil.Function[0], diff --git a/src/mesa/drivers/dri/i915/i830_state.c b/src/mesa/drivers/dri/i915/i830_state.c index cf85058..a69c7ea 100644 --- a/src/mesa/drivers/dri/i915/i830_state.c +++ b/src/mesa/drivers/dri/i915/i830_state.c @@ -527,7 +527,7 @@ i830PolygonStipple(struct gl_context * ctx, const GLubyte * mask) * Hardware clipping */ static void -i830Scissor(struct gl_context * ctx, GLint x, GLint y, GLsizei w, GLsizei h) +i830Scissor(struct gl_context * ctx) { struct i830_context *i830 = i830_context(ctx); int x1, y1, x2, y2; @@ -535,22 +535,24 @@ i830Scissor(struct gl_context * ctx, GLint x, GLint y, GLsizei w, GLsizei h) if (!ctx->DrawBuffer) return; - DBG("%s %d,%d %dx%d\n", __FUNCTION__, x, y, w, h); + DBG("%s %d,%d %dx%d\n", __FUNCTION__, + ctx->Scissor.X, ctx->Scissor.Y, + ctx->Scissor.Width, ctx->Scissor.Height); if (_mesa_is_winsys_fbo(ctx->DrawBuffer)) { - x1 = x; - y1 = ctx->DrawBuffer->Height - (y + h); - x2 = x + w - 1; - y2 = y1 + h - 1; + x1 = ctx->Scissor.X; + y1 = ctx->DrawBuffer->Height - (ctx->Scissor.Y + ctx->Scissor.Height); + x2 = ctx->Scissor.X + ctx->Scissor.Width - 1; + y2 = y1 + ctx->Scissor.Height - 1; DBG("%s %d..%d,%d..%d (inverted)\n", __FUNCTION__, x1, x2, y1, y2); } else { /* FBO - not inverted */ - x1 = x; - y1 = y; - x2 = x + w - 1; - y2 = y + h - 1; + x1 = ctx->Scissor.X; + y1 = ctx->Scissor.Y; + x2 = ctx->Scissor.X + ctx->Scissor.Width - 1; + y2 = ctx->Scissor.Y + ctx->Scissor.Height - 1; DBG("%s %d..%d,%d..%d (not inverted)\n", __FUNCTION__, x1, x2, y1, y2); } diff --git a/src/mesa/drivers/dri/i915/i830_vtbl.c b/src/mesa/drivers/dri/i915/i830_vtbl.c index f8749a5..4a9ea56 100644 --- a/src/mesa/drivers/dri/i915/i830_vtbl.c +++ b/src/mesa/drivers/dri/i915/i830_vtbl.c @@ -835,8 +835,7 @@ i830_update_draw_buffer(struct intel_context *intel) /* Set state we know depends on drawable parameters: */ intelCalcViewport(ctx); - ctx->Driver.Scissor(ctx, ctx->Scissor.X, ctx->Scissor.Y, - ctx->Scissor.Width, ctx->Scissor.Height); + ctx->Driver.Scissor(ctx); /* Update culling direction which changes depending on the * orientation of the buffer: diff --git a/src/mesa/drivers/dri/i915/i915_state.c b/src/mesa/drivers/dri/i915/i915_state.c index f867f12..9a25b9e 100644 --- a/src/mesa/drivers/dri/i915/i915_state.c +++ b/src/mesa/drivers/dri/i915/i915_state.c @@ -501,7 +501,7 @@ i915PolygonStipple(struct gl_context * ctx, const GLubyte * mask) * Hardware clipping */ static void -i915Scissor(struct gl_context * ctx, GLint x, GLint y, GLsizei w, GLsizei h) +i915Scissor(struct gl_context * ctx) { struct i915_context *i915 = I915_CONTEXT(ctx); int x1, y1, x2, y2; @@ -509,22 +509,24 @@ i915Scissor(struct gl_context * ctx, GLint x, GLint y, GLsizei w, GLsizei h) if (!ctx->DrawBuffer) return; - DBG("%s %d,%d %dx%d\n", __FUNCTION__, x, y, w, h); + DBG("%s %d,%d %dx%d\n", __FUNCTION__, + ctx->Scissor.X, ctx->Scissor.Y, + ctx->Scissor.Width, ctx->Scissor.Height); if (_mesa_is_winsys_fbo(ctx->DrawBuffer)) { - x1 = x; - y1 = ctx->DrawBuffer->Height - (y + h); - x2 = x + w - 1; - y2 = y1 + h - 1; + x1 = ctx->Scissor.X; + y1 = ctx->DrawBuffer->Height - (ctx->Scissor.Y + ctx->Scissor.Height); + x2 = ctx->Scis
[Mesa-dev] [PATCH 25/40] mesa: Add custom get function for SCISSOR_TEST to _mesa_IsEnabledi
From: Courtney Goeltzenleuchter Now that the scissor enable state is a bitfield need a custom function to extract the correct value from gl_context. Modeled Scissor.EnableFlags after Color.BlendEnabled. --- src/mesa/main/enable.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c index 4841e84..c0ad766 100644 --- a/src/mesa/main/enable.c +++ b/src/mesa/main/enable.c @@ -1137,6 +1137,13 @@ _mesa_IsEnabledi( GLenum cap, GLuint index ) return GL_FALSE; } return (ctx->Color.BlendEnabled >> index) & 1; + case GL_SCISSOR_TEST: + if (index >= ctx->Const.MaxViewports) { + _mesa_error(ctx, GL_INVALID_VALUE, "glIsEnabledIndexed(index=%u)", + index); + return GL_FALSE; + } + return (ctx->Scissor.EnableFlags >> index) & 1; default: _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabledIndexed(cap=%s)", _mesa_lookup_enum_by_nr(cap)); -- 1.8.1.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 20/40] mesa: Set all viewports from _mesa_Viewport and _mesa_DepthRange
From: Ian Romanick In _mesa_Viewport and _mesa_DepthRange, make sure that ctx->Driver.Viewport is only called once instead of once per viewport or depth range. Signed-off-by: Ian Romanick --- src/mesa/main/viewport.c | 30 -- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/mesa/main/viewport.c b/src/mesa/main/viewport.c index cc031b0..13b469a 100644 --- a/src/mesa/main/viewport.c +++ b/src/mesa/main/viewport.c @@ -74,6 +74,7 @@ set_viewport_no_notify(struct gl_context *ctx, unsigned idx, GLint x, GLint y, void GLAPIENTRY _mesa_Viewport(GLint x, GLint y, GLsizei width, GLsizei height) { + unsigned i; GET_CURRENT_CONTEXT(ctx); FLUSH_VERTICES(ctx, 0); @@ -86,7 +87,19 @@ _mesa_Viewport(GLint x, GLint y, GLsizei width, GLsizei height) return; } - set_viewport_no_notify(ctx, 0, x, y, width, height); + /* The GL_ARB_viewport_array spec says: +* +* "Viewport sets the parameters for all viewports to the same values +* and is equivalent (assuming no errors are generated) to: +* +* for (uint i = 0; i < MAX_VIEWPORTS; i++) +* ViewportIndexedf(i, 1, (float)x, (float)y, (float)w, (float)h);" +* +* Set all of the viewports supported by the implementation, but only +* signal the driver once at the end. +*/ + for (i = 0; i < ctx->Const.MaxViewports; i++) + set_viewport_no_notify(ctx, i, x, y, width, height); if (ctx->Driver.Viewport) { /* Many drivers will use this call to check for window size changes @@ -170,6 +183,7 @@ _mesa_set_depth_range(struct gl_context *ctx, unsigned idx, void GLAPIENTRY _mesa_DepthRange(GLclampd nearval, GLclampd farval) { + unsigned i; GET_CURRENT_CONTEXT(ctx); FLUSH_VERTICES(ctx, 0); @@ -177,7 +191,19 @@ _mesa_DepthRange(GLclampd nearval, GLclampd farval) if (MESA_VERBOSE&VERBOSE_API) _mesa_debug(ctx, "glDepthRange %f %f\n", nearval, farval); - set_depth_range_no_notify(ctx, 0, nearval, farval); + /* The GL_ARB_viewport_array spec says: +* +* "DepthRange sets the depth range for all viewports to the same +* values and is equivalent (assuming no errors are generated) to: +* +* for (uint i = 0; i < MAX_VIEWPORTS; i++) +* DepthRangeIndexed(i, n, f);" +* +* Set the depth range for all of the viewports supported by the +* implementation, but only signal the driver once at the end. +*/ + for (i = 0; i < ctx->Const.MaxViewports; i++) + set_depth_range_no_notify(ctx, 0, nearval, farval); if (ctx->Driver.DepthRange) { ctx->Driver.DepthRange(ctx); -- 1.8.1.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 30/40] glsl: Add gl_ViewportIndex built-in variable
From: Courtney Goeltzenleuchter v2 (idr): Fix copy-and-paste bug... s/LAYER/VIEWPORT/ Signed-off-by: Ian Romanick --- src/glsl/builtin_variables.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/glsl/builtin_variables.cpp b/src/glsl/builtin_variables.cpp index f630923..d6bc3c0 100644 --- a/src/glsl/builtin_variables.cpp +++ b/src/glsl/builtin_variables.cpp @@ -780,6 +780,8 @@ void builtin_variable_generator::generate_gs_special_vars() { add_output(VARYING_SLOT_LAYER, int_t, "gl_Layer"); + if (state->ARB_viewport_array_enable) + add_output(VARYING_SLOT_VIEWPORT, int_t, "gl_ViewportIndex"); /* Although gl_PrimitiveID appears in tessellation control and tessellation * evaluation shaders, it has a different function there than it has in -- 1.8.1.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 06/40] mesa: Add extension tracking bit for ARB_viewport_array
From: Courtney Goeltzenleuchter v2 (idr): Split these changes out from the original patch. Only advertise GL_ARB_viewport_array in a core profile because it requires geometry shaders. --- src/mesa/main/extensions.c | 1 + src/mesa/main/mtypes.h | 1 + 2 files changed, 2 insertions(+) diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index 89d4793..827578f 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -175,6 +175,7 @@ static const struct extension extension_table[] = { { "GL_ARB_vertex_shader", o(ARB_vertex_shader), GL, 2002 }, { "GL_ARB_vertex_type_10f_11f_11f_rev", o(ARB_vertex_type_10f_11f_11f_rev), GL, 2013 }, { "GL_ARB_vertex_type_2_10_10_10_rev", o(ARB_vertex_type_2_10_10_10_rev), GL, 2009 }, + { "GL_ARB_viewport_array", o(ARB_viewport_array), GLC,2010 }, { "GL_ARB_window_pos", o(dummy_true), GLL,2001 }, /* EXT extensions */ { "GL_EXT_abgr",o(dummy_true), GL, 1995 }, diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index f23cd81..c4bb099 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -3394,6 +3394,7 @@ struct gl_extensions GLboolean ARB_vertex_shader; GLboolean ARB_vertex_type_10f_11f_11f_rev; GLboolean ARB_vertex_type_2_10_10_10_rev; + GLboolean ARB_viewport_array; GLboolean EXT_blend_color; GLboolean EXT_blend_equation_separate; GLboolean EXT_blend_func_separate; -- 1.8.1.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 32/40] i965: Set the maximum VPIndex
From: Ian Romanick At various stages the hardware clamps the gl_ViewportIndex to these values. Setting them to zero effectively makes gl_ViewportIndex be ignored. This is acutally useful in blorp (so that we don't have to modify all of the viewport / scissor state). Signed-off-by: Ian Romanick --- src/mesa/drivers/dri/i965/brw_defines.h | 1 + src/mesa/drivers/dri/i965/brw_gs_state.c| 2 ++ src/mesa/drivers/dri/i965/gen6_clip_state.c | 3 ++- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/i965/brw_defines.h b/src/mesa/drivers/dri/i965/brw_defines.h index 142b2db..2eb31e7 100644 --- a/src/mesa/drivers/dri/i965/brw_defines.h +++ b/src/mesa/drivers/dri/i965/brw_defines.h @@ -1537,6 +1537,7 @@ enum brw_message_target { # define GEN6_CLIP_MIN_POINT_WIDTH_SHIFT 17 # define GEN6_CLIP_MAX_POINT_WIDTH_SHIFT 6 # define GEN6_CLIP_FORCE_ZERO_RTAINDEX (1 << 5) +# define GEN6_CLIP_MAX_VP_INDEX_MASK (GEN7_NUM_VIEWPORTS-1) #define _3DSTATE_SF0x7813 /* GEN6+ */ /* DW1 (for gen6) */ diff --git a/src/mesa/drivers/dri/i965/brw_gs_state.c b/src/mesa/drivers/dri/i965/brw_gs_state.c index da8449c..4a2e643 100644 --- a/src/mesa/drivers/dri/i965/brw_gs_state.c +++ b/src/mesa/drivers/dri/i965/brw_gs_state.c @@ -83,6 +83,8 @@ brw_upload_gs_unit(struct brw_context *brw) if (unlikely(INTEL_DEBUG & DEBUG_STATS)) gs->thread4.stats_enable = 1; + gs->gs6.max_vp_index = brw->ctx.Const.MaxViewports - 1; + brw->state.dirty.cache |= CACHE_NEW_FF_GS_UNIT; } diff --git a/src/mesa/drivers/dri/i965/gen6_clip_state.c b/src/mesa/drivers/dri/i965/gen6_clip_state.c index e4dc278..3499e37 100644 --- a/src/mesa/drivers/dri/i965/gen6_clip_state.c +++ b/src/mesa/drivers/dri/i965/gen6_clip_state.c @@ -121,7 +121,8 @@ upload_clip_state(struct brw_context *brw) dw2); OUT_BATCH(U_FIXED(0.125, 3) << GEN6_CLIP_MIN_POINT_WIDTH_SHIFT | U_FIXED(255.875, 3) << GEN6_CLIP_MAX_POINT_WIDTH_SHIFT | - (fb->MaxNumLayers > 0 ? 0 : GEN6_CLIP_FORCE_ZERO_RTAINDEX)); + (fb->MaxNumLayers > 0 ? 0 : GEN6_CLIP_FORCE_ZERO_RTAINDEX) | + ((ctx->Const.MaxViewports - 1) & GEN6_CLIP_MAX_VP_INDEX_MASK)); ADVANCE_BATCH(); } -- 1.8.1.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 11/40] i965: Add / remove casts around viewport width and height
From: Ian Romanick Now that gl_viewport_attrib::Width and gl_viewport_attrib::Height are float, we don't need explicit casts to float in the driver. However, we do need some casts when comparing with integer variables. (This could probably be squashed with the previous commit where the gl_viewport_attrib fields changed type.) Signed-off-by: Ian Romanick --- src/mesa/drivers/dri/i965/brw_clip_state.c | 8 src/mesa/drivers/dri/i965/gen6_clip_state.c | 4 ++-- src/mesa/drivers/dri/i965/gen6_viewport_state.c | 4 ++-- src/mesa/drivers/dri/i965/gen7_viewport_state.c | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_clip_state.c b/src/mesa/drivers/dri/i965/brw_clip_state.c index 3d77a09..4bbbcb3 100644 --- a/src/mesa/drivers/dri/i965/brw_clip_state.c +++ b/src/mesa/drivers/dri/i965/brw_clip_state.c @@ -43,8 +43,8 @@ upload_clip_vp(struct brw_context *brw) sizeof(*vp), 32, &brw->clip.vp_offset); const float maximum_post_clamp_delta = 4096; - float gbx = maximum_post_clamp_delta / (float) ctx->ViewportArray[0].Width; - float gby = maximum_post_clamp_delta / (float) ctx->ViewportArray[0].Height; + float gbx = maximum_post_clamp_delta / ctx->ViewportArray[0].Width; + float gby = maximum_post_clamp_delta / ctx->ViewportArray[0].Height; vp->xmin = -gbx; vp->xmax = gbx; @@ -127,8 +127,8 @@ brw_upload_clip_unit(struct brw_context *brw) /* enable guardband clipping if we can */ if (ctx->ViewportArray[0].X == 0 && ctx->ViewportArray[0].Y == 0 && - ctx->ViewportArray[0].Width == fb->Width && - ctx->ViewportArray[0].Height == fb->Height) + ctx->ViewportArray[0].Width == (float) fb->Width && + ctx->ViewportArray[0].Height == (float) fb->Height) { clip->clip5.guard_band_enable = 1; clip->clip6.clipper_viewport_state_ptr = diff --git a/src/mesa/drivers/dri/i965/gen6_clip_state.c b/src/mesa/drivers/dri/i965/gen6_clip_state.c index d2c880d..e4dc278 100644 --- a/src/mesa/drivers/dri/i965/gen6_clip_state.c +++ b/src/mesa/drivers/dri/i965/gen6_clip_state.c @@ -98,8 +98,8 @@ upload_clip_state(struct brw_context *brw) if (ctx->ViewportArray[0].X == 0 && ctx->ViewportArray[0].Y == 0 && - ctx->ViewportArray[0].Width == fb->Width && - ctx->ViewportArray[0].Height == fb->Height) { + ctx->ViewportArray[0].Width == (float) fb->Width && + ctx->ViewportArray[0].Height == (float) fb->Height) { dw2 |= GEN6_CLIP_GB_TEST; } diff --git a/src/mesa/drivers/dri/i965/gen6_viewport_state.c b/src/mesa/drivers/dri/i965/gen6_viewport_state.c index b30f3f3..0c5de0a 100644 --- a/src/mesa/drivers/dri/i965/gen6_viewport_state.c +++ b/src/mesa/drivers/dri/i965/gen6_viewport_state.c @@ -55,8 +55,8 @@ gen6_upload_clip_vp(struct brw_context *brw) * drawable. */ const float maximum_post_clamp_delta = 8192; - float gbx = maximum_post_clamp_delta / (float) ctx->ViewportArray[0].Width; - float gby = maximum_post_clamp_delta / (float) ctx->ViewportArray[0].Height; + float gbx = maximum_post_clamp_delta / ctx->ViewportArray[0].Width; + float gby = maximum_post_clamp_delta / ctx->ViewportArray[0].Height; vp->xmin = -gbx; vp->xmax = gbx; diff --git a/src/mesa/drivers/dri/i965/gen7_viewport_state.c b/src/mesa/drivers/dri/i965/gen7_viewport_state.c index d676919..ed7d8c9 100644 --- a/src/mesa/drivers/dri/i965/gen7_viewport_state.c +++ b/src/mesa/drivers/dri/i965/gen7_viewport_state.c @@ -54,8 +54,8 @@ gen7_upload_sf_clip_viewport(struct brw_context *brw) * drawable. */ const float maximum_guardband_extent = 8192; - float gbx = maximum_guardband_extent / (float) ctx->ViewportArray[0].Width; - float gby = maximum_guardband_extent / (float) ctx->ViewportArray[0].Height; + float gbx = maximum_guardband_extent / ctx->ViewportArray[0].Width; + float gby = maximum_guardband_extent / ctx->ViewportArray[0].Height; vp->guardband.xmin = -gbx; vp->guardband.xmax = gbx; -- 1.8.1.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 19/40] mesa: Restore all the viewports in _mesa_PopAttrib
From: Ian Romanick Signed-off-by: Ian Romanick --- src/mesa/main/attrib.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c index db659ad..7b7cf0e 100644 --- a/src/mesa/main/attrib.c +++ b/src/mesa/main/attrib.c @@ -1357,10 +1357,15 @@ _mesa_PopAttrib(void) break; case GL_VIEWPORT_BIT: { + unsigned i; const struct gl_viewport_attrib *vp; vp = (const struct gl_viewport_attrib *) attr->data; - _mesa_Viewport(vp->X, vp->Y, vp->Width, vp->Height); - _mesa_DepthRange(vp->Near, vp->Far); + + for (i = 0; i < ctx->Const.MaxViewports; i++) { + _mesa_set_viewport(ctx, i, vp[i].X, vp[i].Y, vp[i].Width, + vp[i].Height); + _mesa_set_depth_range(ctx, i, vp[i].Near, vp[i].Far); + } } break; case GL_MULTISAMPLE_BIT_ARB: -- 1.8.1.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 31/40] mesa: Add ARB_viewport_array plumbing
From: Courtney Goeltzenleuchter Define API connections to extension entry points added in previous commits. Update entry points to use floating point arguments as required by the extension. Add get tokens for ARB_viewport_array state. v2: Include review feedback. v3 (idr): Fix 'make check'. Add missing Get infrastructure (some was culled from other pathces). --- src/mapi/glapi/gen/ARB_viewport_array.xml | 79 +++ src/mapi/glapi/gen/Makefile.am| 1 + src/mapi/glapi/gen/gl_API.xml | 2 +- src/mesa/main/get.c | 1 + src/mesa/main/get_hash_params.py | 9 +++- src/mesa/main/tests/dispatch_sanity.cpp | 20 6 files changed, 100 insertions(+), 12 deletions(-) create mode 100644 src/mapi/glapi/gen/ARB_viewport_array.xml diff --git a/src/mapi/glapi/gen/ARB_viewport_array.xml b/src/mapi/glapi/gen/ARB_viewport_array.xml new file mode 100644 index 000..e1c6c2d --- /dev/null +++ b/src/mapi/glapi/gen/ARB_viewport_array.xml @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/mapi/glapi/gen/Makefile.am b/src/mapi/glapi/gen/Makefile.am index 65bd913..6063610 100644 --- a/src/mapi/glapi/gen/Makefile.am +++ b/src/mapi/glapi/gen/Makefile.am @@ -128,6 +128,7 @@ API_XML = \ ARB_texture_view.xml \ ARB_vertex_array_object.xml \ ARB_vertex_attrib_binding.xml \ + ARB_viewport_array.xml \ AMD_draw_buffers_blend.xml \ AMD_performance_monitor.xml \ ARB_vertex_type_2_10_10_10_rev.xml \ diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml index 697b2ec..0c1e445 100644 --- a/src/mapi/glapi/gen/gl_API.xml +++ b/src/mapi/glapi/gen/gl_API.xml @@ -9924,7 +9924,7 @@ - +http://www.w3.org/2001/XInclude"/> diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index 811e283..1928307 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -385,6 +385,7 @@ EXTRA_EXT(ARB_texture_multisample); EXTRA_EXT(ARB_texture_gather); EXTRA_EXT(ARB_shader_atomic_counters); EXTRA_EXT(ARB_draw_indirect); +EXTRA_EXT(ARB_viewport_array); static const int extra_ARB_color_buffer_float_or_glcore[] = { diff --git a/src/mesa/main/get_hash_params.py b/src/mesa/main/get_hash_params.py index 412a951..06ad959 100644 --- a/src/mesa/main/get_hash_params.py +++ b/src/mesa/main/get_hash_params.py @@ -44,7 +44,7 @@ descriptor=[ [ "SUBPIXEL_BITS", "CONTEXT_INT(Const.SubPixelBits), NO_EXTRA" ], [ "TEXTURE_BINDING_2D", "LOC_CUSTOM, TYPE_INT, TEXTURE_2D_INDEX, NO_EXTRA" ], [ "UNPACK_ALIGNMENT", "CONTEXT_INT(Unpack.Alignment), NO_EXTRA" ], - [ "VIEWPORT", "LOC_CUSTOM, TYPE_INT_4, 0, NO_EXTRA" ], + [ "VIEWPORT", "LOC_CUSTOM, TYPE_FLOAT_4, 0, NO_EXTRA" ], # GL_ARB_multitexture [ "ACTIVE_TEXTURE", "LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA" ], @@ -750,6 +750,13 @@ descriptor=[ [ "TEXTURE_BUFFER_OFFSET_ALIGNMENT", "CONTEXT_INT(Const.TextureBufferOffsetAlignment), extra_ARB_texture_buffer_range" ], # GL_ARB_draw_indirect [ "DRAW_INDIRECT_BUFFER_BINDING", "LOC_CUSTOM, TYPE_INT, 0, extra_ARB_draw_indirect" ], + +# GL_ARB_viewport_array + [ "MAX_VIEWPORTS", "CONTEXT_INT(Const.MaxViewports), extra_ARB_viewport_array" ], + [ "VIEWPORT_SUBPIXEL_BITS", "CONTEXT_INT(Const.ViewportSubpixelBits), extra_ARB_viewport_array" ], + [ "VIEWPORT_BOUNDS_RANGE", "CONTEXT_FLOAT2(Const.ViewportBounds), extra_ARB_viewport_array" ], + [ "LAYER_PROVOKING_VERTEX", "CONTEXT_ENUM(Light.ProvokingVertex), extra_ARB_viewport_array" ], + [ "VIEWPORT_INDEX_PROVOKING_VERTEX", "CONTEXT_ENUM(Light.ProvokingVertex), extra_ARB_viewport_array" ], ]} ] diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp index 227a4fd..544b02e 100644 --- a/src/mesa/main/tests/dispatch_sanity.cpp +++ b/src/mesa/main/tests/dispatch_sanity.cpp @@ -786,16 +786,16 @@ const struct function gl_core_functions_possible[] = { // { "glVertexAttribL4dv", 43, -1 },// XXX: Add to xml // { "glVertexAttribLPointer", 43, -1 },// XXX: Add to xml // { "glGetVertexAttribLdv", 43, -1 }, // XXX: Add to xml -// { "glViewportArrayv", 43, -1 }, // XXX: Add to xml -// { "glViewportIndexedf", 43, -1 },// XXX: Add to xml -// { "glViewportIndexedfv", 43, -1 }, // XXX: Add to xml -// { "glScissorArrayv", 43, -1 }, // XXX: Add to xml -// {
[Mesa-dev] [PATCH 36/40] mesa: Refactor bounding-box calculation out of _mesa_update_draw_buffer_bounds
From: Ian Romanick Drivers that currently use _Xmin and friends to set their scissor rectangle will need to use this code directly once they are updated for GL_ARB_viewport_array. Signed-off-by: Ian Romanick --- src/mesa/main/framebuffer.c | 85 + src/mesa/main/framebuffer.h | 5 +++ 2 files changed, 61 insertions(+), 29 deletions(-) diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c index f14f7a4..04b9a2b 100644 --- a/src/mesa/main/framebuffer.c +++ b/src/mesa/main/framebuffer.c @@ -357,6 +357,56 @@ update_framebuffer_size(struct gl_context *ctx, struct gl_framebuffer *fb) /** + * Calculate the inclusive bounding box for the scissor of a specific viewport + * + * \param ctx GL context. + * \param buffer Framebuffer to be checked against + * \param idx Index of the desired viewport + * \param bboxBounding box for the scissored viewport. Stored as xmin, + *xmax, ymin, ymax. + * + * \warning This function assumes that the framebuffer dimensions are up to + * date (e.g., update_framebuffer_size has been recently called on \c buffer). + * + * \sa _mesa_clip_to_region + */ +void +_mesa_scissor_bounding_box(const struct gl_context *ctx, + const struct gl_framebuffer *buffer, + unsigned idx, int *bbox) +{ + bbox[0] = 0; + bbox[2] = 0; + bbox[1] = buffer->Width; + bbox[3] = buffer->Height; + + if ((ctx->Scissor.EnableFlags >> idx) & 1) { + if (ctx->Scissor.ScissorArray[idx].X > bbox[0]) { +bbox[0] = ctx->Scissor.ScissorArray[idx].X; + } + if (ctx->Scissor.ScissorArray[idx].Y > bbox[2]) { +bbox[2] = ctx->Scissor.ScissorArray[idx].Y; + } + if (ctx->Scissor.ScissorArray[idx].X + ctx->Scissor.ScissorArray[idx].Width < bbox[1]) { +bbox[1] = ctx->Scissor.ScissorArray[idx].X + ctx->Scissor.ScissorArray[idx].Width; + } + if (ctx->Scissor.ScissorArray[idx].Y + ctx->Scissor.ScissorArray[idx].Height < bbox[3]) { +bbox[3] = ctx->Scissor.ScissorArray[idx].Y + ctx->Scissor.ScissorArray[idx].Height; + } + /* finally, check for empty region */ + if (bbox[0] > bbox[1]) { + bbox[0] = bbox[1]; + } + if (bbox[2] > bbox[3]) { + bbox[2] = bbox[3]; + } + } + + ASSERT(bbox[0] <= bbox[1]); + ASSERT(bbox[2] <= bbox[3]); +} + +/** * Update the context's current drawing buffer's Xmin, Xmax, Ymin, Ymax fields. * These values are computed from the buffer's width and height and * the scissor box, if it's enabled. @@ -366,6 +416,7 @@ void _mesa_update_draw_buffer_bounds(struct gl_context *ctx) { struct gl_framebuffer *buffer = ctx->DrawBuffer; + int bbox[4]; if (!buffer) return; @@ -375,36 +426,12 @@ _mesa_update_draw_buffer_bounds(struct gl_context *ctx) update_framebuffer_size(ctx, buffer); } - buffer->_Xmin = 0; - buffer->_Ymin = 0; - buffer->_Xmax = buffer->Width; - buffer->_Ymax = buffer->Height; - /* Default to the first scissor as that's always valid */ - if (ctx->Scissor.EnableFlags & 1) { - if (ctx->Scissor.ScissorArray[0].X > buffer->_Xmin) { -buffer->_Xmin = ctx->Scissor.ScissorArray[0].X; - } - if (ctx->Scissor.ScissorArray[0].Y > buffer->_Ymin) { -buffer->_Ymin = ctx->Scissor.ScissorArray[0].Y; - } - if (ctx->Scissor.ScissorArray[0].X + ctx->Scissor.ScissorArray[0].Width < buffer->_Xmax) { -buffer->_Xmax = ctx->Scissor.ScissorArray[0].X + ctx->Scissor.ScissorArray[0].Width; - } - if (ctx->Scissor.ScissorArray[0].Y + ctx->Scissor.ScissorArray[0].Height < buffer->_Ymax) { -buffer->_Ymax = ctx->Scissor.ScissorArray[0].Y + ctx->Scissor.ScissorArray[0].Height; - } - /* finally, check for empty region */ - if (buffer->_Xmin > buffer->_Xmax) { - buffer->_Xmin = buffer->_Xmax; - } - if (buffer->_Ymin > buffer->_Ymax) { - buffer->_Ymin = buffer->_Ymax; - } - } - - ASSERT(buffer->_Xmin <= buffer->_Xmax); - ASSERT(buffer->_Ymin <= buffer->_Ymax); + _mesa_scissor_bounding_box(ctx, buffer, 0, bbox); + buffer->_Xmin = bbox[0]; + buffer->_Ymin = bbox[2]; + buffer->_Xmax = bbox[1]; + buffer->_Ymax = bbox[3]; } diff --git a/src/mesa/main/framebuffer.h b/src/mesa/main/framebuffer.h index 2645664..a427421 100644 --- a/src/mesa/main/framebuffer.h +++ b/src/mesa/main/framebuffer.h @@ -71,6 +71,11 @@ _mesa_resize_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb, extern void _mesa_resizebuffers( struct gl_context *ctx ); +extern void +_mesa_scissor_bounding_box(const struct gl_context *ctx, + const struct gl_framebuffer *buffer, + unsigned idx, int *bbox); + extern void _mesa_update_draw_buffer_bounds(struct gl_context *ctx); -- 1.8.1.4 ___ mesa-dev mailing list
[Mesa-dev] [PATCH 33/40] i965: Emit writes to viewport index
From: Ian Romanick This variable is handled in a fashion identical to gl_Layer. Signed-off-by: Ian Romanick --- src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 4 src/mesa/drivers/dri/i965/brw_vs.c | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp index 3b8cef6..f6dc3a8 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp @@ -2772,6 +2772,10 @@ vec4_visitor::emit_psiz_and_flags(struct brw_reg reg) emit(MOV(retype(brw_writemask(reg, WRITEMASK_Y), BRW_REGISTER_TYPE_D), src_reg(output_reg[VARYING_SLOT_LAYER]))); } + if (prog_data->vue_map.slots_valid & VARYING_BIT_VIEWPORT) { + emit(MOV(retype(brw_writemask(reg, WRITEMASK_Z), BRW_REGISTER_TYPE_D), + src_reg(output_reg[VARYING_SLOT_VIEWPORT]))); + } } } diff --git a/src/mesa/drivers/dri/i965/brw_vs.c b/src/mesa/drivers/dri/i965/brw_vs.c index 5d50c3c..d2317d8 100644 --- a/src/mesa/drivers/dri/i965/brw_vs.c +++ b/src/mesa/drivers/dri/i965/brw_vs.c @@ -60,10 +60,10 @@ brw_compute_vue_map(struct brw_context *brw, struct brw_vue_map *vue_map, vue_map->slots_valid = slots_valid; int i; - /* gl_Layer doesn't get its own varying slot--it's stored in the virst VUE -* slot (VARYING_SLOT_PSIZ). + /* gl_Layer and gl_ViewportIndex don't get their own varying slots -- they +* are stored in the virst VUE slot (VARYING_SLOT_PSIZ). */ - slots_valid &= ~VARYING_BIT_LAYER; + slots_valid &= ~(VARYING_BIT_LAYER | VARYING_BIT_VIEWPORT); /* Make sure that the values we store in vue_map->varying_to_slot and * vue_map->slot_to_varying won't overflow the signed chars that are used -- 1.8.1.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 29/40] glsl: Add extension infrastructure for ARB_viewport_array
From: Ian Romanick Signed-off-by: Ian Romanick --- src/glsl/glcpp/glcpp-parse.y| 3 +++ src/glsl/glsl_parser_extras.cpp | 1 + src/glsl/glsl_parser_extras.h | 2 ++ src/glsl/standalone_scaffolding.cpp | 1 + 4 files changed, 7 insertions(+) diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y index 55c4981..bbe8a06 100644 --- a/src/glsl/glcpp/glcpp-parse.y +++ b/src/glsl/glcpp/glcpp-parse.y @@ -1284,6 +1284,9 @@ glcpp_parser_create (const struct gl_extensions *extensions, int api) if (extensions->AMD_shader_trinary_minmax) add_builtin_define(parser, "GL_AMD_shader_trinary_minmax", 1); + + if (extensions->ARB_viewport_array) +add_builtin_define(parser, "GL_ARB_viewport_array", 1); } } diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp index 21dc3ab..ddb3d2d 100644 --- a/src/glsl/glsl_parser_extras.cpp +++ b/src/glsl/glsl_parser_extras.cpp @@ -513,6 +513,7 @@ static const _mesa_glsl_extension _mesa_glsl_supported_extensions[] = { EXT(ARB_shader_atomic_counters, true, false, ARB_shader_atomic_counters), EXT(ARB_sample_shading, true, false, ARB_sample_shading), EXT(AMD_shader_trinary_minmax, true, false, dummy_true), + EXT(ARB_viewport_array, true, false, ARB_viewport_array), }; #undef EXT diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h index 2444a96..6f60b73 100644 --- a/src/glsl/glsl_parser_extras.h +++ b/src/glsl/glsl_parser_extras.h @@ -352,6 +352,8 @@ struct _mesa_glsl_parse_state { bool ARB_shader_atomic_counters_warn; bool AMD_shader_trinary_minmax_enable; bool AMD_shader_trinary_minmax_warn; + bool ARB_viewport_array_enable; + bool ARB_viewport_array_warn; /*@}*/ /** Extensions supported by the OpenGL implementation. */ diff --git a/src/glsl/standalone_scaffolding.cpp b/src/glsl/standalone_scaffolding.cpp index 257d2e7..9179471 100644 --- a/src/glsl/standalone_scaffolding.cpp +++ b/src/glsl/standalone_scaffolding.cpp @@ -110,6 +110,7 @@ void initialize_context_to_defaults(struct gl_context *ctx, gl_api api) ctx->Extensions.ARB_texture_query_levels = true; ctx->Extensions.ARB_texture_query_lod = true; ctx->Extensions.ARB_uniform_buffer_object = true; + ctx->Extensions.ARB_viewport_array = true; ctx->Extensions.OES_EGL_image_external = true; ctx->Extensions.OES_standard_derivatives = true; -- 1.8.1.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 39/40] i965: Enable ARB_viewport_array
From: Courtney Goeltzenleuchter v2 (idr): Only enable the extension on GEN7+ w/core profile because it requires geometry shaders. v3 (idr): Add some casting to fix setting of ViewportBounds.Min. Negating an unsigned value, then casting to float doesn't do what you might think it does. Signed-off-by: Ian Romanick --- src/mesa/drivers/dri/i965/brw_context.c | 11 +++ src/mesa/drivers/dri/i965/intel_extensions.c | 6 ++ 2 files changed, 17 insertions(+) diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index 6821029..39897a7 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -474,6 +474,17 @@ brw_initialize_context_constants(struct brw_context *brw) } ctx->ShaderCompilerOptions[MESA_SHADER_VERTEX].PreferDP4 = true; + + /* ARB_viewport_array */ + if (brw->gen >= 7 && ctx->API == API_OPENGL_CORE) { + ctx->Const.MaxViewports = GEN7_NUM_VIEWPORTS; + ctx->Const.ViewportSubpixelBits = 0; + + /* Cast to float before negating becuase MaxViewportWidth is unsigned. + */ + ctx->Const.ViewportBounds.Min = -(float)ctx->Const.MaxViewportWidth; + ctx->Const.ViewportBounds.Max = ctx->Const.MaxViewportWidth; + } } /** diff --git a/src/mesa/drivers/dri/i965/intel_extensions.c b/src/mesa/drivers/dri/i965/intel_extensions.c index de07b7f..a408290 100644 --- a/src/mesa/drivers/dri/i965/intel_extensions.c +++ b/src/mesa/drivers/dri/i965/intel_extensions.c @@ -294,6 +294,12 @@ intelInitExtensions(struct gl_context *ctx) ctx->Extensions.ARB_transform_feedback_instanced = true; ctx->Extensions.ARB_draw_indirect = true; } + + /* Only enable this in core profile because other parts of Mesa behave + * slightly differently when the extension is enabled. + */ + if (ctx->API == API_OPENGL_CORE) + ctx->Extensions.ARB_viewport_array = true; } if (brw->gen == 5 || can_write_oacontrol(brw)) -- 1.8.1.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 37/40] i965: Set all the supported scissor rectangles for GEN7
From: Ian Romanick Currently MaxViewports is still 1, so this won't affect any change. Signed-off-by: Ian Romanick --- src/mesa/drivers/dri/i965/gen6_scissor_state.c | 61 ++ 1 file changed, 34 insertions(+), 27 deletions(-) diff --git a/src/mesa/drivers/dri/i965/gen6_scissor_state.c b/src/mesa/drivers/dri/i965/gen6_scissor_state.c index 7b92b7c..c8438e0 100644 --- a/src/mesa/drivers/dri/i965/gen6_scissor_state.c +++ b/src/mesa/drivers/dri/i965/gen6_scissor_state.c @@ -30,6 +30,7 @@ #include "brw_defines.h" #include "intel_batchbuffer.h" #include "main/fbobject.h" +#include "main/framebuffer.h" static void gen6_upload_scissor_state(struct brw_context *brw) @@ -40,7 +41,8 @@ gen6_upload_scissor_state(struct brw_context *brw) uint32_t scissor_state_offset; scissor = brw_state_batch(brw, AUB_TRACE_SCISSOR_STATE, -sizeof(*scissor), 32, &scissor_state_offset); +sizeof(*scissor) * ctx->Const.MaxViewports, 32, + &scissor_state_offset); /* _NEW_SCISSOR | _NEW_BUFFERS | _NEW_VIEWPORT */ @@ -51,33 +53,38 @@ gen6_upload_scissor_state(struct brw_context *brw) * Note that the hardware's coordinates are inclusive, while Mesa's min is * inclusive but max is exclusive. */ - if (ctx->DrawBuffer->_Xmin == ctx->DrawBuffer->_Xmax || - ctx->DrawBuffer->_Ymin == ctx->DrawBuffer->_Ymax) { - /* If the scissor was out of bounds and got clamped to 0 - * width/height at the bounds, the subtraction of 1 from - * maximums could produce a negative number and thus not clip - * anything. Instead, just provide a min > max scissor inside - * the bounds, which produces the expected no rendering. - */ - scissor->xmin = 1; - scissor->xmax = 0; - scissor->ymin = 1; - scissor->ymax = 0; - } else if (render_to_fbo) { - /* texmemory: Y=0=bottom */ - scissor->xmin = ctx->DrawBuffer->_Xmin; - scissor->xmax = ctx->DrawBuffer->_Xmax - 1; - scissor->ymin = ctx->DrawBuffer->_Ymin; - scissor->ymax = ctx->DrawBuffer->_Ymax - 1; - } - else { - /* memory: Y=0=top */ - scissor->xmin = ctx->DrawBuffer->_Xmin; - scissor->xmax = ctx->DrawBuffer->_Xmax - 1; - scissor->ymin = ctx->DrawBuffer->Height - ctx->DrawBuffer->_Ymax; - scissor->ymax = ctx->DrawBuffer->Height - ctx->DrawBuffer->_Ymin - 1; - } + for (unsigned i = 0; i < ctx->Const.MaxViewports; i++) { + int bbox[4]; + _mesa_scissor_bounding_box(ctx, ctx->DrawBuffer, i, bbox); + + if (bbox[0] == bbox[1] || + bbox[2] == bbox[3]) { + /* If the scissor was out of bounds and got clamped to 0 width/height + * at the bounds, the subtraction of 1 from maximums could produce a + * negative number and thus not clip anything. Instead, just provide + * a min > max scissor inside the bounds, which produces the expected + * no rendering. + */ + scissor[i].xmin = 1; + scissor[i].xmax = 0; + scissor[i].ymin = 1; + scissor[i].ymax = 0; + } else if (render_to_fbo) { + /* texmemory: Y=0=bottom */ + scissor[i].xmin = bbox[0]; + scissor[i].xmax = bbox[1] - 1; + scissor[i].ymin = bbox[2]; + scissor[i].ymax = bbox[3] - 1; + } + else { + /* memory: Y=0=top */ + scissor[i].xmin = bbox[0]; + scissor[i].xmax = bbox[1] - 1; + scissor[i].ymin = ctx->DrawBuffer->Height - bbox[3]; + scissor[i].ymax = ctx->DrawBuffer->Height - bbox[2] - 1; + } + } BEGIN_BATCH(2); OUT_BATCH(_3DSTATE_SCISSOR_STATE_POINTERS << 16 | (2 - 2)); OUT_BATCH(scissor_state_offset); -- 1.8.1.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 28/40] mesa: Add varying slot for viewport index
From: Ian Romanick Signed-off-by: Ian Romanick --- src/mesa/main/mtypes.h| 2 ++ src/mesa/program/prog_print.c | 10 ++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 305b752..0d85f9d 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -235,6 +235,7 @@ typedef enum VARYING_SLOT_CLIP_DIST1, VARYING_SLOT_PRIMITIVE_ID, /* Does not appear in VS */ VARYING_SLOT_LAYER, /* Appears as VS or GS output */ + VARYING_SLOT_VIEWPORT, /* Appears as VS or GS output */ VARYING_SLOT_FACE, /* FS only */ VARYING_SLOT_PNTC, /* FS only */ VARYING_SLOT_VAR0, /* First generic varying slot */ @@ -270,6 +271,7 @@ typedef enum #define VARYING_BIT_CLIP_DIST1 BITFIELD64_BIT(VARYING_SLOT_CLIP_DIST1) #define VARYING_BIT_PRIMITIVE_ID BITFIELD64_BIT(VARYING_SLOT_PRIMITIVE_ID) #define VARYING_BIT_LAYER BITFIELD64_BIT(VARYING_SLOT_LAYER) +#define VARYING_BIT_VIEWPORT BITFIELD64_BIT(VARYING_SLOT_VIEWPORT) #define VARYING_BIT_FACE BITFIELD64_BIT(VARYING_SLOT_FACE) #define VARYING_BIT_PNTC BITFIELD64_BIT(VARYING_SLOT_PNTC) #define VARYING_BIT_VAR(V) BITFIELD64_BIT(VARYING_SLOT_VAR0 + (V)) diff --git a/src/mesa/program/prog_print.c b/src/mesa/program/prog_print.c index 9391e99..02ba01e 100644 --- a/src/mesa/program/prog_print.c +++ b/src/mesa/program/prog_print.c @@ -144,8 +144,9 @@ arb_input_attrib_string(GLint index, GLenum progType) "fragment.(eighteen)", /* VARYING_SLOT_CLIP_DIST1 */ "fragment.(nineteen)", /* VARYING_SLOT_PRIMITIVE_ID */ "fragment.(twenty)", /* VARYING_SLOT_LAYER */ - "fragment.(twenty-one)", /* VARYING_SLOT_FACE */ - "fragment.(twenty-two)", /* VARYING_SLOT_PNTC */ + "fragment.(twenty-one)", /* VARYING_SLOT_VIEWPORT */ + "fragment.(twenty-two)", /* VARYING_SLOT_FACE */ + "fragment.(twenty-three)", /* VARYING_SLOT_PNTC */ "fragment.varying[0]", "fragment.varying[1]", "fragment.varying[2]", @@ -268,8 +269,9 @@ arb_output_attrib_string(GLint index, GLenum progType) "result.(eighteen)", /* VARYING_SLOT_CLIP_DIST1 */ "result.(nineteen)", /* VARYING_SLOT_PRIMITIVE_ID */ "result.(twenty)", /* VARYING_SLOT_LAYER */ - "result.(twenty-one)", /* VARYING_SLOT_FACE */ - "result.(twenty-two)", /* VARYING_SLOT_PNTC */ + "result.(twenty-one)", /* VARYING_SLOT_VIEWPORT */ + "result.(twenty-two)", /* VARYING_SLOT_FACE */ + "result.(twenty-three)", /* VARYING_SLOT_PNTC */ "result.varying[0]", "result.varying[1]", "result.varying[2]", -- 1.8.1.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 16/40] mesa: Add an index parameter to _mesa_set_scissor
From: Ian Romanick Signed-off-by: Ian Romanick --- src/mesa/main/attrib.c | 2 +- src/mesa/main/context.c | 2 +- src/mesa/main/scissor.c | 6 +++--- src/mesa/main/scissor.h | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c index 3a6bf05..f55433e 100644 --- a/src/mesa/main/attrib.c +++ b/src/mesa/main/attrib.c @@ -1271,7 +1271,7 @@ _mesa_PopAttrib(void) { const struct gl_scissor_attrib *scissor; scissor = (const struct gl_scissor_attrib *) attr->data; - _mesa_set_scissor(ctx, + _mesa_set_scissor(ctx, 0, scissor->ScissorArray[0].X, scissor->ScissorArray[0].Y, scissor->ScissorArray[0].Width, diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index e850cae..f840918 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1439,7 +1439,7 @@ _mesa_check_init_viewport(struct gl_context *ctx, GLuint width, GLuint height) */ ctx->ViewportInitialized = GL_TRUE; _mesa_set_viewport(ctx, 0, 0, 0, width, height); - _mesa_set_scissor(ctx, 0, 0, width, height); + _mesa_set_scissor(ctx, 0, 0, 0, width, height); } } diff --git a/src/mesa/main/scissor.c b/src/mesa/main/scissor.c index cc4ce69..9266f1e 100644 --- a/src/mesa/main/scissor.c +++ b/src/mesa/main/scissor.c @@ -70,7 +70,7 @@ _mesa_Scissor( GLint x, GLint y, GLsizei width, GLsizei height ) return; } - _mesa_set_scissor(ctx, x, y, width, height); + _mesa_set_scissor(ctx, 0, x, y, width, height); } @@ -88,10 +88,10 @@ _mesa_Scissor( GLint x, GLint y, GLsizei width, GLsizei height ) * the dd_function_table::Scissor callback. */ void -_mesa_set_scissor(struct gl_context *ctx, +_mesa_set_scissor(struct gl_context *ctx, unsigned idx, GLint x, GLint y, GLsizei width, GLsizei height) { - set_scissor_no_notify(ctx, 0, x, y, width, height); + set_scissor_no_notify(ctx, idx, x, y, width, height); if (ctx->Driver.Scissor) ctx->Driver.Scissor(ctx); diff --git a/src/mesa/main/scissor.h b/src/mesa/main/scissor.h index 0d7e201..5726a00 100644 --- a/src/mesa/main/scissor.h +++ b/src/mesa/main/scissor.h @@ -36,7 +36,7 @@ _mesa_Scissor( GLint x, GLint y, GLsizei width, GLsizei height ); extern void -_mesa_set_scissor(struct gl_context *ctx, +_mesa_set_scissor(struct gl_context *ctx, unsigned idx, GLint x, GLint y, GLsizei width, GLsizei height); -- 1.8.1.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 08/40] mesa: Update gl_scissor_attrib to support ARB_viewport_array
From: Courtney Goeltzenleuchter Update Mesa and drivers to access updated gl_scissor_attrib. Now have an enable bitfield and array of gl_scissor_rects. Drivers have been updated to the new scissor enable state attribute (gl_context.scissor.EnableFlags) but still treat it as a single boolean which is okay as mesa will only use bit 0 when communicating with a driver that does not support ARB_viewport_array. v2 (idr): Rebase fixes. --- src/mesa/drivers/common/driverfuncs.c | 2 +- src/mesa/drivers/common/meta.c | 6 +++--- src/mesa/drivers/dri/i915/i830_state.c | 24 ++-- src/mesa/drivers/dri/i915/i915_state.c | 24 ++-- src/mesa/drivers/dri/i915/intel_fbo.c | 2 +- src/mesa/drivers/dri/i965/brw_clear.c | 12 ++-- src/mesa/drivers/dri/i965/brw_sf_state.c| 2 +- src/mesa/drivers/dri/i965/gen6_sf_state.c | 2 +- src/mesa/drivers/dri/i965/gen7_sf_state.c | 2 +- src/mesa/drivers/dri/i965/intel_fbo.c | 2 +- src/mesa/drivers/dri/radeon/radeon_common.c | 6 +++--- src/mesa/main/attrib.c | 22 -- src/mesa/main/enable.c | 29 - src/mesa/main/framebuffer.c | 19 ++- src/mesa/main/get.c | 12 src/mesa/main/get_hash_params.py| 2 +- src/mesa/main/mtypes.h | 8 ++-- src/mesa/main/scissor.c | 26 +- src/mesa/state_tracker/st_atom_rasterizer.c | 2 +- src/mesa/state_tracker/st_atom_scissor.c| 14 +++--- src/mesa/state_tracker/st_cb_bitmap.c | 2 +- src/mesa/state_tracker/st_cb_clear.c| 10 +- src/mesa/state_tracker/st_cb_drawpixels.c | 2 +- src/mesa/swrast/s_context.c | 2 +- 24 files changed, 140 insertions(+), 94 deletions(-) diff --git a/src/mesa/drivers/common/driverfuncs.c b/src/mesa/drivers/common/driverfuncs.c index e8dcb24..6d56838 100644 --- a/src/mesa/drivers/common/driverfuncs.c +++ b/src/mesa/drivers/common/driverfuncs.c @@ -274,7 +274,7 @@ _mesa_init_driver_state(struct gl_context *ctx) ctx->Driver.Enable(ctx, GL_LIGHTING, ctx->Light.Enabled); ctx->Driver.Enable(ctx, GL_LINE_SMOOTH, ctx->Line.SmoothFlag); ctx->Driver.Enable(ctx, GL_POLYGON_STIPPLE, ctx->Polygon.StippleFlag); - ctx->Driver.Enable(ctx, GL_SCISSOR_TEST, ctx->Scissor.Enabled); + ctx->Driver.Enable(ctx, GL_SCISSOR_TEST, ctx->Scissor.EnableFlags); ctx->Driver.Enable(ctx, GL_STENCIL_TEST, ctx->Stencil._Enabled); ctx->Driver.Enable(ctx, GL_TEXTURE_1D, GL_FALSE); ctx->Driver.Enable(ctx, GL_TEXTURE_2D, GL_FALSE); diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c index 1294514..173b45c 100644 --- a/src/mesa/drivers/common/meta.c +++ b/src/mesa/drivers/common/meta.c @@ -933,9 +933,9 @@ _mesa_meta_end(struct gl_context *ctx) } if (state & MESA_META_SCISSOR) { - _mesa_set_enable(ctx, GL_SCISSOR_TEST, save->Scissor.Enabled); - _mesa_Scissor(save->Scissor.X, save->Scissor.Y, -save->Scissor.Width, save->Scissor.Height); + _mesa_set_enable(ctx, GL_SCISSOR_TEST, save->Scissor.EnableFlags); + _mesa_Scissor(save->Scissor.ScissorArray[0].X, save->Scissor.ScissorArray[0].Y, +save->Scissor.ScissorArray[0].Width, save->Scissor.ScissorArray[0].Height); } if (state & MESA_META_SHADER) { diff --git a/src/mesa/drivers/dri/i915/i830_state.c b/src/mesa/drivers/dri/i915/i830_state.c index a69c7ea..4ae1fed 100644 --- a/src/mesa/drivers/dri/i915/i830_state.c +++ b/src/mesa/drivers/dri/i915/i830_state.c @@ -536,23 +536,27 @@ i830Scissor(struct gl_context * ctx) return; DBG("%s %d,%d %dx%d\n", __FUNCTION__, - ctx->Scissor.X, ctx->Scissor.Y, - ctx->Scissor.Width, ctx->Scissor.Height); + ctx->Scissor.ScissorArray[0].X, ctx->Scissor.ScissorArray[0].Y, + ctx->Scissor.ScissorArray[0].Width, ctx->Scissor.ScissorArray[0].Height); if (_mesa_is_winsys_fbo(ctx->DrawBuffer)) { - x1 = ctx->Scissor.X; - y1 = ctx->DrawBuffer->Height - (ctx->Scissor.Y + ctx->Scissor.Height); - x2 = ctx->Scissor.X + ctx->Scissor.Width - 1; - y2 = y1 + ctx->Scissor.Height - 1; + x1 = ctx->Scissor.ScissorArray[0].X; + y1 = ctx->DrawBuffer->Height - (ctx->Scissor.ScissorArray[0].Y + + ctx->Scissor.ScissorArray[0].Height); + x2 = ctx->Scissor.ScissorArray[0].X + + ctx->Scissor.ScissorArray[0].Width - 1; + y2 = y1 + ctx->Scissor.ScissorArray[0].Height - 1; DBG("%s %d..%d,%d..%d (inverted)\n", __FUNCTION__, x1, x2, y1, y2); } else { /* FBO - not inverted */ - x1 = ctx->Scissor.X; - y1 = ctx->Scissor.Y; - x2 = ctx->Scissor.X + ctx->Scissor.Width - 1; - y2 = ctx->Scissor.Y + ctx->Scissor.Hei
[Mesa-dev] [PATCH 22/40] meta: Restore all scissor state
From: Ian Romanick Previously the restore code would enable all scissor rectangles if any scissor rectangles were enabled on entry to meta. When there is only one scissor rectangle, this is fine. As soon as a driver supports multiple viewports, this will be a problem. Signed-off-by: Ian Romanick --- src/mesa/drivers/common/meta.c | 14 +++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c index 551c5d6..5b33840 100644 --- a/src/mesa/drivers/common/meta.c +++ b/src/mesa/drivers/common/meta.c @@ -933,9 +933,17 @@ _mesa_meta_end(struct gl_context *ctx) } if (state & MESA_META_SCISSOR) { - _mesa_set_enable(ctx, GL_SCISSOR_TEST, save->Scissor.EnableFlags); - _mesa_Scissor(save->Scissor.ScissorArray[0].X, save->Scissor.ScissorArray[0].Y, -save->Scissor.ScissorArray[0].Width, save->Scissor.ScissorArray[0].Height); + unsigned i; + + for (i = 0; i < ctx->Const.MaxViewports; i++) { + _mesa_set_scissor(ctx, i, + save->Scissor.ScissorArray[i].X, + save->Scissor.ScissorArray[i].Y, + save->Scissor.ScissorArray[i].Width, + save->Scissor.ScissorArray[i].Height); + _mesa_set_enablei(ctx, GL_SCISSOR_TEST, i, + (save->Scissor.EnableFlags >> i) & 1); + } } if (state & MESA_META_SHADER) { -- 1.8.1.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 12/40] mesa: Add an index parameter to _mesa_set_viewport
From: Ian Romanick Signed-off-by: Ian Romanick --- src/mesa/drivers/common/meta.c | 14 +++--- src/mesa/main/context.c| 2 +- src/mesa/main/viewport.c | 24 ++-- src/mesa/main/viewport.h | 2 +- 4 files changed, 23 insertions(+), 19 deletions(-) diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c index 9b2f7d0..551c5d6 100644 --- a/src/mesa/drivers/common/meta.c +++ b/src/mesa/drivers/common/meta.c @@ -746,7 +746,7 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state) ctx->ViewportArray[0].Y != 0 || ctx->ViewportArray[0].Width != ctx->DrawBuffer->Width || ctx->ViewportArray[0].Height != ctx->DrawBuffer->Height) { - _mesa_set_viewport(ctx, 0, 0, + _mesa_set_viewport(ctx, 0, 0, 0, ctx->DrawBuffer->Width, ctx->DrawBuffer->Height); } /* save depth range state */ @@ -1093,7 +1093,7 @@ _mesa_meta_end(struct gl_context *ctx) save->ViewportY != ctx->ViewportArray[0].Y || save->ViewportW != ctx->ViewportArray[0].Width || save->ViewportH != ctx->ViewportArray[0].Height) { - _mesa_set_viewport(ctx, save->ViewportX, save->ViewportY, + _mesa_set_viewport(ctx, 0, save->ViewportX, save->ViewportY, save->ViewportW, save->ViewportH); } _mesa_DepthRange(save->DepthNear, save->DepthFar); @@ -1761,7 +1761,7 @@ blitframebuffer_texture(struct gl_context *ctx, } /* setup viewport */ - _mesa_set_viewport(ctx, dstX, dstY, dstW, dstH); + _mesa_set_viewport(ctx, 0, dstX, dstY, dstW, dstH); _mesa_ColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); _mesa_DepthMask(GL_FALSE); _mesa_DrawArrays(GL_TRIANGLE_FAN, 0, 4); @@ -1916,7 +1916,7 @@ _mesa_meta_BlitFramebuffer(struct gl_context *ctx, _mesa_BufferSubData(GL_ARRAY_BUFFER_ARB, 0, sizeof(verts), verts); } - _mesa_set_viewport(ctx, dstX, dstY, dstW, dstH); + _mesa_set_viewport(ctx, 0, dstX, dstY, dstW, dstH); _mesa_ColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); _mesa_set_enable(ctx, GL_DEPTH_TEST, GL_FALSE); _mesa_DepthMask(GL_FALSE); @@ -1965,7 +1965,7 @@ _mesa_meta_BlitFramebuffer(struct gl_context *ctx, _mesa_DepthFunc(GL_ALWAYS); _mesa_DepthMask(GL_TRUE); - _mesa_set_viewport(ctx, dstX, dstY, dstW, dstH); + _mesa_set_viewport(ctx, 0, dstX, dstY, dstW, dstH); _mesa_BufferSubData(GL_ARRAY_BUFFER_ARB, 0, sizeof(verts), verts); _mesa_DrawArrays(GL_TRIANGLE_FAN, 0, 4); mask &= ~GL_DEPTH_BUFFER_BIT; @@ -3782,7 +3782,7 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum target, assert(dstHeight == ctx->DrawBuffer->Height); /* setup viewport */ - _mesa_set_viewport(ctx, 0, 0, dstWidth, dstHeight); + _mesa_set_viewport(ctx, 0, 0, 0, dstWidth, dstHeight); _mesa_DrawArrays(GL_TRIANGLE_FAN, 0, 4); } @@ -4072,7 +4072,7 @@ decompress_texture_image(struct gl_context *ctx, _mesa_MatrixMode(GL_PROJECTION); _mesa_LoadIdentity(); _mesa_Ortho(0.0, width, 0.0, height, -1.0, 1.0); - _mesa_set_viewport(ctx, 0, 0, width, height); + _mesa_set_viewport(ctx, 0, 0, 0, width, height); /* upload new vertex data */ _mesa_BufferSubData(GL_ARRAY_BUFFER_ARB, 0, sizeof(verts), verts); diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 61d5dd5..e850cae 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1438,7 +1438,7 @@ _mesa_check_init_viewport(struct gl_context *ctx, GLuint width, GLuint height) * potential infinite recursion. */ ctx->ViewportInitialized = GL_TRUE; - _mesa_set_viewport(ctx, 0, 0, width, height); + _mesa_set_viewport(ctx, 0, 0, 0, width, height); _mesa_set_scissor(ctx, 0, 0, width, height); } } diff --git a/src/mesa/main/viewport.c b/src/mesa/main/viewport.c index 360f066..d4b0393 100644 --- a/src/mesa/main/viewport.c +++ b/src/mesa/main/viewport.c @@ -57,7 +57,7 @@ _mesa_Viewport(GLint x, GLint y, GLsizei width, GLsizei height) return; } - _mesa_set_viewport(ctx, x, y, width, height); + _mesa_set_viewport(ctx, 0, x, y, width, height); } @@ -66,22 +66,23 @@ _mesa_Viewport(GLint x, GLint y, GLsizei width, GLsizei height) * matrix). Usually called from _mesa_Viewport(). * * \param ctx GL context. + * \param idxIndex of the viewport to be updated. * \param x, y coordinates of the lower left corner of the viewport rectangle. * \param width width of the viewport rectangle. * \param height height of the viewport rectangle. */ void -_mesa_set_viewport(struct gl_context *ctx, GLint x, GLint y, +_mesa_set_viewport(struct gl_context *ctx, unsigned idx, GLint x, GLint y, GLsizei width, GLsizei height) { /* clamp width and height to the implem
[Mesa-dev] [PATCH 15/40] mesa: Refactor scissor rectangle setting even more
From: Ian Romanick Create an internal function that just writes data into the scissor rectangle. In future patches this will see more use because we only want to call dd_function_table::Scissor once after setting all of the scissor rectangles instead of once per scissor rectangle. Signed-off-by: Ian Romanick --- src/mesa/main/scissor.c | 42 +++--- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/src/mesa/main/scissor.c b/src/mesa/main/scissor.c index 7ec927e..cc4ce69 100644 --- a/src/mesa/main/scissor.c +++ b/src/mesa/main/scissor.c @@ -30,6 +30,31 @@ /** + * Set scissor rectangle data directly in ScissorArray + * + * This is an internal function that performs no error checking on the + * supplied data. It also does \b not call \c dd_function_table::Scissor. + * + * \sa _mesa_set_scissor + */ +static void +set_scissor_no_notify(struct gl_context *ctx, unsigned idx, + GLint x, GLint y, GLsizei width, GLsizei height) +{ + if (x == ctx->Scissor.ScissorArray[idx].X && + y == ctx->Scissor.ScissorArray[idx].Y && + width == ctx->Scissor.ScissorArray[idx].Width && + height == ctx->Scissor.ScissorArray[idx].Height) + return; + + FLUSH_VERTICES(ctx, _NEW_SCISSOR); + ctx->Scissor.ScissorArray[idx].X = x; + ctx->Scissor.ScissorArray[idx].Y = y; + ctx->Scissor.ScissorArray[idx].Width = width; + ctx->Scissor.ScissorArray[idx].Height = height; +} + +/** * Called via glScissor */ void GLAPIENTRY @@ -66,17 +91,7 @@ void _mesa_set_scissor(struct gl_context *ctx, GLint x, GLint y, GLsizei width, GLsizei height) { - if (x == ctx->Scissor.ScissorArray[0].X && - y == ctx->Scissor.ScissorArray[0].Y && - width == ctx->Scissor.ScissorArray[0].Width && - height == ctx->Scissor.ScissorArray[0].Height) - return; - - FLUSH_VERTICES(ctx, _NEW_SCISSOR); - ctx->Scissor.ScissorArray[0].X = x; - ctx->Scissor.ScissorArray[0].Y = y; - ctx->Scissor.ScissorArray[0].Width = width; - ctx->Scissor.ScissorArray[0].Height = height; + set_scissor_no_notify(ctx, 0, x, y, width, height); if (ctx->Driver.Scissor) ctx->Driver.Scissor(ctx); @@ -92,8 +107,5 @@ _mesa_init_scissor(struct gl_context *ctx) { /* Scissor group */ ctx->Scissor.EnableFlags = GL_FALSE; - ctx->Scissor.ScissorArray[0].X = 0; - ctx->Scissor.ScissorArray[0].Y = 0; - ctx->Scissor.ScissorArray[0].Width = 0; - ctx->Scissor.ScissorArray[0].Height = 0; + set_scissor_no_notify(ctx, 0, 0, 0, 0, 0); } -- 1.8.1.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 17/40] mesa: Initialize all the viewports
From: Ian Romanick v2: Use MAX_VIEWPORTS instead of ctx->Const.MaxViewports because the driver may not set ctx->Const.MaxViewports yet. Signed-off-by: Ian Romanick --- src/mesa/main/context.c | 10 +- src/mesa/main/viewport.c | 33 + 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index f840918..d4d0653 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1434,11 +1434,19 @@ void _mesa_check_init_viewport(struct gl_context *ctx, GLuint width, GLuint height) { if (!ctx->ViewportInitialized && width > 0 && height > 0) { + unsigned i; + /* Note: set flag here, before calling _mesa_set_viewport(), to prevent * potential infinite recursion. */ ctx->ViewportInitialized = GL_TRUE; - _mesa_set_viewport(ctx, 0, 0, 0, width, height); + + /* Note: ctx->Const.MaxViewports may not have been set by the driver + * yet, so just initialize all of them. + */ + for (i = 0; i < MAX_VIEWPORTS; i++) { + _mesa_set_viewport(ctx, i, 0, 0, width, height); + } _mesa_set_scissor(ctx, 0, 0, 0, width, height); } } diff --git a/src/mesa/main/viewport.c b/src/mesa/main/viewport.c index ac891c8..cc031b0 100644 --- a/src/mesa/main/viewport.c +++ b/src/mesa/main/viewport.c @@ -197,18 +197,24 @@ _mesa_DepthRangef(GLclampf nearval, GLclampf farval) void _mesa_init_viewport(struct gl_context *ctx) { GLfloat depthMax = 65535.0F; /* sorf of arbitrary */ + unsigned i; - /* Viewport group */ - ctx->ViewportArray[0].X = 0; - ctx->ViewportArray[0].Y = 0; - ctx->ViewportArray[0].Width = 0; - ctx->ViewportArray[0].Height = 0; - ctx->ViewportArray[0].Near = 0.0; - ctx->ViewportArray[0].Far = 1.0; - _math_matrix_ctr(&ctx->ViewportArray[0]._WindowMap); - - _math_matrix_viewport(&ctx->ViewportArray[0]._WindowMap, 0, 0, 0, 0, - 0.0F, 1.0F, depthMax); + /* Note: ctx->Const.MaxViewports may not have been set by the driver yet, +* so just initialize all of them. +*/ + for (i = 0; i < MAX_VIEWPORTS; i++) { + /* Viewport group */ + ctx->ViewportArray[i].X = 0; + ctx->ViewportArray[i].Y = 0; + ctx->ViewportArray[i].Width = 0; + ctx->ViewportArray[i].Height = 0; + ctx->ViewportArray[i].Near = 0.0; + ctx->ViewportArray[i].Far = 1.0; + _math_matrix_ctr(&ctx->ViewportArray[i]._WindowMap); + + _math_matrix_viewport(&ctx->ViewportArray[i]._WindowMap, 0, 0, 0, 0, +0.0F, 1.0F, depthMax); + } } @@ -218,6 +224,9 @@ void _mesa_init_viewport(struct gl_context *ctx) */ void _mesa_free_viewport_data(struct gl_context *ctx) { - _math_matrix_dtr(&ctx->ViewportArray[0]._WindowMap); + unsigned i; + + for (i = 0; i < MAX_VIEWPORTS; i++) + _math_matrix_dtr(&ctx->ViewportArray[i]._WindowMap); } -- 1.8.1.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 21/40] mesa: Set all scissor rects
From: Ian Romanick In _mesa_Scissor, make sure that ctx->Driver.Scissor is only called once instead of once per scissor rectangle. v2: Use MAX_VIEWPORTS instead of ctx->Const.MaxViewports because the driver may not set ctx->Const.MaxViewports yet. Signed-off-by: Ian Romanick --- src/mesa/main/context.c | 2 +- src/mesa/main/scissor.c | 30 +++--- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index d4d0653..9e6ed84 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1446,8 +1446,8 @@ _mesa_check_init_viewport(struct gl_context *ctx, GLuint width, GLuint height) */ for (i = 0; i < MAX_VIEWPORTS; i++) { _mesa_set_viewport(ctx, i, 0, 0, width, height); + _mesa_set_scissor(ctx, i, 0, 0, width, height); } - _mesa_set_scissor(ctx, 0, 0, 0, width, height); } } diff --git a/src/mesa/main/scissor.c b/src/mesa/main/scissor.c index 9266f1e..9caac2e 100644 --- a/src/mesa/main/scissor.c +++ b/src/mesa/main/scissor.c @@ -60,6 +60,7 @@ set_scissor_no_notify(struct gl_context *ctx, unsigned idx, void GLAPIENTRY _mesa_Scissor( GLint x, GLint y, GLsizei width, GLsizei height ) { + unsigned i; GET_CURRENT_CONTEXT(ctx); if (MESA_VERBOSE & VERBOSE_API) @@ -70,7 +71,23 @@ _mesa_Scissor( GLint x, GLint y, GLsizei width, GLsizei height ) return; } - _mesa_set_scissor(ctx, 0, x, y, width, height); + /* The GL_ARB_viewport_array spec says: +* +* "Scissor sets the scissor rectangle for all viewports to the same +* values and is equivalent (assuming no errors are generated) to: +* +* for (uint i = 0; i < MAX_VIEWPORTS; i++) { +* ScissorIndexed(i, left, bottom, width, height); +* }" +* +* Set the scissor rectangle for all of the viewports supported by the +* implementation, but only signal the driver once at the end. +*/ + for (i = 0; i < ctx->Const.MaxViewports; i++) + set_scissor_no_notify(ctx, i, x, y, width, height); + + if (ctx->Driver.Scissor) + ctx->Driver.Scissor(ctx); } @@ -105,7 +122,14 @@ _mesa_set_scissor(struct gl_context *ctx, unsigned idx, void _mesa_init_scissor(struct gl_context *ctx) { + unsigned i; + /* Scissor group */ - ctx->Scissor.EnableFlags = GL_FALSE; - set_scissor_no_notify(ctx, 0, 0, 0, 0, 0); + ctx->Scissor.EnableFlags = 0; + + /* Note: ctx->Const.MaxViewports may not have been set by the driver yet, +* so just initialize all of them. +*/ + for (i = 0; i < MAX_VIEWPORTS; i++) + set_scissor_no_notify(ctx, i, 0, 0, 0, 0); } -- 1.8.1.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 38/40] i965: Consider all viewports before enabling guardband clipping
From: Ian Romanick Signed-off-by: Ian Romanick --- src/mesa/drivers/dri/i965/gen6_clip_state.c | 14 +- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/mesa/drivers/dri/i965/gen6_clip_state.c b/src/mesa/drivers/dri/i965/gen6_clip_state.c index 3499e37..ed7afd7 100644 --- a/src/mesa/drivers/dri/i965/gen6_clip_state.c +++ b/src/mesa/drivers/dri/i965/gen6_clip_state.c @@ -96,11 +96,15 @@ upload_clip_state(struct brw_context *brw) dw2 |= (ctx->Transform.ClipPlanesEnabled << GEN6_USER_CLIP_CLIP_DISTANCES_SHIFT); - if (ctx->ViewportArray[0].X == 0 && - ctx->ViewportArray[0].Y == 0 && - ctx->ViewportArray[0].Width == (float) fb->Width && - ctx->ViewportArray[0].Height == (float) fb->Height) { - dw2 |= GEN6_CLIP_GB_TEST; + dw2 |= GEN6_CLIP_GB_TEST; + for (unsigned i = 0; i < ctx->Const.MaxViewports; i++) { + if (ctx->ViewportArray[i].X != 0 || + ctx->ViewportArray[i].Y != 0 || + ctx->ViewportArray[i].Width != (float) fb->Width || + ctx->ViewportArray[i].Height != (float) fb->Height) { + dw2 &= ~GEN6_CLIP_GB_TEST; + break; + } } /* BRW_NEW_RASTERIZER_DISCARD */ -- 1.8.1.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 34/40] i965: Set all the supported viewports for GEN7
From: Ian Romanick Currently MaxViewports is still 1, so this won't affect any change. Signed-off-by: Ian Romanick --- src/mesa/drivers/dri/i965/brw_cc.c | 21 + src/mesa/drivers/dri/i965/brw_defines.h | 1 + src/mesa/drivers/dri/i965/gen7_viewport_state.c | 63 + 3 files changed, 48 insertions(+), 37 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_cc.c b/src/mesa/drivers/dri/i965/brw_cc.c index f6de89e..3712054 100644 --- a/src/mesa/drivers/dri/i965/brw_cc.c +++ b/src/mesa/drivers/dri/i965/brw_cc.c @@ -45,16 +45,21 @@ brw_upload_cc_vp(struct brw_context *brw) struct brw_cc_viewport *ccv; ccv = brw_state_batch(brw, AUB_TRACE_CC_VP_STATE, -sizeof(*ccv), 32, &brw->cc.vp_offset); +sizeof(*ccv) * ctx->Const.MaxViewports, 32, + &brw->cc.vp_offset); /* _NEW_TRANSFORM */ - if (ctx->Transform.DepthClamp) { - /* _NEW_VIEWPORT */ - ccv->min_depth = MIN2(ctx->ViewportArray[0].Near, ctx->ViewportArray[0].Far); - ccv->max_depth = MAX2(ctx->ViewportArray[0].Near, ctx->ViewportArray[0].Far); - } else { - ccv->min_depth = 0.0; - ccv->max_depth = 1.0; + for (unsigned i = 0; i < ctx->Const.MaxViewports; i++) { + if (ctx->Transform.DepthClamp) { + /* _NEW_VIEWPORT */ + ccv[i].min_depth = MIN2(ctx->ViewportArray[i].Near, + ctx->ViewportArray[i].Far); + ccv[i].max_depth = MAX2(ctx->ViewportArray[i].Near, + ctx->ViewportArray[i].Far); + } else { + ccv[i].min_depth = 0.0; + ccv[i].max_depth = 1.0; + } } brw->state.dirty.cache |= CACHE_NEW_CC_VP; diff --git a/src/mesa/drivers/dri/i965/brw_defines.h b/src/mesa/drivers/dri/i965/brw_defines.h index 2eb31e7..240f946 100644 --- a/src/mesa/drivers/dri/i965/brw_defines.h +++ b/src/mesa/drivers/dri/i965/brw_defines.h @@ -1421,6 +1421,7 @@ enum brw_message_target { # define GEN6_CC_VIEWPORT_MODIFY (1 << 12) # define GEN6_SF_VIEWPORT_MODIFY (1 << 11) # define GEN6_CLIP_VIEWPORT_MODIFY (1 << 10) +# define GEN7_NUM_VIEWPORTS16 #define _3DSTATE_VIEWPORT_STATE_POINTERS_CC0x7823 /* GEN7+ */ #define _3DSTATE_VIEWPORT_STATE_POINTERS_SF_CL 0x7821 /* GEN7+ */ diff --git a/src/mesa/drivers/dri/i965/gen7_viewport_state.c b/src/mesa/drivers/dri/i965/gen7_viewport_state.c index ed7d8c9..9e23505 100644 --- a/src/mesa/drivers/dri/i965/gen7_viewport_state.c +++ b/src/mesa/drivers/dri/i965/gen7_viewport_state.c @@ -34,34 +34,14 @@ gen7_upload_sf_clip_viewport(struct brw_context *brw) const GLfloat depth_scale = 1.0F / ctx->DrawBuffer->_DepthMaxF; GLfloat y_scale, y_bias; const bool render_to_fbo = _mesa_is_user_fbo(ctx->DrawBuffer); - const GLfloat *v = ctx->ViewportArray[0]._WindowMap.m; struct gen7_sf_clip_viewport *vp; vp = brw_state_batch(brw, AUB_TRACE_SF_VP_STATE, - sizeof(*vp), 64, &brw->sf.vp_offset); +sizeof(*vp) * ctx->Const.MaxViewports, 64, +&brw->sf.vp_offset); /* Also assign to clip.vp_offset in case something uses it. */ brw->clip.vp_offset = brw->sf.vp_offset; - /* According to the "Vertex X,Y Clamping and Quantization" section of the -* Strips and Fans documentation, objects must not have a screen-space -* extents of over 8192 pixels, or they may be mis-rasterized. The maximum -* screen space coordinates of a small object may larger, but we have no -* way to enforce the object size other than through clipping. -* -* If you're surprised that we set clip to -gbx to +gbx and it seems like -* we'll end up with 16384 wide, note that for a 8192-wide render target, -* we'll end up with a normal (-1, 1) clip volume that just covers the -* drawable. -*/ - const float maximum_guardband_extent = 8192; - float gbx = maximum_guardband_extent / ctx->ViewportArray[0].Width; - float gby = maximum_guardband_extent / ctx->ViewportArray[0].Height; - - vp->guardband.xmin = -gbx; - vp->guardband.xmax = gbx; - vp->guardband.ymin = -gby; - vp->guardband.ymax = gby; - /* _NEW_BUFFERS */ if (render_to_fbo) { y_scale = 1.0; @@ -71,13 +51,38 @@ gen7_upload_sf_clip_viewport(struct brw_context *brw) y_bias = ctx->DrawBuffer->Height; } - /* _NEW_VIEWPORT */ - vp->viewport.m00 = v[MAT_SX]; - vp->viewport.m11 = v[MAT_SY] * y_scale; - vp->viewport.m22 = v[MAT_SZ] * depth_scale; - vp->viewport.m30 = v[MAT_TX]; - vp->viewport.m31 = v[MAT_TY] * y_scale + y_bias; - vp->viewport.m32 = v[MAT_TZ] * depth_scale; + for (unsigned i = 0; i < ctx->Const.MaxViewports; i++) { + const GLfloat *const v = ctx->ViewportArray[i]._WindowMap.m; + + /* According to the "Vertex X,Y Clamping and Quantization" section o
[Mesa-dev] [PATCH 23/40] mesa: Change parameter to _mesa_set_viewport to float
From: Ian Romanick This matches the expectations of GL_ARB_viewport_array and the storage type where the values will land. Signed-off-by: Ian Romanick --- src/mesa/main/viewport.c | 13 +++-- src/mesa/main/viewport.h | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/mesa/main/viewport.c b/src/mesa/main/viewport.c index 13b469a..3cd171e 100644 --- a/src/mesa/main/viewport.c +++ b/src/mesa/main/viewport.c @@ -35,12 +35,13 @@ #include "viewport.h" static void -set_viewport_no_notify(struct gl_context *ctx, unsigned idx, GLint x, GLint y, - GLsizei width, GLsizei height) +set_viewport_no_notify(struct gl_context *ctx, unsigned idx, + GLfloat x, GLfloat y, + GLfloat width, GLfloat height) { /* clamp width and height to the implementation dependent range */ - width = MIN2(width, (GLsizei) ctx->Const.MaxViewportWidth); - height = MIN2(height, (GLsizei) ctx->Const.MaxViewportHeight); + width = MIN2(width, (GLfloat) ctx->Const.MaxViewportWidth); + height = MIN2(height, (GLfloat) ctx->Const.MaxViewportHeight); ctx->ViewportArray[idx].X = x; ctx->ViewportArray[idx].Width = width; @@ -121,8 +122,8 @@ _mesa_Viewport(GLint x, GLint y, GLsizei width, GLsizei height) * \param height height of the viewport rectangle. */ void -_mesa_set_viewport(struct gl_context *ctx, unsigned idx, GLint x, GLint y, -GLsizei width, GLsizei height) +_mesa_set_viewport(struct gl_context *ctx, unsigned idx, GLfloat x, GLfloat y, +GLfloat width, GLfloat height) { set_viewport_no_notify(ctx, idx, x, y, width, height); diff --git a/src/mesa/main/viewport.h b/src/mesa/main/viewport.h index 44bca1b..6e4c738 100644 --- a/src/mesa/main/viewport.h +++ b/src/mesa/main/viewport.h @@ -36,8 +36,8 @@ _mesa_Viewport(GLint x, GLint y, GLsizei width, GLsizei height); extern void -_mesa_set_viewport(struct gl_context *ctx, unsigned idx, GLint x, GLint y, - GLsizei width, GLsizei height); +_mesa_set_viewport(struct gl_context *ctx, unsigned idx, GLfloat x, GLfloat y, + GLfloat width, GLfloat height); extern void GLAPIENTRY -- 1.8.1.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 40/40] docs: Note that GL_ARB_viewport_array is done on i965
From: Ian Romanick At least for GEN7+, anyway. Signed-off-by: Ian Romanick --- docs/GL3.txt| 2 +- docs/relnotes/10.1.html | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/GL3.txt b/docs/GL3.txt index f98a54a..eda44a3 100644 --- a/docs/GL3.txt +++ b/docs/GL3.txt @@ -120,7 +120,7 @@ GL 4.1: GL_ARB_separate_shader_objects some infrastructure done GL_ARB_shader_precision not started GL_ARB_vertex_attrib_64bit not started - GL_ARB_viewport_arraynot started + GL_ARB_viewport_arrayDONE (i965) GL 4.2: diff --git a/docs/relnotes/10.1.html b/docs/relnotes/10.1.html index 1089c71..0c90b21 100644 --- a/docs/relnotes/10.1.html +++ b/docs/relnotes/10.1.html @@ -46,6 +46,7 @@ Note: some of the new features are only available with certain drivers. GL_ARB_draw_indirect on i965. GL_ARB_clear_buffer_object +GL_ARB_viewport_array on i965. GL_AMD_shader_trinary_minmax. -- 1.8.1.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 0/40] Implement GL_ARB_viewport_array
(Sent after the fact... sorry.) This represents a medling of GL_ARB_viewport_array code written by Courtney Goeltzenleuchter (LunarG) and myself over the last couple months. It implements all of the core Mesa code for the extension and enables it in the i965 driver. Like layered rendering, this extension depends on geometry shaders, so it is currently only enabled in core profiles. There is one bit of core Mesa code that behaves differently when the extension is enabled (see "mesa: Add new viewport and depth-range entry points for GL_ARB_viewport_array"), so the enable flag is only set by the i965 driver in core profile. When multiple viewports, depth ranges, or scissor rectangles are updated in one API call, the driver is only notified once, at the end. There is also no per-viewport "dirty" tracking. The i965 driver has to send all of the data when anything changes, so it didn't need that feature. If some other hardware could use per-viewport dirty tracking as an optimization, it would be trivial to add that tracking to the gl_context. Then the driver state update (or dd_function_table::Viewport) function could consult the appropriate dirty bits before doing the update. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 24/40] mesa: Add new get entrypoints for ARB_viewport_array
From: Courtney Goeltzenleuchter v2 (idr): Fix several "comparison between signed and unsigned integer expressions" warnings. --- src/mesa/main/get.c | 189 src/mesa/main/get.h | 6 ++ 2 files changed, 195 insertions(+) diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index 99b91d0..811e283 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -1719,6 +1719,31 @@ find_value_indexed(const char *func, GLenum pname, GLuint index, union value *v) v->value_int_4[3] = ctx->Color.ColorMask[index][ACOMP] ? 1 : 0; return TYPE_INT_4; + case GL_SCISSOR_BOX: + if (index >= ctx->Const.MaxViewports) + goto invalid_value; + v->value_int_4[0] = ctx->Scissor.ScissorArray[index].X; + v->value_int_4[1] = ctx->Scissor.ScissorArray[index].Y; + v->value_int_4[2] = ctx->Scissor.ScissorArray[index].Width; + v->value_int_4[3] = ctx->Scissor.ScissorArray[index].Height; + return TYPE_INT_4; + + case GL_VIEWPORT: + if (index >= ctx->Const.MaxViewports) + goto invalid_value; + v->value_float_4[0] = ctx->ViewportArray[index].X; + v->value_float_4[1] = ctx->ViewportArray[index].Y; + v->value_float_4[2] = ctx->ViewportArray[index].Width; + v->value_float_4[3] = ctx->ViewportArray[index].Height; + return TYPE_FLOAT_4; + + case GL_DEPTH_RANGE: + if (index >= ctx->Const.MaxViewports) + goto invalid_value; + v->value_double_2[0] = ctx->ViewportArray[index].Near; + v->value_double_2[1] = ctx->ViewportArray[index].Far; + return TYPE_DOUBLEN_2; + case GL_TRANSFORM_FEEDBACK_BUFFER_START: if (index >= ctx->Const.MaxTransformFeedbackBuffers) goto invalid_value; @@ -1869,6 +1894,26 @@ _mesa_GetIntegeri_v( GLenum pname, GLuint index, GLint *params ) find_value_indexed("glGetIntegeri_v", pname, index, &v); switch (type) { + case TYPE_FLOAT_4: + case TYPE_FLOATN_4: + params[3] = IROUND(v.value_float_4[3]); + case TYPE_FLOAT_3: + case TYPE_FLOATN_3: + params[2] = IROUND(v.value_float_4[2]); + case TYPE_FLOAT_2: + case TYPE_FLOATN_2: + params[1] = IROUND(v.value_float_4[1]); + case TYPE_FLOAT: + case TYPE_FLOATN: + params[0] = IROUND(v.value_float_4[0]); + break; + + case TYPE_DOUBLEN_2: + params[1] = IROUND(v.value_double_2[1]); + case TYPE_DOUBLEN: + params[0] = IROUND(v.value_double_2[0]); + break; + case TYPE_INT: params[0] = v.value_int; break; @@ -1912,6 +1957,150 @@ _mesa_GetInteger64i_v( GLenum pname, GLuint index, GLint64 *params ) } void GLAPIENTRY +_mesa_GetFloati_v(GLenum pname, GLuint index, GLfloat *params) +{ + int i; + GLmatrix *m; + union value v; + enum value_type type = + find_value_indexed("glGetFloati_v", pname, index, &v); + + switch (type) { + case TYPE_FLOAT_4: + case TYPE_FLOATN_4: + params[3] = v.value_float_4[3]; + case TYPE_FLOAT_3: + case TYPE_FLOATN_3: + params[2] = v.value_float_4[2]; + case TYPE_FLOAT_2: + case TYPE_FLOATN_2: + params[1] = v.value_float_4[1]; + case TYPE_FLOAT: + case TYPE_FLOATN: + params[0] = v.value_float_4[0]; + break; + + case TYPE_DOUBLEN_2: + params[1] = (GLfloat) v.value_double_2[1]; + case TYPE_DOUBLEN: + params[0] = (GLfloat) v.value_double_2[0]; + break; + + case TYPE_INT_4: + params[3] = (GLfloat) v.value_int_4[3]; + case TYPE_INT_3: + params[2] = (GLfloat) v.value_int_4[2]; + case TYPE_INT_2: + case TYPE_ENUM_2: + params[1] = (GLfloat) v.value_int_4[1]; + case TYPE_INT: + case TYPE_ENUM: + params[0] = (GLfloat) v.value_int_4[0]; + break; + + case TYPE_INT_N: + for (i = 0; i < v.value_int_n.n; i++) +params[i] = INT_TO_FLOAT(v.value_int_n.ints[i]); + break; + + case TYPE_INT64: + params[0] = (GLfloat) v.value_int64; + break; + + case TYPE_BOOLEAN: + params[0] = BOOLEAN_TO_FLOAT(v.value_bool); + break; + + case TYPE_MATRIX: + m = *(GLmatrix **) &v; + for (i = 0; i < 16; i++) +params[i] = m->m[i]; + break; + + case TYPE_MATRIX_T: + m = *(GLmatrix **) &v; + for (i = 0; i < 16; i++) +params[i] = m->m[transpose[i]]; + break; + + default: + ; + } +} + +void GLAPIENTRY +_mesa_GetDoublei_v(GLenum pname, GLuint index, GLdouble *params) +{ + int i; + GLmatrix *m; + union value v; + enum value_type type = + find_value_indexed("glGetDoublei_v", pname, index, &v); + + switch (type) { + case TYPE_FLOAT_4: + case TYPE_FLOATN_4: + params[3] = (GLdouble) v.value_float_4[3]; + case TYPE_FLOAT_3: + case TYPE_FLOATN_3: + params[2] = (GLdouble) v.value_float_4[2]; + case TYPE_FLOAT_2: + case TYPE_FLOATN_2: + params[1] = (GLdouble) v.value_float_4[1]; + case TYPE_FLOAT: + case TYPE_FLOATN: + params[0] = (GLdouble) v.value_float_4[0]; + brea
[Mesa-dev] [PATCH 02/40] radeon: Remove dead code
From: Ian Romanick A future patch will rename some of the fields of gl_viewport_attrib, and I don't want to update dead code that I can't test. Signed-off-by: Ian Romanick Cc: Dave Airlie --- src/mesa/drivers/dri/radeon/radeon_common.c | 9 - 1 file changed, 9 deletions(-) diff --git a/src/mesa/drivers/dri/radeon/radeon_common.c b/src/mesa/drivers/dri/radeon/radeon_common.c index 7be0ba7..d083e5b 100644 --- a/src/mesa/drivers/dri/radeon/radeon_common.c +++ b/src/mesa/drivers/dri/radeon/radeon_common.c @@ -317,15 +317,6 @@ void radeon_draw_buffer(struct gl_context *ctx, struct gl_framebuffer *fb) _mesa_reference_renderbuffer(&radeon->state.color.rb, &rrbColor->base.Base); radeon->state.color.draw_offset = offset; -#if 0 - /* update viewport since it depends on window size */ - if (ctx->Driver.Viewport) { - ctx->Driver.Viewport(ctx, ctx->Viewport.X, ctx->Viewport.Y, -ctx->Viewport.Width, ctx->Viewport.Height); - } else { - - } -#endif ctx->NewState |= _NEW_VIEWPORT; /* Set state we know depends on drawable parameters: -- 1.8.1.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 4/5] glsl: Vectorize multiple scalar assignments
On 01/10/2014 03:27 PM, Matt Turner wrote: > On Thu, Jan 9, 2014 at 11:28 AM, Ian Romanick wrote: >> On 01/08/2014 12:43 PM, Matt Turner wrote: >>> +/** >>> + * \file opt_vectorize.cpp >>> + * >>> + * Combines scalar assignments of the same expression (modulo swizzle) to >>> + * multiple channels of the same variable into a single vectorized >>> expression >>> + * and assignment. >>> + * >>> + * Many generated shaders contain scalarized code. That is, they contain >>> + * >>> + * r1.x = log2(v0.x); >>> + * r1.y = log2(v0.y); >>> + * r1.z = log2(v0.z); >>> + * >>> + * rather than >>> + * >>> + * r1.xyz = log2(v0.xyz); >>> + * >>> + * We look for consecutive assignments of the same expression (modulo >>> swizzle) >>> + * to each channel of the same variable. >>> + * >>> + * For instance, we want to convert these three scalar operations >>> + * >>> + * (assign (x) (var_ref r1) (expression float log2 (swiz x (var_ref v0 >>> + * (assign (y) (var_ref r1) (expression float log2 (swiz y (var_ref v0 >>> + * (assign (z) (var_ref r1) (expression float log2 (swiz z (var_ref v0 >>> + * >>> + * into a single vector operation >>> + * >>> + * (assign (xyz) (var_ref r1) (expression vec3 log2 (swiz xyz (var_ref >>> v0 >> >> I think it's worth adding a note that this pass only attempts to combine >> assignments that are sequential. > > That comment block already says that: > > + * We look for consecutive assignments of the same expression (modulo > swizzle) > + * to each channel of the same variable. I guess I overlooked that word. :( > I'll change the first comment to use the word consecutive. > >> The above example gets fully >> vectorized, but this sequence would not: >> >> (assign (x) (var_ref r1) (expression float log2 (swiz x (var_ref v0 >> (assign (x) (var_ref r2) (expression float log2 (swiz y (var_ref v0 >> (assign (y) (var_ref r1) (expression float log2 (swiz z (var_ref v0 >> (assign (y) (var_ref r2) (expression float log2 (swiz w (var_ref v0 >> >> I think this will also break on code like >> >> (assign (x) (var_ref r1) (expression float log2 (swiz w (var_ref r1 >> (assign (y) (var_ref r1) (expression float log2 (swiz z (var_ref r1 >> # r1.xy have different values now. >> (assign (z) (var_ref r1) (expression float log2 (swiz y (var_ref r1 >> (assign (w) (var_ref r1) (expression float log2 (swiz x (var_ref r1 >> >> Maybe just skip assignments where the LHS also appears in the RHS for >> now? Or does the check write_mask_matches_swizzle take care of this? > > It won't break because the code rejects expressions that contain > swizzles that don't match the LHS's write mask. See the call to > write_mask_matches_swizzle(). > > The good thing about this is that we can combine expressions that use > the LHS, like > > (assign (x) (var_ref r1) (expression float log2 (swiz x (var_ref r1 > (assign (y) (var_ref r1) (expression float log2 (swiz y (var_ref r1 Okay... that's what I thought, but I wanted to be sure. With the slight tweak to the header comment (that you mention above), patches 2, 4, and 5 are Reviewed-by: Ian Romanick This means we also won't vectorize things like (assign (x) (var_ref r1) (expression float * (swiz x (var_ref r1)) (swiz x (var_ref r2 (assign (y) (var_ref r1) (expression float * (swiz y (var_ref r1)) (swiz x (var_ref r2 (assign (z) (var_ref r1) (expression float * (swiz z (var_ref r1)) (swiz x (var_ref r2 (assign (w) (var_ref r1) (expression float * (swiz w (var_ref r1)) (swiz x (var_ref r2 Right? If there are occurances of that pattern in shaderdb, that may be an opportunity for some follow-on work... ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 10/40] mesa: Update viewport state for viewport_array
On 01/10/2014 05:40 PM, Ian Romanick wrote: > From: Courtney Goeltzenleuchter > > Include DepthRange as well since it's state is lumped together with > viewport state. Updates all the drivers that reference Viewport state > in gl_context. > > v2 (idr): Rebase fixes. Also, don't have meta call _mesa_Viewport. We > don't want the extra validation overhead, and meta will only ever need > to change viewport 0 (while _mesa_Viewport updates all of them). > > v3 (idr): Remove spurious casts to float in _mesa_DepthRange. > gl_viewport_attrib::Near and gl_viewport_attrib::Far are double now, > just like nearval and farval. As result, the casts aren't just > unnecessary, they're wrong. > > Signed-off-by: Ian Romanick [snip] > diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h > index da65d15..305b752 100644 > --- a/src/mesa/main/mtypes.h > +++ b/src/mesa/main/mtypes.h > @@ -1429,9 +1429,9 @@ struct gl_transform_attrib > */ > struct gl_viewport_attrib > { > - GLint X, Y; /**< position */ > - GLsizei Width, Height;/**< size */ > - GLfloat Near, Far;/**< Depth buffer range */ > + GLfloat X, Y;/**< position */ > + GLfloat Width, Height;/**< size */ > + GLdouble Near, Far; /**< Depth buffer range */ > GLmatrix _WindowMap; /**< Mapping transformation as a > matrix. */ > }; > > @@ -3884,7 +3884,7 @@ struct gl_context > struct gl_stencil_attrib Stencil;/**< Stencil buffer attributes > */ > struct gl_texture_attrib Texture;/**< Texture attributes */ > struct gl_transform_attribTransform; /**< Transformation > attributes */ > - struct gl_viewport_attrib Viewport; /**< Viewport attributes */ > + struct gl_viewport_attrib ViewportArray[MAX_VIEWPORTS]; /**< Viewport > attributes */ > /*@}*/ > > /** \name Client attribute stack */ This patch does four separate things: 1. Converts X/Y from GLint to GLfloat. 2. Converts Width/Height from GLsizei to GLfloat. 3. Converts Near/Far from GLfloat to GLdouble. 4. Converts Viewport to ViewportArray[] Each of those really ought to be a separate patch... ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 4/5] glsl: Vectorize multiple scalar assignments
On Fri, Jan 10, 2014 at 5:53 PM, Ian Romanick wrote: > On 01/10/2014 03:27 PM, Matt Turner wrote: >> On Thu, Jan 9, 2014 at 11:28 AM, Ian Romanick wrote: >>> On 01/08/2014 12:43 PM, Matt Turner wrote: +/** + * \file opt_vectorize.cpp + * + * Combines scalar assignments of the same expression (modulo swizzle) to + * multiple channels of the same variable into a single vectorized expression + * and assignment. + * + * Many generated shaders contain scalarized code. That is, they contain + * + * r1.x = log2(v0.x); + * r1.y = log2(v0.y); + * r1.z = log2(v0.z); + * + * rather than + * + * r1.xyz = log2(v0.xyz); + * + * We look for consecutive assignments of the same expression (modulo swizzle) + * to each channel of the same variable. + * + * For instance, we want to convert these three scalar operations + * + * (assign (x) (var_ref r1) (expression float log2 (swiz x (var_ref v0 + * (assign (y) (var_ref r1) (expression float log2 (swiz y (var_ref v0 + * (assign (z) (var_ref r1) (expression float log2 (swiz z (var_ref v0 + * + * into a single vector operation + * + * (assign (xyz) (var_ref r1) (expression vec3 log2 (swiz xyz (var_ref v0 >>> >>> I think it's worth adding a note that this pass only attempts to combine >>> assignments that are sequential. >> >> That comment block already says that: >> >> + * We look for consecutive assignments of the same expression (modulo >> swizzle) >> + * to each channel of the same variable. > > I guess I overlooked that word. :( > >> I'll change the first comment to use the word consecutive. >> >>> The above example gets fully >>> vectorized, but this sequence would not: >>> >>> (assign (x) (var_ref r1) (expression float log2 (swiz x (var_ref v0 >>> (assign (x) (var_ref r2) (expression float log2 (swiz y (var_ref v0 >>> (assign (y) (var_ref r1) (expression float log2 (swiz z (var_ref v0 >>> (assign (y) (var_ref r2) (expression float log2 (swiz w (var_ref v0 >>> >>> I think this will also break on code like >>> >>> (assign (x) (var_ref r1) (expression float log2 (swiz w (var_ref r1 >>> (assign (y) (var_ref r1) (expression float log2 (swiz z (var_ref r1 >>> # r1.xy have different values now. >>> (assign (z) (var_ref r1) (expression float log2 (swiz y (var_ref r1 >>> (assign (w) (var_ref r1) (expression float log2 (swiz x (var_ref r1 >>> >>> Maybe just skip assignments where the LHS also appears in the RHS for >>> now? Or does the check write_mask_matches_swizzle take care of this? >> >> It won't break because the code rejects expressions that contain >> swizzles that don't match the LHS's write mask. See the call to >> write_mask_matches_swizzle(). >> >> The good thing about this is that we can combine expressions that use >> the LHS, like >> >> (assign (x) (var_ref r1) (expression float log2 (swiz x (var_ref r1 >> (assign (y) (var_ref r1) (expression float log2 (swiz y (var_ref r1 > > Okay... that's what I thought, but I wanted to be sure. > > With the slight tweak to the header comment (that you mention above), > patches 2, 4, and 5 are > > Reviewed-by: Ian Romanick Cool, thanks. I'll fix up patch 3 and send it back out. > This means we also won't vectorize things like > > (assign (x) (var_ref r1) (expression float * (swiz x (var_ref r1)) (swiz x > (var_ref r2 > (assign (y) (var_ref r1) (expression float * (swiz y (var_ref r1)) (swiz x > (var_ref r2 > (assign (z) (var_ref r1) (expression float * (swiz z (var_ref r1)) (swiz x > (var_ref r2 > (assign (w) (var_ref r1) (expression float * (swiz w (var_ref r1)) (swiz x > (var_ref r2 > > Right? If there are occurances of that pattern in shaderdb, that may > be an opportunity for some follow-on work... That's right. I think the best way to find out if that exists in the wild is to implement it in the compiler and see if anything changes. :) ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 09/16] i965/fs: Calculate interference better in register_coalesce.
On Fri, Jan 10, 2014 at 5:19 PM, Jordan Justen wrote: > On Thu, Dec 19, 2013 at 1:40 PM, Matt Turner wrote: >> Previously we simply considered two registers whose live ranges >> overlapped to interfere. Cases such as >> >>set A -- >>... | >>mov B, A --| >>... | B | A >>use B --| >>... | >>use A -- >> >> would be considered to interfere, even though B is an unmodified copy of >> A whose live range fit wholly inside that of A. >> >> If no writes to A or B occur between the mov B, A and the use of B then >> we can safely coalesce them. >> >> Instead of removing MOV instructions, we make them NOPs and remove them >> at once after the main pass is finished in order to avoid recomputing >> live intervals (which are needed to perform the previous step). >> >> total instructions in shared programs: 1543768 -> 1513077 (-1.99%) >> instructions in affected programs: 951563 -> 920872 (-3.23%) >> GAINED:46 >> LOST: 22 >> --- >> src/mesa/drivers/dri/i965/brw_fs.cpp | 69 >> >> 1 file changed, 62 insertions(+), 7 deletions(-) >> >> diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp >> b/src/mesa/drivers/dri/i965/brw_fs.cpp >> index e4ac0a5..ad56b87 100644 >> --- a/src/mesa/drivers/dri/i965/brw_fs.cpp >> +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp >> @@ -2273,7 +2273,7 @@ fs_visitor::register_coalesce() >> int last_use[MAX_SAMPLER_MESSAGE_SIZE]; >> int next_ip = 0; >> >> - foreach_list_safe(node, &this->instructions) { >> + foreach_list(node, &this->instructions) { >>fs_inst *inst = (fs_inst *)node; >> >>int ip = next_ip; >> @@ -2299,8 +2299,39 @@ fs_visitor::register_coalesce() >>int var_to = live_intervals->var_from_reg(&inst->dst); >> >>if (live_intervals->vars_interfere(var_from, var_to) && >> - !inst->dst.equals(inst->src[0])) >> - continue; >> + !inst->dst.equals(inst->src[0])) { >> + >> + if (live_intervals->end[var_to] > live_intervals->end[var_from]) >> +continue; >> + >> + bool overwritten = false; >> + int scan_ip = -1; >> + >> + foreach_list(n, &this->instructions) { >> + fs_inst *scan_inst = (fs_inst *)n; >> +scan_ip++; >> + >> +if (scan_inst->is_control_flow()) { >> + overwritten = true; >> + break; >> +} >> + >> +if (scan_ip <= live_intervals->start[var_to]) >> + continue; >> + >> +if (scan_ip > live_intervals->end[var_to]) >> + break; >> + >> +if (scan_inst->dst.equals(inst->dst) || >> +scan_inst->dst.equals(inst->src[0])) { >> + overwritten = true; >> + break; >> +} >> + } >> + >> + if (overwritten) >> +continue; >> + } >> >>if (reg_from != inst->src[0].reg) { >> reg_from = inst->src[0].reg; >> @@ -2342,9 +2373,18 @@ fs_visitor::register_coalesce() >>if (live_channels_remaining) >> continue; >> >> + bool removed = false; >>for (int i = 0; i < src_size; i++) { >> - if (mov[i]) >> -mov[i]->remove(); >> + if (mov[i]) { >> +removed = true; >> + >> +mov[i]->opcode = BRW_OPCODE_NOP; >> +mov[i]->conditional_mod = BRW_CONDITIONAL_NONE; > > Is conditional_mod == BRW_CONDITIONAL_NONE something we should look > for before considering coalescing a mov? I don't actually know what a mov with a conditional mod would do, and we don't emit a single one in all of shader-db, but it seems like we should be considering predication. >> +mov[i]->dst = reg_undef; >> +mov[i]->src[0] = reg_undef; >> +mov[i]->src[1] = reg_undef; >> +mov[i]->src[2] = reg_undef; >> + } >>} >> >>foreach_list(node, &this->instructions) { >> @@ -2366,11 +2406,26 @@ fs_visitor::register_coalesce() >> scan_inst->src[j].reg_offset = reg_to_offset[i]; >>} >> } >> - >> - progress = true; >> } >> } >>} >> + >> + if (removed) { >> + live_intervals->start[var_to] = MIN2(live_intervals->start[var_to], >> + >> live_intervals->start[var_from]); >> + live_intervals->end[var_to] = MAX2(live_intervals->end[var_to], >> +live_intervals->end[var_from]); >> + reg_from = -1; > > Do you think these are what lead to the lost programs? I don't think so. > I haven't been able to determine why they are needed starting with this > patch... Consider add vgrf3:F, vgrf1:F, vgrf2:F mov vgrf4:F, vgrf3:F mul vgrf5:F, vgrf5:F, vgrf4:F register coale
Re: [Mesa-dev] [PATCH 32/40] i965: Set the maximum VPIndex
On 01/10/2014 05:40 PM, Ian Romanick wrote: > From: Ian Romanick > > At various stages the hardware clamps the gl_ViewportIndex to these > values. Setting them to zero effectively makes gl_ViewportIndex be > ignored. This is acutally useful in blorp (so that we don't have to > modify all of the viewport / scissor state). > > Signed-off-by: Ian Romanick > --- > src/mesa/drivers/dri/i965/brw_defines.h | 1 + > src/mesa/drivers/dri/i965/brw_gs_state.c| 2 ++ > src/mesa/drivers/dri/i965/gen6_clip_state.c | 3 ++- > 3 files changed, 5 insertions(+), 1 deletion(-) > > diff --git a/src/mesa/drivers/dri/i965/brw_defines.h > b/src/mesa/drivers/dri/i965/brw_defines.h > index 142b2db..2eb31e7 100644 > --- a/src/mesa/drivers/dri/i965/brw_defines.h > +++ b/src/mesa/drivers/dri/i965/brw_defines.h > @@ -1537,6 +1537,7 @@ enum brw_message_target { > # define GEN6_CLIP_MIN_POINT_WIDTH_SHIFT 17 > # define GEN6_CLIP_MAX_POINT_WIDTH_SHIFT 6 > # define GEN6_CLIP_FORCE_ZERO_RTAINDEX (1 << 5) > +# define GEN6_CLIP_MAX_VP_INDEX_MASK (GEN7_NUM_VIEWPORTS-1) This should be: # define GEN6_CLIP_MAX_VP_INDEX_MASK INTEL_MASK(3, 0) > > #define _3DSTATE_SF 0x7813 /* GEN6+ */ > /* DW1 (for gen6) */ > diff --git a/src/mesa/drivers/dri/i965/brw_gs_state.c > b/src/mesa/drivers/dri/i965/brw_gs_state.c > index da8449c..4a2e643 100644 > --- a/src/mesa/drivers/dri/i965/brw_gs_state.c > +++ b/src/mesa/drivers/dri/i965/brw_gs_state.c > @@ -83,6 +83,8 @@ brw_upload_gs_unit(struct brw_context *brw) > if (unlikely(INTEL_DEBUG & DEBUG_STATS)) >gs->thread4.stats_enable = 1; > > + gs->gs6.max_vp_index = brw->ctx.Const.MaxViewports - 1; > + This hunk only applies to Gen4-5, so technically it's not necessary, and I don't know that we'll ever support ARB_viewport_array on that hardware. But I suppose it doesn't hurt either, so you may as well leave it. > brw->state.dirty.cache |= CACHE_NEW_FF_GS_UNIT; > } > > diff --git a/src/mesa/drivers/dri/i965/gen6_clip_state.c > b/src/mesa/drivers/dri/i965/gen6_clip_state.c > index e4dc278..3499e37 100644 > --- a/src/mesa/drivers/dri/i965/gen6_clip_state.c > +++ b/src/mesa/drivers/dri/i965/gen6_clip_state.c > @@ -121,7 +121,8 @@ upload_clip_state(struct brw_context *brw) >dw2); > OUT_BATCH(U_FIXED(0.125, 3) << GEN6_CLIP_MIN_POINT_WIDTH_SHIFT | > U_FIXED(255.875, 3) << GEN6_CLIP_MAX_POINT_WIDTH_SHIFT | > - (fb->MaxNumLayers > 0 ? 0 : GEN6_CLIP_FORCE_ZERO_RTAINDEX)); > + (fb->MaxNumLayers > 0 ? 0 : GEN6_CLIP_FORCE_ZERO_RTAINDEX) | > + ((ctx->Const.MaxViewports - 1) & GEN6_CLIP_MAX_VP_INDEX_MASK)); > ADVANCE_BATCH(); > } > > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 35/40] i965: Consider all scissor rectangles in noop_scissor
On 01/10/2014 05:40 PM, Ian Romanick wrote: > From: Ian Romanick > > v2: Use '& 1' instead of '& i'. Noticed by Ken. > > Signed-off-by: Ian Romanick > --- > src/mesa/drivers/dri/i965/brw_clear.c | 14 ++ > 1 file changed, 10 insertions(+), 4 deletions(-) > > diff --git a/src/mesa/drivers/dri/i965/brw_clear.c > b/src/mesa/drivers/dri/i965/brw_clear.c > index 58fd612..19bde0f 100644 > --- a/src/mesa/drivers/dri/i965/brw_clear.c > +++ b/src/mesa/drivers/dri/i965/brw_clear.c > @@ -83,10 +83,16 @@ debug_mask(const char *name, GLbitfield mask) > static bool > noop_scissor(struct gl_context *ctx, struct gl_framebuffer *fb) > { > - return ctx->Scissor.ScissorArray[0].X <= 0 && > - ctx->Scissor.ScissorArray[0].Y <= 0 && > - ctx->Scissor.ScissorArray[0].Width >= fb->Width && > - ctx->Scissor.ScissorArray[0].Height >= fb->Height; > + for (unsigned i = 0; i < ctx->Const.MaxViewports; i++) { > + if (((ctx->Scissor.EnableFlags >> i) & 1) && I would really prefer to see: if ((ctx->Scissor.EnableFlags & (1 << i)) && ... It's much more common in our code. > + (ctx->Scissor.ScissorArray[i].X > 0 || > + ctx->Scissor.ScissorArray[i].Y > 0 || > + ctx->Scissor.ScissorArray[i].Width < fb->Width || > + ctx->Scissor.ScissorArray[i].Height < fb->Height)) > + return false; > + } > + > + return true; > } > > /** ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 17/42] i965/blorp: reduce the scope of the explicit compression control
On 12/20/2013 06:38 AM, Topi Pohjolainen wrote: > By highlighting these special cases makes it clearer to switch > to the fs-generator as the wider scoped compression control > settings used in the current implementation can be simply > dropped. > > No regressions on IVB (piglit quick + unit tests). > > Signed-off-by: Topi Pohjolainen With the typo fixed, Reviewed-by: Ian Romanick > --- > src/mesa/drivers/dri/i965/brw_blorp_blit.cpp | 31 > ++-- > 1 file changed, 20 insertions(+), 11 deletions(-) > > diff --git a/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp > b/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp > index 4d62411..6de4dc2 100644 > --- a/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp > +++ b/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp > @@ -801,7 +801,20 @@ brw_blorp_blit_program::compile(struct brw_context *brw, > memset(&prog_data, 0, sizeof(prog_data)); > prog_data.persample_msaa_dispatch = key->persample_msaa_dispatch; > > - brw_set_compression_control(&func, BRW_COMPRESSION_NONE); > + /* > +* By default everything is emitted as 16-wide with only a few expections ^^ exceptions > +* handled explicitly either here in the compiler or by one of the > specific > +* code emission calls. > +* It should be also noted that here in this file any alterations of the > +* compression control settings are only used to affect the execution size > +* of the instructions. The instruction template used to initialise all > the > +* instructions is effectively not altered -- the value stays at zero > +* representing either GEN6_COMPRESSION_1Q or GEN6_COMPRESSION_1H > depending > +* on the context. > +* If any other settings are used in the instruction headers, they are set > +* elsewhere by the individual code emission calls. > +*/ > + brw_set_compression_control(&func, BRW_COMPRESSION_COMPRESSED); > > alloc_regs(); > compute_frag_coords(); > @@ -1077,8 +1090,10 @@ brw_blorp_blit_program::compute_frag_coords() > struct brw_reg t1_uw1 = retype(t1, BRW_REGISTER_TYPE_UW); > brw_MOV(&func, vec16(t1_uw1), brw_imm_v(0x3210)); > /* Move to UD sample_index register. */ > + brw_set_compression_control(&func, BRW_COMPRESSION_NONE); > brw_MOV(&func, S, stride(t1_uw1, 1, 4, 0)); > brw_MOV(&func, offset(S, 1), suboffset(stride(t1_uw1, 1, 4, 0), 2)); > + brw_set_compression_control(&func, BRW_COMPRESSION_COMPRESSED); > break; >} >case 8: { > @@ -1103,9 +1118,11 @@ brw_blorp_blit_program::compute_frag_coords() > brw_MOV(&func, vec16(t2_uw1), brw_imm_v(0x3210)); > brw_ADD(&func, vec16(S), retype(t1_ud1, BRW_REGISTER_TYPE_UW), > stride(t2_uw1, 1, 4, 0)); > + brw_set_compression_control(&func, BRW_COMPRESSION_NONE); > brw_ADD(&func, offset(S, 1), > retype(t1_ud1, BRW_REGISTER_TYPE_UW), > suboffset(stride(t2_uw1, 1, 4, 0), 2)); > + brw_set_compression_control(&func, BRW_COMPRESSION_COMPRESSED); > break; >} >default: > @@ -1147,7 +1164,6 @@ brw_blorp_blit_program::translate_tiling(bool > old_tiled_w, bool new_tiled_w) > */ > assert(s_is_zero); > > - brw_set_compression_control(&func, BRW_COMPRESSION_COMPRESSED); > if (new_tiled_w) { >/* Given X and Y coordinates that describe an address using Y tiling, > * translate to the X and Y coordinates that describe the same address > @@ -1217,7 +1233,6 @@ brw_blorp_blit_program::translate_tiling(bool > old_tiled_w, bool new_tiled_w) >brw_OR(&func, Yp, t1, t2); >SWAP_XY_AND_XPYP(); > } > - brw_set_compression_control(&func, BRW_COMPRESSION_NONE); > } > > /** > @@ -1234,7 +1249,6 @@ void > brw_blorp_blit_program::encode_msaa(unsigned num_samples, > intel_msaa_layout layout) > { > - brw_set_compression_control(&func, BRW_COMPRESSION_COMPRESSED); > switch (layout) { > case INTEL_MSAA_LAYOUT_NONE: >/* No translation necessary, and S should already be zero. */ > @@ -1306,7 +1320,6 @@ brw_blorp_blit_program::encode_msaa(unsigned > num_samples, >s_is_zero = true; >break; > } > - brw_set_compression_control(&func, BRW_COMPRESSION_NONE); > } > > /** > @@ -1323,7 +1336,6 @@ void > brw_blorp_blit_program::decode_msaa(unsigned num_samples, > intel_msaa_layout layout) > { > - brw_set_compression_control(&func, BRW_COMPRESSION_COMPRESSED); > switch (layout) { > case INTEL_MSAA_LAYOUT_NONE: >/* No translation necessary, and S should already be zero. */ > @@ -1386,7 +1398,6 @@ brw_blorp_blit_program::decode_msaa(unsigned > num_samples, >
Re: [Mesa-dev] [PATCH 16/42] i965/blorp: remove dependency to compression control state
On 01/09/2014 10:05 AM, Matt Turner wrote: > On Fri, Dec 20, 2013 at 6:38 AM, Topi Pohjolainen > wrote: >> Effectively only the mask control bit gets altered for the single >> addition in question and hence there is no real need to use a >> fresh state control level for it -- that is more useful when >> multiple intructions share the same mask and compression settings. >> >> This is a preparation step for removing the explicit compression >> control modifiers in the blit compiler. After this patch there >> are no nested state control levels making the constant nature of >> the compression settings more apparent. >> >> No regressions on IVB (piglit quick + unit tests). >> >> Signed-off-by: Topi Pohjolainen >> --- >> src/mesa/drivers/dri/i965/brw_blorp_blit.cpp | 5 + >> 1 file changed, 1 insertion(+), 4 deletions(-) >> >> diff --git a/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp >> b/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp >> index 112a307..4d62411 100644 >> --- a/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp >> +++ b/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp >> @@ -1407,10 +1407,7 @@ brw_blorp_blit_program::kill_if_outside_dst_rect() >> brw_CMP(&func, null32, BRW_CONDITIONAL_L, Y, dst_y1); >> >> brw_set_predicate_control(&func, BRW_PREDICATE_NONE); >> - brw_push_insn_state(&func); >> - brw_set_mask_control(&func, BRW_MASK_DISABLE); >> - brw_AND(&func, g1, f0, g1); >> - brw_pop_insn_state(&func); >> + brw_AND(&func, g1, f0, g1)->header.mask_control = BRW_MASK_DISABLE; >> } > > Minor comment: I don't really love the function call and pointer > dereference in one line. I'd rather see > > struct brw_instruction *inst = brw_AND(&func, g1, f0, g1); > inst->header.mask_control = BRW_MASK_DISABLE; I agree. With that change, Reviewed-by: Ian Romanick > ___ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 0/40] Implement GL_ARB_viewport_array
On 01/10/2014 05:44 PM, Ian Romanick wrote: > (Sent after the fact... sorry.) > > This represents a medling of GL_ARB_viewport_array code written by > Courtney Goeltzenleuchter (LunarG) and myself over the last couple > months. It implements all of the core Mesa code for the extension and > enables it in the i965 driver. > > Like layered rendering, this extension depends on geometry shaders, so > it is currently only enabled in core profiles. There is one bit of core > Mesa code that behaves differently when the extension is enabled (see > "mesa: Add new viewport and depth-range entry points for > GL_ARB_viewport_array"), so the enable flag is only set by the i965 > driver in core profile. > > When multiple viewports, depth ranges, or scissor rectangles are updated > in one API call, the driver is only notified once, at the end. There is > also no per-viewport "dirty" tracking. The i965 driver has to send all > of the data when anything changes, so it didn't need that feature. If > some other hardware could use per-viewport dirty tracking as an > optimization, it would be trivial to add that tracking to the > gl_context. Then the driver state update (or > dd_function_table::Viewport) function could consult the appropriate > dirty bits before doing the update. I should also note that this is available in the viewport-array-blended (blending meaning that it's code from two sources blended together) branch of my fd.o Mesa tree. > ___ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 36/40] mesa: Refactor bounding-box calculation out of _mesa_update_draw_buffer_bounds
On 01/10/2014 05:40 PM, Ian Romanick wrote: > From: Ian Romanick > > Drivers that currently use _Xmin and friends to set their scissor > rectangle will need to use this code directly once they are updated for > GL_ARB_viewport_array. > > Signed-off-by: Ian Romanick > --- > src/mesa/main/framebuffer.c | 85 > + > src/mesa/main/framebuffer.h | 5 +++ > 2 files changed, 61 insertions(+), 29 deletions(-) > > diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c > index f14f7a4..04b9a2b 100644 > --- a/src/mesa/main/framebuffer.c > +++ b/src/mesa/main/framebuffer.c > @@ -357,6 +357,56 @@ update_framebuffer_size(struct gl_context *ctx, struct > gl_framebuffer *fb) > > > /** > + * Calculate the inclusive bounding box for the scissor of a specific > viewport > + * > + * \param ctx GL context. > + * \param buffer Framebuffer to be checked against > + * \param idx Index of the desired viewport > + * \param bboxBounding box for the scissored viewport. Stored as xmin, > + *xmax, ymin, ymax. > + * > + * \warning This function assumes that the framebuffer dimensions are up to > + * date (e.g., update_framebuffer_size has been recently called on \c > buffer). > + * > + * \sa _mesa_clip_to_region > + */ > +void > +_mesa_scissor_bounding_box(const struct gl_context *ctx, > + const struct gl_framebuffer *buffer, > + unsigned idx, int *bbox) > +{ > + bbox[0] = 0; > + bbox[2] = 0; > + bbox[1] = buffer->Width; > + bbox[3] = buffer->Height; > + > + if ((ctx->Scissor.EnableFlags >> idx) & 1) { Again, I'd prefer: if (ctx->Scissor.EnableFlags & (1 << idx)) { > + if (ctx->Scissor.ScissorArray[idx].X > bbox[0]) { > + bbox[0] = ctx->Scissor.ScissorArray[idx].X; > + } > + if (ctx->Scissor.ScissorArray[idx].Y > bbox[2]) { > + bbox[2] = ctx->Scissor.ScissorArray[idx].Y; > + } > + if (ctx->Scissor.ScissorArray[idx].X + > ctx->Scissor.ScissorArray[idx].Width < bbox[1]) { > + bbox[1] = ctx->Scissor.ScissorArray[idx].X + > ctx->Scissor.ScissorArray[idx].Width; > + } > + if (ctx->Scissor.ScissorArray[idx].Y + > ctx->Scissor.ScissorArray[idx].Height < bbox[3]) { > + bbox[3] = ctx->Scissor.ScissorArray[idx].Y + > ctx->Scissor.ScissorArray[idx].Height; > + } Mixed spaces and tabs here - we just want spaces. > + /* finally, check for empty region */ > + if (bbox[0] > bbox[1]) { > + bbox[0] = bbox[1]; > + } > + if (bbox[2] > bbox[3]) { > + bbox[2] = bbox[3]; > + } > + } > + > + ASSERT(bbox[0] <= bbox[1]); > + ASSERT(bbox[2] <= bbox[3]); You may as well make these assert() instead of ASSERT(). I won't be a stickler about it though. > +} > + > +/** > * Update the context's current drawing buffer's Xmin, Xmax, Ymin, Ymax > fields. > * These values are computed from the buffer's width and height and > * the scissor box, if it's enabled. > @@ -366,6 +416,7 @@ void > _mesa_update_draw_buffer_bounds(struct gl_context *ctx) > { > struct gl_framebuffer *buffer = ctx->DrawBuffer; > + int bbox[4]; > > if (!buffer) >return; > @@ -375,36 +426,12 @@ _mesa_update_draw_buffer_bounds(struct gl_context *ctx) >update_framebuffer_size(ctx, buffer); > } > > - buffer->_Xmin = 0; > - buffer->_Ymin = 0; > - buffer->_Xmax = buffer->Width; > - buffer->_Ymax = buffer->Height; > - > /* Default to the first scissor as that's always valid */ > - if (ctx->Scissor.EnableFlags & 1) { > - if (ctx->Scissor.ScissorArray[0].X > buffer->_Xmin) { > - buffer->_Xmin = ctx->Scissor.ScissorArray[0].X; > - } > - if (ctx->Scissor.ScissorArray[0].Y > buffer->_Ymin) { > - buffer->_Ymin = ctx->Scissor.ScissorArray[0].Y; > - } > - if (ctx->Scissor.ScissorArray[0].X + > ctx->Scissor.ScissorArray[0].Width < buffer->_Xmax) { > - buffer->_Xmax = ctx->Scissor.ScissorArray[0].X + > ctx->Scissor.ScissorArray[0].Width; > - } > - if (ctx->Scissor.ScissorArray[0].Y + > ctx->Scissor.ScissorArray[0].Height < buffer->_Ymax) { > - buffer->_Ymax = ctx->Scissor.ScissorArray[0].Y + > ctx->Scissor.ScissorArray[0].Height; > - } > - /* finally, check for empty region */ > - if (buffer->_Xmin > buffer->_Xmax) { > - buffer->_Xmin = buffer->_Xmax; > - } > - if (buffer->_Ymin > buffer->_Ymax) { > - buffer->_Ymin = buffer->_Ymax; > - } > - } > - > - ASSERT(buffer->_Xmin <= buffer->_Xmax); > - ASSERT(buffer->_Ymin <= buffer->_Ymax); > + _mesa_scissor_bounding_box(ctx, buffer, 0, bbox); > + buffer->_Xmin = bbox[0]; > + buffer->_Ymin = bbox[2]; > + buffer->_Xmax = bbox[1]; > + buffer->_Ymax = bbox[3]; > } > > > diff --git a/src/mesa/main/framebuffer.h b/src/mesa/main/framebuffer.h > index 2645664..a427421 100644 > --- a/src/mesa/main/framebuffer.h > +++ b/src/m
Re: [Mesa-dev] [PATCH 37/40] i965: Set all the supported scissor rectangles for GEN7
On 01/10/2014 05:40 PM, Ian Romanick wrote: > From: Ian Romanick > > Currently MaxViewports is still 1, so this won't affect any change. > > Signed-off-by: Ian Romanick > --- > src/mesa/drivers/dri/i965/gen6_scissor_state.c | 61 > ++ > 1 file changed, 34 insertions(+), 27 deletions(-) > > diff --git a/src/mesa/drivers/dri/i965/gen6_scissor_state.c > b/src/mesa/drivers/dri/i965/gen6_scissor_state.c > index 7b92b7c..c8438e0 100644 > --- a/src/mesa/drivers/dri/i965/gen6_scissor_state.c > +++ b/src/mesa/drivers/dri/i965/gen6_scissor_state.c > @@ -30,6 +30,7 @@ > #include "brw_defines.h" > #include "intel_batchbuffer.h" > #include "main/fbobject.h" > +#include "main/framebuffer.h" > > static void > gen6_upload_scissor_state(struct brw_context *brw) > @@ -40,7 +41,8 @@ gen6_upload_scissor_state(struct brw_context *brw) > uint32_t scissor_state_offset; > > scissor = brw_state_batch(brw, AUB_TRACE_SCISSOR_STATE, > - sizeof(*scissor), 32, &scissor_state_offset); > + sizeof(*scissor) * ctx->Const.MaxViewports, 32, > + &scissor_state_offset); > > /* _NEW_SCISSOR | _NEW_BUFFERS | _NEW_VIEWPORT */ > > @@ -51,33 +53,38 @@ gen6_upload_scissor_state(struct brw_context *brw) > * Note that the hardware's coordinates are inclusive, while Mesa's min is > * inclusive but max is exclusive. > */ > - if (ctx->DrawBuffer->_Xmin == ctx->DrawBuffer->_Xmax || > - ctx->DrawBuffer->_Ymin == ctx->DrawBuffer->_Ymax) { > - /* If the scissor was out of bounds and got clamped to 0 > - * width/height at the bounds, the subtraction of 1 from > - * maximums could produce a negative number and thus not clip > - * anything. Instead, just provide a min > max scissor inside > - * the bounds, which produces the expected no rendering. > - */ > - scissor->xmin = 1; > - scissor->xmax = 0; > - scissor->ymin = 1; > - scissor->ymax = 0; > - } else if (render_to_fbo) { > - /* texmemory: Y=0=bottom */ > - scissor->xmin = ctx->DrawBuffer->_Xmin; > - scissor->xmax = ctx->DrawBuffer->_Xmax - 1; > - scissor->ymin = ctx->DrawBuffer->_Ymin; > - scissor->ymax = ctx->DrawBuffer->_Ymax - 1; > - } > - else { > - /* memory: Y=0=top */ > - scissor->xmin = ctx->DrawBuffer->_Xmin; > - scissor->xmax = ctx->DrawBuffer->_Xmax - 1; > - scissor->ymin = ctx->DrawBuffer->Height - ctx->DrawBuffer->_Ymax; > - scissor->ymax = ctx->DrawBuffer->Height - ctx->DrawBuffer->_Ymin - 1; > - } > + for (unsigned i = 0; i < ctx->Const.MaxViewports; i++) { > + int bbox[4]; > > + _mesa_scissor_bounding_box(ctx, ctx->DrawBuffer, i, bbox); > + > + if (bbox[0] == bbox[1] || > + bbox[2] == bbox[3]) { May as well put these on one line... if (bbox[0] == bbox[1] || bbox[2] == bbox[3]) { > + /* If the scissor was out of bounds and got clamped to 0 > width/height > + * at the bounds, the subtraction of 1 from maximums could produce a > + * negative number and thus not clip anything. Instead, just > provide > + * a min > max scissor inside the bounds, which produces the > expected > + * no rendering. > + */ > + scissor[i].xmin = 1; > + scissor[i].xmax = 0; > + scissor[i].ymin = 1; > + scissor[i].ymax = 0; > + } else if (render_to_fbo) { > + /* texmemory: Y=0=bottom */ > + scissor[i].xmin = bbox[0]; > + scissor[i].xmax = bbox[1] - 1; > + scissor[i].ymin = bbox[2]; > + scissor[i].ymax = bbox[3] - 1; > + } > + else { > + /* memory: Y=0=top */ > + scissor[i].xmin = bbox[0]; > + scissor[i].xmax = bbox[1] - 1; > + scissor[i].ymin = ctx->DrawBuffer->Height - bbox[3]; > + scissor[i].ymax = ctx->DrawBuffer->Height - bbox[2] - 1; > + } > + } > BEGIN_BATCH(2); > OUT_BATCH(_3DSTATE_SCISSOR_STATE_POINTERS << 16 | (2 - 2)); > OUT_BATCH(scissor_state_offset); > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev