Bonjour,

J'ai besoin de passer un tableau de 256 entiers dans la mémoire global de mes shader et je n'y parvient pas.

J'ai tenté d'utiliser un Uniform Buffer Object.

EDIT : Voir la totalité 2 post plus bas

Voila mon code c++ (résumé)
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
 
PFNGLGETUNIFORMBLOCKINDEXPROC glGetUniformBlockIndex = 0;
PFNGLUNIFORMBLOCKBINDINGPROC glUniformBlockBinding = 0;
glGetUniformBlockIndex = (PFNGLGETUNIFORMBLOCKINDEXPROC) ctx->getProcAddress("glGetUniformBlockIndex"); // Ok : non nul
glUniformBlockBinding = (PFNGLUNIFORMBLOCKBINDINGPROC) ctx->getProcAddress("glUniformBlockBinding"); // Ok : non nul
...
// p est mon ShaderProgram (il est compilé et linké)
GLuint uniformIndex = glGetUniformBlockIndex(p.programId(), "perm0");
...
QGLBuffer ubo((QGLBuffer::Type)GL_UNIFORM_BUFFER); // Création du buffer
ubo.create(); // Retourne true
ubo.bind(); // Retourne true
ubo.allocate(256 * sizeof (GLint));
ubo.release();
...
GLint perm[256];
initRandomPerm(perm, 256);
ubo.bind(); // Retourne true
ubo.write(0, perm, 256 * sizeof (GLint));
glUniformBlockBinding(p.programId(), uniformIndex, 0);
ubo.release();
// ici je dessine des rectangles...
Et voila le code de mon fichier vertex
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
 
#version 140
in vec2 vertex;
 
uniform perm0
{
    int perm[256];
};
 
void main(void)
{
    ...
    int gi0 = perm[(ii + perm[jj]) % 256] % 8; // A partir d'ici je ne peux pas verifier mais d'après le résultat qui est de couleur uniforme, perm ne contient pas les bonnes valeurs
    ...
}
Je n'ai plus aucune piste pour résoudre mon problème.
Un peu d'aide serait la bienvenue.

A+