From cd9ab1c9dbec82663c9f55985e70b1f089973bb4 Mon Sep 17 00:00:00 2001 From: baldurk Date: Fri, 3 May 2019 11:14:02 +0100 Subject: [PATCH] Add test of GL_Buffer_Updates --- .../data/GL_Buffer_Updates/backbuffer.png | Bin 0 -> 1028 bytes util/test/demos/gl/gl_buffer_updates.cpp | 60 ++++++++++++------ util/test/tests/GL/GL_Buffer_Updates.py | 38 +++++++++++ 3 files changed, 80 insertions(+), 18 deletions(-) create mode 100644 util/test/data/GL_Buffer_Updates/backbuffer.png create mode 100644 util/test/tests/GL/GL_Buffer_Updates.py diff --git a/util/test/data/GL_Buffer_Updates/backbuffer.png b/util/test/data/GL_Buffer_Updates/backbuffer.png new file mode 100644 index 0000000000000000000000000000000000000000..eb21d64ff1d044edf346f8823ca06f1eb511fbc0 GIT binary patch literal 1028 zcmeAS@N?(olHy`uVBq!ia0y~yV4MKNIvi|3k+<8Q9%5i%KJDq^7*cWT?e&AahZO`| z9Xsv_iSA$*-)Z`QYnz7BbOG%{inA;W{>RMQ=5{`i;eoS$JVQeRgMtDB2L}Ta6A;mq z2et%m1C4nwPeJS>m1m!_dtP$BcYlZRY5TVf1&yFEBGn97XyVid4+^kK0=y5drd53R z85+1*8Z@`Pw*0p3ONYhg8;R|*Wj74V+kv9dEG!I+j1CSA0s;&`CXIOzOJMeac@64U zURc&JGw2C0EW5Gp`HkC`lpmc*0y!}8_#IiGXr3V0Whk29PR3#&WpeP40NV%Q%?nuk z`~xq;4hM!ANw5g+205@@wzwQ9y2BL~d`OyLA&JdEisaz_1DgWjRXFv|J8aJIVWqhR XQ-Y7qg0^O0?q=|G^>bP0l+XkKp$DQ3 literal 0 HcmV?d00001 diff --git a/util/test/demos/gl/gl_buffer_updates.cpp b/util/test/demos/gl/gl_buffer_updates.cpp index 249b7b709..f3a5e1e09 100644 --- a/util/test/demos/gl/gl_buffer_updates.cpp +++ b/util/test/demos/gl/gl_buffer_updates.cpp @@ -297,15 +297,19 @@ void main() ptr = (Vec4f *)glMapBufferRange(GL_UNIFORM_BUFFER, 0, sizeof(Vec4f), GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); - memcpy(ptr, &green, sizeof(Vec4f)); + if(ptr) + memcpy(ptr, &green, sizeof(Vec4f)); glUnmapBuffer(GL_UNIFORM_BUFFER); glBindBuffer(GL_UNIFORM_BUFFER, buffers[CleanBufferMapWriteNonInvalidate]); glBufferData(GL_UNIFORM_BUFFER, sizeof(Vec4f), &red, GL_DYNAMIC_DRAW); ptr = (Vec4f *)glMapBufferRange(GL_UNIFORM_BUFFER, 0, sizeof(Vec4f), GL_MAP_WRITE_BIT); - ptr->x = 0.0f; - ptr->y = 1.0f; + if(ptr) + { + ptr->x = 0.0f; + ptr->y = 1.0f; + } glUnmapBuffer(GL_UNIFORM_BUFFER); glBindBuffer(GL_UNIFORM_BUFFER, buffers[DirtyBufferMapWriteInvalidate]); @@ -313,15 +317,19 @@ void main() ptr = (Vec4f *)glMapBufferRange(GL_UNIFORM_BUFFER, 0, sizeof(Vec4f), GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); - memcpy(ptr, &green, sizeof(Vec4f)); + if(ptr) + memcpy(ptr, &green, sizeof(Vec4f)); glUnmapBuffer(GL_UNIFORM_BUFFER); glBindBuffer(GL_UNIFORM_BUFFER, buffers[DirtyBufferMapWriteNonInvalidate]); glBufferSubData(GL_UNIFORM_BUFFER, 0, sizeof(Vec4f), &red); ptr = (Vec4f *)glMapBufferRange(GL_UNIFORM_BUFFER, 0, sizeof(Vec4f), GL_MAP_WRITE_BIT); - ptr->x = 0.0f; - ptr->y = 1.0f; + if(ptr) + { + ptr->x = 0.0f; + ptr->y = 1.0f; + } glUnmapBuffer(GL_UNIFORM_BUFFER); glBindBuffer(GL_UNIFORM_BUFFER, buffers[CleanBufferMapFlushExplicit]); @@ -329,25 +337,35 @@ void main() ptr = (Vec4f *)glMapBufferRange(GL_UNIFORM_BUFFER, 0, sizeof(Vec4f), GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT); - ptr->x = 0.0f; - ptr->y = 1.0f; + if(ptr) + { + ptr->x = 0.0f; + ptr->y = 1.0f; + } glFlushMappedBufferRange(GL_UNIFORM_BUFFER, 0, sizeof(float) * 2); glUnmapBuffer(GL_UNIFORM_BUFFER); glBindBuffer(GL_UNIFORM_BUFFER, buffers[DirtyBufferMapFlushExplicit]); ptr = (Vec4f *)glMapBufferRange(GL_UNIFORM_BUFFER, 0, sizeof(Vec4f), GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT); - ptr->x = 0.0f; - ptr->y = 1.0f; + if(ptr) + { + ptr->x = 0.0f; + ptr->y = 1.0f; + } glFlushMappedBufferRange(GL_UNIFORM_BUFFER, 0, sizeof(float) * 2); glUnmapBuffer(GL_UNIFORM_BUFFER); - memcpy(ptrs[CoherentMapWrite], &red, sizeof(Vec4f)); - memcpy(ptrs[CoherentMapWriteInvalidateRange], &red, sizeof(Vec4f)); - memcpy(ptrs[CoherentMapWriteInvalidateBuffer], &red, sizeof(Vec4f)); + if(ptrs[CoherentMapWrite]) + memcpy(ptrs[CoherentMapWrite], &red, sizeof(Vec4f)); + if(ptrs[CoherentMapWriteInvalidateRange]) + memcpy(ptrs[CoherentMapWriteInvalidateRange], &red, sizeof(Vec4f)); + if(ptrs[CoherentMapWriteInvalidateBuffer]) + memcpy(ptrs[CoherentMapWriteInvalidateBuffer], &red, sizeof(Vec4f)); glBindBuffer(GL_UNIFORM_BUFFER, buffers[NonCoherentMapFlush]); - memcpy(ptrs[NonCoherentMapFlush], &red, sizeof(Vec4f)); + if(ptrs[NonCoherentMapFlush]) + memcpy(ptrs[NonCoherentMapFlush], &red, sizeof(Vec4f)); glFlushMappedBufferRange(GL_UNIFORM_BUFFER, 0, sizeof(float) * 4); glBindBuffer(GL_UNIFORM_BUFFER, buffers[OffsetMapWrite]); @@ -355,7 +373,8 @@ void main() ptr = (Vec4f *)glMapBufferRange(GL_UNIFORM_BUFFER, sizeof(float) * 2, sizeof(float), GL_MAP_WRITE_BIT); - ptr->x = 0.0f; + if(ptr) + ptr->x = 0.0f; glUnmapBuffer(GL_UNIFORM_BUFFER); glBindBuffer(GL_UNIFORM_BUFFER, buffers[OffsetMapFlush]); @@ -363,7 +382,8 @@ void main() ptr = (Vec4f *)glMapBufferRange(GL_UNIFORM_BUFFER, sizeof(float) * 2, sizeof(float), GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT); - ptr->x = 0.0f; + if(ptr) + ptr->x = 0.0f; glFlushMappedBufferRange(GL_UNIFORM_BUFFER, 0, sizeof(float)); glUnmapBuffer(GL_UNIFORM_BUFFER); @@ -382,12 +402,16 @@ void main() if(buf == CoherentMapWrite || buf == CoherentMapWriteInvalidateRange || buf == CoherentMapWriteInvalidateBuffer) - memcpy(ptrs[buf], &green, sizeof(Vec4f)); + { + if(ptrs[buf]) + memcpy(ptrs[buf], &green, sizeof(Vec4f)); + } if(buf == NonCoherentMapFlush) { glBindBuffer(GL_UNIFORM_BUFFER, buffers[NonCoherentMapFlush]); - memcpy(ptrs[NonCoherentMapFlush], &green, sizeof(Vec4f)); + if(ptrs[NonCoherentMapFlush]) + memcpy(ptrs[NonCoherentMapFlush], &green, sizeof(Vec4f)); glFlushMappedBufferRange(GL_UNIFORM_BUFFER, 0, sizeof(float) * 4); } diff --git a/util/test/tests/GL/GL_Buffer_Updates.py b/util/test/tests/GL/GL_Buffer_Updates.py new file mode 100644 index 000000000..3a3f6fe2f --- /dev/null +++ b/util/test/tests/GL/GL_Buffer_Updates.py @@ -0,0 +1,38 @@ +import rdtest +import renderdoc as rd + + +class GL_Buffer_Updates(rdtest.TestCase): + def get_capture(self): + return rdtest.run_and_capture("demos_x64", "GL_Buffer_Updates", 5) + + def check_capture(self): + self.check_final_backbuffer() + + # Open the capture and grab the thumbnail, check that it is all green too (dirty way of verifying we didn't + # break in-app updates but somehow end up with the right data) + cap = rd.OpenCaptureFile() + + # Open a particular file + status = cap.OpenFile(self.capture_filename, '', None) + + # Make sure the file opened successfully + if status != rd.ReplayStatus.Succeeded: + cap.Shutdown() + raise rdtest.TestFailureException("Couldn't open '{}': {}".format(self.capture_filename, str(status))) + + thumb: rd.Thumbnail = cap.GetThumbnail(rd.FileType.PNG, 0) + + tmp_path = rdtest.get_tmp_path('thumbnail.png') + + with open(tmp_path, 'wb') as f: + f.write(thumb.data) + + # The original thumbnail should also be identical, since we have the uncompressed extended thumbnail. + ref_path = self.get_ref_path('backbuffer.png') + + if not rdtest.png_compare(tmp_path, ref_path): + raise rdtest.TestFailureException("Reference backbuffer and thumbnail image differ", tmp_path, ref_path) + + rdtest.log.success("Thumbnail is identical to reference") +