mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-22 15:40:11 +01:00
r300: copy ntt to r300 compiler
Signed-off-by: Pavel Ondračka <pavel.ondracka@gmail.com> Reviewed-by: Emma Anholt <emma@anholt.net> Reviewed-by: Filip Gawin <filip.gawin@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23437>
This commit is contained in:
parent
6c5512568b
commit
ed8b7eaec9
4 changed files with 4151 additions and 11 deletions
4079
src/gallium/drivers/r300/compiler/nir_to_rc.c
Normal file
4079
src/gallium/drivers/r300/compiler/nir_to_rc.c
Normal file
File diff suppressed because it is too large
Load diff
59
src/gallium/drivers/r300/compiler/nir_to_rc.h
Normal file
59
src/gallium/drivers/r300/compiler/nir_to_rc.h
Normal file
|
|
@ -0,0 +1,59 @@
|
||||||
|
/*
|
||||||
|
* 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"),
|
||||||
|
* to deal in the Software without restriction, including without limitation
|
||||||
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
* and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
* Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice (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 NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||||
|
* IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef NIR_TO_RC_H
|
||||||
|
#define NIR_TO_RC_H
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include "pipe/p_defines.h"
|
||||||
|
|
||||||
|
struct nir_shader;
|
||||||
|
struct pipe_screen;
|
||||||
|
struct pipe_shader_state;
|
||||||
|
|
||||||
|
struct nir_to_rc_options {
|
||||||
|
bool lower_cmp;
|
||||||
|
/* Emit MAX(a,-a) instead of abs src modifier) */
|
||||||
|
bool lower_fabs;
|
||||||
|
bool unoptimized_ra;
|
||||||
|
bool lower_ssbo_bindings;
|
||||||
|
uint32_t ubo_vec4_max;
|
||||||
|
};
|
||||||
|
|
||||||
|
const void *nir_to_rc(struct nir_shader *s,
|
||||||
|
struct pipe_screen *screen);
|
||||||
|
|
||||||
|
const void *nir_to_rc_options(struct nir_shader *s,
|
||||||
|
struct pipe_screen *screen,
|
||||||
|
const struct nir_to_rc_options *ntr_options);
|
||||||
|
|
||||||
|
const void *
|
||||||
|
nir_to_rc_get_compiler_options(struct pipe_screen *pscreen,
|
||||||
|
enum pipe_shader_ir ir,
|
||||||
|
unsigned shader);
|
||||||
|
|
||||||
|
const void *
|
||||||
|
r300_pipe_shader_state_to_tgsi_tokens(struct pipe_screen *screen,
|
||||||
|
const struct pipe_shader_state *cso);
|
||||||
|
|
||||||
|
#endif /* NIR_TO_RC_H */
|
||||||
|
|
@ -62,6 +62,8 @@ files_r300 = files(
|
||||||
'r300_vs.h',
|
'r300_vs.h',
|
||||||
'compiler/memory_pool.c',
|
'compiler/memory_pool.c',
|
||||||
'compiler/memory_pool.h',
|
'compiler/memory_pool.h',
|
||||||
|
'compiler/nir_to_rc.c',
|
||||||
|
'compiler/nir_to_rc.h',
|
||||||
'compiler/r300_fragprog.c',
|
'compiler/r300_fragprog.c',
|
||||||
'compiler/r300_fragprog_emit.c',
|
'compiler/r300_fragprog_emit.c',
|
||||||
'compiler/r300_fragprog.h',
|
'compiler/r300_fragprog.h',
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@
|
||||||
#include "r300_texture.h"
|
#include "r300_texture.h"
|
||||||
#include "r300_vs.h"
|
#include "r300_vs.h"
|
||||||
#include "compiler/r300_nir.h"
|
#include "compiler/r300_nir.h"
|
||||||
#include "nir/nir_to_tgsi.h"
|
#include "compiler/nir_to_rc.h"
|
||||||
|
|
||||||
/* r300_state: Functions used to initialize state context by translating
|
/* r300_state: Functions used to initialize state context by translating
|
||||||
* Gallium state objects into semi-native r300 state objects. */
|
* Gallium state objects into semi-native r300 state objects. */
|
||||||
|
|
@ -1047,7 +1047,7 @@ static void* r300_create_fs_state(struct pipe_context* pipe,
|
||||||
if (fs->state.type == PIPE_SHADER_IR_NIR) {
|
if (fs->state.type == PIPE_SHADER_IR_NIR) {
|
||||||
if (r300->screen->caps.is_r500)
|
if (r300->screen->caps.is_r500)
|
||||||
NIR_PASS_V(shader->ir.nir, r300_transform_fs_trig_input);
|
NIR_PASS_V(shader->ir.nir, r300_transform_fs_trig_input);
|
||||||
fs->state.tokens = nir_to_tgsi(shader->ir.nir, pipe->screen);
|
fs->state.tokens = nir_to_rc(shader->ir.nir, pipe->screen);
|
||||||
} else {
|
} else {
|
||||||
assert(fs->state.type == PIPE_SHADER_IR_TGSI);
|
assert(fs->state.type == PIPE_SHADER_IR_TGSI);
|
||||||
/* we need to keep a local copy of the tokens */
|
/* we need to keep a local copy of the tokens */
|
||||||
|
|
@ -1945,21 +1945,21 @@ static void* r300_create_vs_state(struct pipe_context* pipe,
|
||||||
vs->state = *shader;
|
vs->state = *shader;
|
||||||
|
|
||||||
if (vs->state.type == PIPE_SHADER_IR_NIR) {
|
if (vs->state.type == PIPE_SHADER_IR_NIR) {
|
||||||
static const struct nir_to_tgsi_options swtcl_options = {0};
|
static const struct nir_to_rc_options swtcl_options = {0};
|
||||||
static const struct nir_to_tgsi_options hwtcl_r300_options = {
|
static const struct nir_to_rc_options hwtcl_r300_options = {
|
||||||
.lower_cmp = true,
|
.lower_cmp = true,
|
||||||
.lower_fabs = true,
|
.lower_fabs = true,
|
||||||
.ubo_vec4_max = 0x00ff,
|
.ubo_vec4_max = 0x00ff,
|
||||||
.unoptimized_ra = true,
|
.unoptimized_ra = true,
|
||||||
};
|
};
|
||||||
static const struct nir_to_tgsi_options hwtcl_r500_options = {
|
static const struct nir_to_rc_options hwtcl_r500_options = {
|
||||||
.ubo_vec4_max = 0x00ff,
|
.ubo_vec4_max = 0x00ff,
|
||||||
.unoptimized_ra = true,
|
.unoptimized_ra = true,
|
||||||
};
|
};
|
||||||
const struct nir_to_tgsi_options *ntt_options;
|
const struct nir_to_rc_options *ntr_options;
|
||||||
if (r300->screen->caps.has_tcl) {
|
if (r300->screen->caps.has_tcl) {
|
||||||
if (r300->screen->caps.is_r500) {
|
if (r300->screen->caps.is_r500) {
|
||||||
ntt_options = &hwtcl_r500_options;
|
ntr_options = &hwtcl_r500_options;
|
||||||
|
|
||||||
/* Only nine should set both NTT shader name and
|
/* Only nine should set both NTT shader name and
|
||||||
* use_legacy_math_rules and D3D9 already mandates
|
* use_legacy_math_rules and D3D9 already mandates
|
||||||
|
|
@ -1972,12 +1972,12 @@ static void* r300_create_vs_state(struct pipe_context* pipe,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ntt_options = &hwtcl_r300_options;
|
ntr_options = &hwtcl_r300_options;
|
||||||
} else {
|
} else {
|
||||||
ntt_options = &swtcl_options;
|
ntr_options = &swtcl_options;
|
||||||
}
|
}
|
||||||
vs->state.tokens = nir_to_tgsi_options(shader->ir.nir, pipe->screen,
|
vs->state.tokens = nir_to_rc_options(shader->ir.nir, pipe->screen,
|
||||||
ntt_options);
|
ntr_options);
|
||||||
} else {
|
} else {
|
||||||
assert(vs->state.type == PIPE_SHADER_IR_TGSI);
|
assert(vs->state.type == PIPE_SHADER_IR_TGSI);
|
||||||
/* we need to keep a local copy of the tokens */
|
/* we need to keep a local copy of the tokens */
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue