mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 20:18:12 +02:00
gallium: Drop post-processing filters
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Reviewed-by: Marek Olšák <maraeo@gmail.com> Reviewed-by: Emma Anholt <emma@anholt.net> Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com> Reviewed-by: Christian Gmeiner <cgmeiner@igalia.co Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5448>
This commit is contained in:
parent
168141fbac
commit
6397ddd15d
16 changed files with 0 additions and 5036 deletions
|
|
@ -120,20 +120,6 @@ files_libgallium = files(
|
|||
'pipebuffer/pb_cache.h',
|
||||
'pipebuffer/pb_validate.c',
|
||||
'pipebuffer/pb_validate.h',
|
||||
'postprocess/filters.h',
|
||||
'postprocess/postprocess.h',
|
||||
'postprocess/pp_celshade.c',
|
||||
'postprocess/pp_celshade.h',
|
||||
'postprocess/pp_colors.c',
|
||||
'postprocess/pp_colors.h',
|
||||
'postprocess/pp_filters.h',
|
||||
'postprocess/pp_init.c',
|
||||
'postprocess/pp_mlaa_areamap.h',
|
||||
'postprocess/pp_mlaa.c',
|
||||
'postprocess/pp_mlaa.h',
|
||||
'postprocess/pp_private.h',
|
||||
'postprocess/pp_program.c',
|
||||
'postprocess/pp_run.c',
|
||||
'rtasm/rtasm_execmem.c',
|
||||
'rtasm/rtasm_execmem.h',
|
||||
'rtasm/rtasm_x86sse.c',
|
||||
|
|
|
|||
|
|
@ -1,87 +0,0 @@
|
|||
How to add a new post-processing filter
|
||||
=======================================
|
||||
|
||||
The Gallium post-processing queue works by passing the current screen to a fragment shader.
|
||||
These shaders may be written in any supported language, but are added here in TGSI text
|
||||
assembly.
|
||||
|
||||
You can translate GLSL/ARB fairly easily via llvmpipe (LP_DEBUG=tgsi). I don't know the
|
||||
status of the D3D gallium frontend, but if/when that works, I'd assume HLSL would be possible
|
||||
too.
|
||||
|
||||
|
||||
|
||||
Steps
|
||||
=====
|
||||
|
||||
1. Add it to PP
|
||||
2. Make it known to PP
|
||||
3. Make it known to driconf
|
||||
4. ????
|
||||
5. Profit
|
||||
|
||||
|
||||
|
||||
|
||||
1. Add it to PP
|
||||
---------------
|
||||
|
||||
Once you have the shader(s) in TGSI asm, put them to static const char arrays in a header
|
||||
file (see pp_colors.h).
|
||||
|
||||
Add the filter's prototypes (main and init functions) to postprocess.h. This is mostly a
|
||||
copy-paste job with only changing the name.
|
||||
|
||||
Then create a file containing empty main and init functions, named as you specified above.
|
||||
See pp_colors.c for an example.
|
||||
|
||||
|
||||
|
||||
2. Make it known to PP
|
||||
----------------------
|
||||
|
||||
Add your filter to filters.h, in a correct place. Placement is important, AA should usually
|
||||
be the last effect in the queue for example.
|
||||
|
||||
Name is the config option your filter will be enabled by, both in driconf and as an env var.
|
||||
|
||||
Inner temp means an intermediate framebuffer you may use in your filter to store
|
||||
results between passes. If you have a single-pass filter, request 0 of those.
|
||||
|
||||
Shaders is the number of shaders your filter needs. The minimum is 2.
|
||||
|
||||
|
||||
You could also write the init and main functions now. If your filter is single-pass without
|
||||
a vertex shader and any other input than the main screen, you can use pp_nocolor as your
|
||||
main function as is.
|
||||
|
||||
|
||||
|
||||
3. Make it known to driconf
|
||||
---------------------------
|
||||
|
||||
First time outside of auxiliary/postprocess. First, add a suitable description to
|
||||
src/util/driconf.h.
|
||||
Use the name you put into filters.h as the config option name.
|
||||
|
||||
With driconf aware of the option, make Gallium aware of it too. Add it to
|
||||
frontends/dri/common/dri_screen.c in a proper section, specifying its default value and
|
||||
the accepted range (if applicable).
|
||||
|
||||
Do check that __driNConfigOptions is still correct after the addition.
|
||||
|
||||
|
||||
|
||||
4. ????
|
||||
-------
|
||||
|
||||
Testing, praying, hookers, blow, sacrificial lambs...
|
||||
|
||||
|
||||
|
||||
5. Profit
|
||||
---------
|
||||
|
||||
Assuming you got here, sharing is caring. Send your filter to mesa-dev.
|
||||
|
||||
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2011 Lauri Kasanen
|
||||
* 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, 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 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 PP_EXTERNAL_FILTERS_H
|
||||
#define PP_EXTERNAL_FILTERS_H
|
||||
|
||||
#include "postprocess/postprocess.h"
|
||||
|
||||
#define PP_FILTERS 6 /* Increment this if you add filters */
|
||||
#define PP_MAX_PASSES 6
|
||||
|
||||
|
||||
typedef bool (*pp_init_func) (struct pp_queue_t *, unsigned int,
|
||||
unsigned int);
|
||||
typedef void (*pp_free_func) (struct pp_queue_t *, unsigned int);
|
||||
|
||||
struct pp_filter_t
|
||||
{
|
||||
const char *name; /* Config name */
|
||||
unsigned int inner_tmps; /* Request how many inner temps */
|
||||
unsigned int shaders; /* Request how many shaders */
|
||||
unsigned int verts; /* How many are vertex shaders */
|
||||
pp_init_func init; /* Init function */
|
||||
pp_func main; /* Run function */
|
||||
pp_free_func free; /* Free function */
|
||||
};
|
||||
|
||||
extern const struct pp_filter_t pp_filters[PP_FILTERS];
|
||||
#endif
|
||||
|
|
@ -1,103 +0,0 @@
|
|||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2011 Lauri Kasanen
|
||||
* 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, 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 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 POSTPROCESS_H
|
||||
#define POSTPROCESS_H
|
||||
|
||||
#include "pipe/p_state.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct cso_context;
|
||||
struct st_context;
|
||||
|
||||
struct pp_queue_t; /* Forward definition */
|
||||
struct pp_program;
|
||||
|
||||
/* Less typing later on */
|
||||
typedef void (*pp_func) (struct pp_queue_t *, struct pipe_resource *,
|
||||
struct pipe_resource *, unsigned int);
|
||||
|
||||
typedef void (*pp_st_invalidate_state_func)(struct st_context *st,
|
||||
unsigned flags);
|
||||
|
||||
/* Main functions */
|
||||
|
||||
/**
|
||||
* Note enabled is an array of values, one per filter stage.
|
||||
* Zero indicates the stage is disabled. Non-zero indicates the
|
||||
* stage is enabled. For some stages, the value controls quality.
|
||||
*/
|
||||
struct pp_queue_t *pp_init(struct pipe_context *pipe,
|
||||
const unsigned int *enabled,
|
||||
struct cso_context *,
|
||||
struct st_context *st,
|
||||
pp_st_invalidate_state_func st_invalidate_state);
|
||||
|
||||
void pp_run(struct pp_queue_t *, struct pipe_resource *,
|
||||
struct pipe_resource *, struct pipe_resource *);
|
||||
void pp_free(struct pp_queue_t *);
|
||||
|
||||
void pp_init_fbos(struct pp_queue_t *, unsigned int, unsigned int);
|
||||
|
||||
|
||||
/* The filters */
|
||||
|
||||
void pp_nocolor(struct pp_queue_t *, struct pipe_resource *,
|
||||
struct pipe_resource *, unsigned int);
|
||||
|
||||
void pp_jimenezmlaa(struct pp_queue_t *, struct pipe_resource *,
|
||||
struct pipe_resource *, unsigned int);
|
||||
void pp_jimenezmlaa_color(struct pp_queue_t *, struct pipe_resource *,
|
||||
struct pipe_resource *, unsigned int);
|
||||
|
||||
/* The filter init functions */
|
||||
|
||||
bool pp_celshade_init(struct pp_queue_t *, unsigned int, unsigned int);
|
||||
|
||||
bool pp_nored_init(struct pp_queue_t *, unsigned int, unsigned int);
|
||||
bool pp_nogreen_init(struct pp_queue_t *, unsigned int, unsigned int);
|
||||
bool pp_noblue_init(struct pp_queue_t *, unsigned int, unsigned int);
|
||||
|
||||
bool pp_jimenezmlaa_init(struct pp_queue_t *, unsigned int, unsigned int);
|
||||
bool pp_jimenezmlaa_init_color(struct pp_queue_t *, unsigned int,
|
||||
unsigned int);
|
||||
|
||||
/* The filter free functions */
|
||||
|
||||
void pp_celshade_free(struct pp_queue_t *, unsigned int);
|
||||
void pp_nocolor_free(struct pp_queue_t *, unsigned int);
|
||||
void pp_jimenezmlaa_free(struct pp_queue_t *, unsigned int);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2011 Lauri Kasanen
|
||||
* 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, 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 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 "postprocess/postprocess.h"
|
||||
#include "postprocess/pp_celshade.h"
|
||||
#include "postprocess/pp_filters.h"
|
||||
#include "postprocess/pp_private.h"
|
||||
|
||||
/** Init function */
|
||||
bool
|
||||
pp_celshade_init(struct pp_queue_t *ppq, unsigned int n, unsigned int val)
|
||||
{
|
||||
ppq->shaders[n][1] =
|
||||
pp_tgsi_to_state(ppq->p->pipe, celshade, false, "celshade");
|
||||
|
||||
return (ppq->shaders[n][1] != NULL) ? true : false;
|
||||
}
|
||||
|
||||
/** Free function */
|
||||
void
|
||||
pp_celshade_free(struct pp_queue_t *ppq, unsigned int n)
|
||||
{
|
||||
}
|
||||
|
|
@ -1,79 +0,0 @@
|
|||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2011 Lauri Kasanen
|
||||
* 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, 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 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 CELSHADE_H
|
||||
#define CELSHADE_H
|
||||
|
||||
static const char celshade[] = "FRAG\n"
|
||||
"PROPERTY FS_COLOR0_WRITES_ALL_CBUFS 1\n"
|
||||
"DCL IN[0], GENERIC[0], PERSPECTIVE\n"
|
||||
"DCL OUT[0], COLOR\n"
|
||||
"DCL SAMP[0]\n"
|
||||
"DCL TEMP[0..4]\n"
|
||||
"IMM FLT32 { 0.2126, 0.7152, 0.0722, 4.0000}\n"
|
||||
"IMM FLT32 { 0.5000, 2.0000, 1.0000, -0.1250}\n"
|
||||
"IMM FLT32 { 0.2500, 0.1000, 0.1250, 3.0000}\n"
|
||||
" 0: TEX TEMP[0], IN[0].xyyy, SAMP[0], 2D\n"
|
||||
" 1: DP3 TEMP[1].x, TEMP[0].xyzz, IMM[0]\n"
|
||||
" 2: MUL TEMP[3].x, TEMP[1].xxxx, IMM[0].wwww\n"
|
||||
" 3: ROUND TEMP[2].x, TEMP[3].xxxx\n"
|
||||
" 4: MUL TEMP[3].x, TEMP[2].xxxx, IMM[2].xxxx\n"
|
||||
" 5: MOV TEMP[2].x, TEMP[3].xxxx\n"
|
||||
" 6: ADD TEMP[4].x, TEMP[1].xxxx, -TEMP[3].xxxx\n"
|
||||
" 7: SGT TEMP[1].w, TEMP[4].xxxx, IMM[2].yyyy\n"
|
||||
" 8: IF TEMP[1].wwww :19\n"
|
||||
" 9: ADD TEMP[4].y, TEMP[3].xxxx, IMM[2].yyyy\n"
|
||||
" 10: ADD TEMP[1].z, TEMP[1].xxxx, -TEMP[4].yyyy\n"
|
||||
" 11: ADD TEMP[1].y, TEMP[3].xxxx, IMM[2].zzzz\n"
|
||||
" 12: ADD TEMP[2].x, TEMP[1].yyyy, -TEMP[4].yyyy\n"
|
||||
" 13: RCP TEMP[4].y, TEMP[2].xxxx\n"
|
||||
" 14: MUL TEMP[2].x, TEMP[1].zzzz, TEMP[4].yyyy\n"
|
||||
" 15: MAD TEMP[1].y, -IMM[1].yyyy, TEMP[2].xxxx, IMM[2].wwww\n"
|
||||
" 16: MUL TEMP[1].z, TEMP[2].xxxx, TEMP[1].yyyy\n"
|
||||
" 17: MUL TEMP[1].y, TEMP[2].xxxx, TEMP[1].zzzz\n"
|
||||
" 18: MAD TEMP[2].x, TEMP[1].yyyy, IMM[2].zzzz, TEMP[3].xxxx\n"
|
||||
" 19: ENDIF\n"
|
||||
" 20: SLT TEMP[3].x, TEMP[4].xxxx, -IMM[2].yyyy\n"
|
||||
" 21: IF TEMP[3].xxxx :34\n"
|
||||
" 22: ADD TEMP[3].x, TEMP[2].xxxx, -IMM[2].zzzz\n"
|
||||
" 23: ADD TEMP[4].x, TEMP[1].xxxx, -TEMP[3].xxxx\n"
|
||||
" 24: ADD TEMP[1].x, TEMP[2].xxxx, -IMM[2].yyyy\n"
|
||||
" 25: ADD TEMP[4].y, TEMP[1].xxxx, -TEMP[3].xxxx\n"
|
||||
" 26: RCP TEMP[3].x, TEMP[4].yyyy\n"
|
||||
" 27: MUL TEMP[1].x, TEMP[4].xxxx, TEMP[3].xxxx\n"
|
||||
" 28: MAD TEMP[4].x, -IMM[1].yyyy, TEMP[1].xxxx, IMM[2].wwww\n"
|
||||
" 29: MUL TEMP[3].x, TEMP[1].xxxx, TEMP[4].xxxx\n"
|
||||
" 30: MUL TEMP[4].x, TEMP[1].xxxx, TEMP[3].xxxx\n"
|
||||
" 31: ADD TEMP[3].x, IMM[1].zzzz, -TEMP[4].xxxx\n"
|
||||
" 32: MAD TEMP[1].x, TEMP[3].xxxx, -IMM[2].zzzz, TEMP[2].xxxx\n"
|
||||
" 33: MOV TEMP[2].x, TEMP[1].xxxx\n"
|
||||
" 34: ENDIF\n"
|
||||
" 35: MAD TEMP[1].x, TEMP[2].xxxx, IMM[1].yyyy, IMM[2].yyyy\n"
|
||||
" 36: MUL OUT[0], TEMP[0], TEMP[1].xxxx\n"
|
||||
" 37: END\n";
|
||||
|
||||
#endif
|
||||
|
|
@ -1,95 +0,0 @@
|
|||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2011 Lauri Kasanen
|
||||
* 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, 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 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 "postprocess/postprocess.h"
|
||||
#include "postprocess/pp_colors.h"
|
||||
#include "postprocess/pp_filters.h"
|
||||
#include "postprocess/pp_private.h"
|
||||
|
||||
/** The run function of the color filters */
|
||||
void
|
||||
pp_nocolor(struct pp_queue_t *ppq, struct pipe_resource *in,
|
||||
struct pipe_resource *out, unsigned int n)
|
||||
{
|
||||
|
||||
struct pp_program *p = ppq->p;
|
||||
struct pipe_context *pipe = p->pipe;
|
||||
const struct pipe_sampler_state *samplers[] = {&p->sampler_point};
|
||||
|
||||
pp_filter_setup_in(p, in);
|
||||
pp_filter_setup_out(p, out);
|
||||
|
||||
pp_filter_set_fb(p);
|
||||
pp_filter_misc_state(p);
|
||||
|
||||
cso_set_samplers(p->cso, MESA_SHADER_FRAGMENT, 1, samplers);
|
||||
pipe->set_sampler_views(pipe, MESA_SHADER_FRAGMENT, 0, 1, 0, &p->view);
|
||||
|
||||
cso_set_vertex_shader_handle(p->cso, ppq->shaders[n][0]);
|
||||
cso_set_fragment_shader_handle(p->cso, ppq->shaders[n][1]);
|
||||
|
||||
pp_filter_draw(p);
|
||||
pp_filter_end_pass(p);
|
||||
}
|
||||
|
||||
|
||||
/* Init functions */
|
||||
|
||||
bool
|
||||
pp_nored_init(struct pp_queue_t *ppq, unsigned int n, unsigned int val)
|
||||
{
|
||||
ppq->shaders[n][1] =
|
||||
pp_tgsi_to_state(ppq->p->pipe, nored, false, "nored");
|
||||
|
||||
return (ppq->shaders[n][1] != NULL) ? true : false;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
pp_nogreen_init(struct pp_queue_t *ppq, unsigned int n, unsigned int val)
|
||||
{
|
||||
ppq->shaders[n][1] =
|
||||
pp_tgsi_to_state(ppq->p->pipe, nogreen, false, "nogreen");
|
||||
|
||||
return (ppq->shaders[n][1] != NULL) ? true : false;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
pp_noblue_init(struct pp_queue_t *ppq, unsigned int n, unsigned int val)
|
||||
{
|
||||
ppq->shaders[n][1] =
|
||||
pp_tgsi_to_state(ppq->p->pipe, noblue, false, "noblue");
|
||||
|
||||
return (ppq->shaders[n][1] != NULL) ? true : false;
|
||||
}
|
||||
|
||||
/* Free functions */
|
||||
void
|
||||
pp_nocolor_free(struct pp_queue_t *ppq, unsigned int n)
|
||||
{
|
||||
}
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2011 Lauri Kasanen
|
||||
* 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, 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 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 PP_COLORS_H
|
||||
#define PP_COLORS_H
|
||||
|
||||
static const char nored[] = "FRAG\n"
|
||||
"PROPERTY FS_COLOR0_WRITES_ALL_CBUFS 1\n"
|
||||
"DCL IN[0], GENERIC[0], PERSPECTIVE\n"
|
||||
"DCL OUT[0], COLOR\n"
|
||||
"DCL SAMP[0]\n"
|
||||
"DCL SVIEW[0], 2D, FLOAT\n"
|
||||
"DCL TEMP[0]\n"
|
||||
"IMM FLT32 { 0.0000, 0.0000, 0.0000, 0.0000}\n"
|
||||
" 0: TEX TEMP[0], IN[0].xyyy, SAMP[0], 2D\n"
|
||||
" 1: MOV TEMP[0].x, IMM[0].xxxx\n"
|
||||
" 2: MOV OUT[0], TEMP[0]\n"
|
||||
" 3: END\n";
|
||||
|
||||
|
||||
static const char nogreen[] = "FRAG\n"
|
||||
"PROPERTY FS_COLOR0_WRITES_ALL_CBUFS 1\n"
|
||||
"DCL IN[0], GENERIC[0], PERSPECTIVE\n"
|
||||
"DCL OUT[0], COLOR\n"
|
||||
"DCL SAMP[0]\n"
|
||||
"DCL SVIEW[0], 2D, FLOAT\n"
|
||||
"DCL TEMP[0]\n"
|
||||
"IMM FLT32 { 0.0000, 0.0000, 0.0000, 0.0000}\n"
|
||||
" 0: TEX TEMP[0], IN[0].xyyy, SAMP[0], 2D\n"
|
||||
" 1: MOV TEMP[0].y, IMM[0].xxxx\n"
|
||||
" 2: MOV OUT[0], TEMP[0]\n"
|
||||
" 3: END\n";
|
||||
|
||||
|
||||
static const char noblue[] = "FRAG\n"
|
||||
"PROPERTY FS_COLOR0_WRITES_ALL_CBUFS 1\n"
|
||||
"DCL IN[0], GENERIC[0], PERSPECTIVE\n"
|
||||
"DCL OUT[0], COLOR\n"
|
||||
"DCL SAMP[0]\n"
|
||||
"DCL SVIEW[0], 2D, FLOAT\n"
|
||||
"DCL TEMP[0]\n"
|
||||
"IMM FLT32 { 0.0000, 0.0000, 0.0000, 0.0000}\n"
|
||||
" 0: TEX TEMP[0], IN[0].xyyy, SAMP[0], 2D\n"
|
||||
" 1: MOV TEMP[0].z, IMM[0].xxxx\n"
|
||||
" 2: MOV OUT[0], TEMP[0]\n"
|
||||
" 3: END\n";
|
||||
|
||||
#endif
|
||||
|
|
@ -1,56 +0,0 @@
|
|||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2011 Lauri Kasanen
|
||||
* 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, 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 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 PP_FILTERS_H
|
||||
#define PP_FILTERS_H
|
||||
|
||||
/* Internal include, mainly for the filters */
|
||||
|
||||
#include "cso_cache/cso_context.h"
|
||||
#include "pipe/p_context.h"
|
||||
#include "pipe/p_shader_tokens.h"
|
||||
#include "pipe/p_state.h"
|
||||
#include "util/u_memory.h"
|
||||
#include "util/u_draw_quad.h"
|
||||
|
||||
#define PP_MAX_TOKENS 2048
|
||||
|
||||
|
||||
/* Helper functions for the filters */
|
||||
|
||||
void pp_filter_setup_in(struct pp_program *, struct pipe_resource *);
|
||||
void pp_filter_setup_out(struct pp_program *, struct pipe_resource *);
|
||||
void pp_filter_end_pass(struct pp_program *);
|
||||
void *pp_tgsi_to_state(struct pipe_context *, const char *, bool,
|
||||
const char *);
|
||||
void pp_filter_misc_state(struct pp_program *);
|
||||
void pp_filter_draw(struct pp_program *);
|
||||
void pp_filter_set_fb(struct pp_program *);
|
||||
void pp_filter_set_clear_fb(struct pp_program *);
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -1,345 +0,0 @@
|
|||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2011 Lauri Kasanen
|
||||
* 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, 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 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 "util/compiler.h"
|
||||
|
||||
#include "postprocess/filters.h"
|
||||
#include "postprocess/pp_private.h"
|
||||
|
||||
#include "pipe/p_screen.h"
|
||||
#include "util/u_inlines.h"
|
||||
#include "util/u_math.h"
|
||||
#include "util/u_debug.h"
|
||||
#include "util/u_memory.h"
|
||||
#include "cso_cache/cso_context.h"
|
||||
|
||||
const struct pp_filter_t pp_filters[PP_FILTERS] = {
|
||||
/* name inner shaders verts init run free */
|
||||
{ "pp_noblue", 0, 2, 1, pp_noblue_init, pp_nocolor, pp_nocolor_free },
|
||||
{ "pp_nogreen", 0, 2, 1, pp_nogreen_init, pp_nocolor, pp_nocolor_free },
|
||||
{ "pp_nored", 0, 2, 1, pp_nored_init, pp_nocolor, pp_nocolor_free },
|
||||
{ "pp_celshade", 0, 2, 1, pp_celshade_init, pp_nocolor, pp_celshade_free },
|
||||
{ "pp_jimenezmlaa", 2, 5, 2, pp_jimenezmlaa_init, pp_jimenezmlaa, pp_jimenezmlaa_free },
|
||||
{ "pp_jimenezmlaa_color", 2, 5, 2, pp_jimenezmlaa_init_color, pp_jimenezmlaa_color, pp_jimenezmlaa_free },
|
||||
};
|
||||
|
||||
/** Initialize the post-processing queue. */
|
||||
struct pp_queue_t *
|
||||
pp_init(struct pipe_context *pipe, const unsigned int *enabled,
|
||||
struct cso_context *cso, struct st_context *st,
|
||||
pp_st_invalidate_state_func st_invalidate_state)
|
||||
{
|
||||
unsigned int num_filters = 0;
|
||||
unsigned int curpos = 0, i, tmp_req = 0;
|
||||
struct pp_queue_t *ppq;
|
||||
|
||||
pp_debug("Initializing the post-processing queue.\n");
|
||||
|
||||
/* How many filters were requested? */
|
||||
for (i = 0; i < PP_FILTERS; i++) {
|
||||
if (enabled[i])
|
||||
num_filters++;
|
||||
}
|
||||
if (num_filters == 0)
|
||||
return NULL;
|
||||
|
||||
ppq = CALLOC(1, sizeof(struct pp_queue_t));
|
||||
|
||||
if (!ppq) {
|
||||
pp_debug("Unable to allocate memory for ppq.\n");
|
||||
goto error;
|
||||
}
|
||||
|
||||
ppq->pp_queue = CALLOC(num_filters, sizeof(pp_func));
|
||||
if (ppq->pp_queue == NULL) {
|
||||
pp_debug("Unable to allocate memory for pp_queue.\n");
|
||||
goto error;
|
||||
}
|
||||
|
||||
ppq->shaders = CALLOC(num_filters, sizeof(void *));
|
||||
ppq->filters = CALLOC(num_filters, sizeof(unsigned int));
|
||||
|
||||
if ((ppq->shaders == NULL) ||
|
||||
(ppq->filters == NULL)) {
|
||||
pp_debug("Unable to allocate memory for shaders and filter arrays.\n");
|
||||
goto error;
|
||||
}
|
||||
|
||||
ppq->p = pp_init_prog(ppq, pipe, cso, st, st_invalidate_state);
|
||||
if (ppq->p == NULL) {
|
||||
pp_debug("pp_init_prog returned NULL.\n");
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* Add the enabled filters to the queue, in order */
|
||||
curpos = 0;
|
||||
for (i = 0; i < PP_FILTERS; i++) {
|
||||
if (enabled[i]) {
|
||||
ppq->pp_queue[curpos] = pp_filters[i].main;
|
||||
tmp_req = MAX2(tmp_req, pp_filters[i].inner_tmps);
|
||||
ppq->filters[curpos] = i;
|
||||
|
||||
if (pp_filters[i].shaders) {
|
||||
ppq->shaders[curpos] =
|
||||
CALLOC(pp_filters[i].shaders + 1, sizeof(void *));
|
||||
if (!ppq->shaders[curpos]) {
|
||||
pp_debug("Unable to allocate memory for shader list.\n");
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
/* Call the initialization function for the filter. */
|
||||
if (!pp_filters[i].init(ppq, curpos, enabled[i])) {
|
||||
pp_debug("Initialization for filter %u failed.\n", i);
|
||||
goto error;
|
||||
}
|
||||
|
||||
curpos++;
|
||||
}
|
||||
}
|
||||
|
||||
ppq->n_filters = curpos;
|
||||
ppq->n_tmp = (curpos > 2 ? 2 : 1);
|
||||
ppq->n_inner_tmp = tmp_req;
|
||||
|
||||
ppq->fbos_init = false;
|
||||
|
||||
for (i = 0; i < curpos; i++)
|
||||
ppq->shaders[i][0] = ppq->p->passvs;
|
||||
|
||||
pp_debug("Queue successfully allocated. %u filter(s).\n", curpos);
|
||||
|
||||
return ppq;
|
||||
|
||||
error:
|
||||
|
||||
if (ppq) {
|
||||
/* Assign curpos, since we only need to destroy initialized filters. */
|
||||
ppq->n_filters = curpos;
|
||||
|
||||
/* Call the common free function which must handle partial initialization. */
|
||||
pp_free(ppq);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/** Free any allocated FBOs (temp buffers). Called after resizing for example. */
|
||||
void
|
||||
pp_free_fbos(struct pp_queue_t *ppq)
|
||||
{
|
||||
|
||||
unsigned int i;
|
||||
|
||||
if (!ppq->fbos_init)
|
||||
return;
|
||||
|
||||
for (i = 0; i < ppq->n_tmp; i++) {
|
||||
pipe_resource_reference(&ppq->tmp[i], NULL);
|
||||
}
|
||||
for (i = 0; i < ppq->n_inner_tmp; i++) {
|
||||
pipe_resource_reference(&ppq->inner_tmp[i], NULL);
|
||||
}
|
||||
pipe_resource_reference(&ppq->stencil, NULL);
|
||||
|
||||
ppq->fbos_init = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Free the pp queue. Called on context termination and failure in
|
||||
* pp_init.
|
||||
*/
|
||||
void
|
||||
pp_free(struct pp_queue_t *ppq)
|
||||
{
|
||||
unsigned int i, j;
|
||||
|
||||
if (!ppq)
|
||||
return;
|
||||
|
||||
pp_free_fbos(ppq);
|
||||
|
||||
if (ppq->p) {
|
||||
if (ppq->p->pipe && ppq->filters && ppq->shaders) {
|
||||
for (i = 0; i < ppq->n_filters; i++) {
|
||||
unsigned int filter = ppq->filters[i];
|
||||
|
||||
if (ppq->shaders[i] == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Common shader destruction code for all postprocessing
|
||||
* filters.
|
||||
*/
|
||||
for (j = 0; j < pp_filters[filter].shaders; j++) {
|
||||
if (ppq->shaders[i][j] == NULL) {
|
||||
/* We reached the end of initialized shaders. */
|
||||
break;
|
||||
}
|
||||
|
||||
if (ppq->shaders[i][j] == ppq->p->passvs) {
|
||||
continue;
|
||||
}
|
||||
|
||||
assert(ppq);
|
||||
assert(ppq->p);
|
||||
assert(ppq->p->pipe);
|
||||
|
||||
if (j >= pp_filters[filter].verts) {
|
||||
assert(ppq->p->pipe->delete_fs_state);
|
||||
ppq->p->pipe->delete_fs_state(ppq->p->pipe,
|
||||
ppq->shaders[i][j]);
|
||||
ppq->shaders[i][j] = NULL;
|
||||
} else {
|
||||
assert(ppq->p->pipe->delete_vs_state);
|
||||
ppq->p->pipe->delete_vs_state(ppq->p->pipe,
|
||||
ppq->shaders[i][j]);
|
||||
ppq->shaders[i][j] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Finally call each filter type's free functionality. */
|
||||
pp_filters[filter].free(ppq, i);
|
||||
}
|
||||
}
|
||||
|
||||
FREE(ppq->p);
|
||||
}
|
||||
|
||||
/*
|
||||
* Handle partial initialization for common resource destruction
|
||||
* in the create path.
|
||||
*/
|
||||
FREE(ppq->filters);
|
||||
FREE(ppq->shaders);
|
||||
FREE(ppq->pp_queue);
|
||||
|
||||
FREE(ppq);
|
||||
|
||||
pp_debug("Queue taken down.\n");
|
||||
}
|
||||
|
||||
/** Internal debug function. Should be available to final users. */
|
||||
void
|
||||
pp_debug(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
if (!debug_get_bool_option("PP_DEBUG", false))
|
||||
return;
|
||||
|
||||
va_start(ap, fmt);
|
||||
_debug_vprintf(fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
/** Allocate the temp FBOs. Called on makecurrent and resize. */
|
||||
void
|
||||
pp_init_fbos(struct pp_queue_t *ppq, unsigned int w,
|
||||
unsigned int h)
|
||||
{
|
||||
|
||||
struct pp_program *p = ppq->p; /* The lazy will inherit the earth */
|
||||
|
||||
unsigned int i;
|
||||
struct pipe_resource tmp_res;
|
||||
|
||||
if (ppq->fbos_init)
|
||||
return;
|
||||
|
||||
pp_debug("Initializing FBOs, size %ux%u\n", w, h);
|
||||
pp_debug("Requesting %u temps and %u inner temps\n", ppq->n_tmp,
|
||||
ppq->n_inner_tmp);
|
||||
|
||||
memset(&tmp_res, 0, sizeof(tmp_res));
|
||||
tmp_res.target = PIPE_TEXTURE_2D;
|
||||
tmp_res.format = p->surf.format = PIPE_FORMAT_B8G8R8A8_UNORM;
|
||||
tmp_res.width0 = w;
|
||||
tmp_res.height0 = h;
|
||||
tmp_res.depth0 = 1;
|
||||
tmp_res.array_size = 1;
|
||||
tmp_res.last_level = 0;
|
||||
tmp_res.bind = PIPE_BIND_RENDER_TARGET;
|
||||
|
||||
if (!p->screen->is_format_supported(p->screen, tmp_res.format,
|
||||
tmp_res.target, 1, 1, tmp_res.bind))
|
||||
pp_debug("Temp buffers' format fail\n");
|
||||
|
||||
for (i = 0; i < ppq->n_tmp; i++) {
|
||||
ppq->tmp[i] = p->screen->resource_create(p->screen, &tmp_res);
|
||||
ppq->tmps[i] = p->surf;
|
||||
ppq->tmps[i].texture = ppq->tmp[i];
|
||||
|
||||
if (!ppq->tmp[i])
|
||||
goto error;
|
||||
}
|
||||
|
||||
for (i = 0; i < ppq->n_inner_tmp; i++) {
|
||||
ppq->inner_tmp[i] = p->screen->resource_create(p->screen, &tmp_res);
|
||||
ppq->inner_tmps[i] = p->surf;
|
||||
ppq->inner_tmps[i].texture = ppq->inner_tmp[i];
|
||||
if (!ppq->inner_tmp[i])
|
||||
goto error;
|
||||
}
|
||||
|
||||
tmp_res.bind = PIPE_BIND_DEPTH_STENCIL;
|
||||
|
||||
tmp_res.format = p->surf.format = PIPE_FORMAT_S8_UINT_Z24_UNORM;
|
||||
|
||||
if (!p->screen->is_format_supported(p->screen, tmp_res.format,
|
||||
tmp_res.target, 1, 1, tmp_res.bind)) {
|
||||
|
||||
tmp_res.format = p->surf.format = PIPE_FORMAT_Z24_UNORM_S8_UINT;
|
||||
|
||||
if (!p->screen->is_format_supported(p->screen, tmp_res.format,
|
||||
tmp_res.target, 1, 1, tmp_res.bind))
|
||||
pp_debug("Temp Sbuffer format fail\n");
|
||||
}
|
||||
|
||||
ppq->stencil = p->screen->resource_create(p->screen, &tmp_res);
|
||||
ppq->stencils = p->surf;
|
||||
if (!ppq->stencil)
|
||||
goto error;
|
||||
|
||||
p->framebuffer.width = w;
|
||||
p->framebuffer.height = h;
|
||||
|
||||
p->viewport.scale[0] = p->viewport.translate[0] = (float) w / 2.0f;
|
||||
p->viewport.scale[1] = p->viewport.translate[1] = (float) h / 2.0f;
|
||||
p->viewport.swizzle_x = PIPE_VIEWPORT_SWIZZLE_POSITIVE_X;
|
||||
p->viewport.swizzle_y = PIPE_VIEWPORT_SWIZZLE_POSITIVE_Y;
|
||||
p->viewport.swizzle_z = PIPE_VIEWPORT_SWIZZLE_POSITIVE_Z;
|
||||
p->viewport.swizzle_w = PIPE_VIEWPORT_SWIZZLE_POSITIVE_W;
|
||||
|
||||
ppq->fbos_init = true;
|
||||
|
||||
return;
|
||||
|
||||
error:
|
||||
pp_debug("Failed to allocate temp buffers!\n");
|
||||
}
|
||||
|
|
@ -1,345 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2010 Jorge Jimenez (jorge@iryoku.com)
|
||||
* Copyright (C) 2010 Belen Masia (bmasia@unizar.es)
|
||||
* Copyright (C) 2010 Jose I. Echevarria (joseignacioechevarria@gmail.com)
|
||||
* Copyright (C) 2010 Fernando Navarro (fernandn@microsoft.com)
|
||||
* Copyright (C) 2010 Diego Gutierrez (diegog@unizar.es)
|
||||
* Copyright (C) 2011 Lauri Kasanen (cand@gmx.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the following statement:
|
||||
*
|
||||
* "Uses Jimenez's MLAA. Copyright (C) 2010 by Jorge Jimenez, Belen Masia,
|
||||
* Jose I. Echevarria, Fernando Navarro and Diego Gutierrez."
|
||||
*
|
||||
* Only for use in the Mesa project, this point 2 is filled by naming the
|
||||
* technique Jimenez's MLAA in the Mesa config options.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
|
||||
* IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are
|
||||
* those of the authors and should not be interpreted as representing official
|
||||
* policies, either expressed or implied, of the copyright holders.
|
||||
*/
|
||||
|
||||
#include "util/compiler.h"
|
||||
|
||||
#include "postprocess/postprocess.h"
|
||||
#include "postprocess/pp_mlaa.h"
|
||||
#include "postprocess/pp_filters.h"
|
||||
#include "postprocess/pp_private.h"
|
||||
|
||||
#include "util/box.h"
|
||||
#include "util/u_sampler.h"
|
||||
#include "util/u_inlines.h"
|
||||
#include "util/u_memory.h"
|
||||
#include "util/u_string.h"
|
||||
#include "pipe/p_screen.h"
|
||||
|
||||
#define IMM_SPACE 80
|
||||
|
||||
static float constants[] = { 1, 1, 0, 0 };
|
||||
static unsigned int dimensions[2] = { 0, 0 };
|
||||
|
||||
/** Run function of the MLAA filter. */
|
||||
static void
|
||||
pp_jimenezmlaa_run(struct pp_queue_t *ppq, struct pipe_resource *in,
|
||||
struct pipe_resource *out, unsigned int n, bool iscolor)
|
||||
{
|
||||
|
||||
struct pp_program *p = ppq->p;
|
||||
|
||||
struct pipe_depth_stencil_alpha_state mstencil;
|
||||
struct pipe_sampler_view v_tmp, *tmp_a, *tmp_b, *arr[3];
|
||||
|
||||
unsigned int w = 0;
|
||||
unsigned int h = 0;
|
||||
|
||||
const struct pipe_stencil_ref ref = { {1} };
|
||||
|
||||
struct pipe_resource *releasebuf[2] = { 0 };
|
||||
|
||||
/* Insufficient initialization checks. */
|
||||
assert(p);
|
||||
assert(ppq);
|
||||
assert(ppq->areamaptex);
|
||||
assert(ppq->inner_tmp);
|
||||
assert(ppq->shaders[n]);
|
||||
|
||||
w = p->framebuffer.width;
|
||||
h = p->framebuffer.height;
|
||||
|
||||
memset(&mstencil, 0, sizeof(mstencil));
|
||||
|
||||
cso_set_stencil_ref(p->cso, ref);
|
||||
|
||||
/* Init the pixel size constant */
|
||||
if (dimensions[0] != p->framebuffer.width ||
|
||||
dimensions[1] != p->framebuffer.height) {
|
||||
constants[0] = 1.0f / p->framebuffer.width;
|
||||
constants[1] = 1.0f / p->framebuffer.height;
|
||||
|
||||
dimensions[0] = p->framebuffer.width;
|
||||
dimensions[1] = p->framebuffer.height;
|
||||
}
|
||||
|
||||
struct pipe_constant_buffer cb;
|
||||
cb.buffer = NULL;
|
||||
cb.buffer_offset = 0;
|
||||
cb.buffer_size = sizeof(constants);
|
||||
cb.user_buffer = constants;
|
||||
|
||||
struct pipe_context *pipe = ppq->p->pipe;
|
||||
pipe_upload_constant_buffer0(pipe, MESA_SHADER_VERTEX, &cb, &releasebuf[0]);
|
||||
pipe_upload_constant_buffer0(pipe, MESA_SHADER_FRAGMENT, &cb, &releasebuf[1]);
|
||||
|
||||
mstencil.stencil[0].enabled = 1;
|
||||
mstencil.stencil[0].valuemask = mstencil.stencil[0].writemask = ~0;
|
||||
mstencil.stencil[0].func = PIPE_FUNC_ALWAYS;
|
||||
mstencil.stencil[0].fail_op = PIPE_STENCIL_OP_KEEP;
|
||||
mstencil.stencil[0].zfail_op = PIPE_STENCIL_OP_KEEP;
|
||||
mstencil.stencil[0].zpass_op = PIPE_STENCIL_OP_REPLACE;
|
||||
|
||||
p->framebuffer.zsbuf = ppq->stencils;
|
||||
|
||||
/* First pass: depth edge detection */
|
||||
if (iscolor)
|
||||
pp_filter_setup_in(p, in);
|
||||
else
|
||||
pp_filter_setup_in(p, ppq->depth);
|
||||
|
||||
pp_filter_setup_out(p, ppq->inner_tmp[0]);
|
||||
|
||||
pp_filter_set_fb(p);
|
||||
pp_filter_misc_state(p);
|
||||
cso_set_depth_stencil_alpha(p->cso, &mstencil);
|
||||
p->pipe->clear(p->pipe, PIPE_CLEAR_STENCIL | PIPE_CLEAR_COLOR0, 0xf, 0xff, NULL,
|
||||
&p->clear_color, 0, 0);
|
||||
|
||||
{
|
||||
const struct pipe_sampler_state *samplers[] = {&p->sampler_point};
|
||||
cso_set_samplers(p->cso, MESA_SHADER_FRAGMENT, 1, samplers);
|
||||
}
|
||||
pipe->set_sampler_views(pipe, MESA_SHADER_FRAGMENT, 0, 1, 0, &p->view);
|
||||
|
||||
cso_set_vertex_shader_handle(p->cso, ppq->shaders[n][1]); /* offsetvs */
|
||||
cso_set_fragment_shader_handle(p->cso, ppq->shaders[n][2]);
|
||||
|
||||
pp_filter_draw(p);
|
||||
pp_filter_end_pass(p);
|
||||
|
||||
|
||||
/* Second pass: blend weights */
|
||||
/* Sampler order: areamap, edgesmap, edgesmapL (reversed, thx compiler) */
|
||||
mstencil.stencil[0].func = PIPE_FUNC_EQUAL;
|
||||
mstencil.stencil[0].zpass_op = PIPE_STENCIL_OP_KEEP;
|
||||
cso_set_depth_stencil_alpha(p->cso, &mstencil);
|
||||
|
||||
pp_filter_setup_in(p, ppq->areamaptex);
|
||||
pp_filter_setup_out(p, ppq->inner_tmp[1]);
|
||||
|
||||
u_sampler_view_default_template(&v_tmp, ppq->inner_tmp[0],
|
||||
ppq->inner_tmp[0]->format);
|
||||
arr[1] = arr[2] = tmp_a =
|
||||
p->pipe->create_sampler_view(p->pipe, ppq->inner_tmp[0], &v_tmp);
|
||||
|
||||
pp_filter_set_clear_fb(p);
|
||||
|
||||
{
|
||||
const struct pipe_sampler_state *samplers[] =
|
||||
{&p->sampler_point, &p->sampler_point, &p->sampler};
|
||||
cso_set_samplers(p->cso, MESA_SHADER_FRAGMENT, 3, samplers);
|
||||
}
|
||||
|
||||
arr[0] = p->view;
|
||||
pipe->set_sampler_views(pipe, MESA_SHADER_FRAGMENT, 0, 3, 0, arr);
|
||||
|
||||
cso_set_vertex_shader_handle(p->cso, ppq->shaders[n][0]); /* passvs */
|
||||
cso_set_fragment_shader_handle(p->cso, ppq->shaders[n][3]);
|
||||
|
||||
pp_filter_draw(p);
|
||||
pp_filter_end_pass(p);
|
||||
|
||||
|
||||
/* Third pass: smoothed edges */
|
||||
/* Sampler order: colormap, blendmap (wtf compiler) */
|
||||
pp_filter_setup_in(p, ppq->inner_tmp[1]);
|
||||
pp_filter_setup_out(p, out);
|
||||
|
||||
pp_filter_set_fb(p);
|
||||
|
||||
/* Blit the input to the output */
|
||||
pp_blit(p->pipe, in, 0, 0,
|
||||
w, h, 0, &p->framebuffer.cbufs[0],
|
||||
0, 0, w, h);
|
||||
|
||||
u_sampler_view_default_template(&v_tmp, in, in->format);
|
||||
arr[0] = tmp_b = p->pipe->create_sampler_view(p->pipe, in, &v_tmp);
|
||||
|
||||
{
|
||||
const struct pipe_sampler_state *samplers[] =
|
||||
{&p->sampler_point, &p->sampler_point};
|
||||
cso_set_samplers(p->cso, MESA_SHADER_FRAGMENT, 2, samplers);
|
||||
}
|
||||
|
||||
arr[1] = p->view;
|
||||
pipe->set_sampler_views(pipe, MESA_SHADER_FRAGMENT, 0, 2, 0, arr);
|
||||
|
||||
cso_set_vertex_shader_handle(p->cso, ppq->shaders[n][1]); /* offsetvs */
|
||||
cso_set_fragment_shader_handle(p->cso, ppq->shaders[n][4]);
|
||||
|
||||
p->blend.rt[0].blend_enable = 1;
|
||||
cso_set_blend(p->cso, &p->blend);
|
||||
|
||||
pp_filter_draw(p);
|
||||
pp_filter_end_pass(p);
|
||||
pipe->sampler_view_release(pipe, tmp_a);
|
||||
pipe->sampler_view_release(pipe, tmp_b);
|
||||
|
||||
p->blend.rt[0].blend_enable = 0;
|
||||
memset(&p->framebuffer.zsbuf, 0, sizeof(p->framebuffer.zsbuf));
|
||||
|
||||
pipe_resource_release(pipe, releasebuf[1]);
|
||||
pipe_resource_release(pipe, releasebuf[0]);
|
||||
}
|
||||
|
||||
/** The init function of the MLAA filter. */
|
||||
static bool
|
||||
pp_jimenezmlaa_init_run(struct pp_queue_t *ppq, unsigned int n,
|
||||
unsigned int val, bool iscolor)
|
||||
{
|
||||
|
||||
struct pipe_box box;
|
||||
struct pipe_resource res;
|
||||
char *tmp_text = NULL;
|
||||
|
||||
tmp_text = CALLOC(sizeof(blend2fs_1) + sizeof(blend2fs_2) +
|
||||
IMM_SPACE, sizeof(char));
|
||||
|
||||
if (!tmp_text) {
|
||||
pp_debug("Failed to allocate shader space\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
pp_debug("mlaa: using %u max search steps\n", val);
|
||||
|
||||
sprintf(tmp_text, "%s"
|
||||
"IMM FLT32 { %.8f, 0.0000, 0.0000, 0.0000}\n"
|
||||
"%s\n", blend2fs_1, (float) val, blend2fs_2);
|
||||
|
||||
memset(&res, 0, sizeof(res));
|
||||
|
||||
res.target = PIPE_TEXTURE_2D;
|
||||
res.format = PIPE_FORMAT_R8G8_UNORM;
|
||||
res.width0 = res.height0 = 165;
|
||||
res.bind = PIPE_BIND_SAMPLER_VIEW;
|
||||
res.usage = PIPE_USAGE_DEFAULT;
|
||||
res.depth0 = res.array_size = res.nr_samples = res.nr_storage_samples = 1;
|
||||
|
||||
if (!ppq->p->screen->is_format_supported(ppq->p->screen, res.format,
|
||||
res.target, 1, 1, res.bind))
|
||||
pp_debug("Areamap format not supported\n");
|
||||
|
||||
ppq->areamaptex = ppq->p->screen->resource_create(ppq->p->screen, &res);
|
||||
|
||||
if (ppq->areamaptex == NULL) {
|
||||
pp_debug("Failed to allocate area map texture\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
u_box_2d(0, 0, 165, 165, &box);
|
||||
|
||||
ppq->p->pipe->texture_subdata(ppq->p->pipe, ppq->areamaptex, 0,
|
||||
PIPE_MAP_WRITE, &box,
|
||||
areamap, 165 * 2, sizeof(areamap));
|
||||
|
||||
ppq->shaders[n][1] = pp_tgsi_to_state(ppq->p->pipe, offsetvs, true,
|
||||
"offsetvs");
|
||||
if (iscolor)
|
||||
ppq->shaders[n][2] = pp_tgsi_to_state(ppq->p->pipe, color1fs,
|
||||
false, "color1fs");
|
||||
else
|
||||
ppq->shaders[n][2] = pp_tgsi_to_state(ppq->p->pipe, depth1fs,
|
||||
false, "depth1fs");
|
||||
ppq->shaders[n][3] = pp_tgsi_to_state(ppq->p->pipe, tmp_text, false,
|
||||
"blend2fs");
|
||||
ppq->shaders[n][4] = pp_tgsi_to_state(ppq->p->pipe, neigh3fs, false,
|
||||
"neigh3fs");
|
||||
|
||||
FREE(tmp_text);
|
||||
|
||||
return true;
|
||||
|
||||
fail:
|
||||
|
||||
FREE(tmp_text);
|
||||
|
||||
/*
|
||||
* Call the common free function for destruction of partially initialized
|
||||
* resources.
|
||||
*/
|
||||
pp_jimenezmlaa_free(ppq, n);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Short wrapper to init the depth version. */
|
||||
bool
|
||||
pp_jimenezmlaa_init(struct pp_queue_t *ppq, unsigned int n, unsigned int val)
|
||||
{
|
||||
return pp_jimenezmlaa_init_run(ppq, n, val, false);
|
||||
}
|
||||
|
||||
/** Short wrapper to init the color version. */
|
||||
bool
|
||||
pp_jimenezmlaa_init_color(struct pp_queue_t *ppq, unsigned int n,
|
||||
unsigned int val)
|
||||
{
|
||||
return pp_jimenezmlaa_init_run(ppq, n, val, true);
|
||||
}
|
||||
|
||||
/** Short wrapper to run the depth version. */
|
||||
void
|
||||
pp_jimenezmlaa(struct pp_queue_t *ppq, struct pipe_resource *in,
|
||||
struct pipe_resource *out, unsigned int n)
|
||||
{
|
||||
if (!ppq->depth) {
|
||||
return;
|
||||
}
|
||||
pp_jimenezmlaa_run(ppq, in, out, n, false);
|
||||
}
|
||||
|
||||
/** Short wrapper to run the color version. */
|
||||
void
|
||||
pp_jimenezmlaa_color(struct pp_queue_t *ppq, struct pipe_resource *in,
|
||||
struct pipe_resource *out, unsigned int n)
|
||||
{
|
||||
pp_jimenezmlaa_run(ppq, in, out, n, true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Short wrapper to free the mlaa filter resources. Shaders are freed in
|
||||
* the common code in pp_free.
|
||||
*/
|
||||
void
|
||||
pp_jimenezmlaa_free(struct pp_queue_t *ppq, unsigned int n)
|
||||
{
|
||||
pipe_resource_reference(&ppq->areamaptex, NULL);
|
||||
}
|
||||
|
|
@ -1,348 +0,0 @@
|
|||
/**
|
||||
* Copyright (C) 2010 Jorge Jimenez (jorge@iryoku.com)
|
||||
* Copyright (C) 2010 Belen Masia (bmasia@unizar.es)
|
||||
* Copyright (C) 2010 Jose I. Echevarria (joseignacioechevarria@gmail.com)
|
||||
* Copyright (C) 2010 Fernando Navarro (fernandn@microsoft.com)
|
||||
* Copyright (C) 2010 Diego Gutierrez (diegog@unizar.es)
|
||||
* Copyright (C) 2011 Lauri Kasanen (cand@gmx.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the following statement:
|
||||
*
|
||||
* "Uses Jimenez's MLAA. Copyright (C) 2010 by Jorge Jimenez, Belen Masia,
|
||||
* Jose I. Echevarria, Fernando Navarro and Diego Gutierrez."
|
||||
*
|
||||
* Only for use in the Mesa project, this point 2 is filled by naming the
|
||||
* technique Jimenez's MLAA in the Mesa config options.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
|
||||
* IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are
|
||||
* those of the authors and should not be interpreted as representing official
|
||||
* policies, either expressed or implied, of the copyright holders.
|
||||
*/
|
||||
|
||||
#ifndef PP_MLAA_H
|
||||
#define PP_MLAA_H
|
||||
|
||||
#include "postprocess/pp_mlaa_areamap.h"
|
||||
|
||||
static const char depth1fs[] = "FRAG\n"
|
||||
"PROPERTY FS_COLOR0_WRITES_ALL_CBUFS 1\n"
|
||||
"DCL IN[0], GENERIC[0], PERSPECTIVE\n"
|
||||
"DCL IN[1], GENERIC[10], PERSPECTIVE\n"
|
||||
"DCL IN[2], GENERIC[11], PERSPECTIVE\n"
|
||||
"DCL OUT[0], COLOR\n"
|
||||
"DCL SAMP[0]\n"
|
||||
"DCL SVIEW[0], 2D, FLOAT\n"
|
||||
"DCL TEMP[0..2]\n"
|
||||
"IMM FLT32 { 0.0030, 0.0000, 1.0000, 0.0000}\n"
|
||||
" 0: TEX TEMP[0].x, IN[1].xyyy, SAMP[0], 2D\n"
|
||||
" 1: MOV TEMP[1].x, TEMP[0].xxxx\n"
|
||||
" 2: TEX TEMP[0].x, IN[1].zwww, SAMP[0], 2D\n"
|
||||
" 3: MOV TEMP[1].y, TEMP[0].xxxx\n"
|
||||
" 4: TEX TEMP[0].x, IN[2].xyyy, SAMP[0], 2D\n"
|
||||
" 5: MOV TEMP[1].z, TEMP[0].xxxx\n"
|
||||
" 6: TEX TEMP[0].x, IN[2].zwww, SAMP[0], 2D\n"
|
||||
" 7: MOV TEMP[1].w, TEMP[0].xxxx\n"
|
||||
" 8: TEX TEMP[0].x, IN[0].xyyy, SAMP[0], 2D\n"
|
||||
" 9: ADD TEMP[2], TEMP[0].xxxx, -TEMP[1]\n"
|
||||
" 10: MOV TEMP[0], |TEMP[2]|\n"
|
||||
" 11: SGE TEMP[2], TEMP[0], IMM[0].xxxx\n"
|
||||
" 12: DP4 TEMP[0].x, TEMP[2], IMM[0].zzzz\n"
|
||||
" 13: SEQ TEMP[1].x, TEMP[0].xxxx, IMM[0].yyyy\n"
|
||||
" 14: IF TEMP[1].xxxx :16\n"
|
||||
" 15: KILL\n"
|
||||
" 16: ENDIF\n"
|
||||
" 17: MOV OUT[0], TEMP[2]\n"
|
||||
" 18: END\n";
|
||||
|
||||
|
||||
static const char color1fs[] = "FRAG\n"
|
||||
"PROPERTY FS_COLOR0_WRITES_ALL_CBUFS 1\n"
|
||||
"DCL IN[0], GENERIC[0], PERSPECTIVE\n"
|
||||
"DCL IN[1], GENERIC[10], PERSPECTIVE\n"
|
||||
"DCL IN[2], GENERIC[11], PERSPECTIVE\n"
|
||||
"DCL OUT[0], COLOR\n"
|
||||
"DCL SAMP[0]\n"
|
||||
"DCL SVIEW[0], 2D, FLOAT\n"
|
||||
"DCL TEMP[0..2]\n"
|
||||
"IMM FLT32 { 0.2126, 0.7152, 0.0722, 0.1000}\n"
|
||||
"IMM FLT32 { 1.0000, 0.0000, 0.0000, 0.0000}\n"
|
||||
" 0: TEX TEMP[1].xyz, IN[1].xyyy, SAMP[0], 2D\n"
|
||||
" 1: DP3 TEMP[0].x, TEMP[1].xyzz, IMM[0]\n"
|
||||
" 2: TEX TEMP[1].xyz, IN[1].zwww, SAMP[0], 2D\n"
|
||||
" 3: DP3 TEMP[0].y, TEMP[1].xyzz, IMM[0].xyzz\n"
|
||||
" 4: TEX TEMP[1].xyz, IN[2].xyyy, SAMP[0], 2D\n"
|
||||
" 5: DP3 TEMP[0].z, TEMP[1].xyzz, IMM[0].xyzz\n"
|
||||
" 6: TEX TEMP[1].xyz, IN[2].zwww, SAMP[0], 2D\n"
|
||||
" 7: DP3 TEMP[0].w, TEMP[1].xyzz, IMM[0].xyzz\n"
|
||||
" 8: TEX TEMP[1].xyz, IN[0].xyyy, SAMP[0], 2D\n"
|
||||
" 9: DP3 TEMP[2].x, TEMP[1].xyzz, IMM[0].xyzz\n"
|
||||
" 10: ADD TEMP[1], TEMP[2].xxxx, -TEMP[0]\n"
|
||||
" 11: MOV TEMP[0], |TEMP[1]|\n"
|
||||
" 12: SGE TEMP[2], TEMP[0], IMM[0].wwww\n"
|
||||
" 13: DP4 TEMP[0].x, TEMP[2], IMM[1].xxxx\n"
|
||||
" 14: SEQ TEMP[1].x, TEMP[0].xxxx, IMM[1].yyyy\n"
|
||||
" 15: IF TEMP[1].xxxx :17\n"
|
||||
" 16: KILL\n"
|
||||
" 17: ENDIF\n"
|
||||
" 18: MOV OUT[0], TEMP[2]\n"
|
||||
" 19: END\n";
|
||||
|
||||
|
||||
static const char neigh3fs[] = "FRAG\n"
|
||||
"PROPERTY FS_COLOR0_WRITES_ALL_CBUFS 1\n"
|
||||
"DCL IN[0], GENERIC[0], PERSPECTIVE\n"
|
||||
"DCL IN[1], GENERIC[10], PERSPECTIVE\n"
|
||||
"DCL IN[2], GENERIC[11], PERSPECTIVE\n"
|
||||
"DCL OUT[0], COLOR\n"
|
||||
"DCL SAMP[0]\n"
|
||||
"DCL SVIEW[0], 2D, FLOAT\n"
|
||||
"DCL SAMP[1]\n"
|
||||
"DCL TEMP[0..8]\n"
|
||||
"IMM FLT32 { 1.0000, 0.00001, 0.0000, 0.0000}\n"
|
||||
" 0: TEX TEMP[0], IN[0].xyyy, SAMP[1], 2D\n"
|
||||
" 1: MOV TEMP[1].x, TEMP[0].xxxx\n"
|
||||
" 2: TEX TEMP[2].y, IN[2].zwww, SAMP[1], 2D\n"
|
||||
" 3: MOV TEMP[1].y, TEMP[2].yyyy\n"
|
||||
" 4: MOV TEMP[1].z, TEMP[0].zzzz\n"
|
||||
" 5: TEX TEMP[1].w, IN[2].xyyy, SAMP[1], 2D\n"
|
||||
" 6: MUL TEMP[4], TEMP[1], TEMP[1]\n"
|
||||
" 7: MUL TEMP[5], TEMP[4], TEMP[1]\n"
|
||||
" 8: DP4 TEMP[1].x, TEMP[5], IMM[0].xxxx\n"
|
||||
" 9: SLT TEMP[4].x, TEMP[1].xxxx, IMM[0].yyyy\n"
|
||||
" 10: IF TEMP[4].xxxx :12\n"
|
||||
" 11: KILL\n"
|
||||
" 12: ENDIF\n"
|
||||
" 13: TEX TEMP[4], IN[0].xyyy, SAMP[0], 2D\n"
|
||||
" 14: TEX TEMP[6], IN[1].zwww, SAMP[0], 2D\n"
|
||||
" 15: ADD TEMP[7].x, IMM[0].xxxx, -TEMP[0].xxxx\n"
|
||||
" 16: MUL TEMP[8], TEMP[4], TEMP[7].xxxx\n"
|
||||
" 17: MAD TEMP[7], TEMP[6], TEMP[0].xxxx, TEMP[8]\n"
|
||||
" 18: MUL TEMP[6], TEMP[7], TEMP[5].xxxx\n"
|
||||
" 19: TEX TEMP[7], IN[2].zwww, SAMP[0], 2D\n"
|
||||
" 20: ADD TEMP[8].x, IMM[0].xxxx, -TEMP[2].yyyy\n"
|
||||
" 21: MUL TEMP[3], TEMP[4], TEMP[8].xxxx\n"
|
||||
" 22: MAD TEMP[8], TEMP[7], TEMP[2].yyyy, TEMP[3]\n"
|
||||
" 23: MAD TEMP[2], TEMP[8], TEMP[5].yyyy, TEMP[6]\n"
|
||||
" 24: TEX TEMP[6], IN[1].xyyy, SAMP[0], 2D\n"
|
||||
" 25: ADD TEMP[7].x, IMM[0].xxxx, -TEMP[0].zzzz\n"
|
||||
" 26: MUL TEMP[8], TEMP[4], TEMP[7].xxxx\n"
|
||||
" 27: MAD TEMP[7], TEMP[6], TEMP[0].zzzz, TEMP[8]\n"
|
||||
" 28: MAD TEMP[0], TEMP[7], TEMP[5].zzzz, TEMP[2]\n"
|
||||
" 29: TEX TEMP[2], IN[2].xyyy, SAMP[0], 2D\n"
|
||||
" 30: ADD TEMP[6].x, IMM[0].xxxx, -TEMP[1].wwww\n"
|
||||
" 31: MUL TEMP[7], TEMP[4], TEMP[6].xxxx\n"
|
||||
" 32: MAD TEMP[4], TEMP[2], TEMP[1].wwww, TEMP[7]\n"
|
||||
" 33: MAD TEMP[2], TEMP[4], TEMP[5].wwww, TEMP[0]\n"
|
||||
" 34: RCP TEMP[0].x, TEMP[1].xxxx\n"
|
||||
" 35: MUL OUT[0], TEMP[2], TEMP[0].xxxx\n"
|
||||
" 36: END\n";
|
||||
|
||||
|
||||
static const char offsetvs[] = "VERT\n"
|
||||
"DCL IN[0]\n"
|
||||
"DCL IN[1]\n"
|
||||
"DCL OUT[0], POSITION\n"
|
||||
"DCL OUT[1], GENERIC[0]\n"
|
||||
"DCL OUT[2], GENERIC[10]\n"
|
||||
"DCL OUT[3], GENERIC[11]\n"
|
||||
"DCL CONST[0][0]\n"
|
||||
"IMM FLT32 { 1.0000, 0.0000, -1.0000, 0.0000}\n"
|
||||
" 0: MOV OUT[0], IN[0]\n"
|
||||
" 1: MOV OUT[1], IN[1]\n"
|
||||
" 2: MAD OUT[2], CONST[0][0].xyxy, IMM[0].zyyz, IN[1].xyxy\n"
|
||||
" 3: MAD OUT[3], CONST[0][0].xyxy, IMM[0].xyyx, IN[1].xyxy\n"
|
||||
" 4: END\n";
|
||||
|
||||
|
||||
static const char blend2fs_1[] = "FRAG\n"
|
||||
"PROPERTY FS_COLOR0_WRITES_ALL_CBUFS 1\n"
|
||||
"DCL IN[0], GENERIC[0], PERSPECTIVE\n"
|
||||
"DCL OUT[0], COLOR\n"
|
||||
"DCL SAMP[0]\n"
|
||||
"DCL SVIEW[0], 2D, FLOAT\n"
|
||||
"DCL SAMP[1]\n"
|
||||
"DCL SVIEW[1], 2D, FLOAT\n"
|
||||
"DCL SAMP[2]\n"
|
||||
"DCL SVIEW[2], 2D, FLOAT\n"
|
||||
"DCL CONST[0][0]\n"
|
||||
"DCL TEMP[0..6]\n"
|
||||
"IMM FLT32 { 0.0000, -0.2500, 0.00609756, 0.5000}\n"
|
||||
"IMM FLT32 { -1.5000, -2.0000, 0.9000, 1.5000}\n"
|
||||
"IMM FLT32 { 2.0000, 1.0000, 4.0000, 33.0000}\n";
|
||||
|
||||
static const char blend2fs_2[] =
|
||||
" 0: MOV TEMP[0], IMM[0].xxxx\n"
|
||||
" 1: TEX TEMP[1], IN[0].xyyy, SAMP[1], 2D\n"
|
||||
" 2: MOV TEMP[2].x, TEMP[1]\n"
|
||||
" 3: SNE TEMP[3].x, TEMP[1].yyyy, IMM[0].xxxx\n"
|
||||
" 4: IF TEMP[3].xxxx :76\n"
|
||||
" 5: MOV TEMP[1].xy, IN[0].xyxx\n"
|
||||
" 6: MOV TEMP[4].x, IMM[1].xxxx\n"
|
||||
" 7: BGNLOOP :24\n"
|
||||
" 8: MUL TEMP[5].x, IMM[1].yyyy, IMM[3].xxxx\n"
|
||||
" 9: SLE TEMP[6].x, TEMP[4].xxxx, TEMP[5].xxxx\n"
|
||||
" 10: IF TEMP[6].xxxx :12\n"
|
||||
" 11: BRK\n"
|
||||
" 12: ENDIF\n"
|
||||
" 13: MOV TEMP[4].y, IMM[0].xxxx\n"
|
||||
" 14: MAD TEMP[3].xyz, CONST[0][0].xyyy, TEMP[4].xyyy, TEMP[1].xyyy\n"
|
||||
" 15: MOV TEMP[3].w, IMM[0].xxxx\n"
|
||||
" 16: TXL TEMP[5], TEMP[3], SAMP[2], 2D\n"
|
||||
" 17: MOV TEMP[3].x, TEMP[5].yyyy\n"
|
||||
" 18: SLT TEMP[6].x, TEMP[5].yyyy, IMM[1].zzzz\n"
|
||||
" 19: IF TEMP[6].xxxx :21\n"
|
||||
" 20: BRK\n"
|
||||
" 21: ENDIF\n"
|
||||
" 22: ADD TEMP[6].x, TEMP[4].xxxx, IMM[1].yyyy\n"
|
||||
" 23: MOV TEMP[4].x, TEMP[6].xxxx\n"
|
||||
" 24: ENDLOOP :7\n"
|
||||
" 25: ADD TEMP[1].x, TEMP[4].xxxx, IMM[1].wwww\n"
|
||||
" 26: MAD TEMP[6].x, -IMM[2].xxxx, TEMP[3].xxxx, TEMP[1].xxxx\n"
|
||||
" 27: MUL TEMP[1].x, IMM[1].yyyy, IMM[3].xxxx\n"
|
||||
" 28: MAX TEMP[4].x, TEMP[6].xxxx, TEMP[1].xxxx\n"
|
||||
" 29: MOV TEMP[1].x, TEMP[4].xxxx\n"
|
||||
" 30: MOV TEMP[3].xy, IN[0].xyxx\n"
|
||||
" 31: MOV TEMP[5].x, IMM[1].wwww\n"
|
||||
" 32: BGNLOOP :49\n"
|
||||
" 33: MUL TEMP[6].x, IMM[2].xxxx, IMM[3].xxxx\n"
|
||||
" 34: SGE TEMP[4].x, TEMP[5].xxxx, TEMP[6].xxxx\n"
|
||||
" 35: IF TEMP[4].xxxx :37\n"
|
||||
" 36: BRK\n"
|
||||
" 37: ENDIF\n"
|
||||
" 38: MOV TEMP[5].y, IMM[0].xxxx\n"
|
||||
" 39: MAD TEMP[4].xyz, CONST[0][0].xyyy, TEMP[5].xyyy, TEMP[3].xyyy\n"
|
||||
" 40: MOV TEMP[4].w, IMM[0].xxxx\n"
|
||||
" 41: TXL TEMP[6].xy, TEMP[4], SAMP[2], 2D\n"
|
||||
" 42: MOV TEMP[4].x, TEMP[6].yyyy\n"
|
||||
" 43: SLT TEMP[0].x, TEMP[6].yyyy, IMM[1].zzzz\n"
|
||||
" 44: IF TEMP[0].xxxx :46\n"
|
||||
" 45: BRK\n"
|
||||
" 46: ENDIF\n"
|
||||
" 47: ADD TEMP[6].x, TEMP[5].xxxx, IMM[2].xxxx\n"
|
||||
" 48: MOV TEMP[5].x, TEMP[6].xxxx\n"
|
||||
" 49: ENDLOOP :32\n"
|
||||
" 50: ADD TEMP[3].x, TEMP[5].xxxx, IMM[1].xxxx\n"
|
||||
" 51: MAD TEMP[5].x, IMM[2].xxxx, TEMP[4].xxxx, TEMP[3].xxxx\n"
|
||||
" 52: MUL TEMP[3].x, IMM[2].xxxx, IMM[3].xxxx\n"
|
||||
" 53: MIN TEMP[4].x, TEMP[5].xxxx, TEMP[3].xxxx\n"
|
||||
" 54: MOV TEMP[3].x, TEMP[1].xxxx\n"
|
||||
" 55: MOV TEMP[3].y, TEMP[4].xxxx\n"
|
||||
" 56: MOV TEMP[5].yw, IMM[0].yyyy\n"
|
||||
" 57: MOV TEMP[5].x, TEMP[1].xxxx\n"
|
||||
" 58: ADD TEMP[1].x, TEMP[4].xxxx, IMM[2].yyyy\n"
|
||||
" 59: MOV TEMP[5].z, TEMP[1].xxxx\n"
|
||||
" 60: MAD TEMP[1], TEMP[5], CONST[0][0].xyxy, IN[0].xyxy\n"
|
||||
" 61: MOV TEMP[4], TEMP[1].xyyy\n"
|
||||
" 62: MOV TEMP[4].w, IMM[0].xxxx\n"
|
||||
" 63: TXL TEMP[5].x, TEMP[4], SAMP[2], 2D\n"
|
||||
" 64: MOV TEMP[4].x, TEMP[5].xxxx\n"
|
||||
" 65: MOV TEMP[5], TEMP[1].zwww\n"
|
||||
" 66: MOV TEMP[5].w, IMM[0].xxxx\n"
|
||||
" 67: TXL TEMP[1].x, TEMP[5], SAMP[2], 2D\n"
|
||||
" 68: MOV TEMP[4].y, TEMP[1].xxxx\n"
|
||||
" 69: MUL TEMP[5].xy, IMM[2].zzzz, TEMP[4].xyyy\n"
|
||||
" 70: ROUND TEMP[1].xy, TEMP[5].xyyy\n"
|
||||
" 71: MOV TEMP[4].xy, |TEMP[3].xyyy|\n"
|
||||
" 72: MAD TEMP[3].xy, IMM[2].wwww, TEMP[1].xyyy, TEMP[4].xyyy\n"
|
||||
" 73: MUL TEMP[5].xyz, TEMP[3].xyyy, IMM[0].zzzz\n"
|
||||
" 74: MOV TEMP[5].w, IMM[0].xxxx\n"
|
||||
" 75: TXL TEMP[0].xy, TEMP[5], SAMP[0], 2D\n"
|
||||
" 76: ENDIF\n"
|
||||
" 77: SNE TEMP[1].x, TEMP[2].xxxx, IMM[0].xxxx\n"
|
||||
" 78: IF TEMP[1].xxxx :151\n"
|
||||
" 79: MOV TEMP[1].xy, IN[0].xyxx\n"
|
||||
" 80: MOV TEMP[3].x, IMM[1].xxxx\n"
|
||||
" 81: BGNLOOP :98\n"
|
||||
" 82: MUL TEMP[4].x, IMM[1].yyyy, IMM[3].xxxx\n"
|
||||
" 83: SLE TEMP[5].x, TEMP[3].xxxx, TEMP[4].xxxx\n"
|
||||
" 84: IF TEMP[5].xxxx :86\n"
|
||||
" 85: BRK\n"
|
||||
" 86: ENDIF\n"
|
||||
" 87: MOV TEMP[3].y, IMM[0].xxxx\n"
|
||||
" 88: MAD TEMP[5].xyz, CONST[0][0].xyyy, TEMP[3].yxxx, TEMP[1].xyyy\n"
|
||||
" 89: MOV TEMP[5].w, IMM[0].xxxx\n"
|
||||
" 90: TXL TEMP[4], TEMP[5], SAMP[2], 2D\n"
|
||||
" 91: MOV TEMP[2].x, TEMP[4].xxxx\n"
|
||||
" 92: SLT TEMP[5].x, TEMP[4].xxxx, IMM[1].zzzz\n"
|
||||
" 93: IF TEMP[5].xxxx :95\n"
|
||||
" 94: BRK\n"
|
||||
" 95: ENDIF\n"
|
||||
" 96: ADD TEMP[4].x, TEMP[3].xxxx, IMM[1].yyyy\n"
|
||||
" 97: MOV TEMP[3].x, TEMP[4].xxxx\n"
|
||||
" 98: ENDLOOP :81\n"
|
||||
" 99: ADD TEMP[1].x, TEMP[3].xxxx, IMM[1].wwww\n"
|
||||
"100: MAD TEMP[6].x, -IMM[2].xxxx, TEMP[2].xxxx, TEMP[1].xxxx\n"
|
||||
"101: MUL TEMP[1].x, IMM[1].yyyy, IMM[3].xxxx\n"
|
||||
"102: MAX TEMP[3].x, TEMP[6].xxxx, TEMP[1].xxxx\n"
|
||||
"103: MOV TEMP[1].x, TEMP[3].xxxx\n"
|
||||
"104: MOV TEMP[2].xy, IN[0].xyxx\n"
|
||||
"105: MOV TEMP[4].x, IMM[1].wwww\n"
|
||||
"106: BGNLOOP :123\n"
|
||||
"107: MUL TEMP[5].x, IMM[2].xxxx, IMM[3].xxxx\n"
|
||||
"108: SGE TEMP[6].x, TEMP[4].xxxx, TEMP[5].xxxx\n"
|
||||
"109: IF TEMP[6].xxxx :111\n"
|
||||
"110: BRK\n"
|
||||
"111: ENDIF\n"
|
||||
"112: MOV TEMP[4].y, IMM[0].xxxx\n"
|
||||
"113: MAD TEMP[5].xyz, CONST[0][0].xyyy, TEMP[4].yxxx, TEMP[2].xyyy\n"
|
||||
"114: MOV TEMP[5].w, IMM[0].xxxx\n"
|
||||
"115: TXL TEMP[6], TEMP[5], SAMP[2], 2D\n"
|
||||
"116: MOV TEMP[3].x, TEMP[6].xxxx\n"
|
||||
"117: SLT TEMP[5].x, TEMP[6].xxxx, IMM[1].zzzz\n"
|
||||
"118: IF TEMP[5].xxxx :120\n"
|
||||
"119: BRK\n"
|
||||
"120: ENDIF\n"
|
||||
"121: ADD TEMP[6].x, TEMP[4].xxxx, IMM[2].xxxx\n"
|
||||
"122: MOV TEMP[4].x, TEMP[6].xxxx\n"
|
||||
"123: ENDLOOP :106\n"
|
||||
"124: ADD TEMP[2].x, TEMP[4].xxxx, IMM[1].xxxx\n"
|
||||
"125: MAD TEMP[4].x, IMM[2].xxxx, TEMP[3].xxxx, TEMP[2].xxxx\n"
|
||||
"126: MUL TEMP[2].x, IMM[2].xxxx, IMM[3].xxxx\n"
|
||||
"127: MIN TEMP[3].x, TEMP[4].xxxx, TEMP[2].xxxx\n"
|
||||
"128: MOV TEMP[2].x, TEMP[1].xxxx\n"
|
||||
"129: MOV TEMP[2].y, TEMP[3].xxxx\n"
|
||||
"130: MOV TEMP[4].xz, IMM[0].yyyy\n"
|
||||
"131: MOV TEMP[4].y, TEMP[1].xxxx\n"
|
||||
"132: ADD TEMP[1].x, TEMP[3].xxxx, IMM[2].yyyy\n"
|
||||
"133: MOV TEMP[4].w, TEMP[1].xxxx\n"
|
||||
"134: MAD TEMP[1], TEMP[4], CONST[0][0].xyxy, IN[0].xyxy\n"
|
||||
"135: MOV TEMP[3], TEMP[1].xyyy\n"
|
||||
"136: MOV TEMP[3].w, IMM[0].xxxx\n"
|
||||
"137: TXL TEMP[4].y, TEMP[3], SAMP[2], 2D\n"
|
||||
"138: MOV TEMP[3].x, TEMP[4].yyyy\n"
|
||||
"139: MOV TEMP[4], TEMP[1].zwww\n"
|
||||
"140: MOV TEMP[4].w, IMM[0].xxxx\n"
|
||||
"141: TXL TEMP[1].y, TEMP[4], SAMP[2], 2D\n"
|
||||
"142: MOV TEMP[3].y, TEMP[1].yyyy\n"
|
||||
"143: MUL TEMP[4].xy, IMM[2].zzzz, TEMP[3].xyyy\n"
|
||||
"144: ROUND TEMP[1].xy, TEMP[4].xyyy\n"
|
||||
"145: MOV TEMP[3].xy, |TEMP[2].xyyy|\n"
|
||||
"146: MAD TEMP[2].xy, IMM[2].wwww, TEMP[1].xyyy, TEMP[3].xyyy\n"
|
||||
"147: MUL TEMP[3].xyz, TEMP[2].xyyy, IMM[0].zzzz\n"
|
||||
"148: MOV TEMP[3].w, IMM[0].xxxx\n"
|
||||
"149: TXL TEMP[1].xy, TEMP[3], SAMP[0], 2D\n"
|
||||
"150: MOV TEMP[0].zw, TEMP[1].yyxy\n"
|
||||
"151: ENDIF\n"
|
||||
"152: MOV OUT[0], TEMP[0]\n"
|
||||
"153: END\n";
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,114 +0,0 @@
|
|||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2011 Lauri Kasanen
|
||||
* 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, 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 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 PP_PRIVATE_H
|
||||
#define PP_PRIVATE_H
|
||||
|
||||
|
||||
#include "postprocess.h"
|
||||
#include "cso_cache/cso_context.h"
|
||||
|
||||
|
||||
/**
|
||||
* Internal control details.
|
||||
*/
|
||||
struct pp_program
|
||||
{
|
||||
struct pipe_screen *screen;
|
||||
struct pipe_context *pipe;
|
||||
struct cso_context *cso;
|
||||
|
||||
/* For notifying st_context to rebind states that we clobbered. */
|
||||
struct st_context *st;
|
||||
pp_st_invalidate_state_func st_invalidate_state;
|
||||
|
||||
struct pipe_blend_state blend;
|
||||
struct pipe_depth_stencil_alpha_state depthstencil;
|
||||
struct pipe_rasterizer_state rasterizer;
|
||||
struct pipe_sampler_state sampler; /* bilinear */
|
||||
struct pipe_sampler_state sampler_point; /* point */
|
||||
struct pipe_viewport_state viewport;
|
||||
struct pipe_framebuffer_state framebuffer;
|
||||
struct cso_velems_state velem;
|
||||
|
||||
union pipe_color_union clear_color;
|
||||
|
||||
void *passvs;
|
||||
|
||||
struct pipe_resource *vbuf;
|
||||
struct pipe_surface surf;
|
||||
struct pipe_sampler_view *view;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The main post-processing queue.
|
||||
*/
|
||||
struct pp_queue_t
|
||||
{
|
||||
pp_func *pp_queue; /* An array of pp_funcs */
|
||||
unsigned int n_filters; /* Number of enabled filters */
|
||||
|
||||
struct pipe_resource *tmp[2]; /* Two temp FBOs for the queue */
|
||||
struct pipe_resource *inner_tmp[3]; /* Three for filter use */
|
||||
|
||||
unsigned int n_tmp, n_inner_tmp;
|
||||
|
||||
struct pipe_resource *depth; /* depth of original input */
|
||||
struct pipe_resource *stencil; /* stencil shared by inner_tmps */
|
||||
struct pipe_resource *areamaptex; /* MLAA area map texture */
|
||||
|
||||
struct pipe_surface tmps[2], inner_tmps[3], stencils;
|
||||
|
||||
void ***shaders; /* Shaders in TGSI form */
|
||||
unsigned int *filters; /* Active filter to filters.h mapping. */
|
||||
struct pp_program *p;
|
||||
|
||||
bool fbos_init;
|
||||
};
|
||||
|
||||
|
||||
void pp_free_fbos(struct pp_queue_t *);
|
||||
|
||||
void pp_debug(const char *, ...);
|
||||
|
||||
struct pp_program *pp_init_prog(struct pp_queue_t *, struct pipe_context *pipe,
|
||||
struct cso_context *, struct st_context *st,
|
||||
pp_st_invalidate_state_func st_invalidate_state);
|
||||
|
||||
void pp_blit(struct pipe_context *pipe,
|
||||
struct pipe_resource *src_tex,
|
||||
int srcX0, int srcY0,
|
||||
int srcX1, int srcY1,
|
||||
int srcZ0,
|
||||
struct pipe_surface *dst,
|
||||
int dstX0, int dstY0,
|
||||
int dstX1, int dstY1);
|
||||
|
||||
|
||||
#endif /* PP_PRIVATE_H */
|
||||
|
|
@ -1,147 +0,0 @@
|
|||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2010 Jakob Bornecrantz
|
||||
* Copyright 2011 Lauri Kasanen
|
||||
* 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, 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 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 "postprocess/postprocess.h"
|
||||
#include "postprocess/pp_private.h"
|
||||
|
||||
#include "cso_cache/cso_context.h"
|
||||
#include "pipe/p_screen.h"
|
||||
#include "pipe/p_context.h"
|
||||
#include "pipe/p_state.h"
|
||||
#include "pipe/p_shader_tokens.h"
|
||||
#include "util/u_inlines.h"
|
||||
#include "util/u_simple_shaders.h"
|
||||
#include "util/u_memory.h"
|
||||
|
||||
/** Initialize the internal details */
|
||||
struct pp_program *
|
||||
pp_init_prog(struct pp_queue_t *ppq, struct pipe_context *pipe,
|
||||
struct cso_context *cso, struct st_context *st,
|
||||
pp_st_invalidate_state_func st_invalidate_state)
|
||||
{
|
||||
struct pp_program *p;
|
||||
|
||||
pp_debug("Initializing program\n");
|
||||
if (!pipe)
|
||||
return NULL;
|
||||
|
||||
p = CALLOC(1, sizeof(struct pp_program));
|
||||
if (!p)
|
||||
return NULL;
|
||||
|
||||
p->screen = pipe->screen;
|
||||
p->pipe = pipe;
|
||||
p->cso = cso;
|
||||
p->st = st;
|
||||
p->st_invalidate_state = st_invalidate_state;
|
||||
|
||||
{
|
||||
static const float verts[4][2][4] = {
|
||||
{
|
||||
{1.0f, 1.0f, 0.0f, 1.0f},
|
||||
{1.0f, 1.0f, 0.0f, 1.0f}
|
||||
},
|
||||
{
|
||||
{-1.0f, 1.0f, 0.0f, 1.0f},
|
||||
{0.0f, 1.0f, 0.0f, 1.0f}
|
||||
},
|
||||
{
|
||||
{-1.0f, -1.0f, 0.0f, 1.0f},
|
||||
{0.0f, 0.0f, 0.0f, 1.0f}
|
||||
},
|
||||
{
|
||||
{1.0f, -1.0f, 0.0f, 1.0f},
|
||||
{1.0f, 0.0f, 0.0f, 1.0f}
|
||||
}
|
||||
};
|
||||
|
||||
p->vbuf = pipe_buffer_create(pipe->screen, PIPE_BIND_VERTEX_BUFFER,
|
||||
PIPE_USAGE_DEFAULT, sizeof(verts));
|
||||
pipe_buffer_write(p->pipe, p->vbuf, 0, sizeof(verts), verts);
|
||||
}
|
||||
|
||||
p->blend.rt[0].colormask = PIPE_MASK_RGBA;
|
||||
p->blend.rt[0].rgb_src_factor = p->blend.rt[0].alpha_src_factor =
|
||||
PIPE_BLENDFACTOR_SRC_ALPHA;
|
||||
p->blend.rt[0].rgb_dst_factor = p->blend.rt[0].alpha_dst_factor =
|
||||
PIPE_BLENDFACTOR_INV_SRC_ALPHA;
|
||||
|
||||
p->rasterizer.cull_face = PIPE_FACE_NONE;
|
||||
p->rasterizer.half_pixel_center = 1;
|
||||
p->rasterizer.bottom_edge_rule = 1;
|
||||
p->rasterizer.depth_clip_near = 1;
|
||||
p->rasterizer.depth_clip_far = 1;
|
||||
|
||||
p->sampler.wrap_s = p->sampler.wrap_t = p->sampler.wrap_r =
|
||||
PIPE_TEX_WRAP_CLAMP_TO_EDGE;
|
||||
|
||||
p->sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NONE;
|
||||
p->sampler.min_img_filter = p->sampler.mag_img_filter =
|
||||
PIPE_TEX_FILTER_LINEAR;
|
||||
|
||||
p->sampler_point.wrap_s = p->sampler_point.wrap_t =
|
||||
p->sampler_point.wrap_r = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
|
||||
p->sampler_point.min_mip_filter = PIPE_TEX_MIPFILTER_NONE;
|
||||
p->sampler_point.min_img_filter = p->sampler_point.mag_img_filter =
|
||||
PIPE_TEX_FILTER_NEAREST;
|
||||
|
||||
p->velem.count = 2;
|
||||
p->velem.velems[0].src_offset = 0;
|
||||
p->velem.velems[0].instance_divisor = 0;
|
||||
p->velem.velems[0].vertex_buffer_index = 0;
|
||||
p->velem.velems[0].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
|
||||
p->velem.velems[0].src_stride = 2 * 4 * sizeof(float);
|
||||
p->velem.velems[1].src_offset = 1 * 4 * sizeof(float);
|
||||
p->velem.velems[1].instance_divisor = 0;
|
||||
p->velem.velems[1].vertex_buffer_index = 0;
|
||||
p->velem.velems[1].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
|
||||
p->velem.velems[1].src_stride = 2 * 4 * sizeof(float);
|
||||
|
||||
if (!p->screen->is_format_supported(p->screen,
|
||||
PIPE_FORMAT_R32G32B32A32_FLOAT,
|
||||
PIPE_BUFFER, 1, 1,
|
||||
PIPE_BIND_VERTEX_BUFFER))
|
||||
pp_debug("Vertex buf format fail\n");
|
||||
|
||||
|
||||
{
|
||||
const enum tgsi_semantic semantic_names[] = { TGSI_SEMANTIC_POSITION,
|
||||
TGSI_SEMANTIC_GENERIC
|
||||
};
|
||||
const unsigned semantic_indexes[] = { 0, 0 };
|
||||
p->passvs = util_make_vertex_passthrough_shader(p->pipe, 2,
|
||||
semantic_names,
|
||||
semantic_indexes, false);
|
||||
}
|
||||
|
||||
p->framebuffer.nr_cbufs = 1;
|
||||
|
||||
p->surf.format = PIPE_FORMAT_B8G8R8A8_UNORM;
|
||||
|
||||
return p;
|
||||
}
|
||||
|
|
@ -1,310 +0,0 @@
|
|||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2011 Lauri Kasanen
|
||||
* 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, 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 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 "postprocess.h"
|
||||
#include "postprocess/pp_filters.h"
|
||||
#include "postprocess/pp_private.h"
|
||||
|
||||
#include "frontend/api.h"
|
||||
#include "util/u_inlines.h"
|
||||
#include "util/u_sampler.h"
|
||||
|
||||
#include "tgsi/tgsi_parse.h"
|
||||
#include "tgsi/tgsi_text.h"
|
||||
|
||||
|
||||
void
|
||||
pp_blit(struct pipe_context *pipe,
|
||||
struct pipe_resource *src_tex,
|
||||
int srcX0, int srcY0,
|
||||
int srcX1, int srcY1,
|
||||
int srcZ0,
|
||||
struct pipe_surface *dst,
|
||||
int dstX0, int dstY0,
|
||||
int dstX1, int dstY1)
|
||||
{
|
||||
struct pipe_blit_info blit;
|
||||
|
||||
memset(&blit, 0, sizeof(blit));
|
||||
|
||||
blit.src.resource = src_tex;
|
||||
blit.src.level = 0;
|
||||
blit.src.format = src_tex->format;
|
||||
blit.src.box.x = srcX0;
|
||||
blit.src.box.y = srcY0;
|
||||
blit.src.box.z = srcZ0;
|
||||
blit.src.box.width = srcX1 - srcX0;
|
||||
blit.src.box.height = srcY1 - srcY0;
|
||||
blit.src.box.depth = 1;
|
||||
|
||||
blit.dst.resource = dst->texture;
|
||||
blit.dst.level = dst->level;
|
||||
blit.dst.format = dst->format;
|
||||
blit.dst.box.x = dstX0;
|
||||
blit.dst.box.y = dstY0;
|
||||
blit.dst.box.z = 0;
|
||||
blit.dst.box.width = dstX1 - dstX0;
|
||||
blit.dst.box.height = dstY1 - dstY0;
|
||||
blit.dst.box.depth = 1;
|
||||
|
||||
blit.mask = PIPE_MASK_RGBA;
|
||||
|
||||
pipe->blit(pipe, &blit);
|
||||
}
|
||||
|
||||
/**
|
||||
* Main run function of the PP queue. Called on swapbuffers/flush.
|
||||
*
|
||||
* Runs all requested filters in order and handles shuffling the temp
|
||||
* buffers in between.
|
||||
*/
|
||||
void
|
||||
pp_run(struct pp_queue_t *ppq, struct pipe_resource *in,
|
||||
struct pipe_resource *out, struct pipe_resource *indepth)
|
||||
{
|
||||
struct pipe_resource *refin = NULL, *refout = NULL;
|
||||
unsigned int i;
|
||||
struct cso_context *cso = ppq->p->cso;
|
||||
|
||||
if (ppq->n_filters == 0)
|
||||
return;
|
||||
|
||||
assert(ppq->pp_queue);
|
||||
assert(ppq->tmp[0]);
|
||||
|
||||
if (in->width0 != ppq->p->framebuffer.width ||
|
||||
in->height0 != ppq->p->framebuffer.height) {
|
||||
pp_debug("Resizing the temp pp buffers\n");
|
||||
pp_free_fbos(ppq);
|
||||
pp_init_fbos(ppq, in->width0, in->height0);
|
||||
}
|
||||
|
||||
if (in == out && ppq->n_filters == 1) {
|
||||
/* Make a copy of in to tmp[0] in this case. */
|
||||
unsigned int w = ppq->p->framebuffer.width;
|
||||
unsigned int h = ppq->p->framebuffer.height;
|
||||
|
||||
|
||||
pp_blit(ppq->p->pipe, in, 0, 0,
|
||||
w, h, 0, &ppq->tmps[0],
|
||||
0, 0, w, h);
|
||||
|
||||
in = ppq->tmp[0];
|
||||
}
|
||||
|
||||
/* save state (restored below) */
|
||||
cso_save_state(cso, (CSO_BIT_BLEND |
|
||||
CSO_BIT_DEPTH_STENCIL_ALPHA |
|
||||
CSO_BIT_FRAMEBUFFER |
|
||||
CSO_BIT_RASTERIZER |
|
||||
CSO_BIT_SAMPLE_MASK |
|
||||
CSO_BIT_MIN_SAMPLES |
|
||||
CSO_BIT_FRAGMENT_SAMPLERS |
|
||||
CSO_BIT_STENCIL_REF |
|
||||
CSO_BIT_STREAM_OUTPUTS |
|
||||
CSO_BIT_VERTEX_ELEMENTS |
|
||||
CSO_BIT_MESH_SHADER |
|
||||
CSO_BITS_VERTEX_PIPE_SHADERS |
|
||||
CSO_BIT_VIEWPORT |
|
||||
CSO_BIT_PAUSE_QUERIES |
|
||||
CSO_BIT_RENDER_CONDITION));
|
||||
|
||||
/* set default state */
|
||||
cso_set_sample_mask(cso, ~0);
|
||||
cso_set_min_samples(cso, 1);
|
||||
cso_set_stream_outputs(cso, 0, NULL, NULL, 0);
|
||||
cso_set_tessctrl_shader_handle(cso, NULL);
|
||||
cso_set_tesseval_shader_handle(cso, NULL);
|
||||
cso_set_geometry_shader_handle(cso, NULL);
|
||||
cso_set_mesh_shader_handle(cso, NULL);
|
||||
cso_set_render_condition(cso, NULL, false, 0);
|
||||
|
||||
// Kept only for this frame.
|
||||
pipe_resource_reference(&ppq->depth, indepth);
|
||||
pipe_resource_reference(&refin, in);
|
||||
pipe_resource_reference(&refout, out);
|
||||
|
||||
switch (ppq->n_filters) {
|
||||
case 0:
|
||||
/* Failsafe, but never reached. */
|
||||
break;
|
||||
case 1: /* No temp buf */
|
||||
ppq->pp_queue[0] (ppq, in, out, 0);
|
||||
break;
|
||||
case 2: /* One temp buf */
|
||||
|
||||
ppq->pp_queue[0] (ppq, in, ppq->tmp[0], 0);
|
||||
ppq->pp_queue[1] (ppq, ppq->tmp[0], out, 1);
|
||||
|
||||
break;
|
||||
default: /* Two temp bufs */
|
||||
assert(ppq->tmp[1]);
|
||||
ppq->pp_queue[0] (ppq, in, ppq->tmp[0], 0);
|
||||
|
||||
for (i = 1; i < (ppq->n_filters - 1); i++) {
|
||||
if (i % 2 == 0)
|
||||
ppq->pp_queue[i] (ppq, ppq->tmp[1], ppq->tmp[0], i);
|
||||
|
||||
else
|
||||
ppq->pp_queue[i] (ppq, ppq->tmp[0], ppq->tmp[1], i);
|
||||
}
|
||||
|
||||
if (i % 2 == 0)
|
||||
ppq->pp_queue[i] (ppq, ppq->tmp[1], out, i);
|
||||
|
||||
else
|
||||
ppq->pp_queue[i] (ppq, ppq->tmp[0], out, i);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
/* restore state we changed */
|
||||
cso_restore_state(cso, CSO_UNBIND_FS_SAMPLERVIEWS |
|
||||
CSO_UNBIND_FS_IMAGE0 |
|
||||
CSO_UNBIND_VS_CONSTANTS |
|
||||
CSO_UNBIND_FS_CONSTANTS);
|
||||
|
||||
/* restore states not restored by cso */
|
||||
if (ppq->p->st) {
|
||||
ppq->p->st_invalidate_state(ppq->p->st,
|
||||
ST_INVALIDATE_FS_SAMPLER_VIEWS |
|
||||
ST_INVALIDATE_FS_CONSTBUF0 |
|
||||
ST_INVALIDATE_VS_CONSTBUF0 |
|
||||
ST_INVALIDATE_VERTEX_BUFFERS);
|
||||
}
|
||||
|
||||
pipe_resource_reference(&ppq->depth, NULL);
|
||||
pipe_resource_reference(&refin, NULL);
|
||||
pipe_resource_reference(&refout, NULL);
|
||||
}
|
||||
|
||||
|
||||
/* Utility functions for the filters. You're not forced to use these if */
|
||||
/* your filter is more complicated. */
|
||||
|
||||
/** Setup this resource as the filter input. */
|
||||
void
|
||||
pp_filter_setup_in(struct pp_program *p, struct pipe_resource *in)
|
||||
{
|
||||
struct pipe_sampler_view v_tmp;
|
||||
u_sampler_view_default_template(&v_tmp, in, in->format);
|
||||
p->view = p->pipe->create_sampler_view(p->pipe, in, &v_tmp);
|
||||
}
|
||||
|
||||
/** Setup this resource as the filter output. */
|
||||
void
|
||||
pp_filter_setup_out(struct pp_program *p, struct pipe_resource *out)
|
||||
{
|
||||
p->surf.format = out->format;
|
||||
|
||||
p->framebuffer.cbufs[0] = p->surf;
|
||||
p->framebuffer.cbufs[0].texture = out;
|
||||
}
|
||||
|
||||
/** Clean up the input and output set with the above. */
|
||||
void
|
||||
pp_filter_end_pass(struct pp_program *p)
|
||||
{
|
||||
pipe_sampler_view_release_ptr(&p->view);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the TGSI assembly to a runnable shader.
|
||||
*
|
||||
* We need not care about geometry shaders. All we have is screen quads.
|
||||
*/
|
||||
void *
|
||||
pp_tgsi_to_state(struct pipe_context *pipe, const char *text, bool isvs,
|
||||
const char *name)
|
||||
{
|
||||
struct pipe_shader_state state;
|
||||
struct tgsi_token *tokens = NULL;
|
||||
void *ret_state = NULL;
|
||||
|
||||
/*
|
||||
* Allocate temporary token storage. State creation will duplicate
|
||||
* tokens so we must free them on exit.
|
||||
*/
|
||||
tokens = tgsi_alloc_tokens(PP_MAX_TOKENS);
|
||||
|
||||
if (!tokens) {
|
||||
pp_debug("Failed to allocate temporary token storage.\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (tgsi_text_translate(text, tokens, PP_MAX_TOKENS) == false) {
|
||||
_debug_printf("pp: Failed to translate a shader for %s\n", name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pipe_shader_state_from_tgsi(&state, tokens);
|
||||
|
||||
if (isvs) {
|
||||
ret_state = pipe->create_vs_state(pipe, &state);
|
||||
FREE(tokens);
|
||||
} else {
|
||||
ret_state = pipe->create_fs_state(pipe, &state);
|
||||
FREE(tokens);
|
||||
}
|
||||
|
||||
return ret_state;
|
||||
}
|
||||
|
||||
/** Setup misc state for the filter. */
|
||||
void
|
||||
pp_filter_misc_state(struct pp_program *p)
|
||||
{
|
||||
cso_set_blend(p->cso, &p->blend);
|
||||
cso_set_depth_stencil_alpha(p->cso, &p->depthstencil);
|
||||
cso_set_rasterizer(p->cso, &p->rasterizer);
|
||||
cso_set_viewport(p->cso, &p->viewport);
|
||||
|
||||
cso_set_vertex_elements(p->cso, &p->velem);
|
||||
}
|
||||
|
||||
/** Draw with the filter to the set output. */
|
||||
void
|
||||
pp_filter_draw(struct pp_program *p)
|
||||
{
|
||||
util_draw_vertex_buffer(p->pipe, p->cso, p->vbuf, 0,
|
||||
MESA_PRIM_QUADS, 4, 2);
|
||||
}
|
||||
|
||||
/** Set the framebuffer as active. */
|
||||
void
|
||||
pp_filter_set_fb(struct pp_program *p)
|
||||
{
|
||||
cso_set_framebuffer(p->cso, &p->framebuffer);
|
||||
}
|
||||
|
||||
/** Set the framebuffer as active and clear it. */
|
||||
void
|
||||
pp_filter_set_clear_fb(struct pp_program *p)
|
||||
{
|
||||
cso_set_framebuffer(p->cso, &p->framebuffer);
|
||||
p->pipe->clear(p->pipe, PIPE_CLEAR_COLOR0, 0xf, 0, NULL, &p->clear_color, 0, 0);
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue