Re: [Mesa-dev] [PATCH 0/4] drisw/glx: use XShm if possible
On 10/06/2015 18:08, Marc-André Lureau wrote : Hi, XPutImage requires to copy the images around, and the request may be split over several chunks. Using XShm should improve performance. Another way of doing that is to make the swrast loader allocate the buffers, and have swrast swap buffers instead of copying content. For example there could be a request to allocate a first buffer, and then a request to present an already allocated buffer, which would return a new buffer (could be the same). Doing that way, it could use XShm behind the scene, and it would fit different usages, like having a zero copy mechanism for wayland swrast. Yours, Axel Davy ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [RFC] DRI3 support for EGL
On Wed, 1 Jul 2015, Eero Tamminen wrote: Hi, Does this address comments raised for the 2014 EGL/DRI3 patch: http://patchwork.freedesktop.org/patch/35399/ ? - Eero Hello, The patch you mention wasn't really bringing DRI3 support to EGL, it was just using PRESENT to speed up the DRI2 implementation. It was misnamed. Thus the answer to your question is yes. Yours, Axel Davy ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH RFC] egl/dri2: Add dri3 support to x11 platform
On 04/07/2015 05:18, Boyan Ding wrote : Hi Emil, On 07/03/2015 10:36 PM, Emil Velikov wrote: [snip] +/* FIXME: Is this right? Seems problematic for WL_bind_wayland_display */ What seems to be the problem ? Afaik xcb_dri3_open_reply_fds should return an FD which is ok (be that a render_node device, or a master one with explicit auth). The problem is that WL_bind_wayland_display don't work under dri3 on x11. I only found it yesterday that to get it work, we'll need to add a mechanism to pass fd instead of name of dri device in wl_drm protocol. Previously, if a wayland client wants to use hardware accelerated EGL, it (with the help of libEGL in mesa) will bind to wl_drm object, and wl_drm will immediately send the name of dri device to the wayland client (actually also libEGL in mesa). After wayland platform code opens the device, it has to send the fd to the X server or drm to get authentication. Things are different with dri3, where a fd is directly sent to the client without the need to authenticate. I propose the following addition in wl_drm protocol: There are two kinds of wl_drm implementation. One is the current form. The other one, called "dri3-capable" (or whatever name), include wl_drm object built on dri3 directly or indirectly through wayland platform. If a client binds to a "dri3-capable" wl_drm object, it will send a "device" event to the client with NULL or empty string (so a client who knows nothing about it can safely fail). If the client knows about dri3-capable wl_drm object, it will send a request named get_fd and wl_drm will respond it with an fd acquired with dri3. If the wl_drm object is not "dri3-capable" it will raise an error if it receives a get_fd request, so will a "dri3-capable" wl_drm object if it receives authenticate request. So the following dri3_authenticate function is not needed. Let's not expose WL_bind_wayland_display for now, and its enablement should be separate patches. Hi, Both XWayland DRI3 and EGL Wayland are able to handle render-nodes, and render-nodes have been available for quite some time now. In fact there has been several times discussions on wayland irc channel to only advertise render-nodes via wl_drm. Instead of adding a function to wl_drm to get an fd directly, I advocate just advertising the render node name (if your device is not a render node, it is possible to get the render node name), and then you don't have to authenticate. In case render-nodes are not available, then it's ok not to advertise the extension. Yours, Axel Davy ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [RFC] loader: libudev vs sysfs vs libdrm
On 08/07/2015 00:15, Emil Velikov wrote : Can anyone shed a light/cast their 2c ? Thanks Emil ___ The DRI3/Wayland/Gallium Nine DRI_PRIME path uses libudev, and I'm not sure it could work without. It is based on the ID_PATH_TAG advertised by udev with the device. Perhaps there is another way to compute that tag though. Axel Davy ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [RFC] loader: libudev vs sysfs vs libdrm
On 09/07/2015 15:33, Emil Velikov wrote : Yakes forgot about that one. From a quick look we can (I know it feels durty) use readlink( /sys/dev/char/$(major):$(minor)). Everything seems to be there - bus type and exact location of the device on the bus. It's limited to sysfs users, but they are more than the libudev ones (perhaps not by much). How does that sound ? Cheers, Emil The idea behind using udev for the tag was that arbitrary tag could be used, especially to identify usb devices. Ofc another solution could be used. Yours, Axel ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH v2 6/7] radeonsi: Add DCC decompress.
On 12/10/2015 17:05, Bas Nieuwenhuizen wrote: Hi Marek, Thanks for the quick review. I do not think I understand the sharing semantics. We currently have fast clear for scanout surfaces with the CMASK and eliminate it on flush resource. I would think we could do that similarly with DCC fast clear. Both require a flush_resource after modifying the resource before other applications can use it. Furthermore, if we disable DCC for image stores, we also need to communicate that. We could leave DCC enabled for sampling as long as the DCC buffer stays in decompressed state. But we would need to communicate that DCC should not be used anymore for rendering. Do we still want patch 6 and 7 or should I drop them until we have an actual user? Yours sincerely, Bas Nieuwenhuizen ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev Hi, I think it would be better perf wise to not disable DCC for the backbuffer (which is both shared and scanout currently). Decompressing anything that needs to be decompressed in flush_resource seems to me a good idea. For dx9 apps, it seems the applications do render a lot of draw calls to the backbuffer directly. Likely having the backbuffer compressed with DCC (after it's been cleared), and then decompressing before sending it should - I guess - be faster than keeping it uncompressed. I don't know for gl apps, but I guess it's the same than dx9. I tested the current serie, and it seems to boost some apps. Yours, Axel ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH v2 6/7] radeonsi: Add DCC decompress.
On 13/10/2015 00:42, Bas Nieuwenhuizen wrote: Hi Axel, Using DCC for scanout surfaces is problematic because as far as I understand the display hardware does not support it. We could solve that partially by decompressing when displaying. However, the X server can also use these surfaces as a front buffer and for that case we cannot just use decompression without performance regressions for decompressing often. Furthermore, when using such a surface as back buffer, we would still need a single decompression before displaying it. It really depends on the application whether that improves performances or regresses it. For example, Xonotic regresses for me if I enable DCC for scanout surfaces. Yours sincerely, Bas Nieuwenhuizen Hi Bas, When the application is fullscreen, the backbuffer can be reused as is for the display. This is not done in practice in all scenario. DRI2 with vsync does it, Wayland and DRI3 do it. In X world that also depends whether the compositor enforces compositing for fullscreen applications or not. The backbuffer needs to be scanout able in case the backbuffer is used for the display. When a backbuffer is used for displaying, we use another one for rendering. Given usually apps do render to backbuffer directly, it seems good to me to have the backbuffer compressed during rendering, and then decompressed before presenting the buffer. I guess some scenarios can be hit, for example if application is rendering everything to a framebuffer, and then copying to backbuffer in the end before presenting. Perhaps it is what Xonotic does ? I suggest to use commercial games for testing. Is the card able to use the dma engine to decompress dcc ? That should solve the performance hits when decompressing. Yours, Axel ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 37/40] targets/nine: add note about fd owndership
On 18/10/2015 12:25, Emil Velikov wrote: +/* XXX: Is the owner responsible for FD owndership or are we ? + * In the former we're screwing things hard here */ This will be updated to "Although the fd is provided from external source, mesa/nine takes ownership of it." based on input from Axel. -Emil Ok, I understand the confusion. Yeah, wine side gives an fd to nine and nine takes its ownership. Then loader_get_user_preferred_fd will either return the same fd, or close the previous fd and give a new one. Then in drm_destroy the fd gets closed. Axel ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH v3 1/7] radeonsi: Allocate buffers for DCC.
On 21/10/2015 00:10, Bas Nieuwenhuizen wrote: DCC is disabled for textures that can be shared as sharing the DCC buffers has not been implemented yet. + surf->dcc_enabled = !(surf->flags & RADEON_SURF_Z_OR_SBUFFER) && +!(surf->flags & RADEON_SURF_SCANOUT) && +!compressed && AddrDccIn.numSamples <= 1; + Testing if a surface is scanout is not enough to avoid shared surfaces. In practice, it may be true currently mesa, and glamor via gbm, would use the scanout flag for shared buffers. It seems however a bit weak to rely on that. I suggest rather to use the pipe shared bind flag. I noticed in some case of imported surfaces the bind flag is not advertised, I'm going to send a patch to fix that. Yours, Axel Davy ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/4] egl/wayland: Use scanout flag for backbuffers
The back buffers need to be scanout-able in case the compositor wants to use the buffer (once sent) as display framebuffer. Signed-off-by: Axel Davy --- src/egl/drivers/dri2/platform_wayland.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c index 0d161f6..92ff2af 100644 --- a/src/egl/drivers/dri2/platform_wayland.c +++ b/src/egl/drivers/dri2/platform_wayland.c @@ -305,7 +305,7 @@ get_back_bo(struct dri2_egl_surface *dri2_surf) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(dri2_surf->base.Resource.Display); - int i; + int i, use_flags; unsigned int dri_image_format; /* currently supports three WL DRM formats, @@ -352,6 +352,8 @@ get_back_bo(struct dri2_egl_surface *dri2_surf) if (dri2_surf->back == NULL) return -1; + use_flags = __DRI_IMAGE_USE_SHARE | __DRI_IMAGE_USE_SCANOUT; + if (dri2_dpy->is_different_gpu && dri2_surf->back->linear_copy == NULL) { dri2_surf->back->linear_copy = @@ -359,7 +361,7 @@ get_back_bo(struct dri2_egl_surface *dri2_surf) dri2_surf->base.Width, dri2_surf->base.Height, dri_image_format, - __DRI_IMAGE_USE_SHARE | + use_flags | __DRI_IMAGE_USE_LINEAR, NULL); if (dri2_surf->back->linear_copy == NULL) @@ -373,7 +375,7 @@ get_back_bo(struct dri2_egl_surface *dri2_surf) dri2_surf->base.Height, dri_image_format, dri2_dpy->is_different_gpu ? - 0 : __DRI_IMAGE_USE_SHARE, + 0 : use_flags, NULL); dri2_surf->back->age = 0; } -- 2.6.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 4/4] pipe: Add new bind flag for shared resources with flush_resource call
Add a new bind flag to differentiate shared resources that must be readable after any flush, or that can afford being readable only after flush_resource. Previously the two cases were mixed, and implictly things were done such that there would be no issues. flush_resource is called for: . st/nine back buffers . dri2 and dri3 back buffers (both wayland and x11) flush_resource is not called for: . gbm buffers . dri2 and dri3 x11 (fake/real) front buffers . EGLImages (they can be shared) I didn't look at what the other state trackers do, but a grep said there is no flush_resource call outside dri2 and nine state trackers. Signed-off-by: Axel Davy --- src/gallium/include/pipe/p_defines.h | 8 src/gallium/state_trackers/dri/dri2.c | 17 + src/gallium/state_trackers/dri/dri_drawable.c | 9 +++-- src/gallium/state_trackers/nine/swapchain9.c | 10 +++--- 4 files changed, 31 insertions(+), 13 deletions(-) diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h index 1ad545a..f877893 100644 --- a/src/gallium/include/pipe/p_defines.h +++ b/src/gallium/include/pipe/p_defines.h @@ -399,6 +399,14 @@ enum pipe_flush_flags #define PIPE_BIND_SHARED (1 << 19) /* get_texture_handle ??? */ #define PIPE_BIND_LINEAR (1 << 20) +/* This flag indicates that in addition to being shared, the resource won't be + * read by any external process before we call flush_resource. This allows + * things like compressing the buffer when drawing, while uncompressing on + * flush_resource. The PIPE_BIND_SHARED must still be set with this flag. + * If PIPE_BIND_SHARED is specified but not + * PIPE_BIND_SHARED_FLUSH_RESOURCE, then the resource must be + * readable by external processes after any normal flush. */ +#define PIPE_BIND_SHARED_FLUSH_RESOURCE (1 << 21) /** * Flags for the driver about resource behaviour: diff --git a/src/gallium/state_trackers/dri/dri2.c b/src/gallium/state_trackers/dri/dri2.c index 5f5bc86..74b398f 100644 --- a/src/gallium/state_trackers/dri/dri2.c +++ b/src/gallium/state_trackers/dri/dri2.c @@ -291,27 +291,25 @@ dri2_allocate_buffer(__DRIscreen *sPriv, struct dri2_buffer *buffer; struct pipe_resource templ; enum pipe_format pf; - unsigned bind = 0; + unsigned bind = PIPE_BIND_SHARED; /* because we get the handle and stride */ struct winsys_handle whandle; switch (attachment) { case __DRI_BUFFER_FRONT_LEFT: case __DRI_BUFFER_FAKE_FRONT_LEFT: - bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW; + bind |= PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW; break; case __DRI_BUFFER_BACK_LEFT: - bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW; + bind |= PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW | +PIPE_BIND_SHARED_FLUSH_RESOURCE; break; case __DRI_BUFFER_DEPTH: case __DRI_BUFFER_DEPTH_STENCIL: case __DRI_BUFFER_STENCIL: -bind = PIPE_BIND_DEPTH_STENCIL; /* XXX sampler? */ +bind |= PIPE_BIND_DEPTH_STENCIL; /* XXX sampler? */ break; } - /* because we get the handle and stride */ - bind |= PIPE_BIND_SHARED; - switch (format) { case 32: pf = PIPE_FORMAT_BGRA_UNORM; @@ -555,7 +553,8 @@ dri2_allocate_textures(struct dri_context *ctx, if (drawable->textures[statt]) { templ.format = drawable->textures[statt]->format; templ.bind = drawable->textures[statt]->bind & - ~(PIPE_BIND_SCANOUT | PIPE_BIND_SHARED); + ~(PIPE_BIND_SCANOUT | PIPE_BIND_SHARED | + PIPE_BIND_SHARED_FLUSH_RESOURCE); templ.nr_samples = drawable->stvis.samples; /* Try to reuse the resource. @@ -834,6 +833,8 @@ dri2_create_image(__DRIscreen *_screen, tex_usage |= PIPE_BIND_SCANOUT; if (use & __DRI_IMAGE_USE_SHARE) tex_usage |= PIPE_BIND_SHARED; + if (use & __DRI_IMAGE_USE_BACKBUFFER) + tex_usage |= PIPE_BIND_SHARED | PIPE_BIND_SHARED_FLUSH_RESOURCE; if (use & __DRI_IMAGE_USE_LINEAR) tex_usage |= PIPE_BIND_LINEAR; if (use & __DRI_IMAGE_USE_CURSOR) { diff --git a/src/gallium/state_trackers/dri/dri_drawable.c b/src/gallium/state_trackers/dri/dri_drawable.c index 04041d6..badd111 100644 --- a/src/gallium/state_trackers/dri/dri_drawable.c +++ b/src/gallium/state_trackers/dri/dri_drawable.c @@ -276,9 +276,7 @@ dri_drawable_get_format(struct dri_drawable *drawable, { switch (statt) { case ST_ATTACHMENT_FRONT_LEFT: - case ST_ATTACHMENT_BACK_LEFT: case ST_ATTACHMENT_FRONT_RIGHT: - case ST_ATTACHMENT_BACK_RIGHT: /* Other pieces of the driver stack get confused and behave incorrectly * when they get an sRGB drawable. st/mesa receives "drawable->stvis" * though
[Mesa-dev] [PATCH 2/4] st/dri2: Add shared flag to missing locations
The PIPE_BIND_SHARED flag should be added whenever the resource may be shared with another process. In particular if the resource is imported, or may be exported, the flag should be used. Signed-off-by: Axel Davy --- src/gallium/state_trackers/dri/dri2.c | 9 +++-- src/gallium/state_trackers/dri/dri_drawable.c | 3 ++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/gallium/state_trackers/dri/dri2.c b/src/gallium/state_trackers/dri/dri2.c index 019414b..5f5bc86 100644 --- a/src/gallium/state_trackers/dri/dri2.c +++ b/src/gallium/state_trackers/dri/dri2.c @@ -554,7 +554,8 @@ dri2_allocate_textures(struct dri_context *ctx, if (drawable->textures[statt]) { templ.format = drawable->textures[statt]->format; -templ.bind = drawable->textures[statt]->bind & ~PIPE_BIND_SCANOUT; +templ.bind = drawable->textures[statt]->bind & + ~(PIPE_BIND_SCANOUT | PIPE_BIND_SHARED); templ.nr_samples = drawable->stvis.samples; /* Try to reuse the resource. @@ -717,7 +718,8 @@ dri2_create_image_from_winsys(__DRIscreen *_screen, unsigned tex_usage; enum pipe_format pf; - tex_usage = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW; + tex_usage = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW | + PIPE_BIND_SHARED; switch (format) { case __DRI_IMAGE_FORMAT_RGB565: @@ -1089,6 +1091,9 @@ dri2_create_from_texture(__DRIcontext *context, int target, unsigned texture, return NULL; } + /* TODO: The initial texture was not created with the PIPE_BIND_SHARED flag. +* There should be a way to add this flag after creation. This flag is +* needed for EGLImages. */ pipe_resource_reference(&img->texture, tex); *error = __DRI_IMAGE_ERROR_SUCCESS; diff --git a/src/gallium/state_trackers/dri/dri_drawable.c b/src/gallium/state_trackers/dri/dri_drawable.c index f0cc4a2..04041d6 100644 --- a/src/gallium/state_trackers/dri/dri_drawable.c +++ b/src/gallium/state_trackers/dri/dri_drawable.c @@ -285,7 +285,8 @@ dri_drawable_get_format(struct dri_drawable *drawable, * to use an sRGB format here. */ *format = util_format_linear(drawable->stvis.color_format); - *bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW; + *bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW | + PIPE_BIND_SHARED; break; case ST_ATTACHMENT_DEPTH_STENCIL: *format = drawable->stvis.depth_stencil_format; -- 2.6.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 3/4] dri: Add backbuffer use flag
Add __DRI_IMAGE_USE_BACKBUFFER to indicate the image is going to be used as a backbuffer. Backbuffers are going to be attached as __DRI_BUFFER_BACK_LEFT or __DRI_BUFFER_BACK_RIGHT. This flag enables the driver to assume the buffer will only be read by an external process after a swapbuffer, in contrary to gbm buffers, front buffers and fake front buffers, which could be read after a flush. Signed-off-by: Axel Davy --- include/GL/internal/dri_interface.h | 1 + src/egl/drivers/dri2/platform_wayland.c | 3 ++- src/glx/dri3_glx.c | 6 -- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h index a0f155a..555894a 100644 --- a/include/GL/internal/dri_interface.h +++ b/include/GL/internal/dri_interface.h @@ -1091,6 +1091,7 @@ struct __DRIdri2ExtensionRec { #define __DRI_IMAGE_USE_SCANOUT0x0002 #define __DRI_IMAGE_USE_CURSOR 0x0004 /* Depricated */ #define __DRI_IMAGE_USE_LINEAR 0x0008 +#define __DRI_IMAGE_USE_BACKBUFFER 0x0010 /** diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c index 92ff2af..1fbc271 100644 --- a/src/egl/drivers/dri2/platform_wayland.c +++ b/src/egl/drivers/dri2/platform_wayland.c @@ -352,7 +352,8 @@ get_back_bo(struct dri2_egl_surface *dri2_surf) if (dri2_surf->back == NULL) return -1; - use_flags = __DRI_IMAGE_USE_SHARE | __DRI_IMAGE_USE_SCANOUT; + use_flags = __DRI_IMAGE_USE_SHARE | __DRI_IMAGE_USE_SCANOUT | + __DRI_IMAGE_USE_BACKBUFFER; if (dri2_dpy->is_different_gpu && dri2_surf->back->linear_copy == NULL) { diff --git a/src/glx/dri3_glx.c b/src/glx/dri3_glx.c index 96f13e6..feee6e6 100644 --- a/src/glx/dri3_glx.c +++ b/src/glx/dri3_glx.c @@ -880,7 +880,8 @@ dri3_alloc_render_buffer(struct glx_screen *glx_screen, Drawable draw, width, height, format, __DRI_IMAGE_USE_SHARE | - __DRI_IMAGE_USE_SCANOUT, + __DRI_IMAGE_USE_SCANOUT | + __DRI_IMAGE_USE_BACKBUFFER, buffer); pixmap_buffer = buffer->image; @@ -904,7 +905,8 @@ dri3_alloc_render_buffer(struct glx_screen *glx_screen, Drawable draw, width, height, format, __DRI_IMAGE_USE_SHARE | - __DRI_IMAGE_USE_LINEAR, + __DRI_IMAGE_USE_LINEAR | + __DRI_IMAGE_USE_BACKBUFFER, buffer); pixmap_buffer = buffer->linear_buffer; -- 2.6.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 4/4] pipe: Add new bind flag for shared resources with flush_resource call
On 21/10/2015 13:16, Bas Nieuwenhuizen wrote: On Wed, Oct 21, 2015 at 12:28 PM, Axel Davy wrote: +/* This flag indicates that in addition to being shared, the resource won't be + * read by any external process before we call flush_resource. This allows + * things like compressing the buffer when drawing, while uncompressing on + * flush_resource. The PIPE_BIND_SHARED must still be set with this flag. + * If PIPE_BIND_SHARED is specified but not + * PIPE_BIND_SHARED_FLUSH_RESOURCE, then the resource must be + * readable by external processes after any normal flush. */ I think these comments would allow the dri2 front buffer to have this flag set as it is never shared with another process? - Bas The front buffer is read by the X server, which is another process. In the case we have a fake front buffer, waitX/waitGL will trigger read/writes with the X server real front buffer. We could advertise the flag for fake front buffers if we were calling flush_resource for waitX/waitGL, but we don't do that. Axel ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 4/4] pipe: Add new bind flag for shared resources with flush_resource call
On 21/10/2015 13:36, Bas Nieuwenhuizen wrote: My apologies, wrong term. I meant the front buffer of the X server in the non-compositing case. - Bas I think only glamor uses mesa for X rendering. Depending on the DDX, the front buffer will either be created with gbm, or imported as an EGLImage. As we don't call flush_resource for them, the flag won't be advertised. I understand your nitpick on the word 'process'. Would you have a better suggestion ? Axel ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 0/7] DRI3 support for EGL (v4)
Hi, I did take a look, and it looks good to me. I'm happy you implemented DRI_PRIME support as well. About it, do you need testers to check everything works ? A mistake about it I noticed is that you don't disable EGL_KHR_image_pixmap when is_different_gpu is set. It should be disabled, just like GLX_EXT_texture_from_pixmap is for GLX. Yours, Axel Davy On 10/11/2015 18:30, Martin Peres wrote: Here is an update to the v3, addressing almost all the comments I got during the previous round. The one item that is left to do is the handling of EGL_BUFFER_PRESERVED which will take some time since I need to write a piglit test for it. In the mean time, I would really appreciate if you could review the build-system part since I am not the most familiar with autotools. It seems like scons is not building the EGL X11 platform, so I did not bother adding support for the X11 DRI3 there. I tested the code using GLES apps and ran a full piglit/cts run on all the platforms. Nothing display-related failed. The only regression visible is spec/egl_nok_swap_region/basic going from pass to skip as the EGL extension EGL_NOK_swap_region is not yet implemented. I guess this is OK to work on that after this series lands. Boyan Ding (6): loader: Add dri3 helper glx/dri3: Convert to use dri3 helper in loader library egl_dri2: Add a function to let platform code return dri drawable from _EGLSurface egl/x11: Implement dri3 support with loader's dri3 helper loader/dri3: Expose function to create __DRIimage from pixmap egl/x11_dri3: Implement EGL_KHR_image_pixmap Martin Peres (1): egl: make it clear which platform x11 backend is being used (dri2 or 3) configure.ac | 12 +- src/egl/Makefile.am | 10 +- src/egl/drivers/dri2/egl_dri2.c | 118 ++- src/egl/drivers/dri2/egl_dri2.h | 19 +- src/egl/drivers/dri2/platform_android.c |1 + src/egl/drivers/dri2/platform_drm.c |1 + src/egl/drivers/dri2/platform_wayland.c |2 + src/egl/drivers/dri2/platform_x11.c | 112 ++- src/egl/drivers/dri2/platform_x11_dri3.c | 547 src/egl/drivers/dri2/platform_x11_dri3.h | 41 + src/glx/Makefile.am |2 + src/glx/dri3_glx.c | 1407 +++--- src/glx/dri3_priv.h | 94 +- src/loader/Makefile.am | 15 +- src/loader/loader_dri3_helper.c | 1396 + src/loader/loader_dri3_helper.h | 241 + 16 files changed, 2613 insertions(+), 1405 deletions(-) create mode 100644 src/egl/drivers/dri2/platform_x11_dri3.c create mode 100644 src/egl/drivers/dri2/platform_x11_dri3.h create mode 100644 src/loader/loader_dri3_helper.c create mode 100644 src/loader/loader_dri3_helper.h ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] killing off the address reg in tgsi
Hi, for Gallium Nine we use ARR and UARL. Do all cards supporting integers support indexing with an integer register ? If yes we could remove our UARL usage. As for ARR, if all cards are ok with normal registers, we could use a normal one too, as long as we can get the same rounding behaviour (either to a integer directly if card supports it, or to float). Axel Davy On 29/01/2015 22:20, Roland Scheidegger wrote : Hi, the address reg in tgsi is quite a nuisance. glsl-to-tgsi code assumes that indirections can only be done through the address reg and has quite some extra code to deal with this. Even though hardware and apis which worked like that are definitely old by now. Thus, I'm proposing the address reg be nuked. I am however not quite sure what the implications for drivers are, other than I'm certain llvmpipe can handle that already. For that reason, I suspect at least initially a new cap bit would be required so glsl-to-tgsi would skip the extra code. I tend to think longer term it would be great if it could be nuked completely, I am however not sure if that is easily done with drivers for old hw (such as r300) - I guess if necessary we could keep operations such as ARL (or even ARR though clearly not UARL!) and just define them to be usable with temp regs. Opinions? Roland ___ 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 01/43] st/nine: Explicit nine requirements
This patch raises nine requirements and disables nine for old hw that don't match them. Currently for these cards only games that don't have tight requirements would work well with nine. However nine is missing several checks regarding these limitations. To make code and future patches less heavy, dropping support for these old card seems a good solution. That makes r500 the only dx9 generation cards supported by nine. It seems the one with the less limitations for nine. Still not everything is ok, and we'll have for example to implement shader recompilation for these cards to include integer and boolean constants in the shader. Eventually when this is done, we can reintroduce support for older cards. Signed-off-by: Axel Davy --- src/gallium/state_trackers/nine/adapter9.c | 106 + src/gallium/state_trackers/nine/device9.c | 9 +-- 2 files changed, 66 insertions(+), 49 deletions(-) diff --git a/src/gallium/state_trackers/nine/adapter9.c b/src/gallium/state_trackers/nine/adapter9.c index 481f863..bdf547e 100644 --- a/src/gallium/state_trackers/nine/adapter9.c +++ b/src/gallium/state_trackers/nine/adapter9.c @@ -39,6 +39,7 @@ NineAdapter9_ctor( struct NineAdapter9 *This, struct NineUnknownParams *pParams, struct d3dadapter9_context *pCTX ) { +struct pipe_screen *hal = pCTX->hal; HRESULT hr = NineUnknown_ctor(&This->base, pParams); if (FAILED(hr)) { return hr; } @@ -46,7 +47,7 @@ NineAdapter9_ctor( struct NineAdapter9 *This, nine_dump_D3DADAPTER_IDENTIFIER9(DBG_CHANNEL, &pCTX->identifier); This->ctx = pCTX; -if (!This->ctx->hal->get_param(This->ctx->hal, PIPE_CAP_CLIP_HALFZ)) { +if (!hal->get_param(hal, PIPE_CAP_CLIP_HALFZ)) { ERR("Driver doesn't support d3d9 coordinates\n"); return D3DERR_DRIVERINTERNALERROR; } @@ -54,7 +55,44 @@ NineAdapter9_ctor( struct NineAdapter9 *This, !This->ctx->ref->get_param(This->ctx->ref, PIPE_CAP_CLIP_HALFZ)) { ERR("Warning: Sotware rendering driver doesn't support d3d9 coordinates\n"); } - +/* Old cards had tricks to bypass some restrictions to implement + * everything and fit tight the requirements: number of constants, + * number of temp registers, special behaviours, etc. Since we don't + * have access to all this, we need a bit more than what dx9 required. + * For example we have to use more than 32 temp registers to emulate + * behaviours, while some dx9 hw don't have more. As for sm2 hardware, + * we could support vs2 / ps2 for them but it needs some more care, and + * as these are very old, we choose to drop support for them */ + +/* checks minimum requirements, most are vs3/ps3 strict requirements */ +if (!hal->get_param(hal, PIPE_CAP_SM3) || +hal->get_shader_param(hal, PIPE_SHADER_VERTEX, + PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE) < 256 * sizeof(float[4]) || +hal->get_shader_param(hal, PIPE_SHADER_FRAGMENT, + PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE) < 244 * sizeof(float[4]) || +hal->get_shader_param(hal, PIPE_SHADER_VERTEX, + PIPE_SHADER_CAP_MAX_TEMPS) < 32 || +hal->get_shader_param(hal, PIPE_SHADER_FRAGMENT, + PIPE_SHADER_CAP_MAX_TEMPS) < 32 || +hal->get_shader_param(hal, PIPE_SHADER_VERTEX, + PIPE_SHADER_CAP_MAX_INPUTS) < 16 || +hal->get_shader_param(hal, PIPE_SHADER_FRAGMENT, + PIPE_SHADER_CAP_MAX_INPUTS) < 10) { +ERR("Your card is not supported by Gallium Nine. Minimum requirement " +"is >= r500, >= nv50, >= i965\n"); +return D3DERR_DRIVERINTERNALERROR; +} +/* for r500 */ +if (hal->get_shader_param(hal, PIPE_SHADER_VERTEX, + PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE) < 276 * sizeof(float[4]) || /* we put bool and int constants with float constants */ +hal->get_shader_param(hal, PIPE_SHADER_VERTEX, + PIPE_SHADER_CAP_MAX_TEMPS) < 40 || /* we use some more temp registers */ +hal->get_shader_param(hal, PIPE_SHADER_FRAGMENT, + PIPE_SHADER_CAP_MAX_TEMPS) < 40 || +hal->get_shader_param(hal, PIPE_SHADER_FRAGMENT, + PIPE_SHADER_CAP_MAX_INPUTS) < 20) /* we don't pack inputs as much as we could */ +ERR("Your card is at the limit of Gallium Nine requirements. Some games " +"may run into issues because requirements are too tight\n"); return D3D_OK; } @@ -472,7 +510,6 @@ NineAdapter9_GetDeviceCaps( struct NineAdapter9 *This,
[Mesa-dev] [PATCH 25/43] st/nine: Set [out] argument to NULL for some functions
From: Patrick Rudolph Wine tests, and probably some apps, check for errors by checking for NULL instead of error codes. Fixes wine test test_surface_blocks() Reviewed-by: Axel davy Signed-off-by: Patrick Rudolph --- src/gallium/state_trackers/nine/device9.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c index 46b4c5a..fdcf7a2 100644 --- a/src/gallium/state_trackers/nine/device9.c +++ b/src/gallium/state_trackers/nine/device9.c @@ -765,6 +765,7 @@ NineDevice9_CreateTexture( struct NineDevice9 *This, D3DUSAGE_DYNAMIC | D3DUSAGE_NONSECURE | D3DUSAGE_RENDERTARGET | D3DUSAGE_SOFTWAREPROCESSING | D3DUSAGE_TEXTAPI; +*ppTexture = NULL; user_assert(Width && Height, D3DERR_INVALIDCALL); user_assert(!pSharedHandle || This->ex, D3DERR_INVALIDCALL); /* When is used shared handle, Pool must be @@ -806,6 +807,7 @@ NineDevice9_CreateVolumeTexture( struct NineDevice9 *This, Usage &= D3DUSAGE_DYNAMIC | D3DUSAGE_NONSECURE | D3DUSAGE_SOFTWAREPROCESSING; +*ppVolumeTexture = NULL; user_assert(Width && Height && Depth, D3DERR_INVALIDCALL); user_assert(!pSharedHandle || Pool == D3DPOOL_DEFAULT, D3DERR_INVALIDCALL); @@ -839,6 +841,7 @@ NineDevice9_CreateCubeTexture( struct NineDevice9 *This, D3DUSAGE_NONSECURE | D3DUSAGE_RENDERTARGET | D3DUSAGE_SOFTWAREPROCESSING; +*ppCubeTexture = NULL; user_assert(EdgeLength, D3DERR_INVALIDCALL); user_assert(!pSharedHandle || Pool == D3DPOOL_DEFAULT, D3DERR_INVALIDCALL); @@ -1020,6 +1023,7 @@ NineDevice9_CreateRenderTarget( struct NineDevice9 *This, IDirect3DSurface9 **ppSurface, HANDLE *pSharedHandle ) { +*ppSurface = NULL; return create_zs_or_rt_surface(This, 0, D3DPOOL_DEFAULT, Width, Height, Format, MultiSample, MultisampleQuality, @@ -1037,6 +1041,7 @@ NineDevice9_CreateDepthStencilSurface( struct NineDevice9 *This, IDirect3DSurface9 **ppSurface, HANDLE *pSharedHandle ) { +*ppSurface = NULL; return create_zs_or_rt_surface(This, 1, D3DPOOL_DEFAULT, Width, Height, Format, MultiSample, MultisampleQuality, @@ -1474,6 +1479,7 @@ NineDevice9_CreateOffscreenPlainSurface( struct NineDevice9 *This, Width, Height, d3dformat_to_string(Format), Format, Pool, ppSurface, pSharedHandle); +*ppSurface = NULL; user_assert(!pSharedHandle || Pool == D3DPOOL_DEFAULT || Pool == D3DPOOL_SYSTEMMEM, D3DERR_INVALIDCALL); user_assert(Pool != D3DPOOL_MANAGED, D3DERR_INVALIDCALL); -- 2.1.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 11/43] st/nine: fix early basetexture destruction
Signed-off-by: Axel Davy --- src/gallium/state_trackers/nine/basetexture9.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gallium/state_trackers/nine/basetexture9.c b/src/gallium/state_trackers/nine/basetexture9.c index 5134de2..8d183e6 100644 --- a/src/gallium/state_trackers/nine/basetexture9.c +++ b/src/gallium/state_trackers/nine/basetexture9.c @@ -85,7 +85,8 @@ NineBaseTexture9_dtor( struct NineBaseTexture9 *This ) pipe_sampler_view_reference(&This->view[0], NULL); pipe_sampler_view_reference(&This->view[1], NULL); -list_del(&This->list), +if (This->list.prev != NULL && This->list.next != NULL) +list_del(&This->list), NineResource9_dtor(&This->base); } -- 2.1.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 27/43] st/nine: Check for aligned offset in each vertex element
From: Patrick Rudolph Fixes wine test test_vertex_declaration_alignment() Reviewed-by: Axel Davy Signed-off-by: Patrick Rudolph --- src/gallium/state_trackers/nine/vertexdeclaration9.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gallium/state_trackers/nine/vertexdeclaration9.c b/src/gallium/state_trackers/nine/vertexdeclaration9.c index 49e5937..9e4cb55 100644 --- a/src/gallium/state_trackers/nine/vertexdeclaration9.c +++ b/src/gallium/state_trackers/nine/vertexdeclaration9.c @@ -184,8 +184,10 @@ NineVertexDeclaration9_ctor( struct NineVertexDeclaration9 *This, /* wine */ for (This->nelems = 0; pElements[This->nelems].Stream != 0xFF; - ++This->nelems) + ++This->nelems) { user_assert(pElements[This->nelems].Type != D3DDECLTYPE_UNUSED, E_FAIL); +user_assert(!(pElements[This->nelems].Offset & 3), E_FAIL); +} caps = NineDevice9_GetCaps(This->base.device); user_assert(This->nelems <= caps->MaxStreams, D3DERR_INVALIDCALL); -- 2.1.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 20/43] st/nine: Implement AMD alpha to coverage
This D3D hack is supposed to be supported by all AMD SM2+ cards. Apps use it without checking if they are on AMD. Signed-off-by: Axel Davy --- src/gallium/state_trackers/nine/device9.c| 17 +++-- src/gallium/state_trackers/nine/nine_pipe.c | 2 +- src/gallium/state_trackers/nine/nine_state.c | 3 ++- src/gallium/state_trackers/nine/nine_state.h | 3 ++- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c index a446c8f..63f9f16 100644 --- a/src/gallium/state_trackers/nine/device9.c +++ b/src/gallium/state_trackers/nine/device9.c @@ -2049,6 +2049,9 @@ NineDevice9_ResolveZ( struct NineDevice9 *This ) return D3D_OK; } +#define ALPHA_TO_COVERAGE_ENABLE MAKEFOURCC('A', '2', 'M', '1') +#define ALPHA_TO_COVERAGE_DISABLE MAKEFOURCC('A', '2', 'M', '0') + HRESULT WINAPI NineDevice9_SetRenderState( struct NineDevice9 *This, D3DRENDERSTATETYPE State, @@ -2059,8 +2062,18 @@ NineDevice9_SetRenderState( struct NineDevice9 *This, DBG("This=%p State=%u(%s) Value=%08x\n", This, State, nine_d3drs_to_string(State), Value); -if (State == D3DRS_POINTSIZE && Value == RESZ_CODE) -return NineDevice9_ResolveZ(This); +/* Amd hacks (equivalent to GL extensions) */ +if (State == D3DRS_POINTSIZE) { +if (Value == RESZ_CODE) +return NineDevice9_ResolveZ(This); + +if (Value == ALPHA_TO_COVERAGE_ENABLE || +Value == ALPHA_TO_COVERAGE_DISABLE) { +state->rs[NINED3DRS_ALPHACOVERAGE] = (Value == ALPHA_TO_COVERAGE_ENABLE); +state->changed.group |= NINE_STATE_BLEND; +return D3D_OK; +} +} user_assert(State < Elements(state->rs), D3DERR_INVALIDCALL); diff --git a/src/gallium/state_trackers/nine/nine_pipe.c b/src/gallium/state_trackers/nine/nine_pipe.c index 8543b27..0da0b20 100644 --- a/src/gallium/state_trackers/nine/nine_pipe.c +++ b/src/gallium/state_trackers/nine/nine_pipe.c @@ -146,7 +146,7 @@ nine_convert_blend_state(struct cso_context *ctx, const DWORD *rs) blend.dither = !!rs[D3DRS_DITHERENABLE]; /* blend.alpha_to_one = 0; */ - /* blend.alpha_to_coverage = 0; */ /* XXX */ +blend.alpha_to_coverage = !!rs[NINED3DRS_ALPHACOVERAGE]; blend.rt[0].blend_enable = !!rs[D3DRS_ALPHABLENDENABLE]; if (blend.rt[0].blend_enable) { diff --git a/src/gallium/state_trackers/nine/nine_state.c b/src/gallium/state_trackers/nine/nine_state.c index 972ed1f..1e53335 100644 --- a/src/gallium/state_trackers/nine/nine_state.c +++ b/src/gallium/state_trackers/nine/nine_state.c @@ -957,7 +957,8 @@ static const DWORD nine_render_state_defaults[NINED3DRS_LAST + 1] = [D3DRS_DESTBLENDALPHA] = D3DBLEND_ZERO, [D3DRS_BLENDOPALPHA] = D3DBLENDOP_ADD, [NINED3DRS_VSPOINTSIZE] = FALSE, -[NINED3DRS_RTMASK] = 0xf +[NINED3DRS_RTMASK] = 0xf, +[NINED3DRS_ALPHACOVERAGE] = FALSE }; static const DWORD nine_tex_stage_state_defaults[NINED3DTSS_LAST + 1] = { diff --git a/src/gallium/state_trackers/nine/nine_state.h b/src/gallium/state_trackers/nine/nine_state.h index 6e94e68..0cb2933 100644 --- a/src/gallium/state_trackers/nine/nine_state.h +++ b/src/gallium/state_trackers/nine/nine_state.h @@ -34,9 +34,10 @@ #define NINED3DRS_VSPOINTSIZE (D3DRS_BLENDOPALPHA + 1) #define NINED3DRS_RTMASK (D3DRS_BLENDOPALPHA + 2) #define NINED3DRS_ZBIASSCALE (D3DRS_BLENDOPALPHA + 3) +#define NINED3DRS_ALPHACOVERAGE (D3DRS_BLENDOPALPHA + 4) #define D3DRS_LAST D3DRS_BLENDOPALPHA -#define NINED3DRS_LAST NINED3DRS_ZBIASSCALE /* 212 */ +#define NINED3DRS_LAST NINED3DRS_ALPHACOVERAGE /* 213 */ #define NINED3DSAMP_LAST NINED3DSAMP_SHADOW /* 15 */ #define NINED3DTSS_LAST D3DTSS_CONSTANT #define NINED3DTS_LAST D3DTS_WORLDMATRIX(255) -- 2.1.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 09/43] st/nine: Check block alignment for compressed textures in NineSurface9_CopySurface
From: Patrick Rudolph Reviewed-by: Axel Davy Signed-off-by: Patrick Rudolph --- src/gallium/state_trackers/nine/surface9.c | 24 1 file changed, 24 insertions(+) diff --git a/src/gallium/state_trackers/nine/surface9.c b/src/gallium/state_trackers/nine/surface9.c index b3c7c18..8c8d653 100644 --- a/src/gallium/state_trackers/nine/surface9.c +++ b/src/gallium/state_trackers/nine/surface9.c @@ -549,6 +549,30 @@ NineSurface9_CopySurface( struct NineSurface9 *This, r_src = NULL; } +/* check source block align for compressed textures */ +if (util_format_is_compressed(From->base.info.format) && +((src_box.width != From->desc.Width) || + (src_box.height != From->desc.Height))) { +const unsigned w = util_format_get_blockwidth(From->base.info.format); +const unsigned h = util_format_get_blockheight(From->base.info.format); +user_assert(!(src_box.width % w) && +!(src_box.height % h), +D3DERR_INVALIDCALL); +} + +/* check destination block align for compressed textures */ +if (util_format_is_compressed(This->base.info.format) && +((dst_box.width != This->desc.Width) || + (dst_box.height != This->desc.Height) || + dst_box.x != 0 || + dst_box.y != 0)) { +const unsigned w = util_format_get_blockwidth(This->base.info.format); +const unsigned h = util_format_get_blockheight(This->base.info.format); +user_assert(!(dst_box.x % w) && !(dst_box.width % w) && +!(dst_box.y % h) && !(dst_box.height % h), +D3DERR_INVALIDCALL); +} + if (r_dst && r_src) { pipe->resource_copy_region(pipe, r_dst, This->level, -- 2.1.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 05/43] st/nine: Introduce failure handling for shader parsing.
Instead of crashing on buggy shaders, we should return an error. This patch introduces this behaviour in the case of invalid constant access Signed-off-by: Axel Davy --- src/gallium/state_trackers/nine/nine_shader.c | 38 +-- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/src/gallium/state_trackers/nine/nine_shader.c b/src/gallium/state_trackers/nine/nine_shader.c index 66cfc1f..3e39a08 100644 --- a/src/gallium/state_trackers/nine/nine_shader.c +++ b/src/gallium/state_trackers/nine/nine_shader.c @@ -495,6 +495,7 @@ struct shader_translator struct sm1_local_const lconstb[NINE_MAX_CONST_B]; boolean indirect_const_access; +boolean failure; struct nine_shader_info *info; @@ -504,6 +505,8 @@ struct shader_translator #define IS_VS (tx->processor == TGSI_PROCESSOR_VERTEX) #define IS_PS (tx->processor == TGSI_PROCESSOR_FRAGMENT) +#define FAILURE_VOID(cond) if ((cond)) {tx->failure=1;return;} + static void sm1_read_semantic(struct shader_translator *, struct sm1_semantic *); @@ -523,7 +526,10 @@ static boolean tx_lconstf(struct shader_translator *tx, struct ureg_src *src, INT index) { INT i; - assert(index >= 0 && index < (NINE_MAX_CONST_F * 2)); + if (index < 0 || index >= (NINE_MAX_CONST_F * 2)) { + tx->failure = TRUE; + return FALSE; + } for (i = 0; i < tx->num_lconstf; ++i) { if (tx->lconstf[i].idx == index) { *src = tx->lconstf[i].reg; @@ -535,7 +541,10 @@ tx_lconstf(struct shader_translator *tx, struct ureg_src *src, INT index) static boolean tx_lconsti(struct shader_translator *tx, struct ureg_src *src, INT index) { - assert(index >= 0 && index < NINE_MAX_CONST_I); + if (index < 0 || index >= NINE_MAX_CONST_I) { + tx->failure = TRUE; + return FALSE; + } if (tx->lconsti[index].idx == index) *src = tx->lconsti[index].reg; return tx->lconsti[index].idx == index; @@ -543,7 +552,10 @@ tx_lconsti(struct shader_translator *tx, struct ureg_src *src, INT index) static boolean tx_lconstb(struct shader_translator *tx, struct ureg_src *src, INT index) { - assert(index >= 0 && index < NINE_MAX_CONST_B); + if (index < 0 || index >= NINE_MAX_CONST_B) { + tx->failure = TRUE; + return FALSE; + } if (tx->lconstb[index].idx == index) *src = tx->lconstb[index].reg; return tx->lconstb[index].idx == index; @@ -555,7 +567,7 @@ tx_set_lconstf(struct shader_translator *tx, INT index, float f[4]) unsigned n; /* Anno1404 sets out of range constants. */ -assert(index >= 0 && index < (NINE_MAX_CONST_F * 2)); +FAILURE_VOID(index < 0 || index >= (NINE_MAX_CONST_F * 2)) if (index >= NINE_MAX_CONST_F) WARN("lconstf index %i too high, indirect access won't work\n", index); @@ -579,7 +591,7 @@ tx_set_lconstf(struct shader_translator *tx, INT index, float f[4]) static void tx_set_lconsti(struct shader_translator *tx, INT index, int i[4]) { -assert(index >= 0 && index < NINE_MAX_CONST_I); +FAILURE_VOID(index < 0 || index >= NINE_MAX_CONST_I) tx->lconsti[index].idx = index; tx->lconsti[index].reg = tx->native_integers ? ureg_imm4i(tx->ureg, i[0], i[1], i[2], i[3]) : @@ -588,7 +600,7 @@ tx_set_lconsti(struct shader_translator *tx, INT index, int i[4]) static void tx_set_lconstb(struct shader_translator *tx, INT index, BOOL b) { -assert(index >= 0 && index < NINE_MAX_CONST_B); +FAILURE_VOID(index < 0 || index >= NINE_MAX_CONST_B) tx->lconstb[index].idx = index; tx->lconstb[index].reg = tx->native_integers ? ureg_imm1u(tx->ureg, b ? 0x : 0) : @@ -598,7 +610,10 @@ tx_set_lconstb(struct shader_translator *tx, INT index, BOOL b) static INLINE struct ureg_dst tx_scratch(struct shader_translator *tx) { -assert(tx->num_scratch < Elements(tx->regs.t)); +if (tx->num_scratch >= Elements(tx->regs.t)) { +tx->failure = TRUE; +return tx->regs.t[0]; +} if (ureg_dst_is_undef(tx->regs.t[tx->num_scratch])) tx->regs.t[tx->num_scratch] = ureg_DECL_local_temporary(tx->ureg); return tx->regs.t[tx->num_scratch++]; @@ -3097,10 +3112,17 @@ nine_translate_shader(struct NineDevice9 *device, struct nine_shader_info *info) ureg_property(tx->ureg, TGSI_PROPERTY_FS_COORD_PIXEL_CENTER, TGSI_FS_COORD_PIXEL_CENTER_INTEGER); } -while (!sm1_parse_eof(tx)) +while (!sm1_parse_eof(tx) && !tx->failure) sm1_parse_instruction(tx); tx->parse++; /* for byte_size */ +if (tx->failure) { +ERR("Encountered buggy shader\n"); +ureg_destroy(tx->ureg); +hr = D3DERR_INVALIDCALL; +goto
[Mesa-dev] [PATCH 15/43] st/nine: Refactor format d3d9 to pipe conversion
Move the checks of whether the format is supported into a common place. The advantage is that allows to handle when a d3d9 format can be mapped to several formats, and that cards don't support all of them. Signed-off-by: Axel Davy --- src/gallium/state_trackers/nine/adapter9.c | 87 ++-- src/gallium/state_trackers/nine/cubetexture9.c | 7 +- src/gallium/state_trackers/nine/device9.c| 6 +- src/gallium/state_trackers/nine/nine_helpers.h | 4 -- src/gallium/state_trackers/nine/nine_pipe.c | 2 +- src/gallium/state_trackers/nine/nine_pipe.h | 55 ++- src/gallium/state_trackers/nine/surface9.c | 7 +- src/gallium/state_trackers/nine/swapchain9.c | 22 +- src/gallium/state_trackers/nine/texture9.c | 7 +- src/gallium/state_trackers/nine/volume9.c| 9 ++- src/gallium/state_trackers/nine/volumetexture9.c | 7 +- 11 files changed, 136 insertions(+), 77 deletions(-) diff --git a/src/gallium/state_trackers/nine/adapter9.c b/src/gallium/state_trackers/nine/adapter9.c index 154d8be..84469b1 100644 --- a/src/gallium/state_trackers/nine/adapter9.c +++ b/src/gallium/state_trackers/nine/adapter9.c @@ -204,19 +204,15 @@ NineAdapter9_CheckDeviceType( struct NineAdapter9 *This, hr = NineAdapter9_GetScreen(This, DevType, &screen); if (FAILED(hr)) { return hr; } -dfmt = d3d9_to_pipe_format(AdapterFormat); -bfmt = d3d9_to_pipe_format(BackBufferFormat); +dfmt = d3d9_to_pipe_format_checked(screen, AdapterFormat, PIPE_TEXTURE_2D, + 1, + PIPE_BIND_DISPLAY_TARGET | + PIPE_BIND_SHARED, FALSE); +bfmt = d3d9_to_pipe_format_checked(screen, BackBufferFormat, PIPE_TEXTURE_2D, + 1, + PIPE_BIND_DISPLAY_TARGET | + PIPE_BIND_SHARED, FALSE); if (dfmt == PIPE_FORMAT_NONE || bfmt == PIPE_FORMAT_NONE) { -DBG("Invalid Adapter/BackBufferFormat.\n"); -return D3DERR_NOTAVAILABLE; -} - -if (!screen->is_format_supported(screen, dfmt, PIPE_TEXTURE_2D, 1, - PIPE_BIND_DISPLAY_TARGET | - PIPE_BIND_SHARED) || -!screen->is_format_supported(screen, bfmt, PIPE_TEXTURE_2D, 1, - PIPE_BIND_DISPLAY_TARGET | - PIPE_BIND_SHARED)) { DBG("Unsupported Adapter/BackBufferFormat.\n"); return D3DERR_NOTAVAILABLE; } @@ -258,6 +254,7 @@ NineAdapter9_CheckDeviceFormat( struct NineAdapter9 *This, enum pipe_format pf; enum pipe_texture_target target; unsigned bind = 0; +boolean srgb; /* Check adapter format. */ @@ -271,11 +268,10 @@ NineAdapter9_CheckDeviceFormat( struct NineAdapter9 *This, hr = NineAdapter9_GetScreen(This, DeviceType, &screen); if (FAILED(hr)) return hr; -pf = d3d9_to_pipe_format(AdapterFormat); -if (pf == PIPE_FORMAT_NONE || -!screen->is_format_supported(screen, pf, PIPE_TEXTURE_2D, 0, +pf = d3d9_to_pipe_format_checked(screen, AdapterFormat, PIPE_TEXTURE_2D, 0, PIPE_BIND_DISPLAY_TARGET | - PIPE_BIND_SHARED)) { + PIPE_BIND_SHARED, FALSE); +if (pf == PIPE_FORMAT_NONE) { DBG("AdapterFormat %s not available.\n", d3dformat_to_string(AdapterFormat)); return D3DERR_NOTAVAILABLE; @@ -330,12 +326,9 @@ NineAdapter9_CheckDeviceFormat( struct NineAdapter9 *This, } -pf = d3d9_to_pipe_format(CheckFormat); -if (Usage & (D3DUSAGE_QUERY_SRGBREAD | D3DUSAGE_QUERY_SRGBWRITE)) -pf = util_format_srgb(pf); - -if (pf == PIPE_FORMAT_NONE || -!screen->is_format_supported(screen, pf, target, 0, bind)) { +srgb = (Usage & (D3DUSAGE_QUERY_SRGBREAD | D3DUSAGE_QUERY_SRGBWRITE)) != 0; +pf = d3d9_to_pipe_format_checked(screen, CheckFormat, target, 0, bind, srgb); +if (pf == PIPE_FORMAT_NONE) { DBG("NOT AVAILABLE\n"); return D3DERR_NOTAVAILABLE; } @@ -362,7 +355,6 @@ NineAdapter9_CheckDeviceMultiSampleType( struct NineAdapter9 *This, struct pipe_screen *screen; HRESULT hr; enum pipe_format pf; -unsigned bind; DBG("This=%p DeviceType=%s SurfaceFormat=%s Windowed=%i MultiSampleType=%u " "pQualityLevels=%p\n", This, nine_D3DDEVTYPE_to_str(DeviceType), @@ -373,13 +365,11 @@ NineAdapter9_CheckDeviceMultiSampleType( struct NineAdapter9 *This, if (FAILED(hr)) return hr; -pf = d3d9_to_pipe_format(SurfaceFormat); -bind = util_format_is_depth_or_stencil(pf) ? -PIPE_BIND_DEPTH_STENCIL :
[Mesa-dev] [PATCH 03/43] st/nine: Declare constants only up to the maximum needed.
Previously 276 constants were declared everytime. This patch makes shaders declare constants up to the maximum constant needed and moves the moment we print the TGSI shader after the moment we declare the constants. This is needed for r500, since when indirect addressing is used, it cannot reduce the amount of constants needed, and that it is restricted to 256 constant slots. Signed-off-by: Axel Davy --- src/gallium/state_trackers/nine/nine_shader.c | 38 --- 1 file changed, 11 insertions(+), 27 deletions(-) diff --git a/src/gallium/state_trackers/nine/nine_shader.c b/src/gallium/state_trackers/nine/nine_shader.c index 1984087..8a8695a 100644 --- a/src/gallium/state_trackers/nine/nine_shader.c +++ b/src/gallium/state_trackers/nine/nine_shader.c @@ -620,24 +620,6 @@ tx_src_scalar(struct ureg_dst dst) return src; } -/* Need to declare all constants if indirect addressing is used, - * otherwise we could scan the shader to determine the maximum. - * TODO: It doesn't really matter for nv50 so I won't do the scan, - * but radeon drivers might care, if they don't infer it from TGSI. - */ -static void -tx_decl_constants(struct shader_translator *tx) -{ -unsigned i, n = 0; - -for (i = 0; i < NINE_MAX_CONST_F; ++i) -ureg_DECL_constant(tx->ureg, n++); -for (i = 0; i < NINE_MAX_CONST_I; ++i) -ureg_DECL_constant(tx->ureg, n++); -for (i = 0; i < (NINE_MAX_CONST_B / 4); ++i) -ureg_DECL_constant(tx->ureg, n++); -} - static INLINE void tx_temp_alloc(struct shader_translator *tx, INT idx) { @@ -3067,7 +3049,7 @@ nine_translate_shader(struct NineDevice9 *device, struct nine_shader_info *info) struct shader_translator *tx; HRESULT hr = D3D_OK; const unsigned processor = tgsi_processor_from_type(info->type); -unsigned slot_max; +unsigned s, slot_max; user_assert(processor != ~0, D3DERR_INVALIDCALL); @@ -3095,7 +3077,6 @@ nine_translate_shader(struct NineDevice9 *device, struct nine_shader_info *info) hr = E_OUTOFMEMORY; goto out; } -tx_decl_constants(tx); tx->native_integers = GET_SHADER_CAP(INTEGERS); tx->inline_subroutines = !GET_SHADER_CAP(SUBROUTINES); @@ -3134,13 +3115,6 @@ nine_translate_shader(struct NineDevice9 *device, struct nine_shader_info *info) if (IS_VS && !ureg_dst_is_undef(tx->regs.oPts)) info->point_size = TRUE; -if (debug_get_bool_option("NINE_TGSI_DUMP", FALSE)) { -unsigned count; -const struct tgsi_token *toks = ureg_get_tokens(tx->ureg, &count); -tgsi_dump(toks, 0); -ureg_free_tokens(toks); -} - /* record local constants */ if (tx->num_lconstf && tx->indirect_const_access) { struct nine_range *ranges; @@ -3210,6 +3184,16 @@ nine_translate_shader(struct NineDevice9 *device, struct nine_shader_info *info) info->num_float_consts_slots; info->const_used_size = sizeof(float[4]) * slot_max; /* slots start from 1 */ +for(s = 0; s < slot_max; s++) +ureg_DECL_constant(tx->ureg, s); + +if (debug_get_bool_option("NINE_TGSI_DUMP", FALSE)) { +unsigned count; +const struct tgsi_token *toks = ureg_get_tokens(tx->ureg, &count); +tgsi_dump(toks, 0); +ureg_free_tokens(toks); +} + info->cso = ureg_create_shader_and_destroy(tx->ureg, device->pipe); if (!info->cso) { hr = D3DERR_DRIVERINTERNALERROR; -- 2.1.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 12/43] st/nine: Implement RESZ hack
This D3D hack allows to resolve a multisampled depth buffer into a single sampled one. Note that the implementation is slightly incorrect. When querying the content of D3DRS_POINTSIZE, it should return the resz code if it has been set. This behaviour will be implemented when state changes will be reworked. For now the current behaviour is ok, since apps use the D3DCREATE_PUREDEVICE flag when creating the device, which means they won't read states and in exchange get better performance. Signed-off-by: Axel Davy --- This patch requires gallium: Add MULTISAMPLE_Z_RESOLVE cap include/D3D9/d3d9types.h| 1 + src/gallium/state_trackers/nine/adapter9.c | 6 +++ src/gallium/state_trackers/nine/device9.c | 57 + src/gallium/state_trackers/nine/nine_pipe.h | 1 + 4 files changed, 65 insertions(+) diff --git a/include/D3D9/d3d9types.h b/include/D3D9/d3d9types.h index 456ae9f..859c2f5 100644 --- a/include/D3D9/d3d9types.h +++ b/include/D3D9/d3d9types.h @@ -658,6 +658,7 @@ typedef enum _D3DFORMAT { D3DFMT_NVDB = MAKEFOURCC('N', 'V', 'D', 'B'), D3DFMT_NV11 = MAKEFOURCC('N', 'V', '1', '1'), D3DFMT_NV12 = MAKEFOURCC('N', 'V', '1', '2'), +D3DFMT_RESZ = MAKEFOURCC('R', 'E', 'S', 'Z'), D3DFMT_Y210 = MAKEFOURCC('Y', '2', '1', '0'), D3DFMT_Y216 = MAKEFOURCC('Y', '2', '1', '6'), D3DFMT_Y410 = MAKEFOURCC('Y', '4', '1', '0') diff --git a/src/gallium/state_trackers/nine/adapter9.c b/src/gallium/state_trackers/nine/adapter9.c index bdf547e..6ff197e 100644 --- a/src/gallium/state_trackers/nine/adapter9.c +++ b/src/gallium/state_trackers/nine/adapter9.c @@ -305,6 +305,12 @@ NineAdapter9_CheckDeviceFormat( struct NineAdapter9 *This, RType == D3DRTYPE_TEXTURE)) return D3D_OK; +/* RESZ hack */ +if (CheckFormat == D3DFMT_RESZ && bind == PIPE_BIND_RENDER_TARGET && +RType == D3DRTYPE_SURFACE) +return screen->get_param(screen, PIPE_CAP_MULTISAMPLE_Z_RESOLVE) ? + D3D_OK : D3DERR_NOTAVAILABLE; + if (Usage & D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING) bind |= PIPE_BIND_BLENDABLE; diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c index b7e83a4..0326442 100644 --- a/src/gallium/state_trackers/nine/device9.c +++ b/src/gallium/state_trackers/nine/device9.c @@ -1991,6 +1991,60 @@ NineDevice9_GetClipPlane( struct NineDevice9 *This, return D3D_OK; } +#define RESZ_CODE 0x7fa05000 + +static HRESULT +NineDevice9_ResolveZ( struct NineDevice9 *This ) +{ +struct nine_state *state = &This->state; +const struct util_format_description *desc; +struct NineSurface9 *source = state->ds; +struct NineBaseTexture9 *destination = state->texture[0]; +struct pipe_resource *src, *dst; +struct pipe_blit_info blit; + +DBG("RESZ resolve\n"); + +user_assert(source && destination && +destination->base.type == D3DRTYPE_TEXTURE, D3DERR_INVALIDCALL); + +src = source->base.resource; +dst = destination->base.resource; + +user_assert(src && dst, D3DERR_INVALIDCALL); + +/* check dst is depth format. we know already for src */ +desc = util_format_description(dst->format); +user_assert(desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS, D3DERR_INVALIDCALL); + +blit.src.resource = src; +blit.src.level = 0; +blit.src.format = src->format; +blit.src.box.z = 0; +blit.src.box.depth = 1; +blit.src.box.x = 0; +blit.src.box.y = 0; +blit.src.box.width = src->width0; +blit.src.box.height = src->height0; + +blit.dst.resource = dst; +blit.dst.level = 0; +blit.dst.format = dst->format; +blit.dst.box.z = 0; +blit.dst.box.depth = 1; +blit.dst.box.x = 0; +blit.dst.box.y = 0; +blit.dst.box.width = dst->width0; +blit.dst.box.height = dst->height0; + +blit.mask = PIPE_MASK_ZS; +blit.filter = PIPE_TEX_FILTER_NEAREST; +blit.scissor_enable = FALSE; + +This->pipe->blit(This->pipe, &blit); +return D3D_OK; +} + HRESULT WINAPI NineDevice9_SetRenderState( struct NineDevice9 *This, D3DRENDERSTATETYPE State, @@ -2001,6 +2055,9 @@ NineDevice9_SetRenderState( struct NineDevice9 *This, DBG("This=%p State=%u(%s) Value=%08x\n", This, State, nine_d3drs_to_string(State), Value); +if (State == D3DRS_POINTSIZE && Value == RESZ_CODE) +return NineDevice9_ResolveZ(This); + user_assert(State < Elements(state->rs), D3DERR_INVALIDCALL); if (likely(state->rs[
[Mesa-dev] [PATCH 17/43] st/nine: NineDevice9_SetClipPlane: pPlane must be non-NULL
Signed-off-by: Axel Davy --- src/gallium/state_trackers/nine/device9.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c index e4b2c90..a446c8f 100644 --- a/src/gallium/state_trackers/nine/device9.c +++ b/src/gallium/state_trackers/nine/device9.c @@ -1968,9 +1968,11 @@ NineDevice9_SetClipPlane( struct NineDevice9 *This, { struct nine_state *state = This->update; -DBG("This=%p Index=%u pPlane=%p(%f %f %f %f)\n", This, Index, pPlane, -pPlane ? pPlane[0] : 0.0f, pPlane ? pPlane[1] : 0.0f, -pPlane ? pPlane[2] : 0.0f, pPlane ? pPlane[3] : 0.0f); +user_assert(pPlane, D3DERR_INVALIDCALL); + +DBG("This=%p Index=%u pPlane=%f %f %f %f\n", This, Index, +pPlane[0], pPlane[1], +pPlane[2], pPlane[3]); user_assert(Index < PIPE_MAX_CLIP_PLANES, D3DERR_INVALIDCALL); -- 2.1.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 18/43] st/nine: Change the value of some advertised caps
These values are taken from wine. Signed-off-by: Axel Davy --- src/gallium/state_trackers/nine/adapter9.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gallium/state_trackers/nine/adapter9.c b/src/gallium/state_trackers/nine/adapter9.c index 84469b1..84578ac 100644 --- a/src/gallium/state_trackers/nine/adapter9.c +++ b/src/gallium/state_trackers/nine/adapter9.c @@ -731,7 +731,7 @@ NineAdapter9_GetDeviceCaps( struct NineAdapter9 *This, D3DPIPECAP(TWO_SIDED_STENCIL, D3DSTENCILCAPS_TWOSIDED); pCaps->FVFCaps = -(D3DFVFCAPS_TEXCOORDCOUNTMASK & 0xff) | +8 | /* 8 textures max */ /*D3DFVFCAPS_DONOTSTRIPELEMENTS |*/ D3DFVFCAPS_PSIZE; @@ -787,8 +787,8 @@ NineAdapter9_GetDeviceCaps( struct NineAdapter9 *This, pCaps->MaxPointSize = screen->get_paramf(screen, PIPE_CAPF_MAX_POINT_WIDTH); -pCaps->MaxPrimitiveCount = 0xF; /* <- wine, really 0x; */ -pCaps->MaxVertexIndex = 0xF; /* <- wine, really 0x */ +pCaps->MaxPrimitiveCount = 0x55; /* <- wine, really 0x; */ +pCaps->MaxVertexIndex = 0xFF; /* <- wine, really 0x */ pCaps->MaxStreams = _min(screen->get_shader_param(screen, PIPE_SHADER_VERTEX, PIPE_SHADER_CAP_MAX_INPUTS), -- 2.1.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 31/43] st/nine: D3DRS_FILLMODE set to 0 is D3DFILL_SOLID
From: Tiziano Bacocco Reviewed-by: Axel Davy Reviewed-by: David Heidelberg Signed-off-by: Tiziano Bacocco --- include/D3D9/d3d9types.h| 1 + src/gallium/state_trackers/nine/nine_pipe.h | 1 + 2 files changed, 2 insertions(+) diff --git a/include/D3D9/d3d9types.h b/include/D3D9/d3d9types.h index e96f751..52fbc99 100644 --- a/include/D3D9/d3d9types.h +++ b/include/D3D9/d3d9types.h @@ -573,6 +573,7 @@ typedef enum _D3DDEVTYPE { } D3DDEVTYPE; typedef enum _D3DFILLMODE { +D3DFILL_SOLID_ZERO = 0, D3DFILL_POINT = 1, D3DFILL_WIREFRAME = 2, D3DFILL_SOLID = 3 diff --git a/src/gallium/state_trackers/nine/nine_pipe.h b/src/gallium/state_trackers/nine/nine_pipe.h index c1269b3..9521d1a 100644 --- a/src/gallium/state_trackers/nine/nine_pipe.h +++ b/src/gallium/state_trackers/nine/nine_pipe.h @@ -516,6 +516,7 @@ d3dfillmode_to_pipe_polygon_mode(D3DFILLMODE mode) case D3DFILL_POINT: return PIPE_POLYGON_MODE_POINT; case D3DFILL_WIREFRAME: return PIPE_POLYGON_MODE_LINE; case D3DFILL_SOLID: return PIPE_POLYGON_MODE_FILL; +case D3DFILL_SOLID_ZERO:return PIPE_POLYGON_MODE_FILL; default: assert(0); return PIPE_POLYGON_MODE_FILL; -- 2.1.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 29/43] st/nine: Implement fallback behaviour when rts and ds don't match
This seems to be the behaviour on Win. Previous behaviour led to different issues depending on the driver. Signed-off-by: Axel Davy --- src/gallium/state_trackers/nine/nine_state.c | 46 +--- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/src/gallium/state_trackers/nine/nine_state.c b/src/gallium/state_trackers/nine/nine_state.c index 1e53335..02fef9a 100644 --- a/src/gallium/state_trackers/nine/nine_state.c +++ b/src/gallium/state_trackers/nine/nine_state.c @@ -44,7 +44,10 @@ update_framebuffer(struct NineDevice9 *device) struct nine_state *state = &device->state; struct pipe_framebuffer_state *fb = &device->state.fb; unsigned i; -unsigned w = 0, h = 0; /* no surface can have width or height 0 */ +struct NineSurface9 *rt0 = state->rt[0]; +unsigned w = rt0->desc.Width; +unsigned h = rt0->desc.Height; +D3DMULTISAMPLE_TYPE nr_samples = rt0->desc.MultiSampleType; const int sRGB = state->rs[D3DRS_SRGBWRITEENABLE] ? 1 : 0; @@ -53,19 +56,31 @@ update_framebuffer(struct NineDevice9 *device) state->rt_mask = 0x0; fb->nr_cbufs = 0; +/* all render targets must have the same size and the depth buffer must be + * bigger. Multisample has to match, according to spec. But some apps do + * things wrong there, and no error is returned. The behaviour they get + * apparently is that depth buffer is disabled if it doesn't match. + * Surely the same for render targets. */ + +/* Special case: D3DFMT_NULL is used to bound no real render target, + * but render to depth buffer. We have to not take into account the render + * target info. TODO: know what should happen when there are several render targers + * and the first one is D3DFMT_NULL */ +if (rt0->desc.Format == D3DFMT_NULL && state->ds) { +w = state->ds->desc.Width; +h = state->ds->desc.Height; +nr_samples = state->ds->desc.MultiSampleType; +} + for (i = 0; i < device->caps.NumSimultaneousRTs; ++i) { -if (state->rt[i] && state->rt[i]->desc.Format != D3DFMT_NULL) { -struct NineSurface9 *rt = state->rt[i]; +struct NineSurface9 *rt = state->rt[i]; + +if (rt && rt->desc.Format != D3DFMT_NULL && rt->desc.Width == w && +rt->desc.Height == h && rt->desc.MultiSampleType == nr_samples) { fb->cbufs[i] = NineSurface9_GetSurface(rt, sRGB); state->rt_mask |= 1 << i; fb->nr_cbufs = i + 1; -if (w) { -w = MIN2(w, rt->desc.Width); -h = MIN2(h, rt->desc.Height); -} else { -w = rt->desc.Width; -h = rt->desc.Height; -} + if (unlikely(rt->desc.Usage & D3DUSAGE_AUTOGENMIPMAP)) { assert(rt->texture == D3DRTYPE_TEXTURE || rt->texture == D3DRTYPE_CUBETEXTURE); @@ -79,15 +94,10 @@ update_framebuffer(struct NineDevice9 *device) } } -if (state->ds) { +if (state->ds && state->ds->desc.Width >= w && +state->ds->desc.Height >= h && +state->ds->desc.MultiSampleType == nr_samples) { fb->zsbuf = NineSurface9_GetSurface(state->ds, 0); -if (w) { -w = MIN2(w, state->ds->desc.Width); -h = MIN2(h, state->ds->desc.Height); -} else { -w = state->ds->desc.Width; -h = state->ds->desc.Height; -} } else { fb->zsbuf = NULL; } -- 2.1.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 04/43] st/nine: Print warnings for r500 when shader is likely to go wrong
r500 hasn't enough float constants for vs to fill all needs. Overlapping issues can happen with complex shaders. The fix would be to recompile shaders to include the integer and boolean constants, instead of reserving slots for them. Signed-off-by: Axel Davy --- src/gallium/state_trackers/nine/nine_shader.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/src/gallium/state_trackers/nine/nine_shader.c b/src/gallium/state_trackers/nine/nine_shader.c index 8a8695a..66cfc1f 100644 --- a/src/gallium/state_trackers/nine/nine_shader.c +++ b/src/gallium/state_trackers/nine/nine_shader.c @@ -3173,6 +3173,12 @@ nine_translate_shader(struct NineDevice9 *device, struct nine_shader_info *info) hr = D3D_OK; } +/* r500 */ +if (info->num_float_consts_slots > device->max_vs_const_f && +(info->num_int_consts_slots || info->num_bool_consts_slots)) +ERR("Overlapping constant slots. The shader is likely to be buggy\n"); + + if (tx->indirect_const_access) /* vs only */ info->num_float_consts_slots = device->max_vs_const_f; -- 2.1.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 08/43] st/nine: Commit sampler views again if srgb state changed.
This fixes a wine test and some minor visual issues on some games. The patch is not optimal, there is probably a more efficient way to fix this issue, but the code there already has some innefficiencies. There is plans to rewrite that part of the code to make it more efficient. Signed-off-by: Axel Davy --- src/gallium/state_trackers/nine/device9.c| 3 +++ src/gallium/state_trackers/nine/nine_state.c | 5 +++-- src/gallium/state_trackers/nine/nine_state.h | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c index 656f488..b7e83a4 100644 --- a/src/gallium/state_trackers/nine/device9.c +++ b/src/gallium/state_trackers/nine/device9.c @@ -2327,6 +2327,9 @@ NineDevice9_SetSamplerState( struct NineDevice9 *This, state->changed.group |= NINE_STATE_SAMPLER; state->changed.sampler[Sampler] |= 1 << Type; +if (Type == D3DSAMP_SRGBTEXTURE) +state->changed.srgb = TRUE; + return D3D_OK; } diff --git a/src/gallium/state_trackers/nine/nine_state.c b/src/gallium/state_trackers/nine/nine_state.c index dad6651..972ed1f 100644 --- a/src/gallium/state_trackers/nine/nine_state.c +++ b/src/gallium/state_trackers/nine/nine_state.c @@ -678,7 +678,7 @@ update_textures_and_samplers(struct NineDevice9 *device) nine_convert_sampler_state(device->cso, s, state->samp[s]); } } -if (state->changed.texture & NINE_PS_SAMPLERS_MASK) +if (state->changed.texture & NINE_PS_SAMPLERS_MASK || state->changed.srgb) pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, num_textures, view); @@ -708,13 +708,14 @@ update_textures_and_samplers(struct NineDevice9 *device) nine_convert_sampler_state(device->cso, s, state->samp[s]); } } -if (state->changed.texture & NINE_VS_SAMPLERS_MASK) +if (state->changed.texture & NINE_VS_SAMPLERS_MASK || state->changed.srgb) pipe->set_sampler_views(pipe, PIPE_SHADER_VERTEX, 0, num_textures, view); if (commit_samplers) cso_single_sampler_done(device->cso, PIPE_SHADER_VERTEX); +state->changed.srgb = FALSE; state->changed.texture = 0; } diff --git a/src/gallium/state_trackers/nine/nine_state.h b/src/gallium/state_trackers/nine/nine_state.h index 028e57d..6e94e68 100644 --- a/src/gallium/state_trackers/nine/nine_state.h +++ b/src/gallium/state_trackers/nine/nine_state.h @@ -123,6 +123,7 @@ struct nine_state uint16_t vs_const_b; /* NINE_MAX_CONST_B == 16 */ uint16_t ps_const_b; uint8_t ucp; +boolean srgb; } changed; struct NineSurface9 *rt[NINE_MAX_SIMULTANEOUS_RENDERTARGETS]; -- 2.1.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 06/43] st/nine: Check for the correct number of constants.
This removes unneeded hack for Anno 1404. This app is not checking the number of supporting constants, and rely on the shader compilation to fail if it puts too many constants. This patch also checks for the correct number of constants for ps. Note that we don't check the official limitations for old vs and ps versions. The restrictions were fixed, unlike for the number of vertex shader constants for later versions. Likely apps use the correct number, and it's not a problem for us if it wants use more. Signed-off-by: Axel Davy --- src/gallium/state_trackers/nine/nine_shader.c | 8 src/gallium/state_trackers/nine/nine_state.h | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/gallium/state_trackers/nine/nine_shader.c b/src/gallium/state_trackers/nine/nine_shader.c index 3e39a08..6a595b6 100644 --- a/src/gallium/state_trackers/nine/nine_shader.c +++ b/src/gallium/state_trackers/nine/nine_shader.c @@ -504,6 +504,7 @@ struct shader_translator #define IS_VS (tx->processor == TGSI_PROCESSOR_VERTEX) #define IS_PS (tx->processor == TGSI_PROCESSOR_FRAGMENT) +#define NINE_MAX_CONST_F_SHADER (tx->processor == TGSI_PROCESSOR_VERTEX ? NINE_MAX_CONST_F : NINE_MAX_CONST_F_PS3) #define FAILURE_VOID(cond) if ((cond)) {tx->failure=1;return;} @@ -526,7 +527,7 @@ static boolean tx_lconstf(struct shader_translator *tx, struct ureg_src *src, INT index) { INT i; - if (index < 0 || index >= (NINE_MAX_CONST_F * 2)) { + if (index < 0 || index >= NINE_MAX_CONST_F_SHADER) { tx->failure = TRUE; return FALSE; } @@ -566,9 +567,8 @@ tx_set_lconstf(struct shader_translator *tx, INT index, float f[4]) { unsigned n; -/* Anno1404 sets out of range constants. */ -FAILURE_VOID(index < 0 || index >= (NINE_MAX_CONST_F * 2)) -if (index >= NINE_MAX_CONST_F) +FAILURE_VOID(index < 0 || index >= NINE_MAX_CONST_F_SHADER) +if (IS_VS && index >= NINE_MAX_CONST_F_SHADER) WARN("lconstf index %i too high, indirect access won't work\n", index); for (n = 0; n < tx->num_lconstf; ++n) diff --git a/src/gallium/state_trackers/nine/nine_state.h b/src/gallium/state_trackers/nine/nine_state.h index 927bfe1..028e57d 100644 --- a/src/gallium/state_trackers/nine/nine_state.h +++ b/src/gallium/state_trackers/nine/nine_state.h @@ -80,6 +80,7 @@ #define NINE_MAX_SIMULTANEOUS_RENDERTARGETS 4 +#define NINE_MAX_CONST_F_PS3 224 #define NINE_MAX_CONST_F 256 #define NINE_MAX_CONST_I 16 #define NINE_MAX_CONST_B 16 -- 2.1.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 41/43] gallium/targets/d3dadapter9: Release the pipe_screen at destruction.
We weren't releasing hal and ref, causing some issues (threads not released, etc) Signed-off-by: Axel Davy --- src/gallium/targets/d3dadapter9/drm.c | 18 -- 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/gallium/targets/d3dadapter9/drm.c b/src/gallium/targets/d3dadapter9/drm.c index bdc402f..f054654 100644 --- a/src/gallium/targets/d3dadapter9/drm.c +++ b/src/gallium/targets/d3dadapter9/drm.c @@ -79,14 +79,20 @@ struct d3dadapter9drm_context static void drm_destroy( struct d3dadapter9_context *ctx ) { +if (ctx->ref) +ctx->ref->destroy(ctx->ref); +/* because ref is a wrapper around hal, freeing ref frees hal too. */ +else if (ctx->hal) +ctx->hal->destroy(ctx->hal); #if !GALLIUM_STATIC_TARGETS -struct d3dadapter9drm_context *drm = (struct d3dadapter9drm_context *)ctx; +{ +struct d3dadapter9drm_context *drm = (struct d3dadapter9drm_context *)ctx; -/* pipe_loader_sw destroys the context */ -if (drm->swdev) -pipe_loader_release(&drm->swdev, 1); -if (drm->dev) -pipe_loader_release(&drm->dev, 1); +if (drm->swdev) +pipe_loader_release(&drm->swdev, 1); +if (drm->dev) +pipe_loader_release(&drm->dev, 1); +} #endif FREE(ctx); -- 2.1.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 22/43] st/nine: Missing sanity check for CALLOC return E_OUTOFMEMORY if allocation of usage_map fails
From: Patrick Rudolph Reviewed-by: Axel Davy Signed-off-by: Patrick Rudolph --- src/gallium/state_trackers/nine/vertexdeclaration9.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/state_trackers/nine/vertexdeclaration9.c b/src/gallium/state_trackers/nine/vertexdeclaration9.c index 4aea116..08b95e2 100644 --- a/src/gallium/state_trackers/nine/vertexdeclaration9.c +++ b/src/gallium/state_trackers/nine/vertexdeclaration9.c @@ -192,7 +192,7 @@ NineVertexDeclaration9_ctor( struct NineVertexDeclaration9 *This, This->decls = CALLOC(This->nelems+1, sizeof(D3DVERTEXELEMENT9)); This->elems = CALLOC(This->nelems, sizeof(struct pipe_vertex_element)); This->usage_map = CALLOC(This->nelems, sizeof(uint16_t)); -if (!This->decls || !This->elems) { return E_OUTOFMEMORY; } +if (!This->decls || !This->elems || !This->usage_map) { return E_OUTOFMEMORY; } memcpy(This->decls, pElements, sizeof(D3DVERTEXELEMENT9)*(This->nelems+1)); for (i = 0; i < This->nelems; ++i) { -- 2.1.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 36/43] st/nine: Fix multisampling support detection
Signed-off-by: Axel Davy --- src/gallium/state_trackers/nine/adapter9.c | 12 +--- src/gallium/state_trackers/nine/nine_pipe.h | 25 - 2 files changed, 9 insertions(+), 28 deletions(-) diff --git a/src/gallium/state_trackers/nine/adapter9.c b/src/gallium/state_trackers/nine/adapter9.c index e9bb9c0..069cc03 100644 --- a/src/gallium/state_trackers/nine/adapter9.c +++ b/src/gallium/state_trackers/nine/adapter9.c @@ -359,6 +359,7 @@ NineAdapter9_CheckDeviceMultiSampleType( struct NineAdapter9 *This, struct pipe_screen *screen; HRESULT hr; enum pipe_format pf; +unsigned bind; DBG("This=%p DeviceType=%s SurfaceFormat=%s Windowed=%i MultiSampleType=%u " "pQualityLevels=%p\n", This, nine_D3DDEVTYPE_to_str(DeviceType), @@ -369,9 +370,14 @@ NineAdapter9_CheckDeviceMultiSampleType( struct NineAdapter9 *This, if (FAILED(hr)) return hr; -pf = d3d9_to_pipe_format_checked_no_bind(screen, SurfaceFormat, - PIPE_TEXTURE_2D, - MultiSampleType, FALSE); +if (depth_stencil_format(SurfaceFormat)) +bind = d3d9_get_pipe_depth_format_bindings(SurfaceFormat); +else /* render-target */ +bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_TRANSFER_READ | + PIPE_BIND_TRANSFER_WRITE | PIPE_BIND_RENDER_TARGET; + +pf = d3d9_to_pipe_format_checked(screen, SurfaceFormat, PIPE_TEXTURE_2D, + MultiSampleType, bind, FALSE); if (pf == PIPE_FORMAT_NONE) { DBG("%s with %u samples not available.\n", diff --git a/src/gallium/state_trackers/nine/nine_pipe.h b/src/gallium/state_trackers/nine/nine_pipe.h index 7295bdf..17844d5 100644 --- a/src/gallium/state_trackers/nine/nine_pipe.h +++ b/src/gallium/state_trackers/nine/nine_pipe.h @@ -309,31 +309,6 @@ d3d9_to_pipe_format_checked(struct pipe_screen *screen, return PIPE_FORMAT_NONE; } -/* same that above, but determines binding flags */ -static INLINE enum pipe_format -d3d9_to_pipe_format_checked_no_bind(struct pipe_screen *screen, -D3DFORMAT format, -enum pipe_texture_target target, -unsigned sample_count, -boolean srgb) -{ -enum pipe_format result; -unsigned bindings; - -result = d3d9_to_pipe_format_internal(format); -if (result == PIPE_FORMAT_NONE) -return PIPE_FORMAT_NONE; - -bindings = util_format_is_depth_or_stencil(result) ? -PIPE_BIND_DEPTH_STENCIL : PIPE_BIND_RENDER_TARGET; -if (srgb) -result = util_format_srgb(result); - -if (format_check_internal(result)) -return result; -return PIPE_FORMAT_NONE; -} - static INLINE const char * d3dformat_to_string(D3DFORMAT fmt) { -- 2.1.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 40/43] gallium/targets/d3dadapter9: Fix device detection for render-nodes
When on a render node the unique ioctl doesn't work. This patch drops the code to detect the device, which relied on an ioctl, and replaces it by the mesa loader function. The mesa loader function is more complete and won't fail for render-nodes. Alternatively we could also have used the pipe cap to determine the vendor and device id from the driver. Signed-off-by: Axel Davy --- src/gallium/targets/d3dadapter9/drm.c | 59 +-- 1 file changed, 14 insertions(+), 45 deletions(-) diff --git a/src/gallium/targets/d3dadapter9/drm.c b/src/gallium/targets/d3dadapter9/drm.c index dd916f1..bdc402f 100644 --- a/src/gallium/targets/d3dadapter9/drm.c +++ b/src/gallium/targets/d3dadapter9/drm.c @@ -135,53 +135,22 @@ get_bus_info( int fd, DWORD *subsysid, DWORD *revision ) { -drm_unique_t u; - -u.unique_len = 0; -u.unique = NULL; - -if (ioctl(fd, DRM_IOCTL_GET_UNIQUE, &u)) { return; } -u.unique = CALLOC(u.unique_len+1, 1); - -if (ioctl(fd, DRM_IOCTL_GET_UNIQUE, &u)) { return; } -u.unique[u.unique_len] = '\0'; - -DBG("DRM Device BusID: %s\n", u.unique); -if (strncmp("pci:", u.unique, 4) == 0) { -char fname[512]; /* this ought to be enough */ -int l = snprintf(fname, 512, "/sys/bus/pci/devices/%s/", u.unique+4); - -/* VendorId */ -snprintf(fname+l, 512-l, "vendor"); -*vendorid = read_file_dword(fname); -/* DeviceId */ -snprintf(fname+l, 512-l, "device"); -*deviceid = read_file_dword(fname); -/* SubSysId */ -snprintf(fname+l, 512-l, "subsystem_device"); -*subsysid = (read_file_dword(fname) << 16) & 0x; -snprintf(fname+l, 512-l, "subsystem_vendor"); -*subsysid |= read_file_dword(fname) & 0x; -/* Revision */ -{ -int cfgfd; - -snprintf(fname+l, 512-l, "config"); -cfgfd = open(fname, O_RDONLY); -if (cfgfd >= 0) { -*revision = read_config_dword(cfgfd, 0x8) & 0x00FF; -close(cfgfd); -} else { -DBG("Unable to get raw PCI information from `%s'\n", fname); -} -} -DBG("PCI info: vendor=0x%04x, device=0x%04x, subsys=0x%08x, rev=%d\n", -*vendorid, *deviceid, *subsysid, *revision); +int vid, did; + +if (loader_get_pci_id_for_fd(fd, &vid, &did)) { +DBG("PCI info: vendor=0x%04x, device=0x%04x\n", +vid, did); +*vendorid = vid; +*deviceid = did; +*subsysid = 0; +*revision = 0; } else { -DBG("Unsupported BusID type.\n"); +DBG("Unable to detect card. Fake GTX 680.\n"); +*vendorid = 0x10de; /* NV GTX 680 */ +*deviceid = 0x1180; +*subsysid = 0; +*revision = 0; } - -FREE(u.unique); } static INLINE void -- 2.1.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 42/43] gallium/targets/d3dadapter9: Free card device
The drm fd wasn't released, causing a crash for wine tests on nouveau, which seems to have a bug when a lot of device descriptors are open. Signed-off-by: Axel Davy --- src/gallium/targets/d3dadapter9/drm.c | 18 ++ 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/gallium/targets/d3dadapter9/drm.c b/src/gallium/targets/d3dadapter9/drm.c index f054654..cb0c48f 100644 --- a/src/gallium/targets/d3dadapter9/drm.c +++ b/src/gallium/targets/d3dadapter9/drm.c @@ -74,27 +74,28 @@ struct d3dadapter9drm_context { struct d3dadapter9_context base; struct pipe_loader_device *dev, *swdev; +int fd; }; static void drm_destroy( struct d3dadapter9_context *ctx ) { +struct d3dadapter9drm_context *drm = (struct d3dadapter9drm_context *)ctx; + if (ctx->ref) ctx->ref->destroy(ctx->ref); /* because ref is a wrapper around hal, freeing ref frees hal too. */ else if (ctx->hal) ctx->hal->destroy(ctx->hal); -#if !GALLIUM_STATIC_TARGETS -{ -struct d3dadapter9drm_context *drm = (struct d3dadapter9drm_context *)ctx; -if (drm->swdev) -pipe_loader_release(&drm->swdev, 1); -if (drm->dev) -pipe_loader_release(&drm->dev, 1); -} +#if !GALLIUM_STATIC_TARGETS +if (drm->swdev) +pipe_loader_release(&drm->swdev, 1); +if (drm->dev) +pipe_loader_release(&drm->dev, 1); #endif +close(drm->fd); FREE(ctx); } @@ -235,6 +236,7 @@ drm_create_adapter( int fd, ctx->base.destroy = drm_destroy; fd = loader_get_user_preferred_fd(fd, &different_device); +ctx->fd = fd; ctx->base.linear_framebuffer = !!different_device; #if GALLIUM_STATIC_TARGETS -- 2.1.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 13/43] st/nine: Improve CheckDeviceFormat debug output
Because the debug output of this function was cut in two parts, sometimes the second part wasn't print when we would return earlier, whereas we would like to get it. The reason of the separation was that it's only at the end of the function we can print what we map to the d3d9 arguments, but we can always retrieve that info by hand. Signed-off-by: Axel Davy --- src/gallium/state_trackers/nine/adapter9.c | 12 +++- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/gallium/state_trackers/nine/adapter9.c b/src/gallium/state_trackers/nine/adapter9.c index 6ff197e..154d8be 100644 --- a/src/gallium/state_trackers/nine/adapter9.c +++ b/src/gallium/state_trackers/nine/adapter9.c @@ -261,11 +261,11 @@ NineAdapter9_CheckDeviceFormat( struct NineAdapter9 *This, /* Check adapter format. */ -/* Nicer output if we only have the line at the end. */ -#if 1 DBG("This=%p DeviceType=%s AdapterFormat=%s\n", This, nine_D3DDEVTYPE_to_str(DeviceType), d3dformat_to_string(AdapterFormat)); -#endif +DBG("Usage=%x RType=%u CheckFormat=%s\n", Usage, RType, +d3dformat_to_string(CheckFormat)); + user_assert(display_format(AdapterFormat, FALSE), D3DERR_INVALIDCALL); hr = NineAdapter9_GetScreen(This, DeviceType, &screen); @@ -334,12 +334,6 @@ NineAdapter9_CheckDeviceFormat( struct NineAdapter9 *This, if (Usage & (D3DUSAGE_QUERY_SRGBREAD | D3DUSAGE_QUERY_SRGBWRITE)) pf = util_format_srgb(pf); -DBG("Format=%s/%s Usage/Bind=%x/%d RType/Target=%u/%s\n", // replace %d to %s -d3dformat_to_string(CheckFormat), util_format_name(pf), -Usage, bind, // temporary simplified for merge, FIXME -/* Usage, util_dump_bind_flags(bind), */ -RType, util_dump_tex_target(target, TRUE)); - if (pf == PIPE_FORMAT_NONE || !screen->is_format_supported(screen, pf, target, 0, bind)) { DBG("NOT AVAILABLE\n"); -- 2.1.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 39/43] st/nine: Dummy sampler should have a=1
Signed-off-by: Axel Davy --- src/gallium/state_trackers/nine/device9.c| 39 +++ src/gallium/state_trackers/nine/device9.h| 3 + src/gallium/state_trackers/nine/nine_ff.c| 7 ++ src/gallium/state_trackers/nine/nine_state.c | 155 +++ src/gallium/state_trackers/nine/nine_state.h | 2 + 5 files changed, 163 insertions(+), 43 deletions(-) diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c index 25e1444..e052464 100644 --- a/src/gallium/state_trackers/nine/device9.c +++ b/src/gallium/state_trackers/nine/device9.c @@ -298,6 +298,43 @@ NineDevice9_ctor( struct NineDevice9 *This, return E_OUTOFMEMORY; } +/* allocate dummy texture/sampler for when there are missing ones bound */ +{ +struct pipe_resource tmplt; +struct pipe_sampler_view templ; + +tmplt.target = PIPE_TEXTURE_2D; +tmplt.width0 = 1; +tmplt.height0 = 1; +tmplt.depth0 = 1; +tmplt.last_level = 0; +tmplt.array_size = 1; +tmplt.usage = PIPE_USAGE_DEFAULT; +tmplt.flags = 0; +tmplt.format = PIPE_FORMAT_B8G8R8A8_UNORM; +tmplt.bind = PIPE_BIND_SAMPLER_VIEW; +tmplt.nr_samples = 0; + +This->dummy_texture = This->screen->resource_create(This->screen, &tmplt); +if (!This->dummy_texture) +return D3DERR_DRIVERINTERNALERROR; + +templ.format = PIPE_FORMAT_B8G8R8A8_UNORM; +templ.u.tex.first_layer = 0; +templ.u.tex.last_layer = 0; +templ.u.tex.first_level = 0; +templ.u.tex.last_level = 0; +templ.swizzle_r = PIPE_SWIZZLE_ZERO; +templ.swizzle_g = PIPE_SWIZZLE_ZERO; +templ.swizzle_b = PIPE_SWIZZLE_ZERO; +templ.swizzle_a = PIPE_SWIZZLE_ONE; +templ.target = This->dummy_texture->target; + +This->dummy_sampler = This->pipe->create_sampler_view(This->pipe, This->dummy_texture, &templ); +if (!This->dummy_sampler) +return D3DERR_DRIVERINTERNALERROR; +} + /* Allocate upload helper for drivers that suck (from st pov ;). */ { unsigned bind = 0; @@ -346,6 +383,8 @@ NineDevice9_dtor( struct NineDevice9 *This ) nine_bind(&This->record, NULL); +pipe_sampler_view_reference(&This->dummy_sampler, NULL); +pipe_resource_reference(&This->dummy_texture, NULL); pipe_resource_reference(&This->constbuf_vs, NULL); pipe_resource_reference(&This->constbuf_ps, NULL); FREE(This->state.vs_const_f); diff --git a/src/gallium/state_trackers/nine/device9.h b/src/gallium/state_trackers/nine/device9.h index dc97ae7..54da9e3 100644 --- a/src/gallium/state_trackers/nine/device9.h +++ b/src/gallium/state_trackers/nine/device9.h @@ -82,6 +82,9 @@ struct NineDevice9 uint16_t max_vs_const_f; uint16_t max_ps_const_f; +struct pipe_resource *dummy_texture; +struct pipe_sampler_view *dummy_sampler; + struct gen_mipmap_state *gen_mipmap; struct { diff --git a/src/gallium/state_trackers/nine/nine_ff.c b/src/gallium/state_trackers/nine/nine_ff.c index 2e3470f..e6f2b21 100644 --- a/src/gallium/state_trackers/nine/nine_ff.c +++ b/src/gallium/state_trackers/nine/nine_ff.c @@ -1493,6 +1493,7 @@ nine_ff_get_ps(struct NineDevice9 *device) enum pipe_error err; struct nine_ff_ps_key key; unsigned s; +uint8_t sampler_mask = 0; assert(sizeof(key) <= sizeof(key.value32)); @@ -1506,12 +1507,17 @@ nine_ff_get_ps(struct NineDevice9 *device) key.ts[s].alphaop = D3DTOP_DISABLE; /* DISABLE == 1, avoid degenerate keys */ break; } + if (!state->texture[s] && state->ff.tex_stage[s][D3DTSS_COLORARG1] == D3DTA_TEXTURE) { /* This should also disable the stage. */ key.ts[s].colorop = key.ts[s].alphaop = D3DTOP_DISABLE; break; } + +if (state->ff.tex_stage[s][D3DTSS_COLORARG1] == D3DTA_TEXTURE) +sampler_mask |= (1 << s); + if (key.ts[s].colorop != D3DTOP_DISABLE) { uint8_t used_c = ps_d3dtop_args_mask(key.ts[s].colorop); if (used_c & 0x1) key.ts[s].colorarg0 = state->ff.tex_stage[s][D3DTSS_COLORARG0]; @@ -1570,6 +1576,7 @@ nine_ff_get_ps(struct NineDevice9 *device) NineUnknown_ConvertRefToBind(NineUnknown(ps)); ps->rt_mask = 0x1; +ps->sampler_mask = sampler_mask; } return ps; } diff --git a/src/gallium/state_trackers/nine/nine_state.c b/src/gallium/state_trackers/nine/nine_state.c index 86a6ca8..ba75817 100644 --- a/src/gallium/state_trackers/nine/nine_state.c +++ b/src/gallium/state_trackers/nine/nine_state.c @@ -279,6 +279,7 @@ update_vs(struct NineDevice9 *device) { struct nine_state *state = &device->state; struct NineVertexSh
[Mesa-dev] [PATCH 34/43] st/nine: Fix depth stencil formats bindings flags.
Signed-off-by: Axel Davy --- src/gallium/state_trackers/nine/adapter9.c | 26 ++ src/gallium/state_trackers/nine/device9.c| 4 ++- src/gallium/state_trackers/nine/nine_pipe.h | 51 src/gallium/state_trackers/nine/swapchain9.c | 20 +-- 4 files changed, 74 insertions(+), 27 deletions(-) diff --git a/src/gallium/state_trackers/nine/adapter9.c b/src/gallium/state_trackers/nine/adapter9.c index 459aac3..e9bb9c0 100644 --- a/src/gallium/state_trackers/nine/adapter9.c +++ b/src/gallium/state_trackers/nine/adapter9.c @@ -385,29 +385,6 @@ NineAdapter9_CheckDeviceMultiSampleType( struct NineAdapter9 *This, return D3D_OK; } -static INLINE boolean -depth_stencil_format( D3DFORMAT fmt ) -{ -static D3DFORMAT allowed[] = { -D3DFMT_D16_LOCKABLE, -D3DFMT_D32, -D3DFMT_D15S1, -D3DFMT_D24S8, -D3DFMT_D24X8, -D3DFMT_D24X4S4, -D3DFMT_D16, -D3DFMT_D32F_LOCKABLE, -D3DFMT_D24FS8, -D3DFMT_D32_LOCKABLE -}; -unsigned i; - -for (i = 0; i < sizeof(allowed)/sizeof(D3DFORMAT); i++) { -if (fmt == allowed[i]) { return TRUE; } -} -return FALSE; -} - HRESULT WINAPI NineAdapter9_CheckDepthStencilMatch( struct NineAdapter9 *This, D3DDEVTYPE DeviceType, @@ -441,7 +418,8 @@ NineAdapter9_CheckDepthStencilMatch( struct NineAdapter9 *This, bfmt = dfmt; zsfmt = d3d9_to_pipe_format_checked(screen, DepthStencilFormat, PIPE_TEXTURE_2D, 0, -PIPE_BIND_DEPTH_STENCIL, FALSE); + d3d9_get_pipe_depth_format_bindings(DepthStencilFormat), +FALSE); if (dfmt == PIPE_FORMAT_NONE || bfmt == PIPE_FORMAT_NONE || zsfmt == PIPE_FORMAT_NONE) { diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c index dfec5f9..fe251fe 100644 --- a/src/gallium/state_trackers/nine/device9.c +++ b/src/gallium/state_trackers/nine/device9.c @@ -971,7 +971,7 @@ create_zs_or_rt_surface(struct NineDevice9 *This, templ.bind = PIPE_BIND_SAMPLER_VIEW; /* StretchRect */ switch (type) { case 0: templ.bind |= PIPE_BIND_RENDER_TARGET; break; -case 1: templ.bind |= PIPE_BIND_DEPTH_STENCIL; break; +case 1: templ.bind = d3d9_get_pipe_depth_format_bindings(Format); break; default: assert(type == 2); break; @@ -1042,6 +1042,8 @@ NineDevice9_CreateDepthStencilSurface( struct NineDevice9 *This, HANDLE *pSharedHandle ) { *ppSurface = NULL; +if (!depth_stencil_format(Format)) +return D3DERR_NOTAVAILABLE; return create_zs_or_rt_surface(This, 1, D3DPOOL_DEFAULT, Width, Height, Format, MultiSample, MultisampleQuality, diff --git a/src/gallium/state_trackers/nine/nine_pipe.h b/src/gallium/state_trackers/nine/nine_pipe.h index 9521d1a..7295bdf 100644 --- a/src/gallium/state_trackers/nine/nine_pipe.h +++ b/src/gallium/state_trackers/nine/nine_pipe.h @@ -175,6 +175,57 @@ pipe_to_d3d9_format(enum pipe_format format) return nine_pipe_to_d3d9_format_map[format]; } +static INLINE boolean +depth_stencil_format( D3DFORMAT fmt ) +{ +static D3DFORMAT allowed[] = { +D3DFMT_D16_LOCKABLE, +D3DFMT_D32, +D3DFMT_D15S1, +D3DFMT_D24S8, +D3DFMT_D24X8, +D3DFMT_D24X4S4, +D3DFMT_D16, +D3DFMT_D32F_LOCKABLE, +D3DFMT_D24FS8, +D3DFMT_D32_LOCKABLE, +D3DFMT_DF16, +D3DFMT_DF24, +D3DFMT_INTZ +}; +unsigned i; + +for (i = 0; i < sizeof(allowed)/sizeof(D3DFORMAT); i++) { +if (fmt == allowed[i]) { return TRUE; } +} +return FALSE; +} + +static INLINE unsigned +d3d9_get_pipe_depth_format_bindings(D3DFORMAT format) +{ +switch (format) { +case D3DFMT_D32: +case D3DFMT_D15S1: +case D3DFMT_D24S8: +case D3DFMT_D24X8: +case D3DFMT_D24X4S4: +case D3DFMT_D16: +case D3DFMT_D24FS8: +return PIPE_BIND_DEPTH_STENCIL; +case D3DFMT_D32F_LOCKABLE: +case D3DFMT_D16_LOCKABLE: +case D3DFMT_D32_LOCKABLE: +return PIPE_BIND_DEPTH_STENCIL | PIPE_BIND_TRANSFER_READ | + PIPE_BIND_TRANSFER_WRITE; +case D3DFMT_DF16: +case D3DFMT_DF24: +case D3DFMT_INTZ: +return PIPE_BIND_DEPTH_STENCIL | PIPE_BIND_SAMPLER_VIEW; +default: assert(0); +} +} + static INLINE enum pipe_format d3d9_to_pipe_format_internal(D3DFORMAT format) { diff --git a/src/gallium/state_trackers/nine/swapchain9.c b/src/gallium/state_trackers/nine/swapchain9.c index 9db6ff4..0e13507 100644 --- a/src/gallium/state_trackers/nine/swapchain9.c +++ b/src/gallium/state_trackers/nine/swapchain9.c @@ -341,8 +341,14 @@ NineSwapChain9_
[Mesa-dev] [PATCH 28/43] st/nine: Fix present_buffers allocation
If has_present_buffers was false at first, but after a device reset, it turns true (for example if we begin to render to a multisampled back buffer), there was a crash due to present_buffers being uninitialised. This patch fixes it. Signed-off-by: Axel Davy --- src/gallium/state_trackers/nine/swapchain9.c | 15 +-- 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/gallium/state_trackers/nine/swapchain9.c b/src/gallium/state_trackers/nine/swapchain9.c index fb692da..a6e9c57 100644 --- a/src/gallium/state_trackers/nine/swapchain9.c +++ b/src/gallium/state_trackers/nine/swapchain9.c @@ -271,12 +271,6 @@ NineSwapChain9_Resize( struct NineSwapChain9 *This, if (!bufs) return E_OUTOFMEMORY; This->buffers = bufs; -if (has_present_buffers) { -This->present_buffers = REALLOC(This->present_buffers, -This->present_buffers == NULL ? 0 : oldBufferCount * sizeof(struct pipe_resource *), -newBufferCount * sizeof(struct pipe_resource *)); -memset(This->present_buffers, 0, newBufferCount * sizeof(struct pipe_resource *)); -} This->present_handles = REALLOC(This->present_handles, oldBufferCount * sizeof(D3DWindowBuffer *), newBufferCount * sizeof(D3DWindowBuffer *)); @@ -286,6 +280,15 @@ NineSwapChain9_Resize( struct NineSwapChain9 *This, } } +if (has_present_buffers && +(newBufferCount != oldBufferCount || !This->present_buffers)) { +This->present_buffers = REALLOC(This->present_buffers, +This->present_buffers == NULL ? 0 : +oldBufferCount * sizeof(struct pipe_resource *), +newBufferCount * sizeof(struct pipe_resource *)); +memset(This->present_buffers, 0, newBufferCount * sizeof(struct pipe_resource *)); +} + for (i = 0; i < newBufferCount; ++i) { tmplt.bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_TRANSFER_READ | PIPE_BIND_TRANSFER_WRITE | PIPE_BIND_RENDER_TARGET; -- 2.1.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 32/43] st/nine: SetResourceResize should track nr_samples too
Signed-off-by: Axel Davy --- src/gallium/state_trackers/nine/surface9.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gallium/state_trackers/nine/surface9.c b/src/gallium/state_trackers/nine/surface9.c index 21a4707..f1b4aa9 100644 --- a/src/gallium/state_trackers/nine/surface9.c +++ b/src/gallium/state_trackers/nine/surface9.c @@ -676,6 +676,7 @@ NineSurface9_SetResourceResize( struct NineSurface9 *This, This->desc.Width = This->base.info.width0 = resource->width0; This->desc.Height = This->base.info.height0 = resource->height0; +This->desc.MultiSampleType = This->base.info.nr_samples = resource->nr_samples; This->stride = util_format_get_stride(This->base.info.format, This->desc.Width); -- 2.1.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 10/43] st/nine: Do not leak private data in volume9.
From: Patrick Rudolph This->data was allocated by nine, but not freed. Reviewed-by: Axel Davy Signed-off-by: Patrick Rudolph --- src/gallium/state_trackers/nine/volume9.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gallium/state_trackers/nine/volume9.c b/src/gallium/state_trackers/nine/volume9.c index 3a2626f..9e83d6b 100644 --- a/src/gallium/state_trackers/nine/volume9.c +++ b/src/gallium/state_trackers/nine/volume9.c @@ -127,6 +127,9 @@ NineVolume9_dtor( struct NineVolume9 *This ) if (This->transfer) NineVolume9_UnlockBox(This); +if (This->data) + FREE(This->data); + pipe_resource_reference(&This->resource, NULL); NineUnknown_dtor(&This->base); -- 2.1.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 19/43] st/nine: Add D3DFMT_DF16 support
This depth buffer format, like D3DFMT_INTZ, can be used to read the depth buffer values when bound to a shader. Some apps may use this format to get better performance when they don't need the precision of INTZ (24 bits for depth, 8 for stencil, whereas DF16 is just 16 bits for depth) We don't add support for DF24 yet, because it implies support for FETCH4, which we don't support for now. Signed-off-by: Axel Davy --- src/gallium/state_trackers/nine/basetexture9.c | 12 ++-- src/gallium/state_trackers/nine/nine_pipe.h| 6 -- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/gallium/state_trackers/nine/basetexture9.c b/src/gallium/state_trackers/nine/basetexture9.c index 8d183e6..f2ca35b 100644 --- a/src/gallium/state_trackers/nine/basetexture9.c +++ b/src/gallium/state_trackers/nine/basetexture9.c @@ -69,8 +69,16 @@ NineBaseTexture9_ctor( struct NineBaseTexture9 *This, D3DTEXF_LINEAR : D3DTEXF_NONE; This->lod = 0; This->lod_resident = -1; -This->shadow = This->format != D3DFMT_INTZ && util_format_has_depth( -util_format_description(This->base.info.format)); +/* When a depth buffer is sampled, it is for shadow mapping, except for + * D3DFMT_INTZ, D3DFMT_DF16 and D3DFMT_DF24. + * In addition D3DFMT_INTZ can be used for both texturing and depth buffering + * if z write is disabled. This particular feature may not work for us in + * practice because OGL doesn't have that. However apparently it is known + * some cards have performance issues with this feature, so real apps + * shouldn't use it. */ +This->shadow = (This->format != D3DFMT_INTZ && This->format != D3DFMT_DF16 && +This->format != D3DFMT_DF24) && + util_format_has_depth(util_format_description(This->base.info.format)); list_inithead(&This->list); diff --git a/src/gallium/state_trackers/nine/nine_pipe.h b/src/gallium/state_trackers/nine/nine_pipe.h index 6e4ee43..640bbdb 100644 --- a/src/gallium/state_trackers/nine/nine_pipe.h +++ b/src/gallium/state_trackers/nine/nine_pipe.h @@ -182,6 +182,7 @@ d3d9_to_pipe_format_internal(D3DFORMAT format) return nine_d3d9_to_pipe_format_map[format]; switch (format) { case D3DFMT_INTZ: return PIPE_FORMAT_S8_UINT_Z24_UNORM; +case D3DFMT_DF16: return PIPE_FORMAT_Z16_UNORM; case D3DFMT_DXT1: return PIPE_FORMAT_DXT1_RGBA; case D3DFMT_DXT2: return PIPE_FORMAT_DXT3_RGBA; /* XXX */ case D3DFMT_DXT3: return PIPE_FORMAT_DXT3_RGBA; @@ -199,8 +200,9 @@ d3d9_to_pipe_format_internal(D3DFORMAT format) case D3DFMT_Y210: /* XXX */ case D3DFMT_Y216: case D3DFMT_NV11: -case D3DFMT_DF16: /* useless, not supported by wine either */ -case D3DFMT_DF24: /* useless, not supported by wine either */ +case D3DFMT_DF24: /* Similar to D3DFMT_DF16 but for 24-bits. +We don't advertise it because when it is supported, Fetch-4 is +supposed to be supported, which we don't support yet. */ case D3DFMT_NULL: /* special cased, only for surfaces */ return PIPE_FORMAT_NONE; default: -- 2.1.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 33/43] st/nine: Fix gpu memory leak in swapchain
Signed-off-by: Axel Davy --- src/gallium/state_trackers/nine/swapchain9.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/gallium/state_trackers/nine/swapchain9.c b/src/gallium/state_trackers/nine/swapchain9.c index a6e9c57..9db6ff4 100644 --- a/src/gallium/state_trackers/nine/swapchain9.c +++ b/src/gallium/state_trackers/nine/swapchain9.c @@ -338,8 +338,7 @@ NineSwapChain9_Resize( struct NineSwapChain9 *This, pipe_resource_reference(&(This->present_buffers[i]), resource); } This->present_handles[i] = D3DWindowBuffer_create(This, resource, depth); -if (!has_present_buffers) -pipe_resource_reference(&resource, NULL); +pipe_resource_reference(&resource, NULL); } if (pParams->EnableAutoDepthStencil) { tmplt.bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_TRANSFER_READ | -- 2.1.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 24/43] st/nine: Remove duplicated debug message
From: Patrick Rudolph Likely a rebase error Reviewed-by: Axel Davy Signed-off-by: Patrick Rudolph --- src/gallium/state_trackers/nine/resource9.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/gallium/state_trackers/nine/resource9.c b/src/gallium/state_trackers/nine/resource9.c index 15c784f..bbc8320 100644 --- a/src/gallium/state_trackers/nine/resource9.c +++ b/src/gallium/state_trackers/nine/resource9.c @@ -52,9 +52,6 @@ NineResource9_ctor( struct NineResource9 *This, This, pParams, initResource, (int) Allocate, Type, Pool, Usage); -DBG("This=%p pParams=%p initResource=%p Allocate=%d Type=%d Pool=%d usage=%d\n", -This, pParams, initResource, Allocate, Type, Pool, Usage); - hr = NineUnknown_ctor(&This->base, pParams); if (FAILED(hr)) return hr; -- 2.1.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 16/43] st/nine: Implement fallback for D3DFMT_D24S8, D3DFMT_D24X8 and D3DFMT_INTZ
Some drivers support PIPE_FORMAT_S8_UINT_Z24_UNORM, some others PIPE_FORMAT_Z24_UNORM_S8_UINT, some both. It doesn't matter which one we use, since the d3d formats they map to aren't lockable (app can read it directly). Signed-off-by: Axel Davy --- src/gallium/state_trackers/nine/nine_pipe.h | 21 - 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/gallium/state_trackers/nine/nine_pipe.h b/src/gallium/state_trackers/nine/nine_pipe.h index 405ca1d..6e4ee43 100644 --- a/src/gallium/state_trackers/nine/nine_pipe.h +++ b/src/gallium/state_trackers/nine/nine_pipe.h @@ -181,7 +181,7 @@ d3d9_to_pipe_format_internal(D3DFORMAT format) if (format <= D3DFMT_A2B10G10R10_XR_BIAS) return nine_d3d9_to_pipe_format_map[format]; switch (format) { -case D3DFMT_INTZ: return PIPE_FORMAT_Z24_UNORM_S8_UINT; +case D3DFMT_INTZ: return PIPE_FORMAT_S8_UINT_Z24_UNORM; case D3DFMT_DXT1: return PIPE_FORMAT_DXT1_RGBA; case D3DFMT_DXT2: return PIPE_FORMAT_DXT3_RGBA; /* XXX */ case D3DFMT_DXT3: return PIPE_FORMAT_DXT3_RGBA; @@ -234,6 +234,25 @@ d3d9_to_pipe_format_checked(struct pipe_screen *screen, if (format_check_internal(result)) return result; + +/* fallback to another format for formats + * that match several pipe_format */ +switch(format) { +/* depth buffer formats are not lockable (except those for which it + * is precised in the name), so it is ok to match to another similar + * format. In all cases, if the app reads the texture with a shader, + * it gets depth on r and doesn't get stencil.*/ +case D3DFMT_INTZ: +case D3DFMT_D24S8: +if (format_check_internal(PIPE_FORMAT_Z24_UNORM_S8_UINT)) +return PIPE_FORMAT_Z24_UNORM_S8_UINT; +break; +case D3DFMT_D24X8: +if (format_check_internal(PIPE_FORMAT_Z24X8_UNORM)) +return PIPE_FORMAT_Z24X8_UNORM; +default: +break; +} return PIPE_FORMAT_NONE; } -- 2.1.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 38/43] st/nine: Fix update_framebuffer binding cbufs the pixel shader wouldn't render to
Signed-off-by: Axel Davy --- src/gallium/state_trackers/nine/device9.c| 8 src/gallium/state_trackers/nine/nine_state.c | 16 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c index 5eb9d54..25e1444 100644 --- a/src/gallium/state_trackers/nine/device9.c +++ b/src/gallium/state_trackers/nine/device9.c @@ -3297,6 +3297,8 @@ NineDevice9_SetPixelShader( struct NineDevice9 *This, IDirect3DPixelShader9 *pShader ) { struct nine_state *state = This->update; +unsigned old_mask = state->ps ? state->ps->rt_mask : 1; +unsigned mask; DBG("This=%p pShader=%p\n", This, pShader); @@ -3304,6 +3306,12 @@ NineDevice9_SetPixelShader( struct NineDevice9 *This, state->changed.group |= NINE_STATE_PS; +mask = state->ps ? state->ps->rt_mask : 1; +/* We need to update cbufs if the pixel shader would + * write to different render targets */ +if (mask != old_mask) +state->changed.group |= NINE_STATE_FB; + return D3D_OK; } diff --git a/src/gallium/state_trackers/nine/nine_state.c b/src/gallium/state_trackers/nine/nine_state.c index 02fef9a..86a6ca8 100644 --- a/src/gallium/state_trackers/nine/nine_state.c +++ b/src/gallium/state_trackers/nine/nine_state.c @@ -48,7 +48,7 @@ update_framebuffer(struct NineDevice9 *device) unsigned w = rt0->desc.Width; unsigned h = rt0->desc.Height; D3DMULTISAMPLE_TYPE nr_samples = rt0->desc.MultiSampleType; - +unsigned mask = state->ps ? state->ps->rt_mask : 1; const int sRGB = state->rs[D3DRS_SRGBWRITEENABLE] ? 1 : 0; DBG("\n"); @@ -75,8 +75,9 @@ update_framebuffer(struct NineDevice9 *device) for (i = 0; i < device->caps.NumSimultaneousRTs; ++i) { struct NineSurface9 *rt = state->rt[i]; -if (rt && rt->desc.Format != D3DFMT_NULL && rt->desc.Width == w && -rt->desc.Height == h && rt->desc.MultiSampleType == nr_samples) { +if (rt && rt->desc.Format != D3DFMT_NULL && (mask & (1 << i)) && +rt->desc.Width == w && rt->desc.Height == h && +rt->desc.MultiSampleType == nr_samples) { fb->cbufs[i] = NineSurface9_GetSurface(rt, sRGB); state->rt_mask |= 1 << i; fb->nr_cbufs = i + 1; @@ -127,12 +128,6 @@ update_framebuffer(struct NineDevice9 *device) } } -#ifdef DEBUG -if (state->rt_mask & (state->ps ? ~state->ps->rt_mask : 0)) -WARN_ONCE("FIXME: writing undefined values to cbufs 0x%x\n", - state->rt_mask & ~state->ps->rt_mask); -#endif - return state->changed.group; } @@ -329,9 +324,6 @@ update_ps(struct NineDevice9 *device) for (s = 0; mask; ++s, mask >>= 1) if ((mask & 1) && !(device->state.texture[NINE_SAMPLER_PS(s)])) WARN_ONCE("FIXME: unbound sampler should return alpha=1\n"); -if (device->state.rt_mask & ~ps->rt_mask) -WARN_ONCE("FIXME: writing undefined values to cbufs 0x%x\n", -device->state.rt_mask & ~ps->rt_mask); } #endif return 0; -- 2.1.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 21/43] st/nine: Implement ATOC hack
ATOC is an hack for Alpha to coverage that is supported by NV and Intel. You need to check the support for it with CheckDeviceFormat. Signed-off-by: Axel Davy --- include/D3D9/d3d9types.h | 1 + src/gallium/state_trackers/nine/adapter9.c | 4 src/gallium/state_trackers/nine/device9.c | 8 3 files changed, 13 insertions(+) diff --git a/include/D3D9/d3d9types.h b/include/D3D9/d3d9types.h index 859c2f5..e0f1e72 100644 --- a/include/D3D9/d3d9types.h +++ b/include/D3D9/d3d9types.h @@ -651,6 +651,7 @@ typedef enum _D3DFORMAT { D3DFMT_BINARYBUFFER = 199, D3DFMT_ATI1 = MAKEFOURCC('A', 'T', 'I', '1'), D3DFMT_ATI2 = MAKEFOURCC('A', 'T', 'I', '2'), +D3DFMT_ATOC = MAKEFOURCC('A', 'T', 'O', 'C'), D3DFMT_DF16 = MAKEFOURCC('D', 'F', '1', '6'), D3DFMT_DF24 = MAKEFOURCC('D', 'F', '2', '4'), D3DFMT_INTZ = MAKEFOURCC('I', 'N', 'T', 'Z'), diff --git a/src/gallium/state_trackers/nine/adapter9.c b/src/gallium/state_trackers/nine/adapter9.c index 84578ac..459aac3 100644 --- a/src/gallium/state_trackers/nine/adapter9.c +++ b/src/gallium/state_trackers/nine/adapter9.c @@ -307,6 +307,10 @@ NineAdapter9_CheckDeviceFormat( struct NineAdapter9 *This, return screen->get_param(screen, PIPE_CAP_MULTISAMPLE_Z_RESOLVE) ? D3D_OK : D3DERR_NOTAVAILABLE; +/* ATOC hack */ +if (CheckFormat == D3DFMT_ATOC && RType == D3DRTYPE_SURFACE) +return D3D_OK; + if (Usage & D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING) bind |= PIPE_BIND_BLENDABLE; diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c index 63f9f16..46b4c5a 100644 --- a/src/gallium/state_trackers/nine/device9.c +++ b/src/gallium/state_trackers/nine/device9.c @@ -2075,6 +2075,14 @@ NineDevice9_SetRenderState( struct NineDevice9 *This, } } +/* NV hack */ +if (State == D3DRS_ADAPTIVETESS_Y && +(Value == D3DFMT_ATOC || (Value == D3DFMT_UNKNOWN && state->rs[NINED3DRS_ALPHACOVERAGE]))) { +state->rs[NINED3DRS_ALPHACOVERAGE] = (Value == D3DFMT_ATOC); +state->changed.group |= NINE_STATE_BLEND; +return D3D_OK; +} + user_assert(State < Elements(state->rs), D3DERR_INVALIDCALL); if (likely(state->rs[State] != Value) || unlikely(This->is_recording)) { -- 2.1.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 26/43] st/nine: Fix bufferoverflow in {Get|Set}PixelShaderConstantF
From: Patrick Rudolph Previous code wasn't checking against the correct limit: 224 for sm3 hardware, but 256. Fixes wine test test_pixel_shader_constant() Reviewed-by: Axel Davy Signed-off-by: Patrick Rudolph --- src/gallium/state_trackers/nine/device9.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c index fdcf7a2..dfec5f9 100644 --- a/src/gallium/state_trackers/nine/device9.c +++ b/src/gallium/state_trackers/nine/device9.c @@ -256,7 +256,7 @@ NineDevice9_ctor( struct NineDevice9 *This, NINE_MAX_CONST_ALL); /* ps 3.0: 224 float constants. All cards supported support at least * 256 constants for ps */ -max_const_ps = 224 + (NINE_MAX_CONST_I + NINE_MAX_CONST_B / 4); +max_const_ps = NINE_MAX_CONST_F_PS3 + (NINE_MAX_CONST_I + NINE_MAX_CONST_B / 4); This->max_vs_const_f = max_const_vs - (NINE_MAX_CONST_I + NINE_MAX_CONST_B / 4); @@ -3309,8 +3309,8 @@ NineDevice9_SetPixelShaderConstantF( struct NineDevice9 *This, DBG("This=%p StartRegister=%u pConstantData=%p Vector4fCount=%u\n", This, StartRegister, pConstantData, Vector4fCount); -user_assert(StartRegister < NINE_MAX_CONST_F, D3DERR_INVALIDCALL); -user_assert(StartRegister + Vector4fCount <= NINE_MAX_CONST_F, D3DERR_INVALIDCALL); +user_assert(StartRegister < NINE_MAX_CONST_F_PS3, D3DERR_INVALIDCALL); +user_assert(StartRegister + Vector4fCount <= NINE_MAX_CONST_F_PS3, D3DERR_INVALIDCALL); if (!Vector4fCount) return D3D_OK; @@ -3337,8 +3337,8 @@ NineDevice9_GetPixelShaderConstantF( struct NineDevice9 *This, { const struct nine_state *state = &This->state; -user_assert(StartRegister < NINE_MAX_CONST_F, D3DERR_INVALIDCALL); -user_assert(StartRegister + Vector4fCount <= NINE_MAX_CONST_F, D3DERR_INVALIDCALL); +user_assert(StartRegister < NINE_MAX_CONST_F_PS3, D3DERR_INVALIDCALL); +user_assert(StartRegister + Vector4fCount <= NINE_MAX_CONST_F_PS3, D3DERR_INVALIDCALL); user_assert(pConstantData, D3DERR_INVALIDCALL); memcpy(pConstantData, -- 2.1.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 23/43] st/nine: Return E_FAIL for unused vertexdeclaration type
From: Patrick Rudolph Add returncode E_FAIL. Return E_FAIL for any vertexdeclaration element with type unused. Reviewed-by: Axel Davy Signed-off-by: Patrick Rudolph --- include/D3D9/d3d9types.h | 1 + src/gallium/state_trackers/nine/vertexdeclaration9.c | 7 --- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/D3D9/d3d9types.h b/include/D3D9/d3d9types.h index e0f1e72..5020934 100644 --- a/include/D3D9/d3d9types.h +++ b/include/D3D9/d3d9types.h @@ -50,6 +50,7 @@ #define E_OUTOFMEMORY MAKE_HRESULT(1, 0x007, 14) #define E_NOINTERFACE MAKE_HRESULT(1, 0x000, 0x4002) #define E_POINTER MAKE_HRESULT(1, 0x000, 0x4003) +#define E_FAILMAKE_HRESULT(1, 0x000, 0x4005) #define S_OK ((HRESULT)0) #define S_FALSE ((HRESULT)1) diff --git a/src/gallium/state_trackers/nine/vertexdeclaration9.c b/src/gallium/state_trackers/nine/vertexdeclaration9.c index 08b95e2..49e5937 100644 --- a/src/gallium/state_trackers/nine/vertexdeclaration9.c +++ b/src/gallium/state_trackers/nine/vertexdeclaration9.c @@ -181,10 +181,11 @@ NineVertexDeclaration9_ctor( struct NineVertexDeclaration9 *This, HRESULT hr = NineUnknown_ctor(&This->base, pParams); if (FAILED(hr)) { return hr; } +/* wine */ for (This->nelems = 0; - pElements[This->nelems].Type != D3DDECLTYPE_UNUSED && - pElements[This->nelems].Stream != 0xFF; /* wine */ - ++This->nelems); + pElements[This->nelems].Stream != 0xFF; + ++This->nelems) +user_assert(pElements[This->nelems].Type != D3DDECLTYPE_UNUSED, E_FAIL); caps = NineDevice9_GetCaps(This->base.device); user_assert(This->nelems <= caps->MaxStreams, D3DERR_INVALIDCALL); -- 2.1.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 37/43] st/nine: Clear: better behave if rt_mask is different to the one of the framebuffer bound
Signed-off-by: Axel Davy --- src/gallium/state_trackers/nine/device9.c | 40 +-- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c index c6bd052..5eb9d54 100644 --- a/src/gallium/state_trackers/nine/device9.c +++ b/src/gallium/state_trackers/nine/device9.c @@ -1610,11 +1610,15 @@ NineDevice9_Clear( struct NineDevice9 *This, float Z, DWORD Stencil ) { +const int sRGB = This->state.rs[D3DRS_SRGBWRITEENABLE] ? 1 : 0; +struct pipe_surface *cbuf, *zsbuf; struct pipe_context *pipe = This->pipe; -struct NineSurface9 *zsbuf = This->state.ds; +struct NineSurface9 *zsbuf_surf = This->state.ds; +struct NineSurface9 *rt; unsigned bufs = 0; unsigned r, i; union pipe_color_union rgba; +unsigned rt_mask = 0; D3DRECT rect; DBG("This=%p Count=%u pRects=%p Flags=%x Color=%08x Z=%f Stencil=%x\n", @@ -1623,8 +1627,8 @@ NineDevice9_Clear( struct NineDevice9 *This, user_assert(This->state.ds || !(Flags & NINED3DCLEAR_DEPTHSTENCIL), D3DERR_INVALIDCALL); user_assert(!(Flags & D3DCLEAR_STENCIL) || -(zsbuf && - util_format_is_depth_and_stencil(zsbuf->base.info.format)), +(zsbuf_surf && + util_format_is_depth_and_stencil(zsbuf_surf->base.info.format)), D3DERR_INVALIDCALL); #ifdef NINE_STRICT user_assert((Count && pRects) || (!Count && !pRects), D3DERR_INVALIDCALL); @@ -1670,7 +1674,14 @@ NineDevice9_Clear( struct NineDevice9 *This, if (rect.x1 >= This->state.fb.width || rect.y1 >= This->state.fb.height) return D3D_OK; + +for (i = 0; i < This->caps.NumSimultaneousRTs; ++i) { +if (This->state.rt[i] && This->state.rt[i]->desc.Format != D3DFMT_NULL) +rt_mask |= 1 << i; +} + if (!Count && +(!(bufs & PIPE_CLEAR_COLOR) || (rt_mask == This->state.rt_mask)) && rect.x1 == 0 && rect.x2 >= This->state.fb.width && rect.y1 == 0 && rect.y2 >= This->state.fb.height) { /* fast path, clears everything at once */ @@ -1678,17 +1689,18 @@ NineDevice9_Clear( struct NineDevice9 *This, pipe->clear(pipe, bufs, &rgba, Z, Stencil); return D3D_OK; } -rect.x2 = MIN2(rect.x2, This->state.fb.width); -rect.y2 = MIN2(rect.y2, This->state.fb.height); if (!Count) { Count = 1; pRects = ▭ } -for (i = 0; (i < This->state.fb.nr_cbufs); ++i) { -if (!This->state.fb.cbufs[i] || !(Flags & D3DCLEAR_TARGET)) +for (i = 0; i < This->caps.NumSimultaneousRTs; ++i) { +rt = This->state.rt[i]; +if (!rt || rt->desc.Format == D3DFMT_NULL || +!(Flags & D3DCLEAR_TARGET)) continue; /* save space, compiler should hoist this */ +cbuf = NineSurface9_GetSurface(rt, sRGB); for (r = 0; r < Count; ++r) { /* Don't trust users to pass these in the right order. */ unsigned x1 = MIN2(pRects[r].x1, pRects[r].x2); @@ -1703,11 +1715,11 @@ NineDevice9_Clear( struct NineDevice9 *This, x1 = MAX2(x1, rect.x1); y1 = MAX2(y1, rect.y1); -x2 = MIN2(x2, rect.x2); -y2 = MIN2(y2, rect.y2); +x2 = MIN3(x2, rect.x2, rt->desc.Width); +y2 = MIN3(y2, rect.y2, rt->desc.Height); DBG("Clearing (%u..%u)x(%u..%u)\n", x1, x2, y1, y2); -pipe->clear_render_target(pipe, This->state.fb.cbufs[i], &rgba, +pipe->clear_render_target(pipe, cbuf, &rgba, x1, y1, x2 - x1, y2 - y1); } } @@ -1729,10 +1741,12 @@ NineDevice9_Clear( struct NineDevice9 *This, x1 = MIN2(x1, rect.x1); y1 = MIN2(y1, rect.y1); -x2 = MIN2(x2, rect.x2); -y2 = MIN2(y2, rect.y2); +x2 = MIN3(x2, rect.x2, zsbuf_surf->desc.Width); +y2 = MIN3(y2, rect.y2, zsbuf_surf->desc.Height); -pipe->clear_depth_stencil(pipe, This->state.fb.zsbuf, bufs, Z, Stencil, +zsbuf = NineSurface9_GetSurface(zsbuf_surf, 0); +assert(zsbuf); +pipe->clear_depth_stencil(pipe, zsbuf, bufs, Z, Stencil, x1, y1, x2 - x1, y2 - y1); } return D3D_OK; -- 2.1.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 14/43] st/nine: Refactor nine_d3d9_to_pipe_format_map
The order of the format is changed to have an increasing ordering of the d3d9 format values. Some missing formats are added and matched to PIPE_FORMAT_NONE Signed-off-by: Axel Davy --- src/gallium/state_trackers/nine/nine_pipe.c | 123 ++-- 1 file changed, 44 insertions(+), 79 deletions(-) diff --git a/src/gallium/state_trackers/nine/nine_pipe.c b/src/gallium/state_trackers/nine/nine_pipe.c index 3a7bb90..0bfb379 100644 --- a/src/gallium/state_trackers/nine/nine_pipe.c +++ b/src/gallium/state_trackers/nine/nine_pipe.c @@ -248,95 +248,60 @@ nine_pipe_context_clear(struct NineDevice9 *This) const enum pipe_format nine_d3d9_to_pipe_format_map[120] = { - [D3DFMT_UNKNOWN] = PIPE_FORMAT_NONE, - - [D3DFMT_A8R8G8B8] = PIPE_FORMAT_B8G8R8A8_UNORM, - [D3DFMT_X8R8G8B8] = PIPE_FORMAT_B8G8R8X8_UNORM, - [D3DFMT_R5G6B5] = PIPE_FORMAT_B5G6R5_UNORM, - [D3DFMT_X1R5G5B5] = PIPE_FORMAT_B5G5R5X1_UNORM, - [D3DFMT_A1R5G5B5] = PIPE_FORMAT_B5G5R5A1_UNORM, - [D3DFMT_A4R4G4B4] = PIPE_FORMAT_B4G4R4A4_UNORM, - [D3DFMT_A8] = PIPE_FORMAT_A8_UNORM, - [D3DFMT_X4R4G4B4] = PIPE_FORMAT_B4G4R4X4_UNORM, - [D3DFMT_R3G3B2] = PIPE_FORMAT_B2G3R3_UNORM, - [D3DFMT_A2B10G10R10] = PIPE_FORMAT_R10G10B10A2_UNORM, - [D3DFMT_A8B8G8R8] = PIPE_FORMAT_R8G8B8A8_UNORM, - [D3DFMT_X8B8G8R8] = PIPE_FORMAT_R8G8B8X8_UNORM, - [D3DFMT_G16R16] = PIPE_FORMAT_R16G16_UNORM, - [D3DFMT_A2R10G10B10] = PIPE_FORMAT_B10G10R10A2_UNORM, - [D3DFMT_A16B16G16R16] = PIPE_FORMAT_R16G16B16A16_UNORM, - -/* palette texture formats not supported by gallium/hardware, TODO ? */ - [D3DFMT_P8] = PIPE_FORMAT_NONE, - [D3DFMT_A8P8] = PIPE_FORMAT_NONE, - - [D3DFMT_L8] = PIPE_FORMAT_L8_UNORM, - [D3DFMT_A8L8] = PIPE_FORMAT_L8A8_UNORM, - [D3DFMT_A4L4] = PIPE_FORMAT_L4A4_UNORM, - - [D3DFMT_V8U8]= PIPE_FORMAT_R8G8_SNORM, - [D3DFMT_Q8W8V8U8]= PIPE_FORMAT_R8G8B8A8_SNORM, - [D3DFMT_V16U16] = PIPE_FORMAT_R16G16_SNORM, - [D3DFMT_A2W10V10U10] = PIPE_FORMAT_R10SG10SB10SA2U_NORM, - - /* [D3DFMT_UYVY] = PIPE_FORMAT_YUYV, fourcc */ - /* [D3DFMT_YUY2] = PIPE_FORMAT_NONE, fourcc */ - - /* XXX: DXT2, DXT4 */ - /* fourcc - [D3DFMT_DXT1] = PIPE_FORMAT_DXT1_RGBA, - [D3DFMT_DXT2] = PIPE_FORMAT_DXT3_RGBA, - [D3DFMT_DXT3] = PIPE_FORMAT_DXT3_RGBA, - [D3DFMT_DXT4] = PIPE_FORMAT_DXT5_RGBA, - [D3DFMT_DXT5] = PIPE_FORMAT_DXT5_RGBA, - */ - - /* XXX: order ? */ - /* fourcc - [D3DFMT_G8R8_G8B8] = PIPE_FORMAT_G8R8_G8B8_UNORM, - [D3DFMT_R8G8_B8G8] = PIPE_FORMAT_R8G8_B8G8_UNORM, - */ - + [D3DFMT_UNKNOWN] = PIPE_FORMAT_NONE, + [D3DFMT_R8G8B8]= PIPE_FORMAT_NONE, + [D3DFMT_A8R8G8B8] = PIPE_FORMAT_B8G8R8A8_UNORM, + [D3DFMT_X8R8G8B8] = PIPE_FORMAT_B8G8R8X8_UNORM, + [D3DFMT_R5G6B5]= PIPE_FORMAT_B5G6R5_UNORM, + [D3DFMT_X1R5G5B5] = PIPE_FORMAT_B5G5R5X1_UNORM, + [D3DFMT_A1R5G5B5] = PIPE_FORMAT_B5G5R5A1_UNORM, + [D3DFMT_A4R4G4B4] = PIPE_FORMAT_B4G4R4A4_UNORM, + [D3DFMT_R3G3B2]= PIPE_FORMAT_B2G3R3_UNORM, + [D3DFMT_A8]= PIPE_FORMAT_A8_UNORM, + [D3DFMT_A8R3G3B2] = PIPE_FORMAT_NONE + [D3DFMT_X4R4G4B4] = PIPE_FORMAT_B4G4R4X4_UNORM, + [D3DFMT_A2B10G10R10] = PIPE_FORMAT_R10G10B10A2_UNORM, + [D3DFMT_A8B8G8R8] = PIPE_FORMAT_R8G8B8A8_UNORM, + [D3DFMT_X8B8G8R8] = PIPE_FORMAT_R8G8B8X8_UNORM, + [D3DFMT_G16R16]= PIPE_FORMAT_R16G16_UNORM, + [D3DFMT_A2R10G10B10] = PIPE_FORMAT_B10G10R10A2_UNORM, + [D3DFMT_A16B16G16R16] = PIPE_FORMAT_R16G16B16A16_UNORM, + [D3DFMT_A8P8] = PIPE_FORMAT_NONE, + [D3DFMT_P8]= PIPE_FORMAT_NONE, + [D3DFMT_L8]= PIPE_FORMAT_L8_UNORM, + [D3DFMT_A8L8] = PIPE_FORMAT_L8A8_UNORM, + [D3DFMT_A4L4] = PIPE_FORMAT_L4A4_UNORM, + [D3DFMT_V8U8] = PIPE_FORMAT_R8G8_SNORM, + [D3DFMT_L6V5U5]= PIPE_FORMAT_NONE, + [D3DFMT_X8L8V8U8] = PIPE_FORMAT_NONE, + [D3DFMT_Q8W8V8U8] = PIPE_FORMAT_R8G8B8A8_SNORM, + [D3DFMT_V16U16]= PIPE_FORMAT_R16G16_SNORM, + [D3DFMT_A2W10V10U10] = PIPE_FORMAT_R10SG10SB10SA2U_NORM, [D3DFMT_D16_LOCKABLE] = PIPE_FORMAT_Z16_UNORM, [D3DFMT_D32] = PIPE_FORMAT_Z32_UNORM, + [D3DFMT_D15S1] = PIPE_FORMAT_Z24_UNORM_S8_UINT, [D3DFMT_D24S8] = PIPE_FORMAT_S8_UINT_Z24_UNORM, [D3DFMT_D24X8] = PIPE_FORMAT_X8Z24_UNORM, + [D3DFMT_D24X4S4] = PIPE_FORMAT_Z24_UNORM_S8_UINT, [D3DFMT_D16] = PIPE_FORMAT_Z16_UNORM, - [D3DFMT_L16] = PIPE_FORMAT_L16_UNORM, [D3DFMT_D32F_LOCKABLE] = PIPE_FORMAT_Z32_FLOAT, - - [D3DFMT_INDEX16] = PIPE_FORMAT_R16_UINT, - [D3DFMT_INDEX32] = PIPE_FORMAT_R32_UINT, - [D3DFMT_Q16W16V16U16] = PIPE_FORMAT_R16G16B16A16_SNORM, - + [D3DFMT_D24FS8]= PIPE_FORMAT_Z32_FLOAT_S8X24_UINT, + [D3DFMT_D32_LOCKABLE] = PIPE_FORMAT_NONE, + [D3DFMT_S8_LOCKABLE] = PIPE_FORMAT_NONE
[Mesa-dev] [PATCH 02/43] st/nine: Refactor how user constbufs sizes are calculated
Count explicitly the slots for float, int and bool constants, and deduce the constbuf size in nine_shader. Signed-off-by: Axel Davy --- src/gallium/state_trackers/nine/nine_shader.c | 17 ++--- src/gallium/state_trackers/nine/nine_shader.h | 22 ++ src/gallium/state_trackers/nine/nine_state.h| 5 - src/gallium/state_trackers/nine/pixelshader9.c | 1 - src/gallium/state_trackers/nine/vertexshader9.c | 2 -- 5 files changed, 24 insertions(+), 23 deletions(-) diff --git a/src/gallium/state_trackers/nine/nine_shader.c b/src/gallium/state_trackers/nine/nine_shader.c index 944b646..1984087 100644 --- a/src/gallium/state_trackers/nine/nine_shader.c +++ b/src/gallium/state_trackers/nine/nine_shader.c @@ -2995,7 +2995,9 @@ tx_ctor(struct shader_translator *tx, struct nine_shader_info *info) info->position_t = FALSE; info->point_size = FALSE; -tx->info->const_used_size = 0; +tx->info->num_float_consts_slots = 0; +tx->info->num_int_consts_slots = 0; +tx->info->num_bool_consts_slots = 0; info->sampler_mask = 0x0; info->rt_mask = 0x0; @@ -3065,6 +3067,7 @@ nine_translate_shader(struct NineDevice9 *device, struct nine_shader_info *info) struct shader_translator *tx; HRESULT hr = D3D_OK; const unsigned processor = tgsi_processor_from_type(info->type); +unsigned slot_max; user_assert(processor != ~0, D3DERR_INVALIDCALL); @@ -3196,8 +3199,16 @@ nine_translate_shader(struct NineDevice9 *device, struct nine_shader_info *info) hr = D3D_OK; } -if (tx->indirect_const_access) -info->const_used_size = ~0; +if (tx->indirect_const_access) /* vs only */ +info->num_float_consts_slots = device->max_vs_const_f; + +slot_max = info->num_bool_consts_slots > 0 ? + device->max_vs_const_f + NINE_MAX_CONST_I + + info->num_bool_consts_slots : + info->num_int_consts_slots > 0 ? + device->max_vs_const_f + info->num_int_consts_slots : + info->num_float_consts_slots; +info->const_used_size = sizeof(float[4]) * slot_max; /* slots start from 1 */ info->cso = ureg_create_shader_and_destroy(tx->ureg, device->pipe); if (!info->cso) { diff --git a/src/gallium/state_trackers/nine/nine_shader.h b/src/gallium/state_trackers/nine/nine_shader.h index ddee372..027f765 100644 --- a/src/gallium/state_trackers/nine/nine_shader.h +++ b/src/gallium/state_trackers/nine/nine_shader.h @@ -63,32 +63,30 @@ struct nine_shader_info unsigned const_b_base; /* in vec4 (16 byte) units */ unsigned const_used_size; +unsigned num_float_consts_slots; +unsigned num_int_consts_slots; +unsigned num_bool_consts_slots; + struct nine_lconstf lconstf; /* out, NOTE: members to be free'd by user */ }; static INLINE void nine_info_mark_const_f_used(struct nine_shader_info *info, int idx) { -unsigned size = (idx + 1) * 16; - -if (info->const_used_size < size) -info->const_used_size = size; +if (info->num_float_consts_slots < (idx + 1)) +info->num_float_consts_slots = idx + 1; } static INLINE void nine_info_mark_const_i_used(struct nine_shader_info *info, int idx) { -unsigned size = (info->const_i_base + (idx + 1)) * 16; - -if (info->const_used_size < size) -info->const_used_size = size; +if (info->num_int_consts_slots < (idx + 1)) +info->num_int_consts_slots = idx + 1; } static INLINE void nine_info_mark_const_b_used(struct nine_shader_info *info, int idx) { -unsigned size = (info->const_b_base + ((idx + 4) / 4)) * 16; - -if (info->const_used_size < size) -info->const_used_size = size; +if (info->num_bool_consts_slots < (idx + 1)) +info->num_bool_consts_slots = idx + 1; } HRESULT diff --git a/src/gallium/state_trackers/nine/nine_state.h b/src/gallium/state_trackers/nine/nine_state.h index 58ca8c9..927bfe1 100644 --- a/src/gallium/state_trackers/nine/nine_state.h +++ b/src/gallium/state_trackers/nine/nine_state.h @@ -91,11 +91,6 @@ ((nconstf)* 4 * sizeof(float) + \ NINE_MAX_CONST_I * 4 * sizeof(int)) -#define NINE_CONSTBUF_SIZE(nconstf) \ -((nconstf)* 4 * sizeof(float) + \ - NINE_MAX_CONST_I * 4 * sizeof(int) + \ - NINE_MAX_CONST_B * 1 * sizeof(float)) - #define NINE_MAX_LIGHTS65536 #define NINE_MAX_LIGHTS_ACTIVE 8 diff --git a/src/gallium/state_trackers/nine/pixelshader9.c b/src/gallium/state_trackers/nine/pixelshader9.c index dcd2346..3f176a3 100644 --- a/src/gallium/state_trackers/nine/pixelshader9.c +++ b/src/gallium/state_trackers/nine/pixelshader9.c @@ -73,7 +73,6 @@ NinePixelShader9_ctor( struct NinePixelShader9 *This, This->rt_mask = info.rt_mask; This->c
[Mesa-dev] [PATCH 07/43] st/nine: Fix use of D3DSP_NOSWIZZLE
D3DSP_NOSWIZZLE already contains the shift. Detected with Clang. Reviewed-by: David Heidelberg Signed-off-by: Axel Davy --- src/gallium/state_trackers/nine/nine_shader.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/state_trackers/nine/nine_shader.c b/src/gallium/state_trackers/nine/nine_shader.c index 6a595b6..e2f0c11 100644 --- a/src/gallium/state_trackers/nine/nine_shader.c +++ b/src/gallium/state_trackers/nine/nine_shader.c @@ -2778,7 +2778,7 @@ sm1_parse_get_param(struct shader_translator *tx, DWORD *reg, DWORD *rel) *rel = (1 << 31) | ((D3DSPR_ADDR << D3DSP_REGTYPE_SHIFT2) & D3DSP_REGTYPE_MASK2) | ((D3DSPR_ADDR << D3DSP_REGTYPE_SHIFT) & D3DSP_REGTYPE_MASK) | -(D3DSP_NOSWIZZLE << D3DSP_SWIZZLE_SHIFT); +D3DSP_NOSWIZZLE; else *rel = TOKEN_NEXT(tx); } -- 2.1.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 30/43] st/nine: Setting D3DRS_ALPHAFUNC to 0 means D3DCMP_NEVER
From: Tiziano Bacocco Reviewed-by: Axel Davy Signed-off-by: Tiziano Bacocco --- include/D3D9/d3d9types.h| 1 + src/gallium/state_trackers/nine/nine_pipe.h | 1 + 2 files changed, 2 insertions(+) diff --git a/include/D3D9/d3d9types.h b/include/D3D9/d3d9types.h index 5020934..e96f751 100644 --- a/include/D3D9/d3d9types.h +++ b/include/D3D9/d3d9types.h @@ -472,6 +472,7 @@ typedef enum _D3DBUSTYPE { } D3DBUSTYPE; typedef enum _D3DCMPFUNC { +D3DCMP_NEVER_ZERO = 0, //Needed to avoid warnings D3DCMP_NEVER = 1, D3DCMP_LESS = 2, D3DCMP_EQUAL = 3, diff --git a/src/gallium/state_trackers/nine/nine_pipe.h b/src/gallium/state_trackers/nine/nine_pipe.h index 640bbdb..c1269b3 100644 --- a/src/gallium/state_trackers/nine/nine_pipe.h +++ b/src/gallium/state_trackers/nine/nine_pipe.h @@ -472,6 +472,7 @@ d3dcmpfunc_to_pipe_func(D3DCMPFUNC func) case D3DCMP_NOTEQUAL: return PIPE_FUNC_NOTEQUAL; case D3DCMP_GREATEREQUAL: return PIPE_FUNC_GEQUAL; case D3DCMP_ALWAYS: return PIPE_FUNC_ALWAYS; +case D3DCMP_NEVER_ZERO: return PIPE_FUNC_NEVER; // Tested on windows + ATI HD5770 default: assert(0); return PIPE_FUNC_NEVER; -- 2.1.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 35/43] st/nine: Fix enabled lights in stateblocks
From: Tiziano Bacocco Signed-off-by: Tiziano Bacocco --- src/gallium/state_trackers/nine/device9.c | 4 +++- src/gallium/state_trackers/nine/stateblock9.c | 6 -- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c index fe251fe..c6bd052 100644 --- a/src/gallium/state_trackers/nine/device9.c +++ b/src/gallium/state_trackers/nine/device9.c @@ -1965,7 +1965,9 @@ NineDevice9_GetLightEnable( struct NineDevice9 *This, for (i = 0; i < state->ff.num_lights_active; ++i) if (state->ff.active_light[i] == Index) break; -*pEnable = i != state->ff.num_lights_active; + +*pEnable = i != state->ff.num_lights_active ? 128 : 0; // Taken from wine + return D3D_OK; } diff --git a/src/gallium/state_trackers/nine/stateblock9.c b/src/gallium/state_trackers/nine/stateblock9.c index 220b196..13217ae 100644 --- a/src/gallium/state_trackers/nine/stateblock9.c +++ b/src/gallium/state_trackers/nine/stateblock9.c @@ -275,7 +275,8 @@ nine_state_copy_common(struct nine_state *dst, if (mask->ff.light[i].Type != NINED3DLIGHT_INVALID) dst->ff.light[i] = src->ff.light[i]; -DBG("TODO: active lights\n"); +memcpy(dst->ff.active_light, src->ff.active_light, sizeof(src->ff.active_light) ); +dst->ff.num_lights_active = src->ff.num_lights_active; } if (mask->changed.group & NINE_STATE_FF_VSTRANSF) { for (i = 0; i < Elements(mask->ff.changed.transform); ++i) { @@ -415,7 +416,8 @@ nine_state_copy_common_all(struct nine_state *dst, memcpy(dst->ff.light, src->ff.light, src->ff.num_lights * sizeof(dst->ff.light[0])); -DBG("TODO: active lights\n"); +memcpy(dst->ff.active_light, src->ff.active_light, sizeof(src->ff.active_light) ); +dst->ff.num_lights_active = src->ff.num_lights_active; } /* Transforms. */ -- 2.1.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 43/43] st/nine: Implement dummy vbo behaviour when vs is missing inputs
From: Tiziano Bacocco Use a dummy vertex buffer object when vs inputs have no corresponding entries in the vertex declaration. This dummy buffer will give to the shader float4(0,0,0,0). This fixes several artifacts on some games. Signed-off-by: Axel Davy Signed-off-by: Tiziano Bacocco --- src/gallium/state_trackers/nine/device9.c| 37 +++ src/gallium/state_trackers/nine/device9.h| 4 ++ src/gallium/state_trackers/nine/nine_state.c | 93 ++-- src/gallium/state_trackers/nine/nine_state.h | 3 + 4 files changed, 119 insertions(+), 18 deletions(-) diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c index e052464..78e148b 100644 --- a/src/gallium/state_trackers/nine/device9.c +++ b/src/gallium/state_trackers/nine/device9.c @@ -221,6 +221,42 @@ NineDevice9_ctor( struct NineDevice9 *This, NineUnknown_ConvertRefToBind(NineUnknown(This->state.rt[i])); } +/* Initialize a dummy VBO to be used when a a vertex declaration does not + * specify all the inputs needed by vertex shader, on win default behavior + * is to pass 0,0,0,0 to the shader */ +{ +struct pipe_transfer *transfer; +struct pipe_resource tmpl; +struct pipe_box box; +unsigned char *data; + +tmpl.target = PIPE_BUFFER; +tmpl.format = PIPE_FORMAT_R8_UNORM; +tmpl.width0 = 16; /* 4 floats */ +tmpl.height0 = 1; +tmpl.depth0 = 1; +tmpl.array_size = 1; +tmpl.last_level = 0; +tmpl.nr_samples = 0; +tmpl.usage = PIPE_USAGE_DEFAULT; +tmpl.bind = PIPE_BIND_VERTEX_BUFFER | PIPE_BIND_TRANSFER_WRITE; +tmpl.flags = 0; +This->dummy_vbo = pScreen->resource_create(pScreen, &tmpl); + +if (!This->dummy_vbo) +return D3DERR_OUTOFVIDEOMEMORY; + +u_box_1d(0, 16, &box); +data = This->pipe->transfer_map(This->pipe, This->dummy_vbo, 0, +PIPE_TRANSFER_WRITE | +PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE, +&box, &transfer); +assert(data); +assert(transfer); +memset(data, 0, 16); +This->pipe->transfer_unmap(This->pipe, transfer); +} + This->cursor.software = FALSE; This->cursor.hotspot.x = -1; This->cursor.hotspot.y = -1; @@ -387,6 +423,7 @@ NineDevice9_dtor( struct NineDevice9 *This ) pipe_resource_reference(&This->dummy_texture, NULL); pipe_resource_reference(&This->constbuf_vs, NULL); pipe_resource_reference(&This->constbuf_ps, NULL); +pipe_resource_reference(&This->dummy_vbo, NULL); FREE(This->state.vs_const_f); FREE(This->state.ps_const_f); FREE(This->state.vs_lconstf_temp); diff --git a/src/gallium/state_trackers/nine/device9.h b/src/gallium/state_trackers/nine/device9.h index 54da9e3..f412088 100644 --- a/src/gallium/state_trackers/nine/device9.h +++ b/src/gallium/state_trackers/nine/device9.h @@ -123,6 +123,10 @@ struct NineDevice9 struct nine_range_pool range_pool; struct hud_context *hud; /* NULL if hud is disabled */ + +/* dummy vbo (containing 0 0 0 0) to bind if vertex shader input + * is not bound to anything by the vertex declaration */ +struct pipe_resource *dummy_vbo; }; static INLINE struct NineDevice9 * NineDevice9( void *data ) diff --git a/src/gallium/state_trackers/nine/nine_state.c b/src/gallium/state_trackers/nine/nine_state.c index ba75817..495cc86 100644 --- a/src/gallium/state_trackers/nine/nine_state.c +++ b/src/gallium/state_trackers/nine/nine_state.c @@ -191,26 +191,55 @@ update_vertex_elements(struct NineDevice9 *device) const struct NineVertexShader9 *vs; unsigned n, b, i; int index; +char vdecl_index_map[16]; /* vs->num_inputs <= 16 */ +char used_streams[device->caps.MaxStreams]; +int dummy_vbo_stream = -1; +BOOL need_dummy_vbo = FALSE; struct pipe_vertex_element ve[PIPE_MAX_ATTRIBS]; state->stream_usage_mask = 0; - +memset(vdecl_index_map, -1, 16); +memset(used_streams, 0, device->caps.MaxStreams); vs = device->state.vs ? device->state.vs : device->ff.vs; if (!vdecl) /* no inputs */ return; -for (n = 0; n < vs->num_inputs; ++n) { -DBG("looking up input %u (usage %u) from vdecl(%p)\n", -n, vs->input_map[n].ndecl, vdecl); -index = -1; -for (i = 0; i < vdecl->nelems; i++) { -if (vdecl->usage_map[i] == vs->input_map[n].ndecl) { -index = i; +if (vdecl) { +for (n = 0; n < vs->num_inputs; ++n) { +DBG("looking up input %u (usage %u) from vdecl(%p)\n", +n, vs->input_map[n].ndecl, vdecl
Re: [Mesa-dev] [PATCH 36/43] st/nine: Fix multisampling support detection
The patch modifies the code used to check for format support. It needs to test for these flags for render targets because we create the back buffers with these. Probably these flags are not required for back buffers, I'll investigate. Axel On 31/01/2015 00:36, Marek Olšák wrote : I recommend not using PIPE_BIND_TRANSFER_READ/WRITE. Transfers with multisample textures should be supported, but the mapped texture is always a resolved single-sample copy, so it's not really an MSAA transfer. Marek On Fri, Jan 30, 2015 at 9:34 PM, Axel Davy wrote: Signed-off-by: Axel Davy --- src/gallium/state_trackers/nine/adapter9.c | 12 +--- src/gallium/state_trackers/nine/nine_pipe.h | 25 - 2 files changed, 9 insertions(+), 28 deletions(-) diff --git a/src/gallium/state_trackers/nine/adapter9.c b/src/gallium/state_trackers/nine/adapter9.c index e9bb9c0..069cc03 100644 --- a/src/gallium/state_trackers/nine/adapter9.c +++ b/src/gallium/state_trackers/nine/adapter9.c @@ -359,6 +359,7 @@ NineAdapter9_CheckDeviceMultiSampleType( struct NineAdapter9 *This, struct pipe_screen *screen; HRESULT hr; enum pipe_format pf; +unsigned bind; DBG("This=%p DeviceType=%s SurfaceFormat=%s Windowed=%i MultiSampleType=%u " "pQualityLevels=%p\n", This, nine_D3DDEVTYPE_to_str(DeviceType), @@ -369,9 +370,14 @@ NineAdapter9_CheckDeviceMultiSampleType( struct NineAdapter9 *This, if (FAILED(hr)) return hr; -pf = d3d9_to_pipe_format_checked_no_bind(screen, SurfaceFormat, - PIPE_TEXTURE_2D, - MultiSampleType, FALSE); +if (depth_stencil_format(SurfaceFormat)) +bind = d3d9_get_pipe_depth_format_bindings(SurfaceFormat); +else /* render-target */ +bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_TRANSFER_READ | + PIPE_BIND_TRANSFER_WRITE | PIPE_BIND_RENDER_TARGET; + +pf = d3d9_to_pipe_format_checked(screen, SurfaceFormat, PIPE_TEXTURE_2D, + MultiSampleType, bind, FALSE); if (pf == PIPE_FORMAT_NONE) { DBG("%s with %u samples not available.\n", diff --git a/src/gallium/state_trackers/nine/nine_pipe.h b/src/gallium/state_trackers/nine/nine_pipe.h index 7295bdf..17844d5 100644 --- a/src/gallium/state_trackers/nine/nine_pipe.h +++ b/src/gallium/state_trackers/nine/nine_pipe.h @@ -309,31 +309,6 @@ d3d9_to_pipe_format_checked(struct pipe_screen *screen, return PIPE_FORMAT_NONE; } -/* same that above, but determines binding flags */ -static INLINE enum pipe_format -d3d9_to_pipe_format_checked_no_bind(struct pipe_screen *screen, -D3DFORMAT format, -enum pipe_texture_target target, -unsigned sample_count, -boolean srgb) -{ -enum pipe_format result; -unsigned bindings; - -result = d3d9_to_pipe_format_internal(format); -if (result == PIPE_FORMAT_NONE) -return PIPE_FORMAT_NONE; - -bindings = util_format_is_depth_or_stencil(result) ? -PIPE_BIND_DEPTH_STENCIL : PIPE_BIND_RENDER_TARGET; -if (srgb) -result = util_format_srgb(result); - -if (format_check_internal(result)) -return result; -return PIPE_FORMAT_NONE; -} - static INLINE const char * d3dformat_to_string(D3DFORMAT fmt) { -- 2.1.0 ___ 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/43] st/nine: Fix multisampling support detection
I checked, and the application is allowed to lock the backbuffer if it specified a specific flag. However it seems locking a multisampled buffer is forbidden. So probably here the PIPE_BIND_TRANSFER_* flags could be removed for multisampling, should I add that behaviour ? Does it matter for some drivers ? Axel On 31/01/2015 07:04, Axel Davy wrote : The patch modifies the code used to check for format support. It needs to test for these flags for render targets because we create the back buffers with these. Probably these flags are not required for back buffers, I'll investigate. Axel On 31/01/2015 00:36, Marek Olšák wrote : I recommend not using PIPE_BIND_TRANSFER_READ/WRITE. Transfers with multisample textures should be supported, but the mapped texture is always a resolved single-sample copy, so it's not really an MSAA transfer. Marek On Fri, Jan 30, 2015 at 9:34 PM, Axel Davy wrote: Signed-off-by: Axel Davy --- src/gallium/state_trackers/nine/adapter9.c | 12 +--- src/gallium/state_trackers/nine/nine_pipe.h | 25 - 2 files changed, 9 insertions(+), 28 deletions(-) diff --git a/src/gallium/state_trackers/nine/adapter9.c b/src/gallium/state_trackers/nine/adapter9.c index e9bb9c0..069cc03 100644 --- a/src/gallium/state_trackers/nine/adapter9.c +++ b/src/gallium/state_trackers/nine/adapter9.c @@ -359,6 +359,7 @@ NineAdapter9_CheckDeviceMultiSampleType( struct NineAdapter9 *This, struct pipe_screen *screen; HRESULT hr; enum pipe_format pf; +unsigned bind; DBG("This=%p DeviceType=%s SurfaceFormat=%s Windowed=%i MultiSampleType=%u " "pQualityLevels=%p\n", This, nine_D3DDEVTYPE_to_str(DeviceType), @@ -369,9 +370,14 @@ NineAdapter9_CheckDeviceMultiSampleType( struct NineAdapter9 *This, if (FAILED(hr)) return hr; -pf = d3d9_to_pipe_format_checked_no_bind(screen, SurfaceFormat, - PIPE_TEXTURE_2D, - MultiSampleType, FALSE); +if (depth_stencil_format(SurfaceFormat)) +bind = d3d9_get_pipe_depth_format_bindings(SurfaceFormat); +else /* render-target */ +bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_TRANSFER_READ | + PIPE_BIND_TRANSFER_WRITE | PIPE_BIND_RENDER_TARGET; + +pf = d3d9_to_pipe_format_checked(screen, SurfaceFormat, PIPE_TEXTURE_2D, + MultiSampleType, bind, FALSE); if (pf == PIPE_FORMAT_NONE) { DBG("%s with %u samples not available.\n", diff --git a/src/gallium/state_trackers/nine/nine_pipe.h b/src/gallium/state_trackers/nine/nine_pipe.h index 7295bdf..17844d5 100644 --- a/src/gallium/state_trackers/nine/nine_pipe.h +++ b/src/gallium/state_trackers/nine/nine_pipe.h @@ -309,31 +309,6 @@ d3d9_to_pipe_format_checked(struct pipe_screen *screen, return PIPE_FORMAT_NONE; } -/* same that above, but determines binding flags */ -static INLINE enum pipe_format -d3d9_to_pipe_format_checked_no_bind(struct pipe_screen *screen, -D3DFORMAT format, -enum pipe_texture_target target, -unsigned sample_count, -boolean srgb) -{ -enum pipe_format result; -unsigned bindings; - -result = d3d9_to_pipe_format_internal(format); -if (result == PIPE_FORMAT_NONE) -return PIPE_FORMAT_NONE; - -bindings = util_format_is_depth_or_stencil(result) ? -PIPE_BIND_DEPTH_STENCIL : PIPE_BIND_RENDER_TARGET; -if (srgb) -result = util_format_srgb(result); - -if (format_check_internal(result)) -return result; -return PIPE_FORMAT_NONE; -} - static INLINE const char * d3dformat_to_string(D3DFORMAT fmt) { -- 2.1.0 ___ 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 mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] radeonsi: fix a crash if a stencil ref state is set before a DSA state
It works fine. Since no state tracker need it currently, why do you want to backport it to older mesa versions ? In all cases, Reviewed-by: Axel Davy (btw: missing signoff) Axel Davy On 15/02/2015 18:21, Marek Olšák wrote : From: Marek Olšák + minor indentation fixes Discovered by Axel Davy. This can't be reproduced with any app, because all state trackers set a DSA state first. Cc: 10.5 10.4 10.3 --- src/gallium/drivers/radeonsi/si_state.c | 12 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c index fb353ad..3eea0b6 100644 --- a/src/gallium/drivers/radeonsi/si_state.c +++ b/src/gallium/drivers/radeonsi/si_state.c @@ -735,12 +735,16 @@ static void si_delete_rs_state(struct pipe_context *ctx, void *state) */ static void si_update_dsa_stencil_ref(struct si_context *sctx) { - struct si_pm4_state *pm4 = CALLOC_STRUCT(si_pm4_state); + struct si_pm4_state *pm4; struct pipe_stencil_ref *ref = &sctx->stencil_ref; -struct si_state_dsa *dsa = sctx->queued.named.dsa; + struct si_state_dsa *dsa = sctx->queued.named.dsa; -if (pm4 == NULL) -return; + if (!dsa) + return; + + pm4 = CALLOC_STRUCT(si_pm4_state); + if (pm4 == NULL) + return; si_pm4_set_reg(pm4, R_028430_DB_STENCILREFMASK, S_028430_STENCILTESTVAL(ref->ref_value[0]) | ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] Gallium: Removal of set_index_buffer (discussion)
On 20/02/2017 20:11, Ilia Mirkin wrote: On Mon, Feb 20, 2017 at 2:01 PM, Marek Olšák wrote: Hi, I'd like to remove pipe_context::set_index_buffer. It's not useful to most drivers and the interface is inconvenient for Mesa/OpenGL, because it's a draw state that is set with a separate driver callback, which is an unnecessary driver roundtrip taking some CPU cycles. I'd prefer to pass the index buffer via pipe_draw_info. I'm aware that the interface was inherited from DX10, but I don't think that makes any difference here. DX10 state trackers can pass the index buffer via pipe_draw_info too. This is my proposal: iff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h index ce19b92..cffbb33 100644 --- a/src/gallium/include/pipe/p_state.h +++ b/src/gallium/include/pipe/p_state.h @@ -635,7 +635,7 @@ struct pipe_index_buffer */ struct pipe_draw_info { - boolean indexed; /**< use index buffer */ + ubyte index_size; /**< 0 = non-indexed */ Isn't that enough to say non-index when index_buffer and user_indices are NULL ? enum pipe_prim_type mode; /**< the mode of the primitive */ boolean primitive_restart; ubyte vertices_per_patch; /**< the number of vertices per patch */ @@ -666,12 +666,18 @@ struct pipe_draw_info unsigned indirect_params_offset; /**< must be 4 byte aligned */ + /** +* Index buffer. Only one can be non-NULL. +*/ + struct pipe_resource *index_buffer; /* "start" is the offset */ Works for me. Is start the offset in bytes or is start * index_size the offset in bytes? Same question here. My understanding is that start is in terms of start * index_size bytes. But we really want to have a byte offset. + void *user_indices; + /* Pointers must be at the end for an optimal structure layout on 64-bit. */ Comments welcome, Marek ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev My understanding of the current interface is that setting the index buffer may be costly. Thus you want to set once, and use for several draw calls with different start or other changes. If setting the index buffer is indeed costly, and independant of the draw calls, the proposed change makes it a bit harder for the driver (it's as if we are setting the index buffer ever draw call, even if it didn't really change). For the state tracker, it doesn't make much difference. Axel Axel ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] st/nine: make use of common uploaders v2
On 20/02/2017 20:22, Constantine Charlamov wrote: Make use of common uploaders that landed recently to Mesa v2: fixed formatting, broken due to thunderbird configuration --- src/gallium/state_trackers/nine/device9.c| 48 src/gallium/state_trackers/nine/device9.h| 5 --- src/gallium/state_trackers/nine/nine_ff.c| 8 ++--- src/gallium/state_trackers/nine/nine_state.c | 48 ++-- 4 files changed, 35 insertions(+), 74 deletions(-) diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c index b9b7a637d7..2ae8678c31 100644 --- a/src/gallium/state_trackers/nine/device9.c +++ b/src/gallium/state_trackers/nine/device9.c @@ -477,31 +477,8 @@ NineDevice9_ctor( struct NineDevice9 *This, This->driver_caps.user_cbufs = GET_PCAP(USER_CONSTANT_BUFFERS); This->driver_caps.user_sw_vbufs = This->screen_sw->get_param(This->screen_sw, PIPE_CAP_USER_VERTEX_BUFFERS); This->driver_caps.user_sw_cbufs = This->screen_sw->get_param(This->screen_sw, PIPE_CAP_USER_CONSTANT_BUFFERS); - -/* Implicit use of context pipe for vertex and index uploaded when - * csmt is not active. Does not need to sync since csmt is unactive, - * thus no need to call NineDevice9_GetPipe at each upload. */ I'd like to have this comment kept somehow (though the use of context pipe is not implicit anymore). I guess it should be in NineDevice9_DrawPrimitiveUP just before if (!This->driver_caps.user_vbufs). It could be: csmt is unactive when user vertex or index buffers are used, thus no need to call NineDevice8_GetPipe. Axel -if (!This->driver_caps.user_vbufs) -This->vertex_uploader = u_upload_create(This->csmt_active ? -This->pipe_secondary : This->context.pipe, -65536, -PIPE_BIND_VERTEX_BUFFER, PIPE_USAGE_STREAM); -This->vertex_sw_uploader = u_upload_create(This->pipe_sw, 65536, -PIPE_BIND_VERTEX_BUFFER, PIPE_USAGE_STREAM); -if (!This->driver_caps.user_ibufs) -This->index_uploader = u_upload_create(This->csmt_active ? -This->pipe_secondary : This->context.pipe, - 128 * 1024, - PIPE_BIND_INDEX_BUFFER, PIPE_USAGE_STREAM); -if (!This->driver_caps.user_cbufs) { +if (!This->driver_caps.user_cbufs) This->constbuf_alignment = GET_PCAP(CONSTANT_BUFFER_OFFSET_ALIGNMENT); -This->constbuf_uploader = u_upload_create(This->context.pipe, This->vs_const_size, - PIPE_BIND_CONSTANT_BUFFER, PIPE_USAGE_STREAM); -} - -This->constbuf_sw_uploader = u_upload_create(This->pipe_sw, 128 * 1024, - PIPE_BIND_CONSTANT_BUFFER, PIPE_USAGE_STREAM); - This->driver_caps.window_space_position_support = GET_PCAP(TGSI_VS_WINDOW_SPACE_POSITION); This->driver_caps.vs_integer = pScreen->get_shader_param(pScreen, PIPE_SHADER_VERTEX, PIPE_SHADER_CAP_INTEGERS); This->driver_caps.ps_integer = pScreen->get_shader_param(pScreen, PIPE_SHADER_FRAGMENT, PIPE_SHADER_CAP_INTEGERS); @@ -552,17 +529,6 @@ NineDevice9_dtor( struct NineDevice9 *This ) nine_state_clear(&This->state, TRUE); nine_context_clear(This); -if (This->vertex_uploader) -u_upload_destroy(This->vertex_uploader); -if (This->index_uploader) -u_upload_destroy(This->index_uploader); -if (This->constbuf_uploader) -u_upload_destroy(This->constbuf_uploader); -if (This->vertex_sw_uploader) -u_upload_destroy(This->vertex_sw_uploader); -if (This->constbuf_sw_uploader) -u_upload_destroy(This->constbuf_sw_uploader); - nine_bind(&This->record, NULL); pipe_sampler_view_reference(&This->dummy_sampler_view, NULL); @@ -2853,14 +2819,14 @@ NineDevice9_DrawPrimitiveUP( struct NineDevice9 *This, vtxbuf.user_buffer = pVertexStreamZeroData; if (!This->driver_caps.user_vbufs) { -u_upload_data(This->vertex_uploader, +u_upload_data(This->context.pipe->stream_uploader, 0, (prim_count_to_vertex_count(PrimitiveType, PrimitiveCount)) * VertexStreamZeroStride, /* XXX */ 4, vtxbuf.user_buffer, &vtxbuf.buffer_offset, &vtxbuf.buffer); -u_upload_unmap(This->vertex_uploader); +u_upload_unmap(This->context.pipe->stream_uploader); vtxbuf.user_buffer = NULL; } @@ -2916,27 +2882,27 @@ NineDevice9_DrawIndexedPrimitiveUP( struct NineDevice9 *This, if (!This->driver_caps.user_vbufs) { const uns
Re: [Mesa-dev] [PATCH] st/nine: make use of common uploaders v3
On 20/02/2017 21:30, Constantine Charlamov wrote: Make use of common uploaders that landed recently to Mesa v2: fixed formatting, broken due to thunderbird configuration v3: per Axel comment: added a comment into NineDevice9_DrawPrimitiveUP --- src/gallium/state_trackers/nine/device9.c| 50 +--- src/gallium/state_trackers/nine/device9.h| 5 --- src/gallium/state_trackers/nine/nine_ff.c| 8 ++--- src/gallium/state_trackers/nine/nine_state.c | 48 +- 4 files changed, 37 insertions(+), 74 deletions(-) diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c index b9b7a637d7..86c8e38535 100644 --- a/src/gallium/state_trackers/nine/device9.c +++ b/src/gallium/state_trackers/nine/device9.c @@ -477,31 +477,8 @@ NineDevice9_ctor( struct NineDevice9 *This, This->driver_caps.user_cbufs = GET_PCAP(USER_CONSTANT_BUFFERS); This->driver_caps.user_sw_vbufs = This->screen_sw->get_param(This->screen_sw, PIPE_CAP_USER_VERTEX_BUFFERS); This->driver_caps.user_sw_cbufs = This->screen_sw->get_param(This->screen_sw, PIPE_CAP_USER_CONSTANT_BUFFERS); - -/* Implicit use of context pipe for vertex and index uploaded when - * csmt is not active. Does not need to sync since csmt is unactive, - * thus no need to call NineDevice9_GetPipe at each upload. */ -if (!This->driver_caps.user_vbufs) -This->vertex_uploader = u_upload_create(This->csmt_active ? -This->pipe_secondary : This->context.pipe, -65536, -PIPE_BIND_VERTEX_BUFFER, PIPE_USAGE_STREAM); -This->vertex_sw_uploader = u_upload_create(This->pipe_sw, 65536, -PIPE_BIND_VERTEX_BUFFER, PIPE_USAGE_STREAM); -if (!This->driver_caps.user_ibufs) -This->index_uploader = u_upload_create(This->csmt_active ? -This->pipe_secondary : This->context.pipe, - 128 * 1024, - PIPE_BIND_INDEX_BUFFER, PIPE_USAGE_STREAM); -if (!This->driver_caps.user_cbufs) { +if (!This->driver_caps.user_cbufs) This->constbuf_alignment = GET_PCAP(CONSTANT_BUFFER_OFFSET_ALIGNMENT); -This->constbuf_uploader = u_upload_create(This->context.pipe, This->vs_const_size, - PIPE_BIND_CONSTANT_BUFFER, PIPE_USAGE_STREAM); -} - -This->constbuf_sw_uploader = u_upload_create(This->pipe_sw, 128 * 1024, - PIPE_BIND_CONSTANT_BUFFER, PIPE_USAGE_STREAM); - This->driver_caps.window_space_position_support = GET_PCAP(TGSI_VS_WINDOW_SPACE_POSITION); This->driver_caps.vs_integer = pScreen->get_shader_param(pScreen, PIPE_SHADER_VERTEX, PIPE_SHADER_CAP_INTEGERS); This->driver_caps.ps_integer = pScreen->get_shader_param(pScreen, PIPE_SHADER_FRAGMENT, PIPE_SHADER_CAP_INTEGERS); @@ -552,17 +529,6 @@ NineDevice9_dtor( struct NineDevice9 *This ) nine_state_clear(&This->state, TRUE); nine_context_clear(This); -if (This->vertex_uploader) -u_upload_destroy(This->vertex_uploader); -if (This->index_uploader) -u_upload_destroy(This->index_uploader); -if (This->constbuf_uploader) -u_upload_destroy(This->constbuf_uploader); -if (This->vertex_sw_uploader) -u_upload_destroy(This->vertex_sw_uploader); -if (This->constbuf_sw_uploader) -u_upload_destroy(This->constbuf_sw_uploader); - nine_bind(&This->record, NULL); pipe_sampler_view_reference(&This->dummy_sampler_view, NULL); @@ -2852,15 +2818,17 @@ NineDevice9_DrawPrimitiveUP( struct NineDevice9 *This, vtxbuf.buffer = NULL; vtxbuf.user_buffer = pVertexStreamZeroData; +// csmt is unactive when user vertex or index buffers are used, thus no +// need to call NineDevice9_GetPipe. Comments in gallium nine are C style. Axel if (!This->driver_caps.user_vbufs) { -u_upload_data(This->vertex_uploader, +u_upload_data(This->context.pipe->stream_uploader, 0, (prim_count_to_vertex_count(PrimitiveType, PrimitiveCount)) * VertexStreamZeroStride, /* XXX */ 4, vtxbuf.user_buffer, &vtxbuf.buffer_offset, &vtxbuf.buffer); -u_upload_unmap(This->vertex_uploader); +u_upload_unmap(This->context.pipe->stream_uploader); vtxbuf.user_buffer = NULL; } @@ -2916,27 +2884,27 @@ NineDevice9_DrawIndexedPrimitiveUP( struct NineDevice9 *This, if (!This->driver_caps.user_vbufs) { const unsigned base = MinVertexIndex * VertexStreamZeroStride; -u_uplo
Re: [Mesa-dev] Gallium: Removal of set_index_buffer (discussion)
On 21/02/2017 16:00, Roland Scheidegger wrote: Am 21.02.2017 um 11:46 schrieb Marek Olšák: On Tue, Feb 21, 2017 at 4:36 AM, Roland Scheidegger wrote: Am 20.02.2017 um 21:58 schrieb Marek Olšák: On Mon, Feb 20, 2017 at 9:28 PM, Roland Scheidegger wrote: Am 20.02.2017 um 20:56 schrieb Marek Olšák: On Mon, Feb 20, 2017 at 8:29 PM, Axel Davy wrote: On 20/02/2017 20:11, Ilia Mirkin wrote: On Mon, Feb 20, 2017 at 2:01 PM, Marek Olšák wrote: Hi, I'd like to remove pipe_context::set_index_buffer. It's not useful to most drivers and the interface is inconvenient for Mesa/OpenGL, because it's a draw state that is set with a separate driver callback, which is an unnecessary driver roundtrip taking some CPU cycles. I'd prefer to pass the index buffer via pipe_draw_info. I'm aware that the interface was inherited from DX10, but I don't think that makes any difference here. DX10 state trackers can pass the index buffer via pipe_draw_info too. This is my proposal: iff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h index ce19b92..cffbb33 100644 --- a/src/gallium/include/pipe/p_state.h +++ b/src/gallium/include/pipe/p_state.h @@ -635,7 +635,7 @@ struct pipe_index_buffer */ struct pipe_draw_info { - boolean indexed; /**< use index buffer */ + ubyte index_size; /**< 0 = non-indexed */ Isn't that enough to say non-index when index_buffer and user_indices are NULL ? We still need index_size and it's only 8 bits as opposed to 64 bits. FWIW at least in d3d10 you can actually have indexed rendering without an index buffer bound. This is perfectly valid, you're just expected to return always zero for all indices... Albeit I believe we actually deal with this with a dummy buffer. enum pipe_prim_type mode; /**< the mode of the primitive */ boolean primitive_restart; ubyte vertices_per_patch; /**< the number of vertices per patch */ @@ -666,12 +666,18 @@ struct pipe_draw_info unsigned indirect_params_offset; /**< must be 4 byte aligned */ + /** +* Index buffer. Only one can be non-NULL. +*/ + struct pipe_resource *index_buffer; /* "start" is the offset */ Works for me. Is start the offset in bytes or is start * index_size the offset in bytes? Same question here. My understanding is that start is in terms of start * index_size bytes. offset = start * index_size; But we really want to have a byte offset. The offset should be aligned to index_size, otherwise hardware won't work. Are you sure of that? d3d10 doesn't seem to have such a requirement, or if it has I can't find it now (so, the startIndex really is in terms of index units, but the offset of the buffer is in terms of bytes, and the docs don't seem to mention it's limited to index alignment). I don't actually see such a limitation in GL neither, albeit some quick googling seems to suggest YMMV (e.g. https://urldefense.proofpoint.com/v2/url?u=http-3A__irrlicht.sourceforge.net_forum_viewtopic.php-3Ff-3D7-26t-3D51444&d=DwIFaQ&c=uilaK90D4TOVoH58JNXRgQ&r=_QIjpv-UJ77xEQY8fIYoQtr5qv8wKrPJc7v7_-CYAb0&m=_nDDEb8aspFcYmYCdx9G-Pfs4rRVzx4rodfxnJNkNyc&s=XPduNXrH7SGk7lVUD2izbWAOfERG60bJWTsI600UWCg&e= ). So, I can't quite tell right now if we really need byte offsets... It's a natural requirement of hardware. It doesn't have to be documented IMO. CPUs might not support it either. I did some quick tests and I believe d3d10 doesn't actually require offsets not aligned to index size, but don't quote me on that. Nevertheless, I've got the feeling this might be expected to work with GL - doesn't look like it would be an error if your indices "pointer" in glDrawElements() isn't aligned, and if it's not an error I don't see why it wouldn't be well defined? (FWIW x86 supports this fine, but indeed not all cpu archs might. Even AVX2 gather supports non-aligned lookups - of course just for uint indices since gather doesn't support smaller than 32bit gathers.) From GL 4.4 Core, section 6.2: "Clients must align data elements consistent with the requirements of the client platform, with an additional base-level requirement that an offset within a buffer to a datum comprising N basic machine units be a multiple of N." Ah, nice find (not in the section I was looking for...). I suppose it isn't expected to work then (albeit it's interesting that it's still not an actual gl error anywhere). Roland What is a basic machine unit ? I_ it supposed to be index_size, or just the required alignment for the platform ? Axel ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] st/nine: make use of common uploaders v4
This looks fine to me. Reviewed-by: Axel Davy I think the patch requires your Signed-off-by though. Axel On 21/02/2017 05:31, Constantine Charlamov wrote: Make use of common uploaders that landed recently to Mesa v2: fixed formatting, broken due to thunderbird configuration v3: per Axel comment: added a comment into NineDevice9_DrawPrimitiveUP v4: per Axel comment: changed style of the comment --- src/gallium/state_trackers/nine/device9.c| 50 +--- src/gallium/state_trackers/nine/device9.h| 5 --- src/gallium/state_trackers/nine/nine_ff.c| 8 ++--- src/gallium/state_trackers/nine/nine_state.c | 48 +- 4 files changed, 37 insertions(+), 74 deletions(-) diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c index b9b7a637d7..86c8e38535 100644 --- a/src/gallium/state_trackers/nine/device9.c +++ b/src/gallium/state_trackers/nine/device9.c @@ -477,31 +477,8 @@ NineDevice9_ctor( struct NineDevice9 *This, This->driver_caps.user_cbufs = GET_PCAP(USER_CONSTANT_BUFFERS); This->driver_caps.user_sw_vbufs = This->screen_sw->get_param(This->screen_sw, PIPE_CAP_USER_VERTEX_BUFFERS); This->driver_caps.user_sw_cbufs = This->screen_sw->get_param(This->screen_sw, PIPE_CAP_USER_CONSTANT_BUFFERS); - -/* Implicit use of context pipe for vertex and index uploaded when - * csmt is not active. Does not need to sync since csmt is unactive, - * thus no need to call NineDevice9_GetPipe at each upload. */ -if (!This->driver_caps.user_vbufs) -This->vertex_uploader = u_upload_create(This->csmt_active ? -This->pipe_secondary : This->context.pipe, -65536, -PIPE_BIND_VERTEX_BUFFER, PIPE_USAGE_STREAM); -This->vertex_sw_uploader = u_upload_create(This->pipe_sw, 65536, -PIPE_BIND_VERTEX_BUFFER, PIPE_USAGE_STREAM); -if (!This->driver_caps.user_ibufs) -This->index_uploader = u_upload_create(This->csmt_active ? -This->pipe_secondary : This->context.pipe, - 128 * 1024, - PIPE_BIND_INDEX_BUFFER, PIPE_USAGE_STREAM); -if (!This->driver_caps.user_cbufs) { +if (!This->driver_caps.user_cbufs) This->constbuf_alignment = GET_PCAP(CONSTANT_BUFFER_OFFSET_ALIGNMENT); -This->constbuf_uploader = u_upload_create(This->context.pipe, This->vs_const_size, - PIPE_BIND_CONSTANT_BUFFER, PIPE_USAGE_STREAM); -} - -This->constbuf_sw_uploader = u_upload_create(This->pipe_sw, 128 * 1024, - PIPE_BIND_CONSTANT_BUFFER, PIPE_USAGE_STREAM); - This->driver_caps.window_space_position_support = GET_PCAP(TGSI_VS_WINDOW_SPACE_POSITION); This->driver_caps.vs_integer = pScreen->get_shader_param(pScreen, PIPE_SHADER_VERTEX, PIPE_SHADER_CAP_INTEGERS); This->driver_caps.ps_integer = pScreen->get_shader_param(pScreen, PIPE_SHADER_FRAGMENT, PIPE_SHADER_CAP_INTEGERS); @@ -552,17 +529,6 @@ NineDevice9_dtor( struct NineDevice9 *This ) nine_state_clear(&This->state, TRUE); nine_context_clear(This); -if (This->vertex_uploader) -u_upload_destroy(This->vertex_uploader); -if (This->index_uploader) -u_upload_destroy(This->index_uploader); -if (This->constbuf_uploader) -u_upload_destroy(This->constbuf_uploader); -if (This->vertex_sw_uploader) -u_upload_destroy(This->vertex_sw_uploader); -if (This->constbuf_sw_uploader) -u_upload_destroy(This->constbuf_sw_uploader); - nine_bind(&This->record, NULL); pipe_sampler_view_reference(&This->dummy_sampler_view, NULL); @@ -2852,15 +2818,17 @@ NineDevice9_DrawPrimitiveUP( struct NineDevice9 *This, vtxbuf.buffer = NULL; vtxbuf.user_buffer = pVertexStreamZeroData; +/* csmt is unactive when user vertex or index buffers are used, thus no + * need to call NineDevice9_GetPipe. */ if (!This->driver_caps.user_vbufs) { -u_upload_data(This->vertex_uploader, +u_upload_data(This->context.pipe->stream_uploader, 0, (prim_count_to_vertex_count(PrimitiveType, PrimitiveCount)) * VertexStreamZeroStride, /* XXX */ 4, vtxbuf.user_buffer, &vtxbuf.buffer_offset, &vtxbuf.buffer); -u_upload_unmap(This->vertex_uploader); +u_upload_unmap(This-&g
Re: [Mesa-dev] [PATCH] st/nine: Remove code for no USER_INDEX_BUFFERS as these are always on
Hi Mike, We really want not to use user index buffers when csmt is active (thus the !This->csmt_active). This should be a one line patch to just remove the part GET_PCAP(USER_INDEX_BUFFERS) Yours, Axel Davy On 25/02/2017 06:23, Mike Lothian wrote: This fixes 4a883966c1f74f43afc145d2c3d27af7b8c5e01a where the pipe cap was removed Now USER_INDEX_BUFFERS are always enabled remove code that checks for them and works around them not being available Signed-off-by: Mike Lothian Cc: Marek Olšák Cc: Axel Davy --- src/gallium/state_trackers/nine/device9.c | 17 - 1 file changed, 17 deletions(-) diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c index b9b7a637d7..2217cc9d0c 100644 --- a/src/gallium/state_trackers/nine/device9.c +++ b/src/gallium/state_trackers/nine/device9.c @@ -473,7 +473,6 @@ NineDevice9_ctor( struct NineDevice9 *This, /* Allocate upload helper for drivers that suck (from st pov ;). */ This->driver_caps.user_vbufs = GET_PCAP(USER_VERTEX_BUFFERS) && !This->csmt_active; -This->driver_caps.user_ibufs = GET_PCAP(USER_INDEX_BUFFERS) && !This->csmt_active; This->driver_caps.user_cbufs = GET_PCAP(USER_CONSTANT_BUFFERS); This->driver_caps.user_sw_vbufs = This->screen_sw->get_param(This->screen_sw, PIPE_CAP_USER_VERTEX_BUFFERS); This->driver_caps.user_sw_cbufs = This->screen_sw->get_param(This->screen_sw, PIPE_CAP_USER_CONSTANT_BUFFERS); @@ -488,11 +487,6 @@ NineDevice9_ctor( struct NineDevice9 *This, PIPE_BIND_VERTEX_BUFFER, PIPE_USAGE_STREAM); This->vertex_sw_uploader = u_upload_create(This->pipe_sw, 65536, PIPE_BIND_VERTEX_BUFFER, PIPE_USAGE_STREAM); -if (!This->driver_caps.user_ibufs) -This->index_uploader = u_upload_create(This->csmt_active ? -This->pipe_secondary : This->context.pipe, - 128 * 1024, - PIPE_BIND_INDEX_BUFFER, PIPE_USAGE_STREAM); if (!This->driver_caps.user_cbufs) { This->constbuf_alignment = GET_PCAP(CONSTANT_BUFFER_OFFSET_ALIGNMENT); This->constbuf_uploader = u_upload_create(This->context.pipe, This->vs_const_size, @@ -2928,17 +2922,6 @@ NineDevice9_DrawIndexedPrimitiveUP( struct NineDevice9 *This, vbuf.buffer_offset -= base; vbuf.user_buffer = NULL; } -if (!This->driver_caps.user_ibufs) { -u_upload_data(This->index_uploader, - 0, - (prim_count_to_vertex_count(PrimitiveType, PrimitiveCount)) * ibuf.index_size, - 4, - ibuf.user_buffer, - &ibuf.offset, - &ibuf.buffer); -u_upload_unmap(This->index_uploader); -ibuf.user_buffer = NULL; -} NineBeforeDraw(This); nine_context_draw_indexed_primitive_from_vtxbuf_idxbuf(This, PrimitiveType, ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 00/71] New Gallium Nine Fixes and Improvements
Some patches we had in our pending queue for quite some time. Overall not quite interesting set of patches, just minor fixes or improvements. As usual you can find the patch serie there: https://github.com/iXit/Mesa-3D/commits/mesa_submit Patch 2 is an interesting feature since instead of advertizing gallium card names, we do advertize the ones they have on win. Wine does the same. Patches 3-7 are fixes Patches 8-13 finish our implementation of software cursor (used when hw cursor can't be used) Patches 14-23 implement correct surface dirty region tracking, and use it to avoid useless updates, like specified in the documentation. Patches 24-36 are fixes to our checks, and do solve several Wine tests. Patches 37-60 are several patches to rework how we do handle state changes, and add support for bumpmats and fog. Initially the state rework was designed to simplify and improve performance and there was a big switch where you'd update only the corresponding gallium struct field depending on the d3d9 state you'd change. However it was not good for performance afterall. As a result two or three of the patches are not very useful for now, as they are just useless refactoring. I hesitated to send them, but I'd still like have them in. Patches 61-67 are some more fixes or improvements Patches 68-71 do silent some compilation warnings Axel Davy (55): st/nine: Fix Swizzle for ATI2 format st/nine: Always set point_quad_rasterization to 1 st/nine: fix D3DRS_DITHERENABLE wrong state group st/nine: Hide hardware cursor when we don't use it st/nine: Force hw cursor for Windowed mode st/nine: Do not call ID3DPresent_GetCursorPos for sw cursor st/nine: Revert to sw cursor in case of failure to set hw cursor st/nine: Simplify Volume9 dirty region tracking st/nine: Split NineSurface9_CopySurface st/nine: Simplify NineVolume9_CopyVolume st/nine: SetAutoGenFilterType should regenerate the sublevels st/nine: Add missing BASETEX_REGISTER_UPDATE calls st/nine: Track dirty region for SYSTEMMEM too st/nine: Textures start dirty st/nine: Only update dirty rect for UpdateTexture st/nine: Track managed textures st/nine: Implement EvictManagedResources st/nine: Fix StretchRect checks st/nine: Fix FillColor Flag check st/nine: Impose restrictions on DXTN texture sizes st/nine: Fix Lock Checks for Compressed textures st/nine: Remove group_mask argument from nine_update_state st/nine: Reorder nine_state. st/nine: Reorder DSA state settings st/nine: Rework rasterizer states st/nine: Avoid useless updates in SetSamplerState st/nine: Improve fallback when driver doesn't support user buffers. st/nine: Rework blend states st/nine: Rework constant buffer state handling st/nine: Rework ff constant buffers st/nine: Fix fixed function fog support st/nine: Begin programmable shader fog support st/nine: Fix nine_ff_ps_key padding st/nine: Remove useless variables st/nine: Rework shader states st/nine: Finish Fog implementation st/nine: Revert to userbuf path when needed st/nine: Advertise Fog flags st/nine: Change a few advertised caps st/nine: Complete ff texture transform implementation st/nine: Programmable ps D3DTTSS_PROJECTED support st/nine: Change nine_state_update order st/nine: Implement ff vertex data passthrough st/nine: Implement special DOTPRODUCT3 behaviour st/nine: Remove NINED3DRS_ZBIASSCALE st/nine: Better check shader constant limits st/nine: Calculate dummy sampler state only once st/nine: Use CSO cache for sampler views st/nine: Fix the number of texture stages st/nine: Avoid Constant upload when there is no change st/nine: Catch setting the same shader st/nine: Silent warning in update_vertex_buffer st/nine: Silent warning in NineCubeTexture9_ctor st/nine: Silent warning in sm1_declusage_to_tgsi st/nine: Silent warning in nine_ff Christoph Bumiller (1): gallium: Add blending to pipe blit David Heidelberg (1): st/nine: Require gcc >= 4.6 Marek Olšák (1): util/u_blitter: implement alpha blending for pipe->blit Patrick Rudolph (12): target/d3dadapter9: Return Windows like card names st/nine: Align texture memory st/nine: Account POINTSIZE_MIN and POINTSIZE_MAX for point size st/nine: Fix GenerateMipSubLevels potential crash st/nine: fix failing wine test device.c test_lockrect_invalid() st/nine: Clean GetPrivateData st/nine: Fix resource SetPriority/GetPriority st/nine: Return NULL pointer in lock error cases st/nine: Fail on D3DUSAGE_DYNAMIC for D3DPOOL_SCRATCH textures st/nine: Return correct error codes in NineDevice9_Reset st/nine: Prevent possible crash st/nine: Fix use of uninitialized values Tiziano Bacocco (1): st/nine: Implement TEXBEM,TEXBEML and BEM configure.ac |4 + src/gallium/auxiliary/util/u_blitter.c | 54 +- src/gallium/auxiliary/util/u_blitter.h |3 +- sr
[Mesa-dev] [PATCH 01/71] st/nine: Require gcc >= 4.6
From: David Heidelberg Fixes bug: fdo #89978 Signed-off-by: David Heidelberg Cc: "10.4 10.5 10.6" --- configure.ac | 4 1 file changed, 4 insertions(+) diff --git a/configure.ac b/configure.ac index 4e751e3..c355092 100644 --- a/configure.ac +++ b/configure.ac @@ -1632,6 +1632,10 @@ if test "x$enable_nine" = xyes; then if test "x$with_gallium_drivers" = xswrast; then AC_MSG_ERROR([nine requires at least one non-swrast gallium driver]) fi +if test $GCC_VERSION_MAJOR -lt 4 -o $GCC_VERSION_MAJOR -eq 4 -a $GCC_VERSION_MINOR -lt 6; then +AC_MSG_ERROR([gcc >= 4.6 is required to build nine]) +fi + if test "x$enable_dri3" = xno; then AC_MSG_WARN([using nine together with wine requires DRI3 enabled system]) fi -- 2.5.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 14/71] st/nine: Simplify Volume9 dirty region tracking
Similar to what was done for Surface9, track the dirty region only in VolumeTexture9. Signed-off-by: Axel Davy --- src/gallium/state_trackers/nine/basetexture9.c | 9 +-- src/gallium/state_trackers/nine/volume9.c | 82 ++ src/gallium/state_trackers/nine/volume9.h | 11 +--- 3 files changed, 35 insertions(+), 67 deletions(-) diff --git a/src/gallium/state_trackers/nine/basetexture9.c b/src/gallium/state_trackers/nine/basetexture9.c index eabf32b..cc74cc9 100644 --- a/src/gallium/state_trackers/nine/basetexture9.c +++ b/src/gallium/state_trackers/nine/basetexture9.c @@ -310,14 +310,12 @@ NineBaseTexture9_UploadSelf( struct NineBaseTexture9 *This ) tex->dirty_box.width, tex->dirty_box.height, tex->dirty_box.depth); if (tex->dirty_box.width) { -for (l = 0; l <= last_level; ++l) { +for (l = min_level_dirty; l <= last_level; ++l) { u_box_minify_2d(&box, &tex->dirty_box, l); -NineVolume9_AddDirtyRegion(tex->volumes[l], &tex->dirty_box); +NineVolume9_UploadSelf(tex->volumes[l], &box); } memset(&tex->dirty_box, 0, sizeof(tex->dirty_box)); } -for (l = min_level_dirty; l <= last_level; ++l) -NineVolume9_UploadSelf(tex->volumes[l]); } else { assert(!"invalid texture type"); } @@ -361,8 +359,7 @@ NineBaseTexture9_UploadSelf( struct NineBaseTexture9 *This ) box.width = u_minify(This->base.info.width0, l); box.height = u_minify(This->base.info.height0, l); box.depth = u_minify(This->base.info.depth0, l); -NineVolume9_AddDirtyRegion(tex->volumes[l], &box); -NineVolume9_UploadSelf(tex->volumes[l]); +NineVolume9_UploadSelf(tex->volumes[l], &box); } } else { assert(!"invalid texture type"); diff --git a/src/gallium/state_trackers/nine/volume9.c b/src/gallium/state_trackers/nine/volume9.c index 8694d3d..3b5b312 100644 --- a/src/gallium/state_trackers/nine/volume9.c +++ b/src/gallium/state_trackers/nine/volume9.c @@ -23,6 +23,7 @@ #include "device9.h" #include "volume9.h" #include "basetexture9.h" /* for marking dirty */ +#include "volumetexture9.h" #include "nine_helpers.h" #include "nine_pipe.h" #include "nine_dump.h" @@ -182,47 +183,23 @@ NineVolume9_GetDesc( struct NineVolume9 *This, return D3D_OK; } -static inline boolean -NineVolume9_IsDirty(struct NineVolume9 *This) -{ -return This->dirty_box[0].width != 0; -} - inline void NineVolume9_AddDirtyRegion( struct NineVolume9 *This, const struct pipe_box *box ) { -struct pipe_box cover_a, cover_b; -float vol[2]; +D3DBOX dirty_region; +struct NineVolumeTexture9 *tex = NineVolumeTexture9(This->base.container); if (!box) { -u_box_3d(0, 0, 0, This->desc.Width, This->desc.Height, - This->desc.Depth, &This->dirty_box[0]); -memset(&This->dirty_box[1], 0, sizeof(This->dirty_box[1])); -return; -} -if (!This->dirty_box[0].width) { -This->dirty_box[0] = *box; -return; -} - -u_box_union_3d(&cover_a, &This->dirty_box[0], box); -vol[0] = u_box_volume_3d(&cover_a); - -if (This->dirty_box[1].width == 0) { -vol[1] = u_box_volume_3d(&This->dirty_box[0]); -if (vol[0] > (vol[1] * 1.5f)) -This->dirty_box[1] = *box; -else -This->dirty_box[0] = cover_a; +NineVolumeTexture9_AddDirtyBox(tex, NULL); } else { -u_box_union_3d(&cover_b, &This->dirty_box[1], box); -vol[1] = u_box_volume_3d(&cover_b); - -if (vol[0] > vol[1]) -This->dirty_box[1] = cover_b; -else -This->dirty_box[0] = cover_a; +dirty_region.Left = box->x << This->level_actual; +dirty_region.Top = box->y << This->level_actual; +dirty_region.Front = box->z << This->level_actual; +dirty_region.Right = dirty_region.Left + (box->width << This->level_actual); +dirty_region.Bottom = dirty_region.Top + (box->height << This->level_actual); +dirty_region.Back = dirty_region.Front + (box->depth << This->level_actual); +NineVolumeTexture9_AddDirtyBox(tex, &dirty_region); } } @@ -312,8 +289,7 @@ NineVolume9_LockBox( struct NineVolume9 *This, if (!(Flags & (D3DLOCK_NO_DIRTY_UPDATE | D3DLOCK_READONLY))) { NineVolume9_MarkContainerDirty(This); -if (This-
[Mesa-dev] [PATCH 17/71] st/nine: SetAutoGenFilterType should regenerate the sublevels
Signed-off-by: Axel Davy --- src/gallium/state_trackers/nine/basetexture9.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gallium/state_trackers/nine/basetexture9.c b/src/gallium/state_trackers/nine/basetexture9.c index cc74cc9..728aafd 100644 --- a/src/gallium/state_trackers/nine/basetexture9.c +++ b/src/gallium/state_trackers/nine/basetexture9.c @@ -153,6 +153,8 @@ NineBaseTexture9_SetAutoGenFilterType( struct NineBaseTexture9 *This, user_assert(FilterType != D3DTEXF_NONE, D3DERR_INVALIDCALL); This->mipfilter = FilterType; +This->dirty_mip = TRUE; +NineBaseTexture9_GenerateMipSubLevels(This); return D3D_OK; } -- 2.1.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 10/71] st/nine: Do not call ID3DPresent_GetCursorPos for sw cursor
For sw cursor we do not tell wine the cursor position (the app tells us directly). We shouldn't use ID3DPresent_GetCursorPos. device->cursor.pos already contains the coordinates the app gave us. Signed-off-by: Axel Davy Reviewed-by: David Heidelberg --- src/gallium/state_trackers/nine/swapchain9.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/gallium/state_trackers/nine/swapchain9.c b/src/gallium/state_trackers/nine/swapchain9.c index a62e6ad..eb84d08 100644 --- a/src/gallium/state_trackers/nine/swapchain9.c +++ b/src/gallium/state_trackers/nine/swapchain9.c @@ -575,9 +575,10 @@ handle_draw_cursor_and_hud( struct NineSwapChain9 *This, struct pipe_resource *r blit.filter = PIPE_TEX_FILTER_NEAREST; blit.scissor_enable = FALSE; -ID3DPresent_GetCursorPos(This->present, &device->cursor.pos); - -/* NOTE: blit messes up when box.x + box.width < 0, fix driver */ +/* NOTE: blit messes up when box.x + box.width < 0, fix driver + * NOTE2: device->cursor.pos contains coordinates relative to the screen. + * This happens to be also the position of the cursor when we are fullscreen. + * We don't use sw cursor for Windowed mode */ blit.dst.box.x = MAX2(device->cursor.pos.x, 0) - device->cursor.hotspot.x; blit.dst.box.y = MAX2(device->cursor.pos.y, 0) - device->cursor.hotspot.y; blit.dst.box.width = blit.src.box.width; -- 2.1.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 02/71] target/d3dadapter9: Return Windows like card names
From: Patrick Rudolph Add support for multiple cards and fill in Windows like card name, driver name and version info. Use fallback for unknown vendors and unknown card names. Reviewed-by: Axel Davy Signed-off-by: Patrick Rudolph --- src/gallium/targets/d3dadapter9/Makefile.am | 1 + src/gallium/targets/d3dadapter9/description.c | 324 ++ src/gallium/targets/d3dadapter9/drm.c | 76 +++--- 3 files changed, 359 insertions(+), 42 deletions(-) create mode 100644 src/gallium/targets/d3dadapter9/description.c diff --git a/src/gallium/targets/d3dadapter9/Makefile.am b/src/gallium/targets/d3dadapter9/Makefile.am index fe5b0b1..e26ca33 100644 --- a/src/gallium/targets/d3dadapter9/Makefile.am +++ b/src/gallium/targets/d3dadapter9/Makefile.am @@ -54,6 +54,7 @@ pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = d3d.pc d3dadapter9_la_SOURCES = \ + description.c \ getproc.c \ drm.c diff --git a/src/gallium/targets/d3dadapter9/description.c b/src/gallium/targets/d3dadapter9/description.c new file mode 100644 index 000..c0a8678 --- /dev/null +++ b/src/gallium/targets/d3dadapter9/description.c @@ -0,0 +1,324 @@ +/* + * Copyright 2015 Patrick Rudolph + * + * 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 + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, 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 NON-INFRINGEMENT. IN NO EVENT SHALL + * THE AUTHOR(S) AND/OR THEIR SUPPLIERS 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 +#include "adapter9.h" + +#define DBG_CHANNEL DBG_ADAPTER + +/* prototypes */ +void +d3d_match_vendor_id( D3DADAPTER_IDENTIFIER9* drvid, +unsigned fallback_ven, +unsigned fallback_dev, +const char* fallback_name ); +void d3d_fill_driver_version(D3DADAPTER_IDENTIFIER9* drvid); +void d3d_fill_cardname(D3DADAPTER_IDENTIFIER9* drvid); + +enum d3d_vendor_id +{ +HW_VENDOR_SOFTWARE = 0x, +HW_VENDOR_AMD = 0x1002, +HW_VENDOR_NVIDIA= 0x10de, +HW_VENDOR_VMWARE= 0x15ad, +HW_VENDOR_INTEL = 0x8086, +}; + +struct card_lookup_table { +const char *mesaname; +const char *d3d9name; +} +cards_amd[] = { +{"HAWAII", "AMD Radeon R9 290"}, +{"KAVERI", "AMD Radeon(TM) R7 Graphics"}, +{"KABINI", "AMD Radeon HD 8400 / R3 Series"}, +{"BONAIRE", "AMD Radeon HD 8770"}, +{"OLAND", "AMD Radeon HD 8670"}, +{"HAINAN", "AMD Radeon HD 8600M Series"}, +{"TAHITI", "AMD Radeon HD 7900 Series"}, +{"PITCAIRN","AMD Radeon HD 7800 Series"}, +{"CAPE VERDE", "AMD Radeon HD 7700 Series"}, +{"ARUBA", "AMD Radeon HD 7660D"}, +{"CAYMAN", "AMD Radeon HD 6900 Series"}, +{"BARTS", "AMD Radeon HD 6800 Series"}, +{"TURKS", "AMD Radeon HD 6600 Series"}, +{"SUMO2", "AMD Radeon HD 6410D"}, +{"SUMO","AMD Radeon HD 6550D"}, +{"CAICOS", "AMD Radeon HD 6400 Series"}, +{"PALM","AMD Radeon HD 6300 series Graphics"}, +{"HEMLOCK", "ATI Radeon HD 5900 Series"}, +{"CYPRESS", "ATI Radeon HD 5800 Series"}, +{"JUNIPER", "ATI Radeon HD 5700 Series"}, +{"REDWOOD", "ATI Radeon HD 5600 Series"}, +{"CEDAR", "
[Mesa-dev] [PATCH 19/71] st/nine: Track dirty region for SYSTEMMEM too
Signed-off-by: Axel Davy --- src/gallium/state_trackers/nine/cubetexture9.c | 6 -- src/gallium/state_trackers/nine/surface9.c | 4 ++-- src/gallium/state_trackers/nine/texture9.c | 10 ++ src/gallium/state_trackers/nine/volumetexture9.c | 8 +--- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/gallium/state_trackers/nine/cubetexture9.c b/src/gallium/state_trackers/nine/cubetexture9.c index e9224d0..1215745 100644 --- a/src/gallium/state_trackers/nine/cubetexture9.c +++ b/src/gallium/state_trackers/nine/cubetexture9.c @@ -265,9 +265,11 @@ NineCubeTexture9_AddDirtyRect( struct NineCubeTexture9 *This, } return D3D_OK; } -This->base.managed.dirty = TRUE; -BASETEX_REGISTER_UPDATE(&This->base); +if (This->base.base.pool == D3DPOOL_MANAGED) { +This->base.managed.dirty = TRUE; +BASETEX_REGISTER_UPDATE(&This->base); +} if (!pDirtyRect) { u_box_origin_2d(This->base.base.info.width0, diff --git a/src/gallium/state_trackers/nine/surface9.c b/src/gallium/state_trackers/nine/surface9.c index 3e9465a..eb941ce 100644 --- a/src/gallium/state_trackers/nine/surface9.c +++ b/src/gallium/state_trackers/nine/surface9.c @@ -273,7 +273,7 @@ NineSurface9_AddDirtyRect( struct NineSurface9 *This, This->texture == D3DRTYPE_CUBETEXTURE || This->texture == D3DRTYPE_TEXTURE); -if (This->base.pool != D3DPOOL_MANAGED) +if (This->base.pool == D3DPOOL_DEFAULT) return; /* Add a dirty rect to level 0 of the parent texture */ @@ -287,7 +287,7 @@ NineSurface9_AddDirtyRect( struct NineSurface9 *This, NineTexture9(This->base.base.container); NineTexture9_AddDirtyRect(tex, &dirty_rect); -} else { /* This->texture == D3DRTYPE_CUBETEXTURE */ +} else if (This->texture == D3DRTYPE_CUBETEXTURE) { struct NineCubeTexture9 *ctex = NineCubeTexture9(This->base.base.container); diff --git a/src/gallium/state_trackers/nine/texture9.c b/src/gallium/state_trackers/nine/texture9.c index a7a679e..0127301 100644 --- a/src/gallium/state_trackers/nine/texture9.c +++ b/src/gallium/state_trackers/nine/texture9.c @@ -295,20 +295,22 @@ NineTexture9_AddDirtyRect( struct NineTexture9 *This, pDirtyRect ? pDirtyRect->left : 0, pDirtyRect ? pDirtyRect->top : 0, pDirtyRect ? pDirtyRect->right : 0, pDirtyRect ? pDirtyRect->bottom : 0); -/* Tracking dirty regions on DEFAULT or SYSTEMMEM resources is pointless, +/* Tracking dirty regions on DEFAULT resources is pointless, * because we always write to the final storage. Just marked it dirty in * case we need to generate mip maps. */ -if (This->base.base.pool != D3DPOOL_MANAGED) { +if (This->base.base.pool == D3DPOOL_DEFAULT) { if (This->base.base.usage & D3DUSAGE_AUTOGENMIPMAP) { This->base.dirty_mip = TRUE; BASETEX_REGISTER_UPDATE(&This->base); } return D3D_OK; } -This->base.managed.dirty = TRUE; -BASETEX_REGISTER_UPDATE(&This->base); +if (This->base.base.pool == D3DPOOL_MANAGED) { +This->base.managed.dirty = TRUE; +BASETEX_REGISTER_UPDATE(&This->base); +} if (!pDirtyRect) { u_box_origin_2d(This->base.base.info.width0, diff --git a/src/gallium/state_trackers/nine/volumetexture9.c b/src/gallium/state_trackers/nine/volumetexture9.c index 1193e12..720ae57 100644 --- a/src/gallium/state_trackers/nine/volumetexture9.c +++ b/src/gallium/state_trackers/nine/volumetexture9.c @@ -193,12 +193,14 @@ NineVolumeTexture9_AddDirtyBox( struct NineVolumeTexture9 *This, { DBG("This=%p pDirtybox=%p\n", This, pDirtyBox); -if (This->base.base.pool != D3DPOOL_MANAGED) { +if (This->base.base.pool == D3DPOOL_DEFAULT) { return D3D_OK; } -This->base.managed.dirty = TRUE; -BASETEX_REGISTER_UPDATE(&This->base); +if (This->base.base.pool == D3DPOOL_MANAGED) { +This->base.managed.dirty = TRUE; +BASETEX_REGISTER_UPDATE(&This->base); +} if (!pDirtyBox) { This->dirty_box.x = 0; -- 2.1.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 11/71] st/nine: Revert to sw cursor in case of failure to set hw cursor
Signed-off-by: Axel Davy Reviewed-by: David Heidelberg --- src/gallium/state_trackers/nine/device9.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c index 9f6c90e..38af8e3 100644 --- a/src/gallium/state_trackers/nine/device9.c +++ b/src/gallium/state_trackers/nine/device9.c @@ -682,7 +682,7 @@ NineDevice9_SetCursorPosition( struct NineDevice9 *This, This->cursor.pos.y = Y; if (!This->cursor.software) -ID3DPresent_SetCursorPos(swap->present, &This->cursor.pos); +This->cursor.software = ID3DPresent_SetCursorPos(swap->present, &This->cursor.pos) != D3D_OK; } BOOL WINAPI @@ -695,7 +695,7 @@ NineDevice9_ShowCursor( struct NineDevice9 *This, This->cursor.visible = bShow && (This->cursor.hotspot.x != -1); if (!This->cursor.software) -ID3DPresent_SetCursor(This->swapchains[0]->present, NULL, NULL, bShow); +This->cursor.software = ID3DPresent_SetCursor(This->swapchains[0]->present, NULL, NULL, bShow) != D3D_OK; return old; } -- 2.1.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 04/71] st/nine: Always set point_quad_rasterization to 1
Both Points and Point Sprites are rasterized like quads, according to d3d9 doc and gallium rasterizer doc. Signed-off-by: Axel Davy --- src/gallium/state_trackers/nine/nine_pipe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/state_trackers/nine/nine_pipe.c b/src/gallium/state_trackers/nine/nine_pipe.c index 4cf37b9..c0b74b8 100644 --- a/src/gallium/state_trackers/nine/nine_pipe.c +++ b/src/gallium/state_trackers/nine/nine_pipe.c @@ -92,7 +92,7 @@ nine_convert_rasterizer_state(struct cso_context *ctx, const DWORD *rs) /* rast.poly_stipple_enable = 0; */ /* rast.point_smooth = 0; */ rast.sprite_coord_mode = PIPE_SPRITE_COORD_UPPER_LEFT; -rast.point_quad_rasterization = !!rs[D3DRS_POINTSPRITEENABLE]; +rast.point_quad_rasterization = 1; rast.point_size_per_vertex = rs[NINED3DRS_VSPOINTSIZE]; rast.multisample = !!rs[D3DRS_MULTISAMPLEANTIALIAS]; rast.line_smooth = !!rs[D3DRS_ANTIALIASEDLINEENABLE]; -- 2.1.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 20/71] st/nine: Textures start dirty
Signed-off-by: Axel Davy --- src/gallium/state_trackers/nine/cubetexture9.c | 6 +- src/gallium/state_trackers/nine/texture9.c | 3 +++ src/gallium/state_trackers/nine/volumetexture9.c | 3 +++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/gallium/state_trackers/nine/cubetexture9.c b/src/gallium/state_trackers/nine/cubetexture9.c index 1215745..c1e6cbd 100644 --- a/src/gallium/state_trackers/nine/cubetexture9.c +++ b/src/gallium/state_trackers/nine/cubetexture9.c @@ -150,8 +150,12 @@ NineCubeTexture9_ctor( struct NineCubeTexture9 *This, } } -for (i = 0; i < 6; ++i) /* width = 0 means empty, depth stays 1 */ +for (i = 0; i < 6; ++i) { +/* Textures start initially dirty */ +This->dirty_rect[i].width = EdgeLength; +This->dirty_rect[i].height = EdgeLength; This->dirty_rect[i].depth = 1; +} return D3D_OK; } diff --git a/src/gallium/state_trackers/nine/texture9.c b/src/gallium/state_trackers/nine/texture9.c index 0127301..6822865 100644 --- a/src/gallium/state_trackers/nine/texture9.c +++ b/src/gallium/state_trackers/nine/texture9.c @@ -202,6 +202,9 @@ NineTexture9_ctor( struct NineTexture9 *This, return hr; } +/* Textures start initially dirty */ +This->dirty_rect.width = Width; +This->dirty_rect.height = Height; This->dirty_rect.depth = 1; /* widht == 0 means empty, depth stays 1 */ if (pSharedHandle && !*pSharedHandle) {/* Pool == D3DPOOL_SYSTEMMEM */ diff --git a/src/gallium/state_trackers/nine/volumetexture9.c b/src/gallium/state_trackers/nine/volumetexture9.c index 720ae57..4b5614d 100644 --- a/src/gallium/state_trackers/nine/volumetexture9.c +++ b/src/gallium/state_trackers/nine/volumetexture9.c @@ -116,6 +116,9 @@ NineVolumeTexture9_ctor( struct NineVolumeTexture9 *This, return hr; } +/* Textures start initially dirty */ +NineVolumeTexture9_AddDirtyBox(This, NULL); + return D3D_OK; } -- 2.1.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 25/71] st/nine: Fix FillColor Flag check
IT is better check if the surface was created with RT flag, instead of checking capability (llvmpipe was complaining) Signed-off-by: Axel Davy --- src/gallium/state_trackers/nine/device9.c | 7 ++- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c index 28daeba..224f7c8 100644 --- a/src/gallium/state_trackers/nine/device9.c +++ b/src/gallium/state_trackers/nine/device9.c @@ -1683,11 +1683,8 @@ NineDevice9_ColorFill( struct NineDevice9 *This, } d3dcolor_to_pipe_color_union(&rgba, color); -fallback = -!This->screen->is_format_supported(This->screen, surf->base.info.format, - surf->base.info.target, - surf->base.info.nr_samples, - PIPE_BIND_RENDER_TARGET); +fallback = !(surf->base.info.bind & PIPE_BIND_RENDER_TARGET); + if (!fallback) { psurf = NineSurface9_GetSurface(surf, 0); if (!psurf) -- 2.1.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 23/71] st/nine: Implement EvictManagedResources
Signed-off-by: Axel Davy --- src/gallium/state_trackers/nine/basetexture9.c | 15 +++ src/gallium/state_trackers/nine/basetexture9.h | 3 +++ src/gallium/state_trackers/nine/device9.c | 12 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/gallium/state_trackers/nine/basetexture9.c b/src/gallium/state_trackers/nine/basetexture9.c index c38a310..110df79 100644 --- a/src/gallium/state_trackers/nine/basetexture9.c +++ b/src/gallium/state_trackers/nine/basetexture9.c @@ -587,6 +587,21 @@ NineBaseTexture9_PreLoad( struct NineBaseTexture9 *This ) NineBaseTexture9_UploadSelf(This); } +void +NineBaseTexture9_UnLoad( struct NineBaseTexture9 *This ) +{ +if (This->base.pool != D3DPOOL_MANAGED || +This->managed.lod_resident == -1) +return; + +pipe_resource_reference(&This->base.resource, NULL); +This->managed.lod_resident = -1; +This->managed.dirty = TRUE; + +/* If the texture is bound, we have to re-upload it */ +BASETEX_REGISTER_UPDATE(This); +} + #ifdef DEBUG void NineBaseTexture9_Dump( struct NineBaseTexture9 *This ) diff --git a/src/gallium/state_trackers/nine/basetexture9.h b/src/gallium/state_trackers/nine/basetexture9.h index 9489824..b19a621 100644 --- a/src/gallium/state_trackers/nine/basetexture9.h +++ b/src/gallium/state_trackers/nine/basetexture9.h @@ -95,6 +95,9 @@ NineBaseTexture9_GenerateMipSubLevels( struct NineBaseTexture9 *This ); void WINAPI NineBaseTexture9_PreLoad( struct NineBaseTexture9 *This ); +void +NineBaseTexture9_UnLoad( struct NineBaseTexture9 *This ); + /* For D3DPOOL_MANAGED only (after SetLOD change): */ HRESULT NineBaseTexture9_CreatePipeResource( struct NineBaseTexture9 *This, diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c index 34199ca..2ac49a1 100644 --- a/src/gallium/state_trackers/nine/device9.c +++ b/src/gallium/state_trackers/nine/device9.c @@ -548,10 +548,14 @@ NineDevice9_GetAvailableTextureMem( struct NineDevice9 *This ) HRESULT WINAPI NineDevice9_EvictManagedResources( struct NineDevice9 *This ) { -/* We don't really need to do anything here, but might want to free up - * the GPU virtual address space by killing pipe_resources. - */ -STUB(D3D_OK); +struct NineBaseTexture9 *tex; + +DBG("This=%p\n", This); +LIST_FOR_EACH_ENTRY(tex, &This->managed_textures, list2) { +NineBaseTexture9_UnLoad(tex); +} + +return D3D_OK; } HRESULT WINAPI -- 2.1.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 30/71] st/nine: Return NULL pointer in lock error cases
From: Patrick Rudolph Tests showed, that in case of errors, the pBits pointer is set to NULL. The pBits field isn't set to NULL in case of an already locked object. Reviewed-by: Axel Davy Signed-off-by: Patrick Rudolph --- src/gallium/state_trackers/nine/surface9.c | 11 +++ src/gallium/state_trackers/nine/volume9.c | 10 +++--- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/gallium/state_trackers/nine/surface9.c b/src/gallium/state_trackers/nine/surface9.c index d20e62a..78c29ca 100644 --- a/src/gallium/state_trackers/nine/surface9.c +++ b/src/gallium/state_trackers/nine/surface9.c @@ -323,6 +323,13 @@ NineSurface9_LockRect( struct NineSurface9 *This, nine_D3DLOCK_to_str(Flags)); NineSurface9_Dump(This); +/* check if it's already locked */ +user_assert(This->lock_count == 0, D3DERR_INVALIDCALL); + +/* set pBits to NULL after lock_count check */ +user_assert(pLockedRect, E_POINTER); +pLockedRect->pBits = NULL; + #ifdef NINE_STRICT user_assert(This->base.pool != D3DPOOL_DEFAULT || (resource && (resource->flags & NINE_RESOURCE_FLAG_LOCKABLE)), @@ -337,10 +344,6 @@ NineSurface9_LockRect( struct NineSurface9 *This, user_assert(!((Flags & D3DLOCK_DISCARD) && (Flags & D3DLOCK_READONLY)), D3DERR_INVALIDCALL); -/* check if it's already locked */ -user_assert(This->lock_count == 0, D3DERR_INVALIDCALL); -user_assert(pLockedRect, E_POINTER); - user_assert(This->desc.MultiSampleType == D3DMULTISAMPLE_NONE, D3DERR_INVALIDCALL); diff --git a/src/gallium/state_trackers/nine/volume9.c b/src/gallium/state_trackers/nine/volume9.c index 5495548..6311103 100644 --- a/src/gallium/state_trackers/nine/volume9.c +++ b/src/gallium/state_trackers/nine/volume9.c @@ -231,15 +231,19 @@ NineVolume9_LockBox( struct NineVolume9 *This, pBox ? pBox->Front : 0, pBox ? pBox->Back : 0, nine_D3DLOCK_to_str(Flags)); +/* check if it's already locked */ +user_assert(This->lock_count == 0, D3DERR_INVALIDCALL); + +/* set pBits to NULL after lock_count check */ +user_assert(pLockedVolume, E_POINTER); +pLockedVolume->pBits = NULL; + user_assert(This->desc.Pool != D3DPOOL_DEFAULT || (This->desc.Usage & D3DUSAGE_DYNAMIC), D3DERR_INVALIDCALL); user_assert(!((Flags & D3DLOCK_DISCARD) && (Flags & D3DLOCK_READONLY)), D3DERR_INVALIDCALL); -user_assert(This->lock_count == 0, D3DERR_INVALIDCALL); -user_assert(pLockedVolume, E_POINTER); - if (pBox && This->desc.Pool == D3DPOOL_DEFAULT && util_format_is_compressed(This->info.format)) { const unsigned w = util_format_get_blockwidth(This->info.format); -- 2.1.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 16/71] st/nine: Simplify NineVolume9_CopyVolume
We had only one usage for this function. Signed-off-by: Axel Davy --- src/gallium/state_trackers/nine/device9.c | 4 +- src/gallium/state_trackers/nine/volume9.c | 90 ++- src/gallium/state_trackers/nine/volume9.h | 8 +-- 3 files changed, 21 insertions(+), 81 deletions(-) diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c index 57831c4..b72045e 100644 --- a/src/gallium/state_trackers/nine/device9.c +++ b/src/gallium/state_trackers/nine/device9.c @@ -1353,8 +1353,8 @@ NineDevice9_UpdateTexture( struct NineDevice9 *This, struct NineVolumeTexture9 *src = NineVolumeTexture9(srcb); for (l = 0; l <= last_level; ++l, ++m) -NineVolume9_CopyVolume(dst->volumes[l], - src->volumes[m], 0, 0, 0, NULL); +NineVolume9_CopyMemToDefault(dst->volumes[l], + src->volumes[m], 0, 0, 0, NULL); } else{ assert(!"invalid texture type"); } diff --git a/src/gallium/state_trackers/nine/volume9.c b/src/gallium/state_trackers/nine/volume9.c index 3b5b312..5495548 100644 --- a/src/gallium/state_trackers/nine/volume9.c +++ b/src/gallium/state_trackers/nine/volume9.c @@ -309,42 +309,31 @@ NineVolume9_UnlockBox( struct NineVolume9 *This ) return D3D_OK; } - +/* When this function is called, we have already checked + * The copy regions fit the volumes */ HRESULT -NineVolume9_CopyVolume( struct NineVolume9 *This, -struct NineVolume9 *From, -unsigned dstx, unsigned dsty, unsigned dstz, -struct pipe_box *pSrcBox ) +NineVolume9_CopyMemToDefault( struct NineVolume9 *This, + struct NineVolume9 *From, + unsigned dstx, unsigned dsty, unsigned dstz, + struct pipe_box *pSrcBox ) { struct pipe_context *pipe = This->pipe; struct pipe_resource *r_dst = This->resource; -struct pipe_resource *r_src = From->resource; -struct pipe_transfer *transfer; struct pipe_box src_box; struct pipe_box dst_box; -uint8_t *p_dst; const uint8_t *p_src; DBG("This=%p From=%p dstx=%u dsty=%u dstz=%u pSrcBox=%p\n", This, From, dstx, dsty, dstz, pSrcBox); -assert(This->desc.Pool != D3DPOOL_MANAGED && - From->desc.Pool != D3DPOOL_MANAGED); -user_assert(This->desc.Format == From->desc.Format, D3DERR_INVALIDCALL); +assert(This->desc.Pool == D3DPOOL_DEFAULT && + From->desc.Pool == D3DPOOL_SYSTEMMEM); dst_box.x = dstx; dst_box.y = dsty; dst_box.z = dstz; if (pSrcBox) { -/* make sure it doesn't range outside the source volume */ -user_assert(pSrcBox->x >= 0 && -(pSrcBox->width - pSrcBox->x) <= From->desc.Width && -pSrcBox->y >= 0 && -(pSrcBox->height - pSrcBox->y) <= From->desc.Height && -pSrcBox->z >= 0 && -(pSrcBox->depth - pSrcBox->z) <= From->desc.Depth, -D3DERR_INVALIDCALL); src_box = *pSrcBox; } else { src_box.x = 0; @@ -354,69 +343,20 @@ NineVolume9_CopyVolume( struct NineVolume9 *This, src_box.height = From->desc.Height; src_box.depth = From->desc.Depth; } -/* limits */ -dst_box.width = This->desc.Width - dst_box.x; -dst_box.height = This->desc.Height - dst_box.y; -dst_box.depth = This->desc.Depth - dst_box.z; - -user_assert(src_box.width <= dst_box.width && -src_box.height <= dst_box.height && -src_box.depth <= dst_box.depth, D3DERR_INVALIDCALL); dst_box.width = src_box.width; dst_box.height = src_box.height; dst_box.depth = src_box.depth; -if (r_dst && r_src) { -pipe->resource_copy_region(pipe, - r_dst, This->level, - dst_box.x, dst_box.y, dst_box.z, - r_src, From->level, - &src_box); -} else -if (r_dst) { -p_src = NineVolume9_GetSystemMemPointer(From, -src_box.x, src_box.y, src_box.z); - -pipe->transfer_inline_write(pipe, r_dst, This->level, -0, /* WRITE|DISCARD are implicit */ -&dst_box, p_src, -From->stride, From->layer_stride); -} else -if (r_src) { -p_dst = NineVolume9_GetSystemMemPointer(This, 0, 0, 0); -p_src = pipe->transfer_map(pipe, r_src, From->level, -
[Mesa-dev] [PATCH 15/71] st/nine: Split NineSurface9_CopySurface
NineSurface9_CopySurface was supporting more cases than what we needed, and doing checks that were innapropriate for some NineSurface9_CopySurface use cases. This patch splits it into two for the two use cases, and moves the checks to the caller. This patch also adds a few checks to NineDevice9_UpdateSurface Signed-off-by: Axel Davy --- src/gallium/state_trackers/nine/device9.c| 81 +++- src/gallium/state_trackers/nine/nine_pipe.h | 17 +++ src/gallium/state_trackers/nine/surface9.c | 176 ++- src/gallium/state_trackers/nine/surface9.h | 14 ++- src/gallium/state_trackers/nine/swapchain9.c | 6 +- 5 files changed, 169 insertions(+), 125 deletions(-) diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c index a1c05b4..57831c4 100644 --- a/src/gallium/state_trackers/nine/device9.c +++ b/src/gallium/state_trackers/nine/device9.c @@ -1185,6 +1185,8 @@ NineDevice9_UpdateSurface( struct NineDevice9 *This, { struct NineSurface9 *dst = NineSurface9(pDestinationSurface); struct NineSurface9 *src = NineSurface9(pSourceSurface); +int copy_width, copy_height; +RECT destRect; DBG("This=%p pSourceSurface=%p pDestinationSurface=%p " "pSourceRect=%p pDestPoint=%p\n", This, @@ -1196,13 +1198,75 @@ NineDevice9_UpdateSurface( struct NineDevice9 *This, if (pDestPoint) DBG("pDestPoint = (%u,%u)\n", pDestPoint->x, pDestPoint->y); +user_assert(dst && src, D3DERR_INVALIDCALL); + user_assert(dst->base.pool == D3DPOOL_DEFAULT, D3DERR_INVALIDCALL); user_assert(src->base.pool == D3DPOOL_SYSTEMMEM, D3DERR_INVALIDCALL); user_assert(dst->desc.MultiSampleType == D3DMULTISAMPLE_NONE, D3DERR_INVALIDCALL); user_assert(src->desc.MultiSampleType == D3DMULTISAMPLE_NONE, D3DERR_INVALIDCALL); -return NineSurface9_CopySurface(dst, src, pDestPoint, pSourceRect); +user_assert(!src->lock_count, D3DERR_INVALIDCALL); +user_assert(!dst->lock_count, D3DERR_INVALIDCALL); + +user_assert(dst->desc.Format == src->desc.Format, D3DERR_INVALIDCALL); +user_assert(!depth_stencil_format(dst->desc.Format), D3DERR_INVALIDCALL); + +if (pSourceRect) { +copy_width = pSourceRect->right - pSourceRect->left; +copy_height = pSourceRect->bottom - pSourceRect->top; + +user_assert(pSourceRect->left >= 0 && +copy_width > 0 && +pSourceRect->right <= src->desc.Width && +pSourceRect->top >= 0 && +copy_height > 0 && +pSourceRect->bottom <= src->desc.Height, +D3DERR_INVALIDCALL); +} else { +copy_width = src->desc.Width; +copy_height = src->desc.Height; +} + +destRect.right = copy_width; +destRect.bottom = copy_height; + +if (pDestPoint) { +user_assert(pDestPoint->x >= 0 && pDestPoint->y >= 0, +D3DERR_INVALIDCALL); +destRect.right += pDestPoint->x; +destRect.bottom += pDestPoint->y; +} + +user_assert(destRect.right <= dst->desc.Width && +destRect.bottom <= dst->desc.Height, +D3DERR_INVALIDCALL); + +if (compressed_format(dst->desc.Format)) { +const unsigned w = util_format_get_blockwidth(dst->base.info.format); +const unsigned h = util_format_get_blockheight(dst->base.info.format); + +if (pDestPoint) { +user_assert(!(pDestPoint->x % w) && !(pDestPoint->y % h), +D3DERR_INVALIDCALL); +} + +if (pSourceRect) { +user_assert(!(pSourceRect->left % w) && !(pSourceRect->top % h), +D3DERR_INVALIDCALL); +} +if (!(copy_width == src->desc.Width && + copy_width == dst->desc.Width && + copy_height == src->desc.Height && + copy_height == dst->desc.Height)) { +user_assert(!(copy_width % w) && !(copy_height % h), +D3DERR_INVALIDCALL); +} +} + +NineSurface9_CopyMemToDefault(dst, src, pDestPoint, pSourceRect); + +return D3D_OK; } HRESULT WINAPI @@ -1267,8 +1331,8 @@ NineDevice9_UpdateTexture( struct NineDevice9 *This, struct NineTexture9 *src = NineTexture9(srcb); for (l = 0; l <= last_level; ++l, ++m) -NineSurface9_CopySurface(dst->surfaces[l], - src->surfaces[m], NULL, NULL); +NineSurface9_CopyMemToDefault(dst->surfaces[l], + src->surfaces[m], NULL, NULL); } else if (dstb->base.ty
[Mesa-dev] [PATCH 21/71] st/nine: Only update dirty rect for UpdateTexture
UpdateTexture is supposed to optimise by uploading only for the dirty region of the source (d3d9 doc, wine tests). This patch adds the behaviour for surfaces, but not entirely for volumes. Signed-off-by: Axel Davy --- src/gallium/state_trackers/nine/device9.c | 47 - src/gallium/state_trackers/nine/nine_pipe.h | 44 +++ 2 files changed, 83 insertions(+), 8 deletions(-) diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c index b72045e..91c1eaa 100644 --- a/src/gallium/state_trackers/nine/device9.c +++ b/src/gallium/state_trackers/nine/device9.c @@ -1278,6 +1278,7 @@ NineDevice9_UpdateTexture( struct NineDevice9 *This, struct NineBaseTexture9 *srcb = NineBaseTexture9(pSourceTexture); unsigned l, m; unsigned last_level = dstb->base.info.last_level; +RECT rect; DBG("This=%p pSourceTexture=%p pDestinationTexture=%p\n", This, pSourceTexture, pDestinationTexture); @@ -1303,10 +1304,6 @@ NineDevice9_UpdateTexture( struct NineDevice9 *This, user_assert(dstb->base.type == srcb->base.type, D3DERR_INVALIDCALL); -/* TODO: We can restrict the update to the dirty portions of the source. - * Yes, this seems silly, but it's what MSDN says ... - */ - /* Find src level that matches dst level 0: */ user_assert(srcb->base.info.width0 >= dstb->base.info.width0 && srcb->base.info.height0 >= dstb->base.info.height0 && @@ -1330,9 +1327,25 @@ NineDevice9_UpdateTexture( struct NineDevice9 *This, struct NineTexture9 *dst = NineTexture9(dstb); struct NineTexture9 *src = NineTexture9(srcb); -for (l = 0; l <= last_level; ++l, ++m) +if (src->dirty_rect.width == 0) +return D3D_OK; + +pipe_box_to_rect(&rect, &src->dirty_rect); +for (l = 0; l < m; ++l) +rect_minify_inclusive(&rect); + +for (l = 0; l <= last_level; ++l, ++m) { +fit_rect_format_inclusive(dst->base.base.info.format, + &rect, + dst->surfaces[l]->desc.Width, + dst->surfaces[l]->desc.Height); NineSurface9_CopyMemToDefault(dst->surfaces[l], - src->surfaces[m], NULL, NULL); + src->surfaces[m], + (POINT *)&rect, + &rect); +rect_minify_inclusive(&rect); +} +u_box_origin_2d(0, 0, &src->dirty_rect); } else if (dstb->base.type == D3DRTYPE_CUBETEXTURE) { struct NineCubeTexture9 *dst = NineCubeTexture9(dstb); @@ -1341,10 +1354,25 @@ NineDevice9_UpdateTexture( struct NineDevice9 *This, /* GPUs usually have them stored as arrays of mip-mapped 2D textures. */ for (z = 0; z < 6; ++z) { +if (src->dirty_rect[z].width == 0) +continue; + +pipe_box_to_rect(&rect, &src->dirty_rect[z]); +for (l = 0; l < m; ++l) +rect_minify_inclusive(&rect); + for (l = 0; l <= last_level; ++l, ++m) { - NineSurface9_CopyMemToDefault(dst->surfaces[l * 6 + z], - src->surfaces[m * 6 + z], NULL, NULL); +fit_rect_format_inclusive(dst->base.base.info.format, + &rect, + dst->surfaces[l * 6 + z]->desc.Width, + dst->surfaces[l * 6 + z]->desc.Height); +NineSurface9_CopyMemToDefault(dst->surfaces[l * 6 + z], + src->surfaces[m * 6 + z], + (POINT *)&rect, + &rect); +rect_minify_inclusive(&rect); } +u_box_origin_2d(0, 0, &src->dirty_rect[z]); m -= l; } } else @@ -1352,9 +1380,12 @@ NineDevice9_UpdateTexture( struct NineDevice9 *This, struct NineVolumeTexture9 *dst = NineVolumeTexture9(dstb); struct NineVolumeTexture9 *src = NineVolumeTexture9(srcb); +if (src->dirty_box.width == 0) +return D3D_OK; for (l = 0; l <= last_level; ++l, ++m) NineVolume9_CopyMemToDefault(dst->volumes[l], src->volumes[m], 0, 0, 0, NULL); +u_box_3d(0, 0, 0, 0, 0, 0, &src->dirty_box); } else{ assert(!"invalid texture type"); } diff --git a/src/gallium/state_tracke
[Mesa-dev] [PATCH 13/71] util/u_blitter: implement alpha blending for pipe->blit
From: Marek Olšák --- src/gallium/auxiliary/util/u_blitter.c | 54 ++--- src/gallium/auxiliary/util/u_blitter.h | 3 +- src/gallium/auxiliary/util/u_surface.c | 3 ++ src/gallium/drivers/i915/i915_surface.c | 3 +- src/gallium/drivers/r300/r300_blit.c| 3 +- src/gallium/drivers/r600/r600_blit.c| 3 +- src/gallium/drivers/radeonsi/si_blit.c | 3 +- 7 files changed, 49 insertions(+), 23 deletions(-) diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c index 85206ea..9bba07a 100644 --- a/src/gallium/auxiliary/util/u_blitter.c +++ b/src/gallium/auxiliary/util/u_blitter.c @@ -104,7 +104,7 @@ struct blitter_context_priv void *fs_resolve_uint[PIPE_MAX_TEXTURE_TYPES][NUM_RESOLVE_FRAG_SHADERS][2]; /* Blend state. */ - void *blend[PIPE_MASK_RGBA+1]; /**< blend state with writemask */ + void *blend[PIPE_MASK_RGBA+1][2]; /**< blend state with writemask */ void *blend_clear[GET_CLEAR_BLEND_STATE_IDX(PIPE_CLEAR_COLOR)+1]; /* Depth stencil alpha state. */ @@ -159,7 +159,7 @@ struct blitter_context *util_blitter_create(struct pipe_context *pipe) struct pipe_rasterizer_state rs_state; struct pipe_sampler_state sampler_state; struct pipe_vertex_element velem[2]; - unsigned i; + unsigned i, j; ctx = CALLOC_STRUCT(blitter_context_priv); if (!ctx) @@ -208,8 +208,20 @@ struct blitter_context *util_blitter_create(struct pipe_context *pipe) memset(&blend, 0, sizeof(blend)); for (i = 0; i <= PIPE_MASK_RGBA; i++) { - blend.rt[0].colormask = i; - ctx->blend[i] = pipe->create_blend_state(pipe, &blend); + for (j = 0; j < 2; j++) { + memset(&blend.rt[0], 0, sizeof(blend.rt[0])); + blend.rt[0].colormask = i; + if (j) { +blend.rt[0].blend_enable = 1; +blend.rt[0].rgb_func = PIPE_BLEND_ADD; +blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_SRC_ALPHA; +blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_INV_SRC_ALPHA; +blend.rt[0].alpha_func = PIPE_BLEND_ADD; +blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_SRC_ALPHA; +blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_INV_SRC_ALPHA; + } + ctx->blend[i][j] = pipe->create_blend_state(pipe, &blend); + } } /* depth stencil alpha state objects */ @@ -409,9 +421,10 @@ void util_blitter_destroy(struct blitter_context *blitter) struct pipe_context *pipe = blitter->pipe; int i, j, f; - for (i = 0; i <= PIPE_MASK_RGBA; i++) { - pipe->delete_blend_state(pipe, ctx->blend[i]); - } + for (i = 0; i <= PIPE_MASK_RGBA; i++) + for (j = 0; j < 2; j++) + pipe->delete_blend_state(pipe, ctx->blend[i][j]); + for (i = 0; i < Elements(ctx->blend_clear); i++) { if (ctx->blend_clear[i]) pipe->delete_blend_state(pipe, ctx->blend_clear[i]); @@ -1217,7 +1230,7 @@ static void *get_clear_blend_state(struct blitter_context_priv *ctx, /* Return an existing blend state. */ if (!clear_buffers) - return ctx->blend[0]; + return ctx->blend[0][0]; index = GET_CLEAR_BLEND_STATE_IDX(clear_buffers); @@ -1483,7 +1496,8 @@ void util_blitter_copy_texture(struct blitter_context *blitter, /* Copy. */ util_blitter_blit_generic(blitter, dst_view, &dstbox, src_view, srcbox, src->width0, src->height0, - PIPE_MASK_RGBAZS, PIPE_TEX_FILTER_NEAREST, NULL); + PIPE_MASK_RGBAZS, PIPE_TEX_FILTER_NEAREST, NULL, + FALSE); pipe_surface_reference(&dst_view, NULL); pipe_sampler_view_reference(&src_view, NULL); @@ -1496,7 +1510,8 @@ void util_blitter_blit_generic(struct blitter_context *blitter, const struct pipe_box *srcbox, unsigned src_width0, unsigned src_height0, unsigned mask, unsigned filter, - const struct pipe_scissor_state *scissor) + const struct pipe_scissor_state *scissor, + boolean alpha_blend) { struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter; struct pipe_context *pipe = ctx->base.pipe; @@ -1550,7 +1565,7 @@ void util_blitter_blit_generic(struct blitter_context *blitter, fb_state.zsbuf = NULL; if (blit_depth || blit_stencil) { - pipe->bind_blend_state(pipe, ctx->blend[0]); + pipe->bind_blend_state(pipe, ctx->blend[0][0]); if (blit_depth && blit_stencil) { pipe->bind_depth_stencil_alpha_state(pipe, @@ -1573,7 +1588,9 @@ void util_blitter_blit_generic(struct blitter_context *blitter, } } else { - pipe->bind_blend_state(pipe, ctx->blend[mask & PIPE_MASK_RGBA]); + unsigned colormask = mask & PIPE_MASK_RGBA; + + pipe->bind_blend_state(pipe, ctx->blend[color
[Mesa-dev] [PATCH 22/71] st/nine: Track managed textures
Signed-off-by: Axel Davy --- src/gallium/state_trackers/nine/basetexture9.c | 7 ++- src/gallium/state_trackers/nine/basetexture9.h | 3 ++- src/gallium/state_trackers/nine/device9.c | 1 + src/gallium/state_trackers/nine/device9.h | 1 + 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/gallium/state_trackers/nine/basetexture9.c b/src/gallium/state_trackers/nine/basetexture9.c index 728aafd..c38a310 100644 --- a/src/gallium/state_trackers/nine/basetexture9.c +++ b/src/gallium/state_trackers/nine/basetexture9.c @@ -85,6 +85,9 @@ NineBaseTexture9_ctor( struct NineBaseTexture9 *This, util_format_has_depth(util_format_description(This->base.info.format)); list_inithead(&This->list); +list_inithead(&This->list2); +if (Pool == D3DPOOL_MANAGED) +list_add(&This->list2, &This->base.base.device->managed_textures); return D3D_OK; } @@ -98,7 +101,9 @@ NineBaseTexture9_dtor( struct NineBaseTexture9 *This ) pipe_sampler_view_reference(&This->view[1], NULL); if (This->list.prev != NULL && This->list.next != NULL) -list_del(&This->list), +list_del(&This->list); +if (This->list2.prev != NULL && This->list2.next != NULL) +list_del(&This->list2); NineResource9_dtor(&This->base); } diff --git a/src/gallium/state_trackers/nine/basetexture9.h b/src/gallium/state_trackers/nine/basetexture9.h index 9d6fb0c..9489824 100644 --- a/src/gallium/state_trackers/nine/basetexture9.h +++ b/src/gallium/state_trackers/nine/basetexture9.h @@ -30,7 +30,8 @@ struct NineBaseTexture9 { struct NineResource9 base; -struct list_head list; +struct list_head list; /* for update_textures */ +struct list_head list2; /* for managed_textures */ /* g3d */ struct pipe_context *pipe; diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c index 91c1eaa..34199ca 100644 --- a/src/gallium/state_trackers/nine/device9.c +++ b/src/gallium/state_trackers/nine/device9.c @@ -186,6 +186,7 @@ NineDevice9_ctor( struct NineDevice9 *This, if (FAILED(hr)) { return hr; } list_inithead(&This->update_textures); +list_inithead(&This->managed_textures); This->screen = pScreen; This->caps = *pCaps; diff --git a/src/gallium/state_trackers/nine/device9.h b/src/gallium/state_trackers/nine/device9.h index 7460745..a5a5ab2 100644 --- a/src/gallium/state_trackers/nine/device9.h +++ b/src/gallium/state_trackers/nine/device9.h @@ -69,6 +69,7 @@ struct NineDevice9 struct nine_state state; /* device state */ struct list_head update_textures; +struct list_head managed_textures; boolean is_recording; boolean in_scene; -- 2.1.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 06/71] st/nine: Account POINTSIZE_MIN and POINTSIZE_MAX for point size
From: Patrick Rudolph When using D3DRS_POINTSIZE make sure the value is at least D3DRS_POINTSIZE_MIN but not greater than D3DRS_POINTSIZE_MAX. Reviewed-by: Axel Davy Signed-off-by: Patrick Rudolph --- src/gallium/state_trackers/nine/nine_pipe.c | 8 +++- src/gallium/state_trackers/nine/nine_state.c | 4 ++-- src/gallium/state_trackers/nine/nine_state.h | 21 ++--- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/gallium/state_trackers/nine/nine_pipe.c b/src/gallium/state_trackers/nine/nine_pipe.c index c0b74b8..ddf8e8b 100644 --- a/src/gallium/state_trackers/nine/nine_pipe.c +++ b/src/gallium/state_trackers/nine/nine_pipe.c @@ -110,7 +110,13 @@ nine_convert_rasterizer_state(struct cso_context *ctx, const DWORD *rs) /* rast.line_stipple_pattern = 0; */ rast.sprite_coord_enable = rs[D3DRS_POINTSPRITEENABLE] ? 0xff : 0x00; rast.line_width = 1.0f; -rast.point_size = rs[NINED3DRS_VSPOINTSIZE] ? 1.0f : asfloat(rs[D3DRS_POINTSIZE]); /* XXX: D3DRS_POINTSIZE_MIN/MAX */ +if (rs[NINED3DRS_VSPOINTSIZE]) { +rast.point_size = 1.0f; +} else { +rast.point_size = CLAMP(asfloat(rs[D3DRS_POINTSIZE]), +asfloat(rs[D3DRS_POINTSIZE_MIN]), +asfloat(rs[D3DRS_POINTSIZE_MAX])); +} rast.offset_units = asfloat(rs[D3DRS_DEPTHBIAS]) * asfloat(rs[NINED3DRS_ZBIASSCALE]); rast.offset_scale = asfloat(rs[D3DRS_SLOPESCALEDEPTHBIAS]); /* rast.offset_clamp = 0.0f; */ diff --git a/src/gallium/state_trackers/nine/nine_state.c b/src/gallium/state_trackers/nine/nine_state.c index 6c83585..db861c4 100644 --- a/src/gallium/state_trackers/nine/nine_state.c +++ b/src/gallium/state_trackers/nine/nine_state.c @@ -1394,7 +1394,7 @@ const uint32_t nine_render_state_group[NINED3DRS_LAST + 1] = [D3DRS_VERTEXBLEND] = NINE_STATE_FF_OTHER, [D3DRS_CLIPPLANEENABLE] = NINE_STATE_RASTERIZER, [D3DRS_POINTSIZE] = NINE_STATE_RASTERIZER, -[D3DRS_POINTSIZE_MIN] = NINE_STATE_MISC_CONST, +[D3DRS_POINTSIZE_MIN] = NINE_STATE_RASTERIZER, [D3DRS_POINTSPRITEENABLE] = NINE_STATE_RASTERIZER, [D3DRS_POINTSCALEENABLE] = NINE_STATE_FF_OTHER, [D3DRS_POINTSCALE_A] = NINE_STATE_FF_OTHER, @@ -1404,7 +1404,7 @@ const uint32_t nine_render_state_group[NINED3DRS_LAST + 1] = [D3DRS_MULTISAMPLEMASK] = NINE_STATE_SAMPLE_MASK, [D3DRS_PATCHEDGESTYLE] = NINE_STATE_UNHANDLED, [D3DRS_DEBUGMONITORTOKEN] = NINE_STATE_UNHANDLED, -[D3DRS_POINTSIZE_MAX] = NINE_STATE_MISC_CONST, +[D3DRS_POINTSIZE_MAX] = NINE_STATE_RASTERIZER, [D3DRS_INDEXEDVERTEXBLENDENABLE] = NINE_STATE_FF_OTHER, [D3DRS_COLORWRITEENABLE] = NINE_STATE_BLEND, [D3DRS_TWEENFACTOR] = NINE_STATE_FF_OTHER, diff --git a/src/gallium/state_trackers/nine/nine_state.h b/src/gallium/state_trackers/nine/nine_state.h index 2bf3f63..cac9af6 100644 --- a/src/gallium/state_trackers/nine/nine_state.h +++ b/src/gallium/state_trackers/nine/nine_state.h @@ -67,17 +67,16 @@ #define NINE_STATE_BLEND_COLOR (1 << 16) #define NINE_STATE_STENCIL_REF (1 << 17) #define NINE_STATE_SAMPLE_MASK (1 << 18) -#define NINE_STATE_MISC_CONST (1 << 19) -#define NINE_STATE_FF (0x1f << 20) -#define NINE_STATE_FF_VS (0x17 << 20) -#define NINE_STATE_FF_PS (0x18 << 20) -#define NINE_STATE_FF_LIGHTING (1 << 20) -#define NINE_STATE_FF_MATERIAL (1 << 21) -#define NINE_STATE_FF_VSTRANSF (1 << 22) -#define NINE_STATE_FF_PSSTAGES (1 << 23) -#define NINE_STATE_FF_OTHER(1 << 24) -#define NINE_STATE_ALL 0x1ff -#define NINE_STATE_UNHANDLED (1 << 25) +#define NINE_STATE_FF (0x1f << 19) +#define NINE_STATE_FF_VS (0x17 << 19) +#define NINE_STATE_FF_PS (0x18 << 19) +#define NINE_STATE_FF_LIGHTING (1 << 19) +#define NINE_STATE_FF_MATERIAL (1 << 20) +#define NINE_STATE_FF_VSTRANSF (1 << 21) +#define NINE_STATE_FF_PSSTAGES (1 << 22) +#define NINE_STATE_FF_OTHER(1 << 23) +#define NINE_STATE_ALL 0x0ff +#define NINE_STATE_UNHANDLED (1 << 24) #define NINE_MAX_SIMULTANEOUS_RENDERTARGETS 4 -- 2.1.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 07/71] st/nine: fix D3DRS_DITHERENABLE wrong state group
D3DRS_DITHERENABLE was assigned to the rasterizer state group, but it was used for the blend group. Assign it to the blend group. Signed-off-by: Axel Davy --- src/gallium/state_trackers/nine/nine_state.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/state_trackers/nine/nine_state.c b/src/gallium/state_trackers/nine/nine_state.c index db861c4..4bf5908 100644 --- a/src/gallium/state_trackers/nine/nine_state.c +++ b/src/gallium/state_trackers/nine/nine_state.c @@ -1353,7 +1353,7 @@ const uint32_t nine_render_state_group[NINED3DRS_LAST + 1] = [D3DRS_ZFUNC] = NINE_STATE_DSA, [D3DRS_ALPHAREF] = NINE_STATE_DSA, [D3DRS_ALPHAFUNC] = NINE_STATE_DSA, -[D3DRS_DITHERENABLE] = NINE_STATE_RASTERIZER, +[D3DRS_DITHERENABLE] = NINE_STATE_BLEND, [D3DRS_ALPHABLENDENABLE] = NINE_STATE_BLEND, [D3DRS_FOGENABLE] = NINE_STATE_FF_OTHER, [D3DRS_SPECULARENABLE] = NINE_STATE_FF_LIGHTING, -- 2.1.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 03/71] st/nine: Fix Swizzle for ATI2 format
We had red and green in the wrong channels for the ATI2 format (RGTC2). Found thanks to wine tests. Signed-off-by: Axel Davy Reviewed-by: David Heidelberg --- src/gallium/state_trackers/nine/basetexture9.c | 5 + 1 file changed, 5 insertions(+) diff --git a/src/gallium/state_trackers/nine/basetexture9.c b/src/gallium/state_trackers/nine/basetexture9.c index 17a8f44..eabf32b 100644 --- a/src/gallium/state_trackers/nine/basetexture9.c +++ b/src/gallium/state_trackers/nine/basetexture9.c @@ -530,6 +530,11 @@ NineBaseTexture9_UpdateSamplerView( struct NineBaseTexture9 *This, swizzle[2] = PIPE_SWIZZLE_RED; swizzle[3] = PIPE_SWIZZLE_RED; } +} else if (resource->format == PIPE_FORMAT_RGTC2_UNORM) { +swizzle[0] = PIPE_SWIZZLE_GREEN; +swizzle[1] = PIPE_SWIZZLE_RED; +swizzle[2] = PIPE_SWIZZLE_ONE; +swizzle[3] = PIPE_SWIZZLE_ONE; } else if (resource->format != PIPE_FORMAT_A8_UNORM && resource->format != PIPE_FORMAT_RGTC1_UNORM) { /* exceptions: -- 2.1.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 08/71] st/nine: Hide hardware cursor when we don't use it
Signed-off-by: Axel Davy Reviewed-by: David Heidelberg --- src/gallium/state_trackers/nine/device9.c | 18 -- 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c index 55948cb..fce19b2 100644 --- a/src/gallium/state_trackers/nine/device9.c +++ b/src/gallium/state_trackers/nine/device9.c @@ -599,11 +599,11 @@ NineDevice9_SetCursorProperties( struct NineDevice9 *This, UINT YHotSpot, IDirect3DSurface9 *pCursorBitmap ) { -/* TODO: hardware cursor */ struct NineSurface9 *surf = NineSurface9(pCursorBitmap); struct pipe_context *pipe = This->pipe; struct pipe_box box; struct pipe_transfer *transfer; +BOOL hw_cursor; void *ptr; DBG_FLAG(DBG_SWAPCHAIN, "This=%p XHotSpot=%u YHotSpot=%u " @@ -613,6 +613,7 @@ NineDevice9_SetCursorProperties( struct NineDevice9 *This, This->cursor.w = MIN2(surf->desc.Width, This->cursor.image->width0); This->cursor.h = MIN2(surf->desc.Height, This->cursor.image->height0); +hw_cursor = This->cursor.w == 32 && This->cursor.h == 32; u_box_origin_2d(This->cursor.w, This->cursor.h, &box); @@ -643,16 +644,21 @@ NineDevice9_SetCursorProperties( struct NineDevice9 *This, lock.pBits, lock.Pitch, This->cursor.w, This->cursor.h); -if (!This->cursor.software && -This->cursor.w == 32 && This->cursor.h == 32) -ID3DPresent_SetCursor(This->swapchains[0]->present, - lock.pBits, &This->cursor.hotspot, - This->cursor.visible); +if (hw_cursor) +hw_cursor = ID3DPresent_SetCursor(This->swapchains[0]->present, + lock.pBits, + &This->cursor.hotspot, + This->cursor.visible) == D3D_OK; NineSurface9_UnlockRect(surf); } pipe->transfer_unmap(pipe, transfer); +/* hide cursor if we emulate it */ +if (!hw_cursor) +ID3DPresent_SetCursor(This->swapchains[0]->present, NULL, NULL, FALSE); +This->cursor.software = !hw_cursor; + return D3D_OK; } -- 2.1.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 31/71] st/nine: Impose restrictions on DXTN texture sizes
This is the expected behaviour. Fixes more than 1 wine tests failures. Signed-off-by: Axel Davy Reviewed-by: David Heidelberg --- src/gallium/state_trackers/nine/cubetexture9.c | 7 +++ src/gallium/state_trackers/nine/device9.c| 7 +++ src/gallium/state_trackers/nine/texture9.c | 7 +++ src/gallium/state_trackers/nine/volumetexture9.c | 7 +++ 4 files changed, 28 insertions(+) diff --git a/src/gallium/state_trackers/nine/cubetexture9.c b/src/gallium/state_trackers/nine/cubetexture9.c index c1e6cbd..a2bb9b9 100644 --- a/src/gallium/state_trackers/nine/cubetexture9.c +++ b/src/gallium/state_trackers/nine/cubetexture9.c @@ -70,6 +70,13 @@ NineCubeTexture9_ctor( struct NineCubeTexture9 *This, if (Format == D3DFMT_ATI1 || Format == D3DFMT_ATI2) return D3DERR_INVALIDCALL; +if (compressed_format(Format)) { +const unsigned w = util_format_get_blockwidth(pf); +const unsigned h = util_format_get_blockheight(pf); + +user_assert(!(EdgeLength % w) && !(EdgeLength % h), D3DERR_INVALIDCALL); +} + info->screen = pParams->device->screen; info->target = PIPE_TEXTURE_CUBE; info->format = pf; diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c index 224f7c8..f84364e 100644 --- a/src/gallium/state_trackers/nine/device9.c +++ b/src/gallium/state_trackers/nine/device9.c @@ -1125,6 +1125,13 @@ create_zs_or_rt_surface(struct NineDevice9 *This, default: break; } +if (compressed_format(Format)) { +const unsigned w = util_format_get_blockwidth(templ.format); +const unsigned h = util_format_get_blockheight(templ.format); + +user_assert(!(Width % w) && !(Height % h), D3DERR_INVALIDCALL); +} + if (Pool == D3DPOOL_DEFAULT && Format != D3DFMT_NULL) { /* resource_create doesn't return an error code, so check format here */ user_assert(templ.format != PIPE_FORMAT_NONE, D3DERR_INVALIDCALL); diff --git a/src/gallium/state_trackers/nine/texture9.c b/src/gallium/state_trackers/nine/texture9.c index 6822865..af97082 100644 --- a/src/gallium/state_trackers/nine/texture9.c +++ b/src/gallium/state_trackers/nine/texture9.c @@ -101,6 +101,13 @@ NineTexture9_ctor( struct NineTexture9 *This, if (Format != D3DFMT_NULL && pf == PIPE_FORMAT_NONE) return D3DERR_INVALIDCALL; +if (compressed_format(Format)) { +const unsigned w = util_format_get_blockwidth(pf); +const unsigned h = util_format_get_blockheight(pf); + +user_assert(!(Width % w) && !(Height % h), D3DERR_INVALIDCALL); +} + info->screen = screen; info->target = PIPE_TEXTURE_2D; info->format = pf; diff --git a/src/gallium/state_trackers/nine/volumetexture9.c b/src/gallium/state_trackers/nine/volumetexture9.c index 4b5614d..e5b2b53 100644 --- a/src/gallium/state_trackers/nine/volumetexture9.c +++ b/src/gallium/state_trackers/nine/volumetexture9.c @@ -64,6 +64,13 @@ NineVolumeTexture9_ctor( struct NineVolumeTexture9 *This, if (Format == D3DFMT_ATI1 || Format == D3DFMT_ATI2) return D3DERR_INVALIDCALL; +if (compressed_format(Format)) { +const unsigned w = util_format_get_blockwidth(pf); +const unsigned h = util_format_get_blockheight(pf); +/* Compressed formats are not compressed on depth component */ +user_assert(!(Width % w) && !(Height % h), D3DERR_INVALIDCALL); +} + info->screen = pParams->device->screen; info->target = PIPE_TEXTURE_3D; info->format = pf; -- 2.1.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 28/71] st/nine: Clean GetPrivateData
From: Patrick Rudolph Move the assert to return error codes in the correct order. Always set the pSizeOfData to the required buffer size. Fixes failing wine test device.c test_private_data() Reviewed-by: Axel Davy Signed-off-by: Patrick Rudolph --- src/gallium/state_trackers/nine/resource9.c | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/gallium/state_trackers/nine/resource9.c b/src/gallium/state_trackers/nine/resource9.c index bbc8320..b6a13e1 100644 --- a/src/gallium/state_trackers/nine/resource9.c +++ b/src/gallium/state_trackers/nine/resource9.c @@ -161,20 +161,22 @@ NineResource9_GetPrivateData( struct NineResource9 *This, DWORD *pSizeOfData ) { struct pheader *header; +DWORD sizeofdata; DBG("This=%p refguid=%p pData=%p pSizeOfData=%p\n", This, refguid, pData, pSizeOfData); -user_assert(pSizeOfData, E_POINTER); - header = util_hash_table_get(This->pdata, refguid); if (!header) { return D3DERR_NOTFOUND; } +user_assert(pSizeOfData, E_POINTER); +sizeofdata = *pSizeOfData; +*pSizeOfData = header->size; + if (!pData) { -*pSizeOfData = header->size; return D3D_OK; } -if (*pSizeOfData < header->size) { +if (sizeofdata < header->size) { return D3DERR_MOREDATA; } -- 2.1.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 05/71] st/nine: Align texture memory
From: Patrick Rudolph Align texture memory on 32 byte boundry to allow SSE/AVX memcpy to work on locked rects. This fixes issue #88. Reviewed-by: David Heidelberg Reviewed-by: Axel Davy Signed-off-by: Patrick Rudolph --- src/gallium/state_trackers/nine/cubetexture9.c | 2 +- src/gallium/state_trackers/nine/surface9.c | 4 ++-- src/gallium/state_trackers/nine/texture9.c | 4 ++-- src/gallium/state_trackers/nine/volume9.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/gallium/state_trackers/nine/cubetexture9.c b/src/gallium/state_trackers/nine/cubetexture9.c index edea1f2..b3ef245 100644 --- a/src/gallium/state_trackers/nine/cubetexture9.c +++ b/src/gallium/state_trackers/nine/cubetexture9.c @@ -106,7 +106,7 @@ NineCubeTexture9_ctor( struct NineCubeTexture9 *This, face_size = nine_format_get_size_and_offsets(pf, level_offsets, EdgeLength, EdgeLength, info->last_level); -This->managed_buffer = MALLOC(6 * face_size); +This->managed_buffer = align_malloc(6 * face_size, 32); if (!This->managed_buffer) return E_OUTOFMEMORY; } diff --git a/src/gallium/state_trackers/nine/surface9.c b/src/gallium/state_trackers/nine/surface9.c index 7533cb3..164b34e 100644 --- a/src/gallium/state_trackers/nine/surface9.c +++ b/src/gallium/state_trackers/nine/surface9.c @@ -104,11 +104,11 @@ NineSurface9_ctor( struct NineSurface9 *This, /* Ram buffer with no parent. Has to allocate the resource itself */ if (!pResource && !pContainer) { assert(!user_buffer); -This->data = MALLOC( +This->data = align_malloc( nine_format_get_level_alloc_size(This->base.info.format, pDesc->Width, pDesc->Height, - 0)); + 0), 32); if (!This->data) return E_OUTOFMEMORY; } diff --git a/src/gallium/state_trackers/nine/texture9.c b/src/gallium/state_trackers/nine/texture9.c index 5900e76..6b4b9e3 100644 --- a/src/gallium/state_trackers/nine/texture9.c +++ b/src/gallium/state_trackers/nine/texture9.c @@ -152,10 +152,10 @@ NineTexture9_ctor( struct NineTexture9 *This, * apps access sublevels of texture even if they locked only first * level) */ level_offsets = alloca(sizeof(unsigned) * (info->last_level + 1)); -user_buffer = MALLOC( +user_buffer = align_malloc( nine_format_get_size_and_offsets(pf, level_offsets, Width, Height, - info->last_level)); + info->last_level), 32); This->managed_buffer = user_buffer; if (!This->managed_buffer) return E_OUTOFMEMORY; diff --git a/src/gallium/state_trackers/nine/volume9.c b/src/gallium/state_trackers/nine/volume9.c index 4dfc559..8694d3d 100644 --- a/src/gallium/state_trackers/nine/volume9.c +++ b/src/gallium/state_trackers/nine/volume9.c @@ -43,7 +43,7 @@ NineVolume9_AllocateData( struct NineVolume9 *This ) DBG("(%p(This=%p),level=%u) Allocating 0x%x bytes of system memory.\n", This->base.container, This, This->level, size); -This->data = (uint8_t *)MALLOC(size); +This->data = (uint8_t *)align_malloc(size, 32); if (!This->data) return E_OUTOFMEMORY; return D3D_OK; -- 2.1.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 09/71] st/nine: Force hw cursor for Windowed mode
Signed-off-by: Axel Davy Reviewed-by: David Heidelberg --- src/gallium/state_trackers/nine/device9.c | 12 +--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c index fce19b2..9f6c90e 100644 --- a/src/gallium/state_trackers/nine/device9.c +++ b/src/gallium/state_trackers/nine/device9.c @@ -611,9 +611,15 @@ NineDevice9_SetCursorProperties( struct NineDevice9 *This, user_assert(pCursorBitmap, D3DERR_INVALIDCALL); -This->cursor.w = MIN2(surf->desc.Width, This->cursor.image->width0); -This->cursor.h = MIN2(surf->desc.Height, This->cursor.image->height0); -hw_cursor = This->cursor.w == 32 && This->cursor.h == 32; +if (This->swapchains[0]->params.Windowed) { +This->cursor.w = MIN2(surf->desc.Width, 32); +This->cursor.h = MIN2(surf->desc.Height, 32); +hw_cursor = 1; /* always use hw cursor for windowed mode */ +} else { +This->cursor.w = MIN2(surf->desc.Width, This->cursor.image->width0); +This->cursor.h = MIN2(surf->desc.Height, This->cursor.image->height0); +hw_cursor = This->cursor.w == 32 && This->cursor.h == 32; +} u_box_origin_2d(This->cursor.w, This->cursor.h, &box); -- 2.1.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 36/71] st/nine: Fix use of uninitialized values
From: Patrick Rudolph Set all values to 0 after allocation. Found using valgrind. Reviewed-by: Axel Davy Signed-off-by: Patrick Rudolph --- src/gallium/state_trackers/nine/device9.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c index 96d27e1..e0f3e39 100644 --- a/src/gallium/state_trackers/nine/device9.c +++ b/src/gallium/state_trackers/nine/device9.c @@ -2138,8 +2138,10 @@ NineDevice9_SetLight( struct NineDevice9 *This, return E_OUTOFMEMORY; state->ff.num_lights = N; -for (; n < Index; ++n) +for (; n < Index; ++n) { +memset(&state->ff.light[n], 0, sizeof(D3DLIGHT9)); state->ff.light[n].Type = (D3DLIGHTTYPE)NINED3DLIGHT_INVALID; +} } state->ff.light[Index] = *pLight; -- 2.1.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 42/71] st/nine: Avoid useless updates in SetSamplerState
Signed-off-by: Axel Davy Reviewed-by: David Heidelberg --- src/gallium/state_trackers/nine/device9.c | 12 +++- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c index 4aa5892..a327bf8 100644 --- a/src/gallium/state_trackers/nine/device9.c +++ b/src/gallium/state_trackers/nine/device9.c @@ -2718,12 +2718,14 @@ NineDevice9_SetSamplerState( struct NineDevice9 *This, if (Sampler >= D3DDMAPSAMPLER) Sampler = Sampler - D3DDMAPSAMPLER + NINE_MAX_SAMPLERS_PS; -state->samp[Sampler][Type] = Value; -state->changed.group |= NINE_STATE_SAMPLER; -state->changed.sampler[Sampler] |= 1 << Type; +if (state->samp[Sampler][Type] != Value || unlikely(This->is_recording)) { +state->samp[Sampler][Type] = Value; +state->changed.group |= NINE_STATE_SAMPLER; +state->changed.sampler[Sampler] |= 1 << Type; -if (Type == D3DSAMP_SRGBTEXTURE) -state->changed.srgb = TRUE; +if (Type == D3DSAMP_SRGBTEXTURE) +state->changed.srgb = TRUE; +} return D3D_OK; } -- 2.1.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 18/71] st/nine: Add missing BASETEX_REGISTER_UPDATE calls
If the texture is bound and dirty_mip is true, BASETEX_REGISTER_UPDATE adds the texture to the list of things to update before the next draw call. Signed-off-by: Axel Davy --- src/gallium/state_trackers/nine/cubetexture9.c | 4 +++- src/gallium/state_trackers/nine/texture9.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/gallium/state_trackers/nine/cubetexture9.c b/src/gallium/state_trackers/nine/cubetexture9.c index b3ef245..e9224d0 100644 --- a/src/gallium/state_trackers/nine/cubetexture9.c +++ b/src/gallium/state_trackers/nine/cubetexture9.c @@ -259,8 +259,10 @@ NineCubeTexture9_AddDirtyRect( struct NineCubeTexture9 *This, user_assert(FaceType < 6, D3DERR_INVALIDCALL); if (This->base.base.pool != D3DPOOL_MANAGED) { -if (This->base.base.usage & D3DUSAGE_AUTOGENMIPMAP) +if (This->base.base.usage & D3DUSAGE_AUTOGENMIPMAP) { This->base.dirty_mip = TRUE; +BASETEX_REGISTER_UPDATE(&This->base); +} return D3D_OK; } This->base.managed.dirty = TRUE; diff --git a/src/gallium/state_trackers/nine/texture9.c b/src/gallium/state_trackers/nine/texture9.c index 6b4b9e3..a7a679e 100644 --- a/src/gallium/state_trackers/nine/texture9.c +++ b/src/gallium/state_trackers/nine/texture9.c @@ -300,8 +300,10 @@ NineTexture9_AddDirtyRect( struct NineTexture9 *This, * case we need to generate mip maps. */ if (This->base.base.pool != D3DPOOL_MANAGED) { -if (This->base.base.usage & D3DUSAGE_AUTOGENMIPMAP) +if (This->base.base.usage & D3DUSAGE_AUTOGENMIPMAP) { This->base.dirty_mip = TRUE; +BASETEX_REGISTER_UPDATE(&This->base); +} return D3D_OK; } This->base.managed.dirty = TRUE; -- 2.1.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 32/71] st/nine: Fix Lock Checks for Compressed textures
Signed-off-by: Axel Davy --- src/gallium/state_trackers/nine/surface9.c | 10 ++ src/gallium/state_trackers/nine/volume9.c | 9 + 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/gallium/state_trackers/nine/surface9.c b/src/gallium/state_trackers/nine/surface9.c index 78c29ca..14c1ce9 100644 --- a/src/gallium/state_trackers/nine/surface9.c +++ b/src/gallium/state_trackers/nine/surface9.c @@ -347,12 +347,14 @@ NineSurface9_LockRect( struct NineSurface9 *This, user_assert(This->desc.MultiSampleType == D3DMULTISAMPLE_NONE, D3DERR_INVALIDCALL); -if (pRect && This->base.pool == D3DPOOL_DEFAULT && -util_format_is_compressed(This->base.info.format)) { +if (pRect && This->desc.Pool == D3DPOOL_DEFAULT && +compressed_format (This->desc.Format)) { const unsigned w = util_format_get_blockwidth(This->base.info.format); const unsigned h = util_format_get_blockheight(This->base.info.format); -user_assert(!(pRect->left % w) && !(pRect->right % w) && -!(pRect->top % h) && !(pRect->bottom % h), +user_assert((pRect->left == 0 && pRect->right == This->desc.Width && + pRect->top == 0 && pRect->bottom == This->desc.Height) || +(!(pRect->left % w) && !(pRect->right % w) && +!(pRect->top % h) && !(pRect->bottom % h)), D3DERR_INVALIDCALL); } diff --git a/src/gallium/state_trackers/nine/volume9.c b/src/gallium/state_trackers/nine/volume9.c index 6311103..0b90056 100644 --- a/src/gallium/state_trackers/nine/volume9.c +++ b/src/gallium/state_trackers/nine/volume9.c @@ -244,12 +244,13 @@ NineVolume9_LockBox( struct NineVolume9 *This, user_assert(!((Flags & D3DLOCK_DISCARD) && (Flags & D3DLOCK_READONLY)), D3DERR_INVALIDCALL); -if (pBox && This->desc.Pool == D3DPOOL_DEFAULT && -util_format_is_compressed(This->info.format)) { +if (pBox && compressed_format (This->desc.Format)) { /* For volume all pools are checked */ const unsigned w = util_format_get_blockwidth(This->info.format); const unsigned h = util_format_get_blockheight(This->info.format); -user_assert(!(pBox->Left % w) && !(pBox->Right % w) && -!(pBox->Top % h) && !(pBox->Bottom % h), +user_assert((pBox->Left == 0 && pBox->Right == This->desc.Width && + pBox->Top == 0 && pBox->Bottom == This->desc.Height) || +(!(pBox->Left % w) && !(pBox->Right % w) && + !(pBox->Top % h) && !(pBox->Bottom % h)), D3DERR_INVALIDCALL); } -- 2.1.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 27/71] st/nine: fix failing wine test device.c test_lockrect_invalid()
From: Patrick Rudolph Mimic WindowsXp behaviour and allow negative values in the rectangle passed. Add comment to point out behaviour used. Reviewed-by: Axel Davy Signed-off-by: Patrick Rudolph --- src/gallium/state_trackers/nine/surface9.c | 8 ++-- 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/gallium/state_trackers/nine/surface9.c b/src/gallium/state_trackers/nine/surface9.c index eb941ce..d20e62a 100644 --- a/src/gallium/state_trackers/nine/surface9.c +++ b/src/gallium/state_trackers/nine/surface9.c @@ -363,13 +363,9 @@ NineSurface9_LockRect( struct NineSurface9 *This, usage |= PIPE_TRANSFER_DONTBLOCK; if (pRect) { +/* Windows XP accepts invalid locking rectangles, Windows 7 rejects + * them. Use Windows XP behaviour for now. */ rect_to_pipe_box(&box, pRect); -if (u_box_clip_2d(&box, &box, This->desc.Width, - This->desc.Height) < 0) { -DBG("pRect clipped by Width=%u Height=%u\n", -This->desc.Width, This->desc.Height); -return D3DERR_INVALIDCALL; -} } else { u_box_origin_2d(This->desc.Width, This->desc.Height, &box); } -- 2.1.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev