Eliminated static_cast from KRPipeline::hasUniform
KRPipeline::setUniform now updates push constants for all stages
This commit is contained in:
@@ -475,67 +475,82 @@ KRPipeline::~KRPipeline() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRPipeline::setUniform(Uniform location, float value)
|
|
||||||
{
|
|
||||||
if (m_pushConstants[0].size[static_cast<size_t>(location)] == sizeof(value)) {
|
|
||||||
float* constant = (float*)(m_pushConstantBuffer + m_pushConstants[0].offset[static_cast<size_t>(location)]);
|
|
||||||
*constant = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool KRPipeline::hasUniform(Uniform location) const
|
bool KRPipeline::hasUniform(Uniform location) const
|
||||||
{
|
{
|
||||||
for (int i = 0; i < static_cast<int>(ShaderStages::shaderStageCount); i++) {
|
for (const PushConstantStageInfo& stageConstants : m_pushConstants) {
|
||||||
if (m_pushConstants[i].size[static_cast<size_t>(location)]) {
|
if (stageConstants.size[static_cast<size_t>(location)]) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void KRPipeline::setUniform(Uniform location, float value)
|
||||||
|
{
|
||||||
|
for (PushConstantStageInfo& stageConstants : m_pushConstants) {
|
||||||
|
if (stageConstants.size[static_cast<size_t>(location)] == sizeof(value)) {
|
||||||
|
float* constant = (float*)(m_pushConstantBuffer + stageConstants.offset[static_cast<size_t>(location)]);
|
||||||
|
*constant = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void KRPipeline::setUniform(Uniform location, int value)
|
void KRPipeline::setUniform(Uniform location, int value)
|
||||||
{
|
{
|
||||||
if (m_pushConstants[0].size[static_cast<size_t>(location)] == sizeof(value)) {
|
for (PushConstantStageInfo& stageConstants : m_pushConstants) {
|
||||||
int* constant = (int*)(m_pushConstantBuffer + m_pushConstants[0].offset[static_cast<size_t>(location)]);
|
if (stageConstants.size[static_cast<size_t>(location)] == sizeof(value)) {
|
||||||
*constant = value;
|
int* constant = (int*)(m_pushConstantBuffer + stageConstants.offset[static_cast<size_t>(location)]);
|
||||||
|
*constant = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRPipeline::setUniform(Uniform location, const Vector2 &value)
|
void KRPipeline::setUniform(Uniform location, const Vector2 &value)
|
||||||
{
|
{
|
||||||
if (m_pushConstants[0].size[static_cast<size_t>(location)] == sizeof(value)) {
|
for (PushConstantStageInfo& stageConstants : m_pushConstants) {
|
||||||
Vector2* constant = (Vector2*)(m_pushConstantBuffer + m_pushConstants[0].offset[static_cast<size_t>(location)]);
|
if (stageConstants.size[static_cast<size_t>(location)] == sizeof(value)) {
|
||||||
*constant = value;
|
Vector2* constant = (Vector2*)(m_pushConstantBuffer + stageConstants.offset[static_cast<size_t>(location)]);
|
||||||
|
*constant = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void KRPipeline::setUniform(Uniform location, const Vector3 &value)
|
void KRPipeline::setUniform(Uniform location, const Vector3 &value)
|
||||||
{
|
{
|
||||||
if (m_pushConstants[0].size[static_cast<size_t>(location)] == sizeof(value)) {
|
for (PushConstantStageInfo& stageConstants : m_pushConstants) {
|
||||||
Vector3* constant = (Vector3*)(m_pushConstantBuffer + m_pushConstants[0].offset[static_cast<size_t>(location)]);
|
if (stageConstants.size[static_cast<size_t>(location)] == sizeof(value)) {
|
||||||
*constant = value;
|
Vector3* constant = (Vector3*)(m_pushConstantBuffer + stageConstants.offset[static_cast<size_t>(location)]);
|
||||||
|
*constant = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRPipeline::setUniform(Uniform location, const Vector4 &value)
|
void KRPipeline::setUniform(Uniform location, const Vector4 &value)
|
||||||
{
|
{
|
||||||
if (m_pushConstants[0].size[static_cast<size_t>(location)] == sizeof(value)) {
|
for (PushConstantStageInfo& stageConstants : m_pushConstants) {
|
||||||
Vector4* constant = (Vector4*)(m_pushConstantBuffer + m_pushConstants[0].offset[static_cast<size_t>(location)]);
|
if (stageConstants.size[static_cast<size_t>(location)] == sizeof(value)) {
|
||||||
*constant = value;
|
Vector4* constant = (Vector4*)(m_pushConstantBuffer + stageConstants.offset[static_cast<size_t>(location)]);
|
||||||
|
*constant = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRPipeline::setUniform(Uniform location, const Matrix4 &value)
|
void KRPipeline::setUniform(Uniform location, const Matrix4 &value)
|
||||||
{
|
{
|
||||||
if (m_pushConstants[0].size[static_cast<size_t>(location)] == sizeof(value)) {
|
for (PushConstantStageInfo& stageConstants : m_pushConstants) {
|
||||||
Matrix4* constant = (Matrix4*)(m_pushConstantBuffer + m_pushConstants[0].offset[static_cast<size_t>(location)]);
|
if (stageConstants.size[static_cast<size_t>(location)] == sizeof(value)) {
|
||||||
*constant = value;
|
Matrix4* constant = (Matrix4*)(m_pushConstantBuffer + m_pushConstants[0].offset[static_cast<size_t>(location)]);
|
||||||
|
*constant = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRPipeline::setUniform(Uniform location, const Matrix4* value, const size_t count)
|
void KRPipeline::setUniform(Uniform location, const Matrix4* value, const size_t count)
|
||||||
{
|
{
|
||||||
// TODO - Vulkan refactoring
|
for (PushConstantStageInfo& stageConstants : m_pushConstants) {
|
||||||
// GLDEBUG(glUniformMatrix4fv(pShader->m_pushConstants[0].offset[KRPipeline::Uniform::bone_transforms], (GLsizei)bones.size(), GL_FALSE, bone_mats));
|
// TODO - Vulkan refactoring
|
||||||
|
// GLDEBUG(glUniformMatrix4fv(pShader->m_pushConstants[0].offset[KRPipeline::Uniform::bone_transforms], (GLsizei)bones.size(), GL_FALSE, bone_mats));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KRPipeline::bind(VkCommandBuffer& commandBuffer, KRCamera &camera, const KRViewport &viewport, const Matrix4 &matModel, const std::vector<KRPointLight *> *point_lights, const std::vector<KRDirectionalLight *> *directional_lights, const std::vector<KRSpotLight *> *spot_lights, const KRNode::RenderPass &renderPass)
|
bool KRPipeline::bind(VkCommandBuffer& commandBuffer, KRCamera &camera, const KRViewport &viewport, const Matrix4 &matModel, const std::vector<KRPointLight *> *point_lights, const std::vector<KRDirectionalLight *> *directional_lights, const std::vector<KRSpotLight *> *spot_lights, const KRNode::RenderPass &renderPass)
|
||||||
|
|||||||
Reference in New Issue
Block a user