* @author Jose Fonseca
*/
+#include <libsync.h>
#include "svga_cmd.h"
#include "svga3d_caps.h"
}
+static int
+vmw_svga_winsys_fence_get_fd(struct svga_winsys_screen *sws,
+ struct pipe_fence_handle *fence,
+ boolean duplicate)
+{
+ if (duplicate)
+ return dup(vmw_fence_get_fd(fence));
+ else
+ return vmw_fence_get_fd(fence);
+}
+
+
+static void
+vmw_svga_winsys_fence_create_fd(struct svga_winsys_screen *sws,
+ struct pipe_fence_handle **fence,
+ int32_t fd)
+{
+ *fence = vmw_fence_create(NULL, 0, 0, 0, dup(fd));
+}
+
+static int
+vmw_svga_winsys_fence_server_sync(struct svga_winsys_screen *sws,
+ int32_t *context_fd,
+ struct pipe_fence_handle *fence)
+{
+ int32_t fd = sws->fence_get_fd(sws, fence, FALSE);
+
+ /* If we don't have fd, we don't need to merge fd into the context's fd. */
+ if (fd == -1)
+ return 0;
+
+ return sync_accumulate("vmwgfx", context_fd, fd);
+}
+
static struct svga_winsys_surface *
vmw_svga_winsys_surface_create(struct svga_winsys_screen *sws,
- SVGA3dSurfaceFlags flags,
+ SVGA3dSurfaceAllFlags flags,
SVGA3dSurfaceFormat format,
unsigned usage,
SVGA3dSize size,
struct vmw_buffer_desc desc;
struct pb_manager *provider;
uint32_t buffer_size;
+ uint32_t num_samples = 1;
+ SVGA3dMSPattern multisample_pattern = SVGA3D_MS_PATTERN_NONE;
memset(&desc, 0, sizeof(desc));
surface = CALLOC_STRUCT(vmw_svga_winsys_surface);
surface->shared = !!(usage & SVGA_SURFACE_USAGE_SHARED);
provider = (surface->shared) ? vws->pools.gmr : vws->pools.mob_fenced;
+ /*
+ * When multisampling is not supported sample count received is 0,
+ * otherwise should have a valid sample count.
+ */
+ if ((flags & SVGA3D_SURFACE_MULTISAMPLE) != 0) {
+ if (sampleCount == 0)
+ goto no_sid;
+ num_samples = sampleCount;
+ multisample_pattern = SVGA3D_MS_PATTERN_STANDARD;
+ }
+
/*
* Used for the backing buffer GB surfaces, and to approximate
* when to flush on non-GB hosts.
*/
- buffer_size = svga3dsurface_get_serialized_size(format, size, numMipLevels,
- numLayers);
+ buffer_size = svga3dsurface_get_serialized_size_extended(format, size,
+ numMipLevels,
+ numLayers,
+ num_samples);
if (flags & SVGA3D_SURFACE_BIND_STREAM_OUTPUT)
buffer_size += sizeof(SVGA3dDXSOState);
size, numLayers,
numMipLevels, sampleCount,
ptr.gmrId,
+ multisample_pattern,
surface->buf ? NULL :
&desc.region);
surface->sid = vmw_ioctl_gb_surface_create(vws, flags, format, usage,
size, numLayers,
numMipLevels, sampleCount,
- 0, &desc.region);
+ 0, multisample_pattern,
+ &desc.region);
if (surface->sid == SVGA3D_INVALID_ID)
goto no_sid;
}
}
}
} else {
- surface->sid = vmw_ioctl_surface_create(vws, flags, format, usage,
- size, numLayers, numMipLevels,
- sampleCount);
+ /* Legacy surface only support 32-bit svga3d flags */
+ surface->sid = vmw_ioctl_surface_create(vws, (SVGA3dSurface1Flags)flags,
+ format, usage, size, numLayers,
+ numMipLevels, sampleCount);
if(surface->sid == SVGA3D_INVALID_ID)
goto no_sid;
SVGA3dSurfaceFormat format,
SVGA3dSize size,
uint32 numLayers,
- uint32 numMipLevels)
+ uint32 numMipLevels,
+ uint32 numSamples)
{
struct vmw_winsys_screen *vws = vmw_winsys_screen(sws);
uint32_t buffer_size;
buffer_size = svga3dsurface_get_serialized_size(format, size,
numMipLevels,
numLayers);
+ if (numSamples > 1)
+ buffer_size *= numSamples;
+
if (buffer_size > vws->ioctl.max_texture_size) {
return FALSE;
}
vws->base.shader_create = vmw_svga_winsys_shader_create;
vws->base.shader_destroy = vmw_svga_winsys_shader_destroy;
vws->base.fence_finish = vmw_svga_winsys_fence_finish;
+ vws->base.fence_get_fd = vmw_svga_winsys_fence_get_fd;
+ vws->base.fence_create_fd = vmw_svga_winsys_fence_create_fd;
+ vws->base.fence_server_sync = vmw_svga_winsys_fence_server_sync;
vws->base.query_create = vmw_svga_winsys_query_create;
vws->base.query_init = vmw_svga_winsys_query_init;