Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query result buffer support #22

Open
LukasBanana opened this issue Jul 26, 2018 · 0 comments
Open

Query result buffer support #22

LukasBanana opened this issue Jul 26, 2018 · 0 comments
Assignees
Labels
feature request Requested features and TODO lists reminder

Comments

@LukasBanana
Copy link
Owner

LukasBanana commented Jul 26, 2018

D3D12 always requires an explicit buffer resource for the results of a query heap.
OpenGL added a buffer type GL_QUERY_BUFFER so the query results can be used in a shader.
This functionality should be added to LLGL.

Proposal:

enum class BufferType {
    /* ... */
    QueryResult,
};

struct BufferFlags {
    enum {
        /* ... */
        // Force creation of query buffer also for GL backend.
        // Otherwise, the buffer is only created for D3D12.
        QueryShaderReadAccess = (1 << 3),
    };
};

class CommandBuffer {
    /* ... */
    void ResolveQuery(
        Buffer&         dstBuffer,
        std::uint64_t   dstOffset,
        QueryHeap&      srcQueryHeap,
        std::uint32_t   firstQuery,
        std::uint32_t   numQueries
    );
};

Example:

myCmdBuffer->Begin();
myCmdBuffer->BeginRenderPass();
myCmdBuffer->BeginQuery(*myQuery, 0);
/* ... */
myCmdBuffer->EndQuery(*myQuery, 0);
myCmdBuffer->EndRenderPass();
myCmdBuffer->ResolveQuery(*myResultBuffer, 0, *myQuery, 0, 1);
myCmdBuffer->End();

myCmdQueue->Submit(*myCmdBuffer);

std::uint64_t result = 0;
if (myCmdQueue->QueryResult(*myQuery, 0, 1, &result, sizeof(result))) {
    /* ... */
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Requested features and TODO lists reminder
Projects
LLGL Project
  
To Do
Development

No branches or pull requests

1 participant