opengl ubo setup

opengl can now compile with ubo buffer objects similar to cbuffers on dx side.

cleaned double up of data from both sides, gfxhandles only need to use the desc info instead of holding onto its own.
This commit is contained in:
marauder2k7 2024-03-13 22:23:01 +00:00
parent fbed04050a
commit 9dc5ae833b
7 changed files with 941 additions and 605 deletions

View file

@ -95,12 +95,9 @@ HRESULT gfxD3D11Include::Close( THIS_ LPCVOID pData )
GFXD3D11ShaderConstHandle::GFXD3D11ShaderConstHandle(GFXD3D11Shader* shader)
: mShader(shader),
mSize(0),
mSampler(-1),
mArraySize(1),
mInstancingConstant(false)
{
mType = GFXSCT_ConstBuffer;
dMemset(&mDesc, 0, sizeof(mDesc));
mValid = false;
mStageFlags = 0;
}
@ -108,18 +105,15 @@ GFXD3D11ShaderConstHandle::GFXD3D11ShaderConstHandle(GFXD3D11Shader* shader)
GFXD3D11ShaderConstHandle::GFXD3D11ShaderConstHandle(GFXD3D11Shader* shader,
const GFXShaderConstDesc& desc)
: mShader(shader),
mSize(desc.size),
mSampler(desc.samplerReg),
mType(desc.constType),
mArraySize(desc.arraySize),
mDesc(desc),
mInstancingConstant(false)
{
if (desc.constType == GFXSCT_ConstBuffer)
mValid = false;
else
mValid = true;
addDesc(desc.shaderStage, desc);
addDesc(desc.shaderStage, desc);
mStageFlags = desc.shaderStage;
}
@ -976,7 +970,7 @@ void GFXD3D11Shader::_getShaderConstants( ID3D11ShaderReflection* refTable,
varDesc.constType = convertConstType(shaderTypeDesc);
#ifdef D3D11_DEBUG_SPEW
Con::printf("Variable Name %s:, offset: %d, size: %d, constantDesc.Elements: %d", varDesc.name.c_str(), varDesc.StartOffset, varDesc.Size, varDesc.arraySize);
Con::printf("Variable Name %s:, offset: %d, size: %d, constantDesc.Elements: %d", varDesc.name.c_str(), varDesc.offset, varDesc.size, varDesc.arraySize);
#endif
mShaderConsts.push_back(varDesc);
}

View file

@ -69,15 +69,15 @@ public:
virtual ~GFXD3D11ShaderConstHandle();
void addDesc(GFXShaderStage stage, const GFXShaderConstDesc& desc);
const GFXShaderConstDesc getDesc(GFXShaderStage stage);
const String& getName() const { return mName; }
GFXShaderConstType getType() const { return mType; }
U32 getArraySize() const { return mArraySize; }
const String& getName() const { return mDesc.name; }
GFXShaderConstType getType() const { return mDesc.constType; }
U32 getArraySize() const { return mDesc.arraySize; }
U32 getSize() const { return mSize; }
U32 getSize() const { return mDesc.size; }
void setValid(bool valid) { mValid = valid; }
/// @warning This will always return the value assigned when the shader was
/// initialized. If the value is later changed this method won't reflect that.
S32 getSamplerRegister() const { return (!isSampler() || !mValid) ? -1 : mSampler; }
S32 getSamplerRegister() const { return (!isSampler() || !mValid) ? -1 : mDesc.samplerReg; }
// Returns true if this is a handle to a sampler register.
bool isSampler() const
@ -93,13 +93,9 @@ public:
mValid = false;
}
GFXShaderConstDesc mDesc;
GFXD3D11Shader* mShader;
DescMap mDescMap;
String mName;
GFXShaderConstType mType;
U32 mSize;
U32 mArraySize;
S32 mSampler; // sampler number, will be -1 if not a sampler.
U32 mStageFlags;
bool mInstancingConstant;
};