Commit d37b0ab8 by Nicolas Capens Committed by Nicolas Capens

Typedef int4/float4 from a vec4<T> template

This prepares for simplifying assigning the same scalar to all elements. Bug: b/146224130 Change-Id: I8499c671f98090ae38fd12bab59f30ef360eff69 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/39508 Presubmit-Ready: Nicolas Capens <nicolascapens@google.com> Tested-by: 's avatarNicolas Capens <nicolascapens@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Reviewed-by: 's avatarBen Clayton <bclayton@google.com>
parent 9e6cce2d
......@@ -15,11 +15,12 @@
#ifndef sw_Clipper_hpp
#define sw_Clipper_hpp
#include "System/Types.hpp"
namespace sw {
struct DrawCall;
struct Polygon;
struct float4;
struct Clipper
{
......
......@@ -15,11 +15,12 @@
#ifndef Matrix_hpp
#define Matrix_hpp
#include "System/Types.hpp"
namespace sw {
struct Vector;
struct Point;
struct float4;
struct Matrix
{
......
......@@ -71,61 +71,37 @@ typedef ALIGN(16, unsigned int) uint4[4];
typedef ALIGN(8, float) float2[2];
struct alignas(16) int4
template<typename T>
struct alignas(sizeof(T) * 4) vec4
{
int x;
int y;
int z;
int w;
T x;
T y;
T z;
T w;
int &operator[](int i)
T &operator[](int i)
{
return (&x)[i];
}
const int &operator[](int i) const
const T &operator[](int i) const
{
return (&x)[i];
}
bool operator!=(const int4 &rhs)
bool operator!=(const vec4 &rhs)
{
return x != rhs.x || y != rhs.y || z != rhs.z || w != rhs.w;
}
bool operator==(const int4 &rhs)
bool operator==(const vec4 &rhs)
{
return x == rhs.x && y == rhs.y && z == rhs.z && w == rhs.w;
}
};
struct alignas(16) float4
{
float x;
float y;
float z;
float w;
float &operator[](int i)
{
return (&x)[i];
}
const float &operator[](int i) const
{
return (&x)[i];
}
bool operator!=(const float4 &rhs)
{
return x != rhs.x || y != rhs.y || z != rhs.z || w != rhs.w;
}
bool operator==(const float4 &rhs)
{
return x == rhs.x && y == rhs.y && z == rhs.z && w == rhs.w;
}
};
using int4 = vec4<int>;
using float4 = vec4<float>;
inline constexpr float4 vector(float x, float y, float z, float w)
{
......
......@@ -15,9 +15,9 @@
#ifndef VK_FORMAT_UTILS_HPP_
#define VK_FORMAT_UTILS_HPP_
#include <Vulkan/VulkanPlatform.h>
#include "System/Types.hpp"
namespace sw { struct float4; }
#include <Vulkan/VulkanPlatform.h>
namespace vk {
......
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