Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Reading a buffer operated on by a compute shader
Forum Updated to NodeBB v4.3 + New Features

Reading a buffer operated on by a compute shader

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 741 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kheaactua
    wrote on last edited by A Former User
    #1

    I have a compute shader operating on my buffer in my QML (5.8) app, the problem is that I cannot seem to read this buffer, only write to it.

    My buffer is a Qt3DRender::QBuffer, I set its contents with

    Qt3DRender::QBuffer::setData(QByteArray::fromRawData(reinterpret_cast<const char*>(points_.linearize()), static_cast<int>(sizeof(PointType) * pc)));
    

    where pc is the number of points.

    To use it, I created a QGeometry which sets up QAttributes, and apply the computer shader as a material component to the Entity

    My material:

    Material {
    	property PointBuffer dataBuffer;
    
    	ShaderProgram {
    		id: computeShader
    		computeShaderCode:  loadSource("qrc:/shaders/pointcloud.comp")
    	}
    
    	effect: Effect {
    		techniques: [
    			Technique {
    				renderPasses: [
    					RenderPass {
    						shaderProgram: computeShader
    						parameters: [
    							// Point buffer
    							Parameter { name: "Particles"; value: dataBuffer }
    						]
    					}
    				] // renderpasses
    				filterKeys: [
    					FilterKey { name: "type"; value: "compute" }
    				]
    				graphicsApiFilter {
    					api: GraphicsApiFilter.OpenGL
    					profile: GraphicsApiFilter.CoreProfile
    					majorVersion: 4
    					minorVersion: 3
    				}
    			} // technique
    		] // techniques
    	}
    }
    

    In my buffer code though, whenever I read from the buffer (Qt3DRender::buffer::data()), I only get the data I wrote to it, not the result of the compute shader.

    I've tried setting the usage to various things, but no dice.

    In my OpenGL book, I see that one can glMapBuffer to have read/write access, and there's even a QOpenGLBuffer that has an ENUM to set the access in a similar way, but I can't seem to make use of either of these; i.e. I can't find a way to map my buffer, and the QOpenGLBuffer doesn't seem compatible with any of the renderers.

    (cross posted this on SO and Qt Center)

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved