mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-30 09:20:23 +01:00
winsys/svga: add new vmw_query.c[h] files
Functions for creating, destroying, getting queries, etc. Signed-off-by: Brian Paul <brianp@vmware.com>
This commit is contained in:
parent
f30cf3258e
commit
75f92e28b4
3 changed files with 214 additions and 1 deletions
|
|
@ -17,4 +17,6 @@ C_SOURCES := \
|
|||
vmw_surface.c \
|
||||
vmw_surface.h \
|
||||
vmw_shader.c \
|
||||
vmw_shader.h
|
||||
vmw_shader.h \
|
||||
vmw_query.c \
|
||||
vmw_query.h
|
||||
|
|
|
|||
144
src/gallium/winsys/svga/drm/vmw_query.c
Normal file
144
src/gallium/winsys/svga/drm/vmw_query.c
Normal file
|
|
@ -0,0 +1,144 @@
|
|||
/**********************************************************
|
||||
* Copyright 2015 VMware, Inc. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use, copy,
|
||||
* modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
* of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
**********************************************************/
|
||||
|
||||
#include "pipebuffer/pb_bufmgr.h"
|
||||
#include "util/u_memory.h"
|
||||
|
||||
#include "vmw_screen.h"
|
||||
#include "vmw_buffer.h"
|
||||
#include "vmw_query.h"
|
||||
|
||||
|
||||
|
||||
struct svga_winsys_gb_query *
|
||||
vmw_svga_winsys_query_create(struct svga_winsys_screen *sws,
|
||||
uint32 queryResultLen)
|
||||
{
|
||||
struct vmw_winsys_screen *vws = vmw_winsys_screen(sws);
|
||||
struct pb_manager *provider = vws->pools.gmr;
|
||||
struct pb_desc desc = {0};
|
||||
struct pb_buffer *pb_buf;
|
||||
struct svga_winsys_gb_query *query;
|
||||
|
||||
query = CALLOC_STRUCT(svga_winsys_gb_query);
|
||||
if (!query)
|
||||
return NULL;
|
||||
|
||||
/* Allocate memory to hold queries for this context */
|
||||
desc.alignment = 4096;
|
||||
pb_buf = provider->create_buffer(provider, queryResultLen, &desc);
|
||||
query->buf = vmw_svga_winsys_buffer_wrap(pb_buf);
|
||||
|
||||
if (!query->buf) {
|
||||
debug_printf("Failed to allocate memory for queries\n");
|
||||
FREE(query);
|
||||
query = NULL;
|
||||
}
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
vmw_svga_winsys_query_destroy(struct svga_winsys_screen *sws,
|
||||
struct svga_winsys_gb_query *query)
|
||||
{
|
||||
vmw_svga_winsys_buffer_destroy(sws, query->buf);
|
||||
FREE(query);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
vmw_svga_winsys_query_init(struct svga_winsys_screen *sws,
|
||||
struct svga_winsys_gb_query *query,
|
||||
unsigned offset,
|
||||
SVGA3dQueryState queryState)
|
||||
{
|
||||
SVGA3dQueryState *state;
|
||||
|
||||
state = (SVGA3dQueryState *) vmw_svga_winsys_buffer_map(sws,
|
||||
query->buf,
|
||||
PIPE_TRANSFER_WRITE);
|
||||
if (!state) {
|
||||
debug_printf("Failed to map query result memory for initialization\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Initialize the query state for the specified query slot */
|
||||
state = (SVGA3dQueryState *)((char *)state + offset);
|
||||
*state = queryState;
|
||||
|
||||
vmw_svga_winsys_buffer_unmap(sws, query->buf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
vmw_svga_winsys_query_get_result(struct svga_winsys_screen *sws,
|
||||
struct svga_winsys_gb_query *query,
|
||||
unsigned offset,
|
||||
SVGA3dQueryState *queryState,
|
||||
void *result, uint32 resultLen)
|
||||
{
|
||||
SVGA3dQueryState *state;
|
||||
|
||||
state = (SVGA3dQueryState *) vmw_svga_winsys_buffer_map(sws,
|
||||
query->buf,
|
||||
PIPE_TRANSFER_READ);
|
||||
if (!state) {
|
||||
debug_printf("Failed to lock query result memory\n");
|
||||
|
||||
if (queryState)
|
||||
*queryState = SVGA3D_QUERYSTATE_FAILED;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
state = (SVGA3dQueryState *)((char *)state + offset);
|
||||
|
||||
if (queryState)
|
||||
*queryState = *state;
|
||||
|
||||
if (result) {
|
||||
memcpy(result, state + 1, resultLen);
|
||||
}
|
||||
|
||||
vmw_svga_winsys_buffer_unmap(sws, query->buf);
|
||||
}
|
||||
|
||||
|
||||
enum pipe_error
|
||||
vmw_swc_query_bind(struct svga_winsys_context *swc,
|
||||
struct svga_winsys_gb_query *query,
|
||||
unsigned flags)
|
||||
{
|
||||
/* no-op on Linux */
|
||||
return PIPE_OK;
|
||||
}
|
||||
|
||||
67
src/gallium/winsys/svga/drm/vmw_query.h
Normal file
67
src/gallium/winsys/svga/drm/vmw_query.h
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
/**********************************************************
|
||||
* Copyright 2015 VMware, Inc. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use, copy,
|
||||
* modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
* of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
**********************************************************/
|
||||
|
||||
#ifndef VMW_DRM_QUERY_H
|
||||
#define VMW_DRM_QUERY_H
|
||||
|
||||
#include "svga3d_reg.h"
|
||||
|
||||
|
||||
|
||||
/** Guest-backed query */
|
||||
struct svga_winsys_gb_query
|
||||
{
|
||||
struct svga_winsys_buffer *buf;
|
||||
};
|
||||
|
||||
|
||||
struct svga_winsys_gb_query *
|
||||
vmw_svga_winsys_query_create(struct svga_winsys_screen *sws,
|
||||
uint32 queryResultLen);
|
||||
|
||||
void
|
||||
vmw_svga_winsys_query_destroy(struct svga_winsys_screen *sws,
|
||||
struct svga_winsys_gb_query *query);
|
||||
|
||||
int
|
||||
vmw_svga_winsys_query_init(struct svga_winsys_screen *sws,
|
||||
struct svga_winsys_gb_query *query,
|
||||
unsigned offset,
|
||||
SVGA3dQueryState queryState);
|
||||
|
||||
void
|
||||
vmw_svga_winsys_query_get_result(struct svga_winsys_screen *sws,
|
||||
struct svga_winsys_gb_query *query,
|
||||
unsigned offset,
|
||||
SVGA3dQueryState *queryState,
|
||||
void *result, uint32 resultLen);
|
||||
|
||||
enum pipe_error
|
||||
vmw_swc_query_bind(struct svga_winsys_context *swc,
|
||||
struct svga_winsys_gb_query *query,
|
||||
unsigned flags);
|
||||
|
||||
#endif /* VMW_DRM_QUERY_H */
|
||||
|
||||
Loading…
Add table
Reference in a new issue