Commit 68d9ad83 by Nicolas Capens Committed by Nicolas Capens

Remove the sw::Color<> class

It was only still being used to store framebuffer blend constants. Use sw::float4 instead. Bug: b/146224130 Change-Id: Ie5660e237f4b675564d5a492f9d0a38505d07953 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/43388Tested-by: 's avatarNicolas Capens <nicolascapens@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarBen Clayton <bclayton@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
parent 9aff7ae7
...@@ -42,7 +42,6 @@ swiftshader_source_set("Device") { ...@@ -42,7 +42,6 @@ swiftshader_source_set("Device") {
"BC_Decoder.cpp", "BC_Decoder.cpp",
"Blitter.cpp", "Blitter.cpp",
"Clipper.cpp", "Clipper.cpp",
"Color.cpp",
"Config.cpp", "Config.cpp",
"Context.cpp", "Context.cpp",
"ETC_Decoder.cpp", "ETC_Decoder.cpp",
......
// Copyright 2016 The SwiftShader Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "Color.hpp"
namespace sw {
} // namespace sw
...@@ -59,28 +59,28 @@ PixelProcessor::~PixelProcessor() ...@@ -59,28 +59,28 @@ PixelProcessor::~PixelProcessor()
routineCache = nullptr; routineCache = nullptr;
} }
void PixelProcessor::setBlendConstant(const Color<float> &blendConstant) void PixelProcessor::setBlendConstant(const float4 &blendConstant)
{ {
// TODO(b/140935644): Check if clamp is required // TODO(b/140935644): Check if clamp is required
factor.blendConstant4W[0] = word4(static_cast<uint16_t>(iround(0xFFFFu * blendConstant.r))); factor.blendConstant4W[0] = word4(static_cast<uint16_t>(iround(0xFFFFu * blendConstant.x)));
factor.blendConstant4W[1] = word4(static_cast<uint16_t>(iround(0xFFFFu * blendConstant.g))); factor.blendConstant4W[1] = word4(static_cast<uint16_t>(iround(0xFFFFu * blendConstant.y)));
factor.blendConstant4W[2] = word4(static_cast<uint16_t>(iround(0xFFFFu * blendConstant.b))); factor.blendConstant4W[2] = word4(static_cast<uint16_t>(iround(0xFFFFu * blendConstant.z)));
factor.blendConstant4W[3] = word4(static_cast<uint16_t>(iround(0xFFFFu * blendConstant.a))); factor.blendConstant4W[3] = word4(static_cast<uint16_t>(iround(0xFFFFu * blendConstant.w)));
factor.invBlendConstant4W[0] = word4(0xFFFFu - factor.blendConstant4W[0][0]); factor.invBlendConstant4W[0] = word4(0xFFFFu - factor.blendConstant4W[0][0]);
factor.invBlendConstant4W[1] = word4(0xFFFFu - factor.blendConstant4W[1][0]); factor.invBlendConstant4W[1] = word4(0xFFFFu - factor.blendConstant4W[1][0]);
factor.invBlendConstant4W[2] = word4(0xFFFFu - factor.blendConstant4W[2][0]); factor.invBlendConstant4W[2] = word4(0xFFFFu - factor.blendConstant4W[2][0]);
factor.invBlendConstant4W[3] = word4(0xFFFFu - factor.blendConstant4W[3][0]); factor.invBlendConstant4W[3] = word4(0xFFFFu - factor.blendConstant4W[3][0]);
factor.blendConstant4F[0] = float4(blendConstant.r); factor.blendConstant4F[0] = float4(blendConstant.x);
factor.blendConstant4F[1] = float4(blendConstant.g); factor.blendConstant4F[1] = float4(blendConstant.y);
factor.blendConstant4F[2] = float4(blendConstant.b); factor.blendConstant4F[2] = float4(blendConstant.z);
factor.blendConstant4F[3] = float4(blendConstant.a); factor.blendConstant4F[3] = float4(blendConstant.w);
factor.invBlendConstant4F[0] = float4(1 - blendConstant.r); factor.invBlendConstant4F[0] = float4(1 - blendConstant.x);
factor.invBlendConstant4F[1] = float4(1 - blendConstant.g); factor.invBlendConstant4F[1] = float4(1 - blendConstant.y);
factor.invBlendConstant4F[2] = float4(1 - blendConstant.b); factor.invBlendConstant4F[2] = float4(1 - blendConstant.z);
factor.invBlendConstant4F[3] = float4(1 - blendConstant.a); factor.invBlendConstant4F[3] = float4(1 - blendConstant.w);
} }
void PixelProcessor::setRoutineCacheSize(int cacheSize) void PixelProcessor::setRoutineCacheSize(int cacheSize)
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#ifndef sw_PixelProcessor_hpp #ifndef sw_PixelProcessor_hpp
#define sw_PixelProcessor_hpp #define sw_PixelProcessor_hpp
#include "Color.hpp"
#include "Context.hpp" #include "Context.hpp"
#include "Memset.hpp" #include "Memset.hpp"
#include "RoutineCache.hpp" #include "RoutineCache.hpp"
...@@ -149,7 +148,7 @@ public: ...@@ -149,7 +148,7 @@ public:
virtual ~PixelProcessor(); virtual ~PixelProcessor();
void setBlendConstant(const Color<float> &blendConstant); void setBlendConstant(const float4 &blendConstant);
protected: protected:
const State update(const Context *context) const; const State update(const Context *context) const;
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#ifndef sw_Sampler_hpp #ifndef sw_Sampler_hpp
#define sw_Sampler_hpp #define sw_Sampler_hpp
#include "Device/Color.hpp"
#include "Device/Config.hpp" #include "Device/Config.hpp"
#include "System/Types.hpp" #include "System/Types.hpp"
#include "Vulkan/VkFormat.h" #include "Vulkan/VkFormat.h"
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#ifndef Vertex_hpp #ifndef Vertex_hpp
#define Vertex_hpp #define Vertex_hpp
#include "Color.hpp"
#include "Device/Config.hpp" #include "Device/Config.hpp"
#include "System/Types.hpp" #include "System/Types.hpp"
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "Device/Config.hpp" #include "Device/Config.hpp"
#include "Device/Sampler.hpp" #include "Device/Sampler.hpp"
#include "System/Debug.hpp" #include "System/Debug.hpp"
#include "System/Math.hpp"
#include "System/Types.hpp" #include "System/Types.hpp"
#include "Vulkan/VkConfig.h" #include "Vulkan/VkConfig.h"
#include "Vulkan/VkDescriptorSet.hpp" #include "Vulkan/VkDescriptorSet.hpp"
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include "ShaderCore.hpp" #include "ShaderCore.hpp"
#include "SpirvShader.hpp" #include "SpirvShader.hpp"
#include "Device/Color.hpp"
#include "Device/VertexProcessor.hpp" #include "Device/VertexProcessor.hpp"
namespace vk { namespace vk {
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#include "VkConfig.h" #include "VkConfig.h"
#include "VkDescriptorSet.hpp" #include "VkDescriptorSet.hpp"
#include "VkObject.hpp" #include "VkObject.hpp"
#include "Device/Color.hpp"
#include "Device/Context.hpp" #include "Device/Context.hpp"
#include <memory> #include <memory>
...@@ -159,7 +158,7 @@ public: ...@@ -159,7 +158,7 @@ public:
{ {
VkViewport viewport; VkViewport viewport;
VkRect2D scissor; VkRect2D scissor;
sw::Color<float> blendConstants; sw::float4 blendConstants;
float depthBiasConstantFactor = 0.0f; float depthBiasConstantFactor = 0.0f;
float depthBiasClamp = 0.0f; float depthBiasClamp = 0.0f;
float depthBiasSlopeFactor = 0.0f; float depthBiasSlopeFactor = 0.0f;
......
...@@ -398,10 +398,10 @@ GraphicsPipeline::GraphicsPipeline(const VkGraphicsPipelineCreateInfo *pCreateIn ...@@ -398,10 +398,10 @@ GraphicsPipeline::GraphicsPipeline(const VkGraphicsPipelineCreateInfo *pCreateIn
if(!hasDynamicState(VK_DYNAMIC_STATE_BLEND_CONSTANTS)) if(!hasDynamicState(VK_DYNAMIC_STATE_BLEND_CONSTANTS))
{ {
blendConstants.r = colorBlendState->blendConstants[0]; blendConstants.x = colorBlendState->blendConstants[0];
blendConstants.g = colorBlendState->blendConstants[1]; blendConstants.y = colorBlendState->blendConstants[1];
blendConstants.b = colorBlendState->blendConstants[2]; blendConstants.z = colorBlendState->blendConstants[2];
blendConstants.a = colorBlendState->blendConstants[3]; blendConstants.w = colorBlendState->blendConstants[3];
} }
for(auto i = 0u; i < colorBlendState->attachmentCount; i++) for(auto i = 0u; i < colorBlendState->attachmentCount; i++)
...@@ -545,7 +545,7 @@ const VkViewport &GraphicsPipeline::getViewport() const ...@@ -545,7 +545,7 @@ const VkViewport &GraphicsPipeline::getViewport() const
return viewport; return viewport;
} }
const sw::Color<float> &GraphicsPipeline::getBlendConstants() const const sw::float4 &GraphicsPipeline::getBlendConstants() const
{ {
return blendConstants; return blendConstants;
} }
......
...@@ -102,7 +102,7 @@ public: ...@@ -102,7 +102,7 @@ public:
const sw::Context &getContext() const; const sw::Context &getContext() const;
const VkRect2D &getScissor() const; const VkRect2D &getScissor() const;
const VkViewport &getViewport() const; const VkViewport &getViewport() const;
const sw::Color<float> &getBlendConstants() const; const sw::float4 &getBlendConstants() const;
bool hasDynamicState(VkDynamicState dynamicState) const; bool hasDynamicState(VkDynamicState dynamicState) const;
bool hasPrimitiveRestartEnable() const { return primitiveRestartEnable; } bool hasPrimitiveRestartEnable() const { return primitiveRestartEnable; }
...@@ -117,7 +117,7 @@ private: ...@@ -117,7 +117,7 @@ private:
sw::Context context; sw::Context context;
VkRect2D scissor; VkRect2D scissor;
VkViewport viewport; VkViewport viewport;
sw::Color<float> blendConstants; sw::float4 blendConstants;
}; };
class ComputePipeline : public Pipeline, public ObjectBase<ComputePipeline, VkPipeline> class ComputePipeline : public Pipeline, public ObjectBase<ComputePipeline, VkPipeline>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment