improve shaders
parent
51320bfab1
commit
34c58f04a9
|
@ -9,11 +9,14 @@ int main() {
|
|||
texture_t tex = texture_create(512, 512, 4, 0, TEXTURE_LINEAR|TEXTURE_FLOAT);
|
||||
|
||||
while ( window_swap() && !input_down(KEY_ESC) ){
|
||||
if (input(KEY_F5)) window_reload();
|
||||
shader_bind(comp);
|
||||
shader_float("t", (float)window_time());
|
||||
shader_image(&tex, 0, 0, -1, READ);
|
||||
shader_image(tex, 0, 0, -1, READ);
|
||||
dispatch(512, 512, 1);
|
||||
imageWriteBarrier();
|
||||
image_write_barrier();
|
||||
fullscreen_quad_rgb(tex, 2.2);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -2366,9 +2366,10 @@ READ_WRITE
|
|||
};
|
||||
unsigned compute(const char *cs);
|
||||
void dispatch(unsigned wx, unsigned wy, unsigned wz);
|
||||
void shader_image(texture_t *t, unsigned unit, unsigned level, int layer , unsigned access);
|
||||
void shader_image(texture_t t, unsigned unit, unsigned level, int layer , unsigned access);
|
||||
void shader_image_unit(unsigned texture, unsigned unit, unsigned level, int layer , unsigned texel_type, unsigned access);
|
||||
void imageWriteBarrier();
|
||||
void image_write_barrier();
|
||||
void write_barrier();
|
||||
enum MESH_FLAGS {
|
||||
MESH_STATIC = 0,
|
||||
MESH_STREAM = 1,
|
||||
|
|
|
@ -16491,9 +16491,10 @@ enum ACCESS_MODE {
|
|||
|
||||
API unsigned compute(const char *cs);
|
||||
API void dispatch(unsigned wx, unsigned wy, unsigned wz);
|
||||
API void shader_image(texture_t *t, unsigned unit, unsigned level, int layer /* -1 to disable layered access */, unsigned access);
|
||||
API void shader_image(texture_t t, unsigned unit, unsigned level, int layer /* -1 to disable layered access */, unsigned access);
|
||||
API void shader_image_unit(unsigned texture, unsigned unit, unsigned level, int layer /* -1 to disable layered access */, unsigned texel_type, unsigned access);
|
||||
API void imageWriteBarrier();
|
||||
API void image_write_barrier();
|
||||
API void write_barrier();
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// meshes (@fixme: deprecate?)
|
||||
|
@ -340154,7 +340155,11 @@ void dispatch(unsigned wx, unsigned wy, unsigned wz){
|
|||
glDispatchCompute(wx, wy, wz);
|
||||
}
|
||||
|
||||
void imageWriteBarrier(){
|
||||
void write_barrier(){
|
||||
glMemoryBarrier(GL_ALL_BARRIER_BITS);
|
||||
}
|
||||
|
||||
void image_write_barrier(){
|
||||
glMemoryBarrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT);
|
||||
}
|
||||
|
||||
|
@ -340190,8 +340195,8 @@ void shader_texture_unit(const char *sampler, unsigned id, unsigned unit) {
|
|||
glActiveTexture(GL_TEXTURE0 + unit);
|
||||
glBindTexture(GL_TEXTURE_2D, id);
|
||||
}
|
||||
void shader_image(texture_t *t, unsigned unit, unsigned level, int layer /* -1 to disable layered access */, unsigned access){
|
||||
shader_image_unit(t->id, unit, level, layer, t->texel_type, access);
|
||||
void shader_image(texture_t t, unsigned unit, unsigned level, int layer /* -1 to disable layered access */, unsigned access){
|
||||
shader_image_unit(t.id, unit, level, layer, t.texel_type, access);
|
||||
}
|
||||
void shader_image_unit(unsigned texture, unsigned unit, unsigned level, int layer, unsigned texel_type, unsigned access){
|
||||
GLenum gl_access[] = {GL_READ_ONLY, GL_WRITE_ONLY, GL_READ_WRITE};
|
||||
|
|
|
@ -240,7 +240,11 @@ void dispatch(unsigned wx, unsigned wy, unsigned wz){
|
|||
glDispatchCompute(wx, wy, wz);
|
||||
}
|
||||
|
||||
void imageWriteBarrier(){
|
||||
void write_barrier(){
|
||||
glMemoryBarrier(GL_ALL_BARRIER_BITS);
|
||||
}
|
||||
|
||||
void image_write_barrier(){
|
||||
glMemoryBarrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT);
|
||||
}
|
||||
|
||||
|
@ -276,8 +280,8 @@ void shader_texture_unit(const char *sampler, unsigned id, unsigned unit) {
|
|||
glActiveTexture(GL_TEXTURE0 + unit);
|
||||
glBindTexture(GL_TEXTURE_2D, id);
|
||||
}
|
||||
void shader_image(texture_t *t, unsigned unit, unsigned level, int layer /* -1 to disable layered access */, unsigned access){
|
||||
shader_image_unit(t->id, unit, level, layer, t->texel_type, access);
|
||||
void shader_image(texture_t t, unsigned unit, unsigned level, int layer /* -1 to disable layered access */, unsigned access){
|
||||
shader_image_unit(t.id, unit, level, layer, t.texel_type, access);
|
||||
}
|
||||
void shader_image_unit(unsigned texture, unsigned unit, unsigned level, int layer, unsigned texel_type, unsigned access){
|
||||
GLenum gl_access[] = {GL_READ_ONLY, GL_WRITE_ONLY, GL_READ_WRITE};
|
||||
|
|
|
@ -336,9 +336,10 @@ enum ACCESS_MODE {
|
|||
|
||||
API unsigned compute(const char *cs);
|
||||
API void dispatch(unsigned wx, unsigned wy, unsigned wz);
|
||||
API void shader_image(texture_t *t, unsigned unit, unsigned level, int layer /* -1 to disable layered access */, unsigned access);
|
||||
API void shader_image(texture_t t, unsigned unit, unsigned level, int layer /* -1 to disable layered access */, unsigned access);
|
||||
API void shader_image_unit(unsigned texture, unsigned unit, unsigned level, int layer /* -1 to disable layered access */, unsigned texel_type, unsigned access);
|
||||
API void imageWriteBarrier();
|
||||
API void image_write_barrier();
|
||||
API void write_barrier();
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// meshes (@fixme: deprecate?)
|
||||
|
|
10
engine/v4k.c
10
engine/v4k.c
|
@ -11154,7 +11154,11 @@ void dispatch(unsigned wx, unsigned wy, unsigned wz){
|
|||
glDispatchCompute(wx, wy, wz);
|
||||
}
|
||||
|
||||
void imageWriteBarrier(){
|
||||
void write_barrier(){
|
||||
glMemoryBarrier(GL_ALL_BARRIER_BITS);
|
||||
}
|
||||
|
||||
void image_write_barrier(){
|
||||
glMemoryBarrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT);
|
||||
}
|
||||
|
||||
|
@ -11190,8 +11194,8 @@ void shader_texture_unit(const char *sampler, unsigned id, unsigned unit) {
|
|||
glActiveTexture(GL_TEXTURE0 + unit);
|
||||
glBindTexture(GL_TEXTURE_2D, id);
|
||||
}
|
||||
void shader_image(texture_t *t, unsigned unit, unsigned level, int layer /* -1 to disable layered access */, unsigned access){
|
||||
shader_image_unit(t->id, unit, level, layer, t->texel_type, access);
|
||||
void shader_image(texture_t t, unsigned unit, unsigned level, int layer /* -1 to disable layered access */, unsigned access){
|
||||
shader_image_unit(t.id, unit, level, layer, t.texel_type, access);
|
||||
}
|
||||
void shader_image_unit(unsigned texture, unsigned unit, unsigned level, int layer, unsigned texel_type, unsigned access){
|
||||
GLenum gl_access[] = {GL_READ_ONLY, GL_WRITE_ONLY, GL_READ_WRITE};
|
||||
|
|
|
@ -2574,9 +2574,10 @@ enum ACCESS_MODE {
|
|||
|
||||
API unsigned compute(const char *cs);
|
||||
API void dispatch(unsigned wx, unsigned wy, unsigned wz);
|
||||
API void shader_image(texture_t *t, unsigned unit, unsigned level, int layer /* -1 to disable layered access */, unsigned access);
|
||||
API void shader_image(texture_t t, unsigned unit, unsigned level, int layer /* -1 to disable layered access */, unsigned access);
|
||||
API void shader_image_unit(unsigned texture, unsigned unit, unsigned level, int layer /* -1 to disable layered access */, unsigned texel_type, unsigned access);
|
||||
API void imageWriteBarrier();
|
||||
API void image_write_barrier();
|
||||
API void write_barrier();
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// meshes (@fixme: deprecate?)
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue