OpenGL EXT: shader_buffer_load
http://www.opengl.org/registry/specs/NV/shader_buffer_load.txt
Overview At a very coarse level, GL has evolved in a way that allows
applications to replace many of the original state machine variables
with blocks of user-defined data. For example, the current vertex
state has been augmented by vertex buffer objects, fixed-function
shading state and parameters have been replaced by shaders/programs
and constant buffers, etc.. Applications switch between coarse sets
of state by binding objects to the context or to other container
objects (e.g. vertex array objects) instead of manipulating state
variables of the context. In terms of the number of GL commands
required to draw an object, modern applications are orders of
magnitude more efficient than legacy applications, but this explosion
of objects bound to other objects has led to a new bottleneck -
pointer chasing and CPU L2 cache misses in the driver, and general
L2 cache pollution. This extension provides a mechanism to read from a flat, 64-bit GPU
address space from programs/shaders, to query GPU addresses of buffer
objects at the API level, and to bind buffer objects to the context in
such a way that they can be accessed via their GPU addresses in any
shader stage. The intent is that applications can avoid re-binding buffer objects
or updating constants between each Draw call and instead simply use
a VertexAttrib (or TexCoord, or InstanceID, or...) to "point" to the
new object's state. In this way, one of the cheapest "state" updates
(from the CPU's point of view) can be used to effect a significant
state change in the shader similarly to how a pointer change may on
the CPU. At the same time, this relieves the limits on how many
buffer objects can be accessed at once by shaders, and allows these
buffer object accesses to be exposed as C-style pointer dereferences
in the shading language. As a very simple example, imagine packing a group of similar objects'
constants into a single buffer object and pointing your program
at object <i> by setting "glVertexAttribI1iEXT(attrLoc, i);"
and using a shader as such: struct MyObjectType {
mat4x4 modelView;
vec4 materialPropertyX;
// etc.
};
uniform MyObjectType *allObjects;
in int objectID; // bound to attrLoc ... mat4x4 thisObjectsMatrix = allObjects[objectID].modelView;
// do transform, shading, etc. This is beneficial in much the same way that texture arrays allow
choosing between similar, but independent, texture maps with a single
coordinate identifying which slice of the texture to use. It also
resembles instancing, where a lightweight change (incrementing the
instance ID) can be used to generate a different and interesting
result, but with additional flexibility over instancing because the
values are app-controlled and not a single incrementing counter. Dependent pointer fetches are allowed, so more complex scene graph
structures can be built into buffer objects providing significant new
flexibility in the use of shaders. Another simple example, showing
something you can't do with existing functionality, is to do dependent
fetches into many buffer objects: GenBuffers(N, dataBuffers);
GenBuffers(1, &pointerBuffer); GLuint64EXT gpuAddrs[N];
for (i = 0; i < N; ++i) {
BindBuffer(target, dataBuffers[i]);
BufferData(target, size[i], myData[i], STATIC_DRAW); // get the address of this buffer and make it resident.
GetBufferParameterui64vNV(target, BUFFER_GPU_ADDRESS,
gpuaddrs[i]);
MakeBufferResidentNV(target, READ_ONLY);
} GLuint64EXT pointerBufferAddr;
BindBuffer(target, pointerBuffer);
BufferData(target, sizeof(GLuint64EXT)*N, gpuAddrs, STATIC_DRAW);
GetBufferParameterui64vNV(target, BUFFER_GPU_ADDRESS,
&pointerBufferAddr);
MakeBufferResidentNV(target, READ_ONLY); // now in the shader, we can use a double indirection
vec4 **ptrToBuffers = pointerBufferAddr;
vec4 *ptrToBufferI = ptrToBuffers[i]; This allows simultaneous access to more buffers than
EXT_bindable_uniform (MAX_VERTEX_BINDABLE_UNIFORMS, etc.) and each
can be larger than MAX_BINDABLE_UNIFORM_SIZE.
OpenGL EXT: shader_buffer_load的更多相关文章
- three.js 相关概念
1.什么是three.js? Three.js 是一个 3D JavaScript 库.Three.js 封装了底层的图形接口,使得程序员能够在无需掌握繁冗的图形学知识的情况下,也能用简单的代码实现三 ...
- opengl入门学习
OpenGL入门学习 说起编程作图,大概还有很多人想起TC的#include <graphics.h>吧? 但是各位是否想过,那些画面绚丽的PC游戏是如何编写出来的?就靠TC那可怜的640 ...
- [翻译]opengl扩展教程1
[翻译]opengl扩展教程1 原文地址https://www.opengl.org/sdk/docs/tutorials/ClockworkCoders/extensions.php [翻译]ope ...
- OpenGL开发环境配置-Windows/MinGW/Clion/CMake
因为某些原因,不想用过于臃肿的VS了,转而使用常用的jetbrains的CLion,Clion沿袭了jetbrans的优良传统,基本代码提示功能还是比较好的,不过就是对于windows不熟悉cmake ...
- OpenGL extension specification (from openGL.org)
Shader read/write/atomic into UAV global memory (need manual sync) http://www.opengl.org/registry/sp ...
- [工作积累] OpenGL ES3.0: glInvalidateFramebuffer
https://www.khronos.org/opengles/sdk/docs/man3/html/glInvalidateFramebuffer.xhtml 这个在GLES2.0上只有Exten ...
- Android OpenGL 学习笔记 --开始篇
转自: http://www.cnblogs.com/TerryBlog/archive/2010/07/09/1774475.html 1.什么是 OpenGL? OpenGL 是个专业的3D程序接 ...
- OpenGL入门学习(转)
OpenGL入门学习 http://www.cppblog.com/doing5552/archive/2009/01/08/71532.html 说起编程作图,大概还有很多人想起TC的#includ ...
- 【OpenGL游戏开发之二】OpenGL常用API
OpenGL常用API 开发基于OpenGL的应用程序,必须先了解OpenGL的库函数.它采用C语言风格,提供大量的函数来进行图形的处理和显示.OpenGL库函数的命名方式非常有规律.所有OpenGL ...
随机推荐
- 转圈游戏(codevs 3285)
题目描述 Description n 个小伙伴(编号从 0 到 n-1)围坐一圈玩游戏.按照顺时针方向给 n 个位置编号,从0 到 n-1.最初,第 0 号小伙伴在第 0 号位置,第 1 号小伙伴在第 ...
- 实现dom元素拖动
本文主要写一下如何实现dom元素拖动,目前使用jquery库实现之. 主要的注释附在代码中,大家可以根据代码画一个小的窗口模型图,以便于理解. <!DOCTYPE html> <ht ...
- hadoop的关键进程
hadoop集群中主要进程有master: NameNode, ResourceManager,slaves: DataNode, NodeManager, RunJar, MRAppMas ...
- WSGI服务器实践二--实践一个基本功能的WSGI服务器
由于各种PYTHON框架都实现了WSGI接口,所以,通用性很广的. 在调试过程过,有一个字母拼错,搞了一个小时. 看来PYTHON自带的编辑器没有高亮,不爽. 在有提示的编辑器里一看就看了来啦..:) ...
- ytu 2029: C语言实验——温度转换(水题)
2029: C语言实验——温度转换 Time Limit: 1 Sec Memory Limit: 64 MBSubmit: 12 Solved: 10[Submit][Status][Web B ...
- HBase伪分布式环境下,HBase的API操作,遇到的问题
在hadoop2.5.2伪分布式上,安装了hbase1.0.1.1的伪分布式 利用HBase的API创建个testapi的表时,提示 Exception in thread "main&q ...
- Android RelativeLayout 实现左右中布局
效果图如下: 代码如下: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns ...
- 2016 Multi-University Training Contest 8
solved 4/11 2016 Multi-University Training Contest 8 贪心 1001 Ball(BH) 代码: #include <bits/stdc++.h ...
- 排序+逆向思维 ACdream 1205 Disappeared Block
题目传送门 /* 从大到小排序,逆向思维,从最后开始考虑,无后向性 每找到一个没被淹没的,对它左右的楼层查询是否它是孤立的,若是++,若不是-- 复杂度 O(n + m),还以为 O(n^2)吓得写了 ...
- Oracle 使用小计(3)
1.出错处理 ORA-00911: invalid character. 这是因为在语句末尾加上了";"的缘故,去掉";"SQL就可以执行了~ (这与SQL ...