Commit 25ec7b0c by Alexis Hetu Committed by Alexis Hétu

Removed references to sw::Surface

Removed sw::Surface dependency from: - Blitter - Context - PixelProcessor - PixelRoutine - Renderer - VkFramebuffer No behavior changes should be happen with this cl. Bug b/126883332 Change-Id: I4146f043ba8e5008eb3d44465c26a0f34a2e1acc Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/26969Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Presubmit-Ready: Alexis Hétu <sugoi@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Reviewed-by: 's avatarChris Forbes <chrisforbes@google.com>
parent 1407297b
......@@ -15,9 +15,10 @@
#ifndef sw_Blitter_hpp
#define sw_Blitter_hpp
#include "Surface.hpp"
#include "RoutineCache.hpp"
#include "Reactor/Reactor.hpp"
#include "System/MutexLock.hpp"
#include "Vulkan/VkFormat.h"
#include <string.h>
......@@ -62,7 +63,7 @@ namespace sw
{
State() = default;
State(const Options &options) : Options(options) {}
State(VkFormat sourceFormat, VkFormat destFormat, int destSamples, const Options &options) :
State(vk::Format sourceFormat, vk::Format destFormat, int destSamples, const Options &options) :
Options(options), sourceFormat(sourceFormat), destFormat(destFormat), destSamples(destSamples) {}
bool operator==(const State &state) const
......@@ -70,9 +71,9 @@ namespace sw
return memcmp(this, &state, sizeof(State)) == 0;
}
VkFormat sourceFormat;
VkFormat destFormat;
int destSamples;
vk::Format sourceFormat = VK_FORMAT_UNDEFINED;
vk::Format destFormat = VK_FORMAT_UNDEFINED;
int destSamples = 0;
};
struct BlitData
......@@ -101,27 +102,21 @@ namespace sw
Blitter();
virtual ~Blitter();
void clear(void *pixel, VkFormat format, Surface *dest, const SliceRect &dRect, unsigned int rgbaMask);
void clear(void *pixel, VkFormat format, vk::Image *dest, const VkImageSubresourceRange& subresourceRange, const VkRect2D* renderArea = nullptr);
void clear(void *pixel, vk::Format format, vk::Image *dest, const VkImageSubresourceRange& subresourceRange, const VkRect2D* renderArea = nullptr);
void blit(Surface *source, const SliceRectF &sRect, Surface *dest, const SliceRect &dRect, const Options &options);
void blit(vk::Image *src, vk::Image *dst, VkImageBlit region, VkFilter filter);
void blit3D(Surface *source, Surface *dest);
private:
bool fastClear(void *pixel, VkFormat format, Surface *dest, const SliceRect &dRect, unsigned int rgbaMask);
bool fastClear(void *pixel, VkFormat format, vk::Image *dest, const VkImageSubresourceRange& subresourceRange, const VkRect2D* renderArea);
bool fastClear(void *pixel, vk::Format format, vk::Image *dest, const VkImageSubresourceRange& subresourceRange, const VkRect2D* renderArea);
bool read(Float4 &color, Pointer<Byte> element, const State &state);
bool write(Float4 &color, Pointer<Byte> element, const State &state);
bool read(Int4 &color, Pointer<Byte> element, const State &state);
bool write(Int4 &color, Pointer<Byte> element, const State &state);
static bool GetScale(float4& scale, VkFormat format);
static bool ApplyScaleAndClamp(Float4 &value, const State &state, bool preScaled = false);
static Int ComputeOffset(Int &x, Int &y, Int &pitchB, int bytes, bool quadLayout);
static Float4 LinearToSRGB(Float4 &color);
static Float4 sRGBtoLinear(Float4 &color);
bool blitReactor(Surface *source, const SliceRectF &sRect, Surface *dest, const SliceRect &dRect, const Options &options);
Routine *getRoutine(const State &state);
Routine *generate(const State &state);
......
......@@ -15,7 +15,6 @@
#include "Context.hpp"
#include "Primitive.hpp"
#include "Surface.hpp"
#include "System/Memory.hpp"
#include "Vulkan/VkDebug.hpp"
#include "Vulkan/VkImageView.hpp"
......
......@@ -14,7 +14,6 @@
#include "PixelProcessor.hpp"
#include "Surface.hpp"
#include "Primitive.hpp"
#include "Pipeline/PixelProgram.hpp"
#include "Pipeline/Constants.hpp"
......@@ -401,7 +400,7 @@ namespace sw
{
state.depthTestActive = true;
state.depthCompareMode = context->depthCompareMode;
state.quadLayoutDepthBuffer = Surface::hasQuadLayout(context->depthBuffer->getFormat());
state.quadLayoutDepthBuffer = context->depthBuffer->getFormat().hasQuadLayout();
state.depthFormat = context->depthBuffer->getFormat();
}
......@@ -427,7 +426,7 @@ namespace sw
state.targetFormat[i] = context->renderTargetInternalFormat(i);
}
state.writeSRGB = context->writeSRGB && context->renderTarget[0] && Surface::isSRGBwritable(context->renderTarget[0]->getFormat());
state.writeSRGB = context->writeSRGB && context->renderTarget[0] && context->renderTarget[0]->getFormat().isSRGBwritable();
state.multiSample = context->sampleCount;
state.multiSampleMask = context->multiSampleMask;
......
......@@ -15,7 +15,6 @@
#include "Renderer.hpp"
#include "Clipper.hpp"
#include "Surface.hpp"
#include "Primitive.hpp"
#include "Polygon.hpp"
#include "WSI/FrameBuffer.hpp"
......@@ -478,21 +477,6 @@ namespace sw
}
}
void Renderer::clear(void *value, VkFormat format, Surface *dest, const Rect &clearRect, unsigned int rgbaMask)
{
blitter->clear(value, format, dest, clearRect, rgbaMask);
}
void Renderer::blit(Surface *source, const SliceRectF &sRect, Surface *dest, const SliceRect &dRect, bool filter, bool isStencil, bool sRGBconversion)
{
blitter->blit(source, sRect, dest, dRect, {filter, isStencil, sRGBconversion});
}
void Renderer::blit3D(Surface *source, Surface *dest)
{
blitter->blit3D(source, dest);
}
void Renderer::threadFunction(void *parameters)
{
Renderer *renderer = static_cast<Parameters*>(parameters)->renderer;
......
......@@ -249,10 +249,6 @@ namespace sw
void draw(DrawType drawType, unsigned int count, bool update = true);
void clear(void *value, VkFormat format, Surface *dest, const Rect &rect, unsigned int rgbaMask);
void blit(Surface *source, const SliceRectF &sRect, Surface *dest, const SliceRect &dRect, bool filter, bool isStencil = false, bool sRGBconversion = true);
void blit3D(Surface *source, Surface *dest);
void setContext(const sw::Context& context);
void setMultiSampleMask(unsigned int mask);
......
......@@ -18,7 +18,6 @@
#include "Constants.hpp"
#include "Device/Renderer.hpp"
#include "Device/QuadRasterizer.hpp"
#include "Device/Surface.hpp"
#include "Device/Primitive.hpp"
#include "Vulkan/VkDebug.hpp"
......@@ -988,7 +987,7 @@ namespace sw
bool PixelRoutine::isSRGB(int index) const
{
return Surface::isSRGBformat(state.targetFormat[index]);
return vk::Format(state.targetFormat[index]).isSRGBformat();
}
void PixelRoutine::readPixel(int index, Pointer<Byte> &cBuffer, Int &x, Vector4s &pixel)
......@@ -1787,13 +1786,14 @@ namespace sw
Short4 c23;
Float4 one;
if(Surface::isFloatFormat(state.targetFormat[index]))
vk::Format format(state.targetFormat[index]);
if(format.isFloatFormat())
{
one = Float4(1.0f);
}
else if(Surface::isNonNormalizedInteger(state.targetFormat[index]))
else if(format.isNonNormalizedInteger())
{
one = As<Float4>(Surface::isUnsignedComponent(state.targetFormat[index], 0) ? Int4(0xFFFFFFFF) : Int4(0x7FFFFFFF));
one = As<Float4>(format.isUnsignedComponent(0) ? Int4(0xFFFFFFFF) : Int4(0x7FFFFFFF));
}
switch(state.targetFormat[index])
......
......@@ -17,6 +17,11 @@
#include <vulkan/vulkan_core.h>
namespace sw
{
struct float4;
}
namespace vk
{
......@@ -24,17 +29,26 @@ class Format
{
public:
Format(VkFormat format) : format(format) {}
operator VkFormat() const { return format; }
inline operator VkFormat() const { return format; }
bool isSignedNonNormalizedInteger() const;
bool isUnsignedNonNormalizedInteger() const;
bool isNonNormalizedInteger() const;
bool isStencil() const;
bool isDepth() const;
bool hasQuadLayout() const;
bool isSRGBformat() const;
bool isSRGBwritable() const;
bool isFloatFormat() const;
bool isUnsignedComponent(int component) const;
int bytes() const;
int pitchB(int width, int border, bool target) const;
int sliceB(int width, int height, int border, bool target) const;
bool getScale(sw::float4 &scale) const;
private:
VkFormat format;
};
......
......@@ -15,7 +15,6 @@
#include "VkFramebuffer.hpp"
#include "VkImageView.hpp"
#include "VkRenderPass.hpp"
#include "Device/Surface.hpp"
#include <algorithm>
#include <memory.h>
......@@ -46,8 +45,9 @@ void Framebuffer::clear(uint32_t clearValueCount, const VkClearValue* pClearValu
for(uint32_t i = 0; i < count; i++)
{
const VkAttachmentDescription attachment = renderPass->getAttachment(i);
bool isDepth = sw::Surface::isDepth(attachment.format);
bool isStencil = sw::Surface::isStencil(attachment.format);
const Format format(attachment.format);
bool isDepth = format.isDepth();
bool isStencil = format.isStencil();
if(isDepth || isStencil)
{
......
......@@ -16,6 +16,7 @@
#define VK_IMAGE_VIEW_HPP_
#include "VkDebug.hpp"
#include "VkFormat.h"
#include "VkObject.hpp"
#include "VkImage.hpp"
......@@ -34,7 +35,7 @@ public:
void clear(const VkClearValue& clearValues, VkImageAspectFlags aspectMask, const VkRect2D& renderArea);
void clear(const VkClearValue& clearValue, VkImageAspectFlags aspectMask, const VkClearRect& renderArea);
VkFormat getFormat() const { return format; }
Format getFormat() const { return format; }
int getSampleCount() const { return image->getSampleCountFlagBits(); }
int rowPitchBytes(VkImageAspectFlagBits aspect) const { return image->rowPitchBytes(aspect, subresourceRange.baseMipLevel); }
int slicePitchBytes(VkImageAspectFlagBits aspect) const { return image->slicePitchBytes(aspect, subresourceRange.baseMipLevel); }
......@@ -48,7 +49,7 @@ private:
Image* image = nullptr;
VkImageViewType viewType = VK_IMAGE_VIEW_TYPE_2D;
VkFormat format = VK_FORMAT_UNDEFINED;
Format format = VK_FORMAT_UNDEFINED;
VkComponentMapping components = {};
VkImageSubresourceRange subresourceRange = {};
};
......
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