diff options
author | Axel Davy <[email protected]> | 2016-12-28 18:24:12 +0100 |
---|---|---|
committer | Axel Davy <[email protected]> | 2017-01-12 20:33:11 +0100 |
commit | f895ab8e22dc520304141ba56c1b81d8d6657ccd (patch) | |
tree | 5edb77cf3b8a8377900131102831d7d25923643d /src/gallium/state_trackers/nine | |
parent | d43bc05e8ba0f326273c21b10f714e4d2514adae (diff) |
st/nine: Rework CreatePipeSurface
Create both surfaces in one call.
Signed-off-by: Axel Davy <[email protected]>
Diffstat (limited to 'src/gallium/state_trackers/nine')
-rw-r--r-- | src/gallium/state_trackers/nine/surface9.c | 49 | ||||
-rw-r--r-- | src/gallium/state_trackers/nine/surface9.h | 3 |
2 files changed, 30 insertions, 22 deletions
diff --git a/src/gallium/state_trackers/nine/surface9.c b/src/gallium/state_trackers/nine/surface9.c index a5c4a9ede8d..4b8e2132abc 100644 --- a/src/gallium/state_trackers/nine/surface9.c +++ b/src/gallium/state_trackers/nine/surface9.c @@ -44,6 +44,9 @@ #define DBG_CHANNEL DBG_SURFACE +static void +NineSurface9_CreatePipeSurfaces( struct NineSurface9 *This ); + HRESULT NineSurface9_ctor( struct NineSurface9 *This, struct NineUnknownParams *pParams, @@ -184,10 +187,8 @@ NineSurface9_ctor( struct NineSurface9 *This, if (This->base.resource && (pDesc->Usage & D3DUSAGE_DYNAMIC)) This->base.resource->flags |= NINE_RESOURCE_FLAG_LOCKABLE; - if (This->base.resource && (pDesc->Usage & (D3DUSAGE_RENDERTARGET | D3DUSAGE_DEPTHSTENCIL))) { - (void) NineSurface9_CreatePipeSurface(This, 0); - (void) NineSurface9_CreatePipeSurface(This, 1); - } + if (This->base.resource && (pDesc->Usage & (D3DUSAGE_RENDERTARGET | D3DUSAGE_DEPTHSTENCIL))) + NineSurface9_CreatePipeSurfaces(This); /* TODO: investigate what else exactly needs to be cleared */ if (This->base.resource && (pDesc->Usage & D3DUSAGE_RENDERTARGET)) @@ -220,8 +221,8 @@ NineSurface9_dtor( struct NineSurface9 *This ) NineResource9_dtor(&This->base); } -struct pipe_surface * -NineSurface9_CreatePipeSurface( struct NineSurface9 *This, const int sRGB ) +static void +NineSurface9_CreatePipeSurfaces( struct NineSurface9 *This ) { struct pipe_context *pipe; struct pipe_screen *screen = NineDevice9_GetScreen(This->base.base.device); @@ -233,21 +234,33 @@ NineSurface9_CreatePipeSurface( struct NineSurface9 *This, const int sRGB ) assert(resource); srgb_format = util_format_srgb(resource->format); - if (sRGB && srgb_format != PIPE_FORMAT_NONE && - screen->is_format_supported(screen, srgb_format, - resource->target, 0, resource->bind)) - templ.format = srgb_format; - else - templ.format = resource->format; + if (srgb_format == PIPE_FORMAT_NONE || + !screen->is_format_supported(screen, srgb_format, + resource->target, 0, resource->bind)) + srgb_format = resource->format; + + memset(&templ, 0, sizeof(templ)); + templ.format = resource->format; templ.u.tex.level = This->level; templ.u.tex.first_layer = This->layer; templ.u.tex.last_layer = This->layer; pipe = nine_context_get_pipe_acquire(This->base.base.device); - This->surface[sRGB] = pipe->create_surface(pipe, resource, &templ); + + This->surface[0] = pipe->create_surface(pipe, resource, &templ); + + memset(&templ, 0, sizeof(templ)); + templ.format = srgb_format; + templ.u.tex.level = This->level; + templ.u.tex.first_layer = This->layer; + templ.u.tex.last_layer = This->layer; + + This->surface[1] = pipe->create_surface(pipe, resource, &templ); + nine_context_get_pipe_release(This->base.base.device); - assert(This->surface[sRGB]); - return This->surface[sRGB]; + + assert(This->surface[0]); /* TODO: Handle failure */ + assert(This->surface[1]); } #ifdef DEBUG @@ -762,10 +775,8 @@ NineSurface9_SetResourceResize( struct NineSurface9 *This, pipe_surface_reference(&This->surface[0], NULL); pipe_surface_reference(&This->surface[1], NULL); - if (resource) { - (void) NineSurface9_CreatePipeSurface(This, 0); - (void) NineSurface9_CreatePipeSurface(This, 1); - } + if (resource) + NineSurface9_CreatePipeSurfaces(This); } diff --git a/src/gallium/state_trackers/nine/surface9.h b/src/gallium/state_trackers/nine/surface9.h index 8263060cd57..6f416f2de6a 100644 --- a/src/gallium/state_trackers/nine/surface9.h +++ b/src/gallium/state_trackers/nine/surface9.h @@ -90,9 +90,6 @@ NineSurface9_dtor( struct NineSurface9 *This ); void NineSurface9_MarkContainerDirty( struct NineSurface9 *This ); -struct pipe_surface * -NineSurface9_CreatePipeSurface( struct NineSurface9 *This, const int sRGB ); - static inline struct pipe_surface * NineSurface9_GetSurface( struct NineSurface9 *This, int sRGB ) { |