[Mesa-dev] [PATCH] mesa: remove DummyShader from atifragshader.c
Miklós Máté
mtmkls at gmail.com
Wed Dec 20 16:33:39 UTC 2017
It's much cleaner to allocate a normal shader struct when
GenFragmentShadersATI is called.
Signed-off-by: Miklós Máté <mtmkls at gmail.com>
---
src/mesa/main/atifragshader.c | 21 ++++++++++-----------
1 file changed, 10 insertions(+), 11 deletions(-)
diff --git a/src/mesa/main/atifragshader.c b/src/mesa/main/atifragshader.c
index 6b636f1dc7..0a5ba26310 100644
--- a/src/mesa/main/atifragshader.c
+++ b/src/mesa/main/atifragshader.c
@@ -34,8 +34,6 @@
#define MESA_DEBUG_ATI_FS 0
-static struct ati_fragment_shader DummyShader;
-
/**
* Allocate and initialize a new ATI fragment shader object.
@@ -61,9 +59,6 @@ _mesa_delete_ati_fragment_shader(struct gl_context *ctx, struct ati_fragment_sha
{
GLuint i;
- if (s == &DummyShader)
- return;
-
for (i = 0; i < MAX_NUM_PASSES_ATI; i++) {
free(s->Instructions[i]);
free(s->SetupInst[i]);
@@ -205,7 +200,13 @@ _mesa_GenFragmentShadersATI(GLuint range)
first = _mesa_HashFindFreeKeyBlock(ctx->Shared->ATIShaders, range);
for (i = 0; i < range; i++) {
- _mesa_HashInsertLocked(ctx->Shared->ATIShaders, first + i, &DummyShader);
+ struct ati_fragment_shader *newProg = _mesa_new_ati_fragment_shader(ctx, first + i);
+ if (!newProg) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindFragmentShaderATI");
+ _mesa_HashUnlockMutex(ctx->Shared->ATIShaders);
+ return;
+ }
+ _mesa_HashInsertLocked(ctx->Shared->ATIShaders, first + i, newProg);
}
_mesa_HashUnlockMutex(ctx->Shared->ATIShaders);
@@ -246,7 +247,7 @@ _mesa_BindFragmentShaderATI(GLuint id)
else {
newProg = (struct ati_fragment_shader *)
_mesa_HashLookup(ctx->Shared->ATIShaders, id);
- if (!newProg || newProg == &DummyShader) {
+ if (!newProg) {
/* allocate a new program now */
newProg = _mesa_new_ati_fragment_shader(ctx, id);
if (!newProg) {
@@ -279,10 +280,8 @@ _mesa_DeleteFragmentShaderATI(GLuint id)
if (id != 0) {
struct ati_fragment_shader *prog = (struct ati_fragment_shader *)
_mesa_HashLookup(ctx->Shared->ATIShaders, id);
- if (prog == &DummyShader) {
- _mesa_HashRemove(ctx->Shared->ATIShaders, id);
- }
- else if (prog) {
+
+ if (prog) {
if (ctx->ATIFragmentShader.Current &&
ctx->ATIFragmentShader.Current->Id == id) {
FLUSH_VERTICES(ctx, _NEW_PROGRAM);
--
2.15.0.rc0
More information about the mesa-dev
mailing list