RHI: Add Compute Pipeline abstraction with D3D12 and OpenGL support
- Add SetComputeShader/GetComputeShader/HasComputeShader to RHIPipelineState - Add m_computePipelineState for D3D12 compute PSO - Add m_computeProgram/m_computeShader for OpenGL - Fix OpenGLCommandList::DispatchCompute bug (was ignoring x,y,z params) - Fix OpenGLShader::GetID usage in OpenGLPipelineState - Mark Priority 8 as completed in RHI_Design_Issues.md
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "XCEngine/RHI/OpenGL/OpenGLPipelineState.h"
|
||||
#include "XCEngine/RHI/OpenGL/OpenGLShader.h"
|
||||
#include <glad/glad.h>
|
||||
|
||||
namespace XCEngine {
|
||||
@@ -37,6 +38,16 @@ void OpenGLPipelineState::SetRenderTargetFormats(uint32_t count, const uint32_t*
|
||||
void OpenGLPipelineState::SetSampleCount(uint32_t count) {
|
||||
}
|
||||
|
||||
void OpenGLPipelineState::SetComputeShader(RHIShader* shader) {
|
||||
m_computeShader = shader;
|
||||
if (shader) {
|
||||
OpenGLShader* glShader = static_cast<OpenGLShader*>(shader);
|
||||
m_computeProgram = glShader->GetID();
|
||||
} else {
|
||||
m_computeProgram = 0;
|
||||
}
|
||||
}
|
||||
|
||||
PipelineStateHash OpenGLPipelineState::GetHash() const {
|
||||
PipelineStateHash hash = {};
|
||||
return hash;
|
||||
@@ -44,11 +55,15 @@ PipelineStateHash OpenGLPipelineState::GetHash() const {
|
||||
|
||||
void OpenGLPipelineState::Shutdown() {
|
||||
m_program = 0;
|
||||
m_computeProgram = 0;
|
||||
m_computeShader = nullptr;
|
||||
m_programAttached = false;
|
||||
}
|
||||
|
||||
void OpenGLPipelineState::Bind() {
|
||||
if (m_programAttached) {
|
||||
if (HasComputeShader()) {
|
||||
glUseProgram(m_computeProgram);
|
||||
} else if (m_programAttached) {
|
||||
glUseProgram(m_program);
|
||||
}
|
||||
Apply();
|
||||
|
||||
Reference in New Issue
Block a user