projects
/
clouds.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
6021139
)
Make PBO speedier
author
Luke Lau
<luke_lau@icloud.com>
Tue, 14 Apr 2020 14:52:24 +0000
(15:52 +0100)
committer
Luke Lau
<luke_lau@icloud.com>
Tue, 14 Apr 2020 14:52:24 +0000
(15:52 +0100)
clouds.cpp
patch
|
blob
|
history
diff --git
a/clouds.cpp
b/clouds.cpp
index ff6e59d8faca801d28a5638897a28e115ffb0b37..5787181c79fbac832a0984d362a654eaaa6ae619 100644
(file)
--- a/
clouds.cpp
+++ b/
clouds.cpp
@@
-167,7
+167,7
@@
mat4 faceView(mat4 m) {
const int shadeWidth = 256, shadeHeight = 256;
#ifdef PBO
const int shadeWidth = 256, shadeHeight = 256;
#ifdef PBO
-const int numPbos =
64
;
+const int numPbos =
512
;
GLuint pboBufs[numPbos];
GLuint pboOffsets[numPbos]; // offsets into GL_PIXEL_PACK_BUFFER that
// mapPixelRead should read from
GLuint pboBufs[numPbos];
GLuint pboOffsets[numPbos]; // offsets into GL_PIXEL_PACK_BUFFER that
// mapPixelRead should read from
@@
-176,8
+176,10
@@
GLbyte sink[shadeWidth * shadeHeight * 4];
void inline mapPixelRead(int pboBuf, int metaball) {
glBindBuffer(GL_PIXEL_PACK_BUFFER, pboBufs[pboBuf]);
GLubyte *src =
void inline mapPixelRead(int pboBuf, int metaball) {
glBindBuffer(GL_PIXEL_PACK_BUFFER, pboBufs[pboBuf]);
GLubyte *src =
- (GLubyte *)glMapBufferRange(GL_PIXEL_PACK_BUFFER,
pboOffsets[pboBuf]
,
+ (GLubyte *)glMapBufferRange(GL_PIXEL_PACK_BUFFER,
0
,
4 * sizeof(GLubyte), GL_MAP_READ_BIT);
4 * sizeof(GLubyte), GL_MAP_READ_BIT);
+ /* (GLubyte *)glMapBufferRange(GL_PIXEL_PACK_BUFFER, pboOffsets[pboBuf], */
+ /* 4 * sizeof(GLubyte), GL_MAP_READ_BIT); */
vec4 pixel = vec4(src[0], src[1], src[2], src[3]) / vec4(255.f);
glUnmapBuffer(GL_PIXEL_PACK_BUFFER);
vec4 pixel = vec4(src[0], src[1], src[2], src[3]) / vec4(255.f);
glUnmapBuffer(GL_PIXEL_PACK_BUFFER);
@@
-272,9
+274,10
@@
void shadeClouds() {
/* glReadPixels(screenPos.x, screenPos.y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE,
*/
/* NULL); */
/* glReadPixels(screenPos.x, screenPos.y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE,
*/
/* NULL); */
- glReadPixels(0, 0, shadeWidth, shadeHeight, GL_RGBA, GL_UNSIGNED_BYTE,
- NULL);
- pboOffsets[pboIdx] = screenPos.x * 4 + screenPos.y * shadeWidth * 4;
+ /* glReadPixels(0, 0, shadeWidth, shadeHeight, GL_RGBA, GL_UNSIGNED_BYTE, */
+ /* NULL); */
+ glReadPixels(screenPos.x, screenPos.y, 64, 64, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+ /* pboOffsets[pboIdx] = screenPos.x * 4 + screenPos.y * shadeWidth * 4; */
int nextPbo = (pboIdx + 1) % numPbos;
if (i >= numPbos - 1) {
int nextPbo = (pboIdx + 1) % numPbos;
if (i >= numPbos - 1) {
@@
-549,7
+552,7
@@
int main(int argc, char **argv) {
glGenBuffers(numPbos, pboBufs);
for (int i = 0; i < numPbos; i++) {
glBindBuffer(GL_PIXEL_PACK_BUFFER, pboBufs[i]);
glGenBuffers(numPbos, pboBufs);
for (int i = 0; i < numPbos; i++) {
glBindBuffer(GL_PIXEL_PACK_BUFFER, pboBufs[i]);
- glBufferData(GL_PIXEL_PACK_BUFFER,
shadeWidth * shadeHeight
* 4, NULL,
+ glBufferData(GL_PIXEL_PACK_BUFFER,
64 * 64
* 4, NULL,
GL_DYNAMIC_READ);
}
glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
GL_DYNAMIC_READ);
}
glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);