summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers
diff options
context:
space:
mode:
authorSamuel Pitoiset <[email protected]>2016-02-24 18:44:56 +0100
committerSamuel Pitoiset <[email protected]>2016-02-26 14:00:27 +0100
commitaad48f86911998ab4164c9bbd091709bf5dd94a7 (patch)
tree2f6771515f70eefc1f4d807bc28f842e00c19a38 /src/gallium/drivers
parente1f5c76047ef961a71a67da9dd55de4b09144bc0 (diff)
nvc0: rework nvc0_compute_validate_program()
Reduce the amount of duplicated code by re-using nvc0_program_validate(). While we are at it, change the prototype to return void and remove nvc0_compute.h which is now useless. Signed-off-by: Samuel Pitoiset <[email protected]> Acked-by: Pierre Moreau <[email protected]> Acked-by: Ilia Mirkin <[email protected]>
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r--src/gallium/drivers/nouveau/Makefile.sources1
-rw-r--r--src/gallium/drivers/nouveau/nvc0/nvc0_compute.c34
-rw-r--r--src/gallium/drivers/nouveau/nvc0/nvc0_compute.h9
-rw-r--r--src/gallium/drivers/nouveau/nvc0/nvc0_context.h1
-rw-r--r--src/gallium/drivers/nouveau/nvc0/nvc0_shader_state.c15
-rw-r--r--src/gallium/drivers/nouveau/nvc0/nve4_compute.c4
6 files changed, 20 insertions, 44 deletions
diff --git a/src/gallium/drivers/nouveau/Makefile.sources b/src/gallium/drivers/nouveau/Makefile.sources
index 43ffce63a25..65f08c7d8d8 100644
--- a/src/gallium/drivers/nouveau/Makefile.sources
+++ b/src/gallium/drivers/nouveau/Makefile.sources
@@ -150,7 +150,6 @@ NVC0_C_SOURCES := \
nvc0/gm107_texture.xml.h \
nvc0/nvc0_3d.xml.h \
nvc0/nvc0_compute.c \
- nvc0/nvc0_compute.h \
nvc0/nvc0_compute.xml.h \
nvc0/nvc0_context.c \
nvc0/nvc0_context.h \
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_compute.c b/src/gallium/drivers/nouveau/nvc0/nvc0_compute.c
index a664aaf47ce..060f59d0c73 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_compute.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_compute.c
@@ -23,7 +23,8 @@
*/
#include "nvc0/nvc0_context.h"
-#include "nvc0/nvc0_compute.h"
+
+#include "nvc0/nvc0_compute.xml.h"
int
nvc0_screen_compute_setup(struct nvc0_screen *screen,
@@ -120,34 +121,6 @@ nvc0_screen_compute_setup(struct nvc0_screen *screen,
return 0;
}
-bool
-nvc0_compute_validate_program(struct nvc0_context *nvc0)
-{
- struct nvc0_program *prog = nvc0->compprog;
-
- if (prog->mem)
- return true;
-
- if (!prog->translated) {
- prog->translated = nvc0_program_translate(
- prog, nvc0->screen->base.device->chipset, &nvc0->base.debug);
- if (!prog->translated)
- return false;
- }
- if (unlikely(!prog->code_size))
- return false;
-
- if (likely(prog->code_size)) {
- if (nvc0_program_upload_code(nvc0, prog)) {
- struct nouveau_pushbuf *push = nvc0->base.pushbuf;
- BEGIN_NVC0(push, NVC0_CP(FLUSH), 1);
- PUSH_DATA (push, NVC0_COMPUTE_FLUSH_CODE);
- return true;
- }
- }
- return false;
-}
-
static void
nvc0_compute_validate_samplers(struct nvc0_context *nvc0)
{
@@ -292,8 +265,7 @@ nvc0_compute_validate_globals(struct nvc0_context *nvc0)
static bool
nvc0_compute_state_validate(struct nvc0_context *nvc0)
{
- if (!nvc0_compute_validate_program(nvc0))
- return false;
+ nvc0_compprog_validate(nvc0);
if (nvc0->dirty_cp & NVC0_NEW_CP_CONSTBUF)
nvc0_compute_validate_constbufs(nvc0);
if (nvc0->dirty_cp & NVC0_NEW_CP_DRIVERCONST)
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_compute.h b/src/gallium/drivers/nouveau/nvc0/nvc0_compute.h
deleted file mode 100644
index a23f7f39dda..00000000000
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_compute.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef NVC0_COMPUTE_H
-#define NVC0_COMPUTE_H
-
-#include "nvc0/nvc0_compute.xml.h"
-
-bool
-nvc0_compute_validate_program(struct nvc0_context *nvc0);
-
-#endif /* NVC0_COMPUTE_H */
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_context.h b/src/gallium/drivers/nouveau/nvc0/nvc0_context.h
index 7aa4b623638..0f1ebb0a6e2 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_context.h
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_context.h
@@ -254,6 +254,7 @@ void nvc0_tctlprog_validate(struct nvc0_context *);
void nvc0_tevlprog_validate(struct nvc0_context *);
void nvc0_gmtyprog_validate(struct nvc0_context *);
void nvc0_fragprog_validate(struct nvc0_context *);
+void nvc0_compprog_validate(struct nvc0_context *);
void nvc0_tfb_validate(struct nvc0_context *);
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_shader_state.c b/src/gallium/drivers/nouveau/nvc0/nvc0_shader_state.c
index 2f46c436a4c..6b02ed5680a 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_shader_state.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_shader_state.c
@@ -28,6 +28,8 @@
#include "nvc0/nvc0_context.h"
#include "nvc0/nvc0_query_hw.h"
+#include "nvc0/nvc0_compute.xml.h"
+
static inline void
nvc0_program_update_context_state(struct nvc0_context *nvc0,
struct nvc0_program *prog, int stage)
@@ -257,6 +259,19 @@ nvc0_gmtyprog_validate(struct nvc0_context *nvc0)
}
void
+nvc0_compprog_validate(struct nvc0_context *nvc0)
+{
+ struct nouveau_pushbuf *push = nvc0->base.pushbuf;
+ struct nvc0_program *cp = nvc0->compprog;
+
+ if (cp && !nvc0_program_validate(nvc0, cp))
+ return;
+
+ BEGIN_NVC0(push, NVC0_CP(FLUSH), 1);
+ PUSH_DATA (push, NVC0_COMPUTE_FLUSH_CODE);
+}
+
+void
nvc0_tfb_validate(struct nvc0_context *nvc0)
{
struct nouveau_pushbuf *push = nvc0->base.pushbuf;
diff --git a/src/gallium/drivers/nouveau/nvc0/nve4_compute.c b/src/gallium/drivers/nouveau/nvc0/nve4_compute.c
index 5c73740d2dd..4a4e8367d28 100644
--- a/src/gallium/drivers/nouveau/nvc0/nve4_compute.c
+++ b/src/gallium/drivers/nouveau/nvc0/nve4_compute.c
@@ -23,7 +23,6 @@
*/
#include "nvc0/nvc0_context.h"
-#include "nvc0/nvc0_compute.h"
#include "nvc0/nve4_compute.h"
#include "codegen/nv50_ir_driver.h"
@@ -306,8 +305,7 @@ nve4_compute_set_tex_handles(struct nvc0_context *nvc0)
static bool
nve4_compute_state_validate(struct nvc0_context *nvc0)
{
- if (!nvc0_compute_validate_program(nvc0))
- return false;
+ nvc0_compprog_validate(nvc0);
if (nvc0->dirty_cp & NVC0_NEW_CP_TEXTURES)
nve4_compute_validate_textures(nvc0);
if (nvc0->dirty_cp & NVC0_NEW_CP_SAMPLERS)