enum piglit_result piglit_display(void) { int i; int chunk_size = 24 * sizeof(float); bool pass = true; glClearColor(0.2, 0.2, 0.2, 0.2); glClear(GL_COLOR_BUFFER_BIT); for (i = 0; i < sizeof(data) / chunk_size; i++) { glTexBufferRange(GL_TEXTURE_BUFFER, GL_RGBA32F, tbo, i * chunk_size, chunk_size); glDrawArrays(GL_TRIANGLES, 0, 6); } for (i = 0; i < sizeof(data) / chunk_size; i++) { float c[4] = { data[i * 24 + 2], data[i * 24 + 3], 0, 1 }; pass = piglit_probe_rect_rgba( piglit_width * 0.5 * (1 + data[i * 24 + 0]), piglit_height * 0.5 * (1 + data[i * 24 + 1]), piglit_width/2, piglit_height/2, c) && pass; } piglit_present_results(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
EXTERN_C_ENTER JNIEXPORT void JNICALL Java_org_lwjgl_opengl_ARBTextureBufferRange_glTexBufferRange(JNIEnv *__env, jclass clazz, jint target, jint internalformat, jint buffer, jlong offset, jlong size) { glTexBufferRangePROC glTexBufferRange = (glTexBufferRangePROC)tlsGetFunction(903); UNUSED_PARAM(clazz) glTexBufferRange(target, internalformat, buffer, (intptr_t)offset, (intptr_t)size); }
bool initTexture() { GLint TextureBufferOffsetAlignment(0); glGetIntegerv(GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT, &TextureBufferOffsetAlignment); glGenTextures(TEXTURE_MAX, &TextureName[0]); glBindTexture(GL_TEXTURE_BUFFER, TextureName[TEXTURE_DISPLACEMENT]); glTexBufferRange(GL_TEXTURE_BUFFER, GL_RGB32F, BufferName[BUFFER_DISPLACEMENT], TextureBufferOffsetAlignment, sizeof(glm::vec3) * 5); glBindTexture(GL_TEXTURE_BUFFER, 0); glBindTexture(GL_TEXTURE_BUFFER, TextureName[TEXTURE_DIFFUSE]); glTexBufferRange(GL_TEXTURE_BUFFER, GL_RGB32F, BufferName[BUFFER_DIFFUSE], TextureBufferOffsetAlignment, sizeof(glm::vec3) * 5); glBindTexture(GL_TEXTURE_BUFFER, 0); return true; }
int gl_TexBufferRange(State& state){ glTexBufferRange( (GLenum) state.stack->to<int>(1), (GLenum) state.stack->to<int>(2), (GLuint) state.stack->to<int>(3), (GLintptr) state.stack->to<int>(4), (GLsizeiptr) state.stack->to<int>(5) ); return 0; }
bool initTexture() { glGenTextures(texture::MAX, TextureName); gli::texture2D Texture(gli::loadStorageDDS(glf::DATA_DIRECTORY + TEXTURE_DIFFUSE)); assert(!Texture.empty()); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, TextureName[texture::DIFFUSE]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_RED); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, GL_GREEN); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_BLUE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, GL_ALPHA); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, GLint(Texture.levels() - 1)); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexStorage2D(GL_TEXTURE_2D, GLint(Texture.levels()), GL_RGBA8, GLsizei(Texture[0].dimensions().x), GLsizei(Texture[0].dimensions().y)); for(gli::texture2D::size_type Level = 0; Level < Texture.levels(); ++Level) { glTexSubImage2D( GL_TEXTURE_2D, GLint(Level), 0, 0, GLsizei(Texture[Level].dimensions().x), GLsizei(Texture[Level].dimensions().y), GL_BGR, GL_UNSIGNED_BYTE, Texture[Level].data()); } glPixelStorei(GL_UNPACK_ALIGNMENT, 4); GLint TextureBufferOffset(0); glGetIntegerv( GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT, &TextureBufferOffset); GLint TextureBufferRange = glm::max(GLint(PositionSize), TextureBufferOffset); glBindTexture(GL_TEXTURE_BUFFER, TextureName[texture::POSITION_INPUT]); glTexBufferRange(GL_TEXTURE_BUFFER, GL_RGBA32F, BufferName[buffer::POSITION_INPUT], 0, TextureBufferRange); glBindTexture(GL_TEXTURE_BUFFER, TextureName[texture::TEXCOORD_INPUT]); glTexBufferRange(GL_TEXTURE_BUFFER, GL_RGBA32F, BufferName[buffer::TEXCOORD_INPUT], 0, TextureBufferRange); glBindTexture(GL_TEXTURE_BUFFER, TextureName[texture::COLOR_INPUT]); glTexBufferRange(GL_TEXTURE_BUFFER, GL_RGBA32F, BufferName[buffer::COLOR_INPUT], 0, TextureBufferRange); glBindTexture(GL_TEXTURE_BUFFER, TextureName[texture::POSITION_OUTPUT]); glTexBufferRange(GL_TEXTURE_BUFFER, GL_RGBA32F, BufferName[buffer::POSITION_OUTPUT], 0, TextureBufferRange); glBindTexture(GL_TEXTURE_BUFFER, TextureName[texture::TEXCOORD_OUTPUT]); glTexBufferRange(GL_TEXTURE_BUFFER, GL_RGBA32F, BufferName[buffer::TEXCOORD_OUTPUT], 0, TextureBufferRange); glBindTexture(GL_TEXTURE_BUFFER, TextureName[texture::COLOR_OUTPUT]); glTexBufferRange(GL_TEXTURE_BUFFER, GL_RGBA32F, BufferName[buffer::COLOR_OUTPUT], 0, TextureBufferRange); glBindTexture(GL_TEXTURE_BUFFER, 0); return true; }
static void create_buffer_texture(struct wined3d_gl_view *view, struct wined3d_context *context, struct wined3d_buffer *buffer, const struct wined3d_format *view_format, unsigned int offset, unsigned int size) { const struct wined3d_gl_info *gl_info = context->gl_info; if (!gl_info->supported[ARB_TEXTURE_BUFFER_OBJECT]) { FIXME("OpenGL implementation does not support buffer textures.\n"); return; } if ((offset & (gl_info->limits.texture_buffer_offset_alignment - 1))) { FIXME("Buffer offset %u is not %u byte aligned.\n", offset, gl_info->limits.texture_buffer_offset_alignment); return; } wined3d_buffer_load_location(buffer, context, WINED3D_LOCATION_BUFFER); view->target = GL_TEXTURE_BUFFER; gl_info->gl_ops.gl.p_glGenTextures(1, &view->name); context_bind_texture(context, GL_TEXTURE_BUFFER, view->name); if (gl_info->supported[ARB_TEXTURE_BUFFER_RANGE]) { GL_EXTCALL(glTexBufferRange(GL_TEXTURE_BUFFER, view_format->glInternal, buffer->buffer_object, offset, size)); } else { if (offset || size != buffer->resource.size) FIXME("OpenGL implementation does not support ARB_texture_buffer_range.\n"); GL_EXTCALL(glTexBuffer(GL_TEXTURE_BUFFER, view_format->glInternal, buffer->buffer_object)); } checkGLcall("Create buffer texture"); context_invalidate_compute_state(context, STATE_COMPUTE_SHADER_RESOURCE_BINDING); context_invalidate_state(context, STATE_GRAPHICS_SHADER_RESOURCE_BINDING); }
void piglit_init(int argc, char **argv) { GLint align, value[2]; GLuint tex, bo; piglit_require_gl_version(20); piglit_require_extension("GL_ARB_texture_buffer_range"); glGenTextures(1, &tex); glBindTexture(GL_TEXTURE_BUFFER, tex); glGenBuffers(1, &bo); glBindBuffer(GL_TEXTURE_BUFFER, bo); glGetIntegerv(GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT, &align); if (align < 1) { fprintf(stderr, "GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT == %i, " "should be >= 1\n", align); piglit_report_result(PIGLIT_FAIL); } /* If <offset> is negative or if <size> is * less than or equal to zero or if <offset> + <size> is greater than * the value of BUFFER_SIZE for the buffer bound to <target>, of if * <offset> is not an integer multiple of * TEXTURE_BUFFER_OFFSET_ALIGNMENT, then the error INVALID_VALUE * is generated. */ glTexBufferRange(GL_TEXTURE_BUFFER, GL_RGBA8, bo, 0, 4); if (!piglit_check_gl_error(GL_INVALID_VALUE)) piglit_report_result(PIGLIT_FAIL); glBufferData(GL_TEXTURE_BUFFER, TBO_SIZE, NULL, GL_STATIC_DRAW); glTexBufferRange(GL_TEXTURE_BUFFER, GL_RGBA8, bo, -align, 4); if (!piglit_check_gl_error(GL_INVALID_VALUE)) piglit_report_result(PIGLIT_FAIL); glTexBufferRange(GL_TEXTURE_BUFFER, GL_RGBA8, bo, 0, 0); if (!piglit_check_gl_error(GL_INVALID_VALUE)) piglit_report_result(PIGLIT_FAIL); glTexBufferRange(GL_TEXTURE_BUFFER, GL_RGBA8, bo, 0, -16); if (!piglit_check_gl_error(GL_INVALID_VALUE)) piglit_report_result(PIGLIT_FAIL); if (align > 1) { glTexBufferRange(GL_TEXTURE_BUFFER, GL_RGBA8, bo, align / 2, 16); if (!piglit_check_gl_error(GL_INVALID_VALUE)) piglit_report_result(PIGLIT_FAIL); } glTexBufferRange(GL_TEXTURE_BUFFER, GL_RGBA8, bo, align, TBO_SIZE - align); if (!piglit_check_gl_error(GL_NO_ERROR)) { fprintf(stderr, "glTexBufferRange failed\n"); piglit_report_result(PIGLIT_FAIL); } glGetTexLevelParameteriv(GL_TEXTURE_BUFFER, 0, GL_TEXTURE_BUFFER_OFFSET, &value[0]); glGetTexLevelParameteriv(GL_TEXTURE_BUFFER, 0, GL_TEXTURE_BUFFER_SIZE, &value[1]); if (value[0] != align || value[1] != TBO_SIZE - align) { fprintf(stderr, "GL_TEXTURE_BUFFER_OFFSET/SIZE returned %i/%i, " "expected %i/%i\n", value[0], value[1], align, TBO_SIZE - align); piglit_report_result(PIGLIT_FAIL); } /* If <buffer> is zero, then any buffer object attached to the * buffer texture is detached, the values <offset> and <size> are * ignored and the state for <offset> and <size> for the * buffer texture are reset to zero. */ glTexBufferRange(GL_TEXTURE_BUFFER, GL_RGBA8, 0, -align, TBO_SIZE * 2); if (!piglit_check_gl_error(GL_NO_ERROR)) piglit_report_result(PIGLIT_FAIL); glGetTexLevelParameteriv(GL_TEXTURE_BUFFER, 0, GL_TEXTURE_BUFFER_OFFSET, &value[0]); glGetTexLevelParameteriv(GL_TEXTURE_BUFFER, 0, GL_TEXTURE_BUFFER_SIZE, &value[1]); if (value[0] || value[1]) { fprintf(stderr, "buffer detached but " "GL_TEXTURE_BUFFER_OFFSET/SIZE " "not reset to 0\n"); piglit_report_result(PIGLIT_FAIL); } piglit_report_result(PIGLIT_PASS); }
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GL43_nglTexBufferRange(JNIEnv *__env, jclass clazz, jint target, jint internalformat, jint buffer, jlong offset, jlong size, jlong __functionAddress) { glTexBufferRangePROC glTexBufferRange = (glTexBufferRangePROC)(intptr_t)__functionAddress; UNUSED_PARAMS(__env, clazz) glTexBufferRange(target, internalformat, buffer, (GLintptr)offset, (GLsizeiptr)size); }
void BufferTexture::setBufferRangeImplementationDefault(BufferTextureFormat internalFormat, Buffer* buffer, GLintptr offset, GLsizeiptr size) { bindInternal(); glTexBufferRange(GL_TEXTURE_BUFFER, GLenum(internalFormat), buffer->id(), offset, size); }
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GL43_nglTexBufferRange(JNIEnv *env, jclass clazz, jint target, jint internalformat, jint buffer, jlong offset, jlong size, jlong function_pointer) { glTexBufferRangePROC glTexBufferRange = (glTexBufferRangePROC)((intptr_t)function_pointer); glTexBufferRange(target, internalformat, buffer, offset, size); }