Commit 3f125bcb authored by Alyssa Rosenzweig's avatar Alyssa Rosenzweig 💜

...

parent b9409d59
......@@ -271,7 +271,7 @@ pipe_panfrost_create_screen(int fd, const struct pipe_screen_config *config)
{
struct pipe_screen *screen;
screen = pan_drm_screen_create(fd);
screen = panfrost_drm_screen_create(fd);
return screen ? debug_screen_wrap(screen) : NULL;
}
......
......@@ -38,7 +38,7 @@ void panfrost_init_state_functions(struct pipe_context *ctx);
struct panfrost_pipe_screen {
struct pipe_screen pscreen;
struct pipe_screen *oscreen;
// struct pipe_screen *oscreen;
};
/*
......@@ -125,14 +125,15 @@ static struct pipe_resource *panfrost_resource_from_handle(struct pipe_screen *s
unsigned usage)
{
struct panfrost_pipe_screen *panfrost_screen = (struct panfrost_pipe_screen*)screen;
struct pipe_screen *oscreen = panfrost_screen->oscreen;
// struct pipe_screen *oscreen = panfrost_screen->oscreen;
struct pipe_resource *result;
struct pipe_resource *panfrost_resource;
result = oscreen->resource_from_handle(oscreen, templ, handle, usage);
panfrost_resource = panfrost_resource_create(screen, result);
pipe_resource_reference(&result, NULL);
return panfrost_resource;
// result = oscreen->resource_from_handle(oscreen, templ, handle, usage);
// panfrost_resource = panfrost_resource_create(screen, result);
//pipe_resource_reference(&result, NULL);
// return panfrost_resource;
return NULL;
}
static boolean panfrost_resource_get_handle(struct pipe_screen *pscreen,
......@@ -142,7 +143,8 @@ static boolean panfrost_resource_get_handle(struct pipe_screen *pscreen,
unsigned usage)
{
struct panfrost_pipe_screen *panfrost_screen = (struct panfrost_pipe_screen*)pscreen;
struct pipe_screen *screen = panfrost_screen->oscreen;
struct pipe_screen *screen = &panfrost_screen->pscreen;
struct pipe_resource *tex;
bool result;
......@@ -378,7 +380,7 @@ static const char *panfrost_get_name(struct pipe_screen* pscreen)
static int panfrost_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
{
struct pipe_screen *screen = ((struct panfrost_pipe_screen*)pscreen)->oscreen;
struct pipe_screen *screen = &((struct panfrost_pipe_screen*)pscreen)->pscreen;
return screen->get_param(screen, param);
}
......@@ -386,7 +388,7 @@ static int panfrost_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
static float panfrost_get_paramf(struct pipe_screen* pscreen,
enum pipe_capf param)
{
struct pipe_screen *screen = ((struct panfrost_pipe_screen*)pscreen)->oscreen;
struct pipe_screen *screen = &((struct panfrost_pipe_screen*)pscreen)->pscreen;
return screen->get_paramf(screen, param);
}
......@@ -395,7 +397,7 @@ static int panfrost_get_shader_param(struct pipe_screen* pscreen,
enum pipe_shader_type shader,
enum pipe_shader_cap param)
{
struct pipe_screen *screen = ((struct panfrost_pipe_screen*)pscreen)->oscreen;
struct pipe_screen *screen = &((struct panfrost_pipe_screen*)pscreen)->pscreen;
return screen->get_shader_param(screen, shader, param);
}
......@@ -405,7 +407,7 @@ static int panfrost_get_compute_param(struct pipe_screen *pscreen,
enum pipe_compute_cap param,
void *ret)
{
struct pipe_screen *screen = ((struct panfrost_pipe_screen*)pscreen)->oscreen;
struct pipe_screen *screen = &((struct panfrost_pipe_screen*)pscreen)->pscreen;
return screen->get_compute_param(screen, ir_type, param, ret);
}
......@@ -416,7 +418,7 @@ static boolean panfrost_is_format_supported(struct pipe_screen* pscreen,
unsigned sample_count,
unsigned usage)
{
struct pipe_screen *screen = ((struct panfrost_pipe_screen*)pscreen)->oscreen;
struct pipe_screen *screen = &((struct panfrost_pipe_screen*)pscreen)->pscreen;
return screen->is_format_supported(screen, format, target, sample_count, usage);
}
......@@ -429,9 +431,11 @@ static uint64_t panfrost_get_timestamp(struct pipe_screen *pscreen)
static void panfrost_destroy_screen(struct pipe_screen *screen)
{
struct panfrost_pipe_screen *panfrost_screen = (struct panfrost_pipe_screen*)screen;
struct pipe_screen *oscreen = panfrost_screen->oscreen;
#if 0
struct pipe_screen *nscreen = panfrost_screen->oscreen;
oscreen->destroy(oscreen);
#endif
FREE(screen);
}
......@@ -453,25 +457,21 @@ static void panfrost_query_memory_info(struct pipe_screen *pscreen,
struct pipe_memory_info *info)
{
struct panfrost_pipe_screen *panfrost_screen = (struct panfrost_pipe_screen*)pscreen;
struct pipe_screen *screen = panfrost_screen->oscreen;
// struct pipe_screen *screen = panfrost_screen->oscreen;
screen->query_memory_info(screen, info);
// screen->query_memory_info(screen, info);
}
struct pipe_screen *panfrost_screen_create(struct pipe_screen *oscreen)
struct pipe_screen *panfrost_screen_create(int fd)
{
struct panfrost_pipe_screen *panfrost_screen;
struct pipe_screen *screen;
if (!debug_get_option_panfrost()) {
return oscreen;
}
panfrost_screen = CALLOC_STRUCT(panfrost_pipe_screen);
if (!panfrost_screen) {
return NULL;
}
panfrost_screen->oscreen = oscreen;
//panfrost_screen->oscreen = oscreen;
screen = &panfrost_screen->pscreen;
screen->destroy = panfrost_destroy_screen;
......
......@@ -24,6 +24,6 @@
#define PANFROST_PUBLIC_H
struct pipe_screen;
struct pipe_screen *panfrost_screen_create(struct pipe_screen *screen);
struct pipe_screen *panfrost_screen_create(int fd);
#endif
......@@ -4,6 +4,6 @@
struct pipe_screen;
struct pipe_screen *pan_drm_screen_create(int drmFD);
struct pipe_screen *panfrost_drm_screen_create(int drmFD);
#endif
/* -*- mode: C; c-file-style: "k&r"; tab-width 4; indent-tabs-mode: t; -*- */
/*
* Copyright (C) 2012 Rob Clark <robclark@freedesktop.org>
* Copyright © 2014 Broadcom
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
......@@ -18,110 +16,27 @@
* 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.
*
* Authors:
* Rob Clark <robclark@freedesktop.org>
* 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 <sys/stat.h>
#include "pipe/p_context.h"
#include "pipe/p_state.h"
#include "util/u_format.h"
#include "util/u_memory.h"
#include "util/u_inlines.h"
#include "util/u_hash_table.h"
#include "os/os_thread.h"
#include <unistd.h>
#include <fcntl.h>
//#include "renderonly/renderonly.h"
#include "panfrost_drm_public.h"
#include "panfrost/panfrost_public.h"
static struct util_hash_table *panfrost_tab = NULL;
static mtx_t panfrost_screen_mutex = _MTX_INITIALIZER_NP;
static void
panfrost_drm_screen_destroy(struct pipe_screen *pscreen)
{
struct panfrost_screen *screen = panfrost_screen(pscreen);
boolean destroy;
mtx_lock(&panfrost_screen_mutex);
destroy = --screen->refcnt == 0;
if (destroy) {
int fd = panfrost_device_fd(screen->dev);
util_hash_table_remove(panfrost_tab, intptr_to_pointer(fd));
}
mtx_unlock(&panfrost_screen_mutex);
if (destroy) {
pscreen->destroy = screen->winsys_priv;
pscreen->destroy(pscreen);
}
}
static unsigned hash_fd(void *key)
{
int fd = pointer_to_intptr(key);
struct stat stat;
fstat(fd, &stat);
return stat.st_dev ^ stat.st_ino ^ stat.st_rdev;
}
static int compare_fd(void *key1, void *key2)
struct pipe_screen *
panfrost_drm_screen_create(int fd)
{
int fd1 = pointer_to_intptr(key1);
int fd2 = pointer_to_intptr(key2);
struct stat stat1, stat2;
fstat(fd1, &stat1);
fstat(fd2, &stat2);
return stat1.st_dev != stat2.st_dev ||
stat1.st_ino != stat2.st_ino ||
stat1.st_rdev != stat2.st_rdev;
return panfrost_screen_create(fcntl(fd, F_DUPFD_CLOEXEC, 3));
}
#if 0
struct pipe_screen *
panfrost_drm_screen_create(int fd)
panfrost_drm_screen_create_renderonly(struct renderonly *ro)
{
struct pipe_screen *pscreen = NULL;
mtx_lock(&panfrost_screen_mutex);
if (!panfrost_tab) {
panfrost_tab = util_hash_table_create(hash_fd, compare_fd);
if (!panfrost_tab)
goto unlock;
}
pscreen = util_hash_table_get(panfrost_tab, intptr_to_pointer(fd));
if (pscreen) {
panfrost_screen(pscreen)->refcnt++;
} else {
struct panfrost_device *dev = panfrost_device_new_dup(fd);
if (!dev)
goto unlock;
pscreen = panfrost_screen_create(dev);
if (pscreen) {
int fd = panfrost_device_fd(dev);
util_hash_table_set(panfrost_tab, intptr_to_pointer(fd), pscreen);
/* Bit of a hack, to avoid circular linkage dependency,
* ie. pipe driver having to call in to winsys, we
* override the pipe drivers screen->destroy():
*/
panfrost_screen(pscreen)->winsys_priv = pscreen->destroy;
pscreen->destroy = panfrost_drm_screen_destroy;
}
}
unlock:
mtx_unlock(&panfrost_screen_mutex);
return pscreen;
return panfrost_screen_create(fcntl(ro->gpu_fd, F_DUPFD_CLOEXEC, 3), ro);
}
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment