Skip to content

Commit

Permalink
Remove some GL/D3D legacy format quirks from vulkan vertex buffers
Browse files Browse the repository at this point in the history
- Fix mapping of B8G8R8A8 -- this is the same as the old D3DCOLOR.
- Remove all the other stream types that don't match anything in Vulkan.
- Remove unused resource pointer in stream

There is still future cleanup work to do here -- we should be able to
do vertex fetch purely based on the VkFormat rather than mapping it onto
the GL model.

Change-Id: Ia100ec68e8930acd17b6cba35a27403b4ef8e883
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/25768
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Tested-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
  • Loading branch information
chrisforbes committed Mar 4, 2019
1 parent c7943e9 commit d318dd3
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 128 deletions.
11 changes: 1 addition & 10 deletions src/Device/Stream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,16 @@

namespace sw
{
class Resource;

enum StreamType ENUM_UNDERLYING_TYPE_UNSIGNED_INT
{
STREAMTYPE_COLOR, // 4 normalized unsigned bytes, ZYXW order
STREAMTYPE_UDEC3, // 3 unsigned 10-bit fields
STREAMTYPE_DEC3N, // 3 normalized signed 10-bit fields
STREAMTYPE_INDICES, // 4 unsigned bytes, stored unconverted into X component
STREAMTYPE_FLOAT, // Normalization ignored
STREAMTYPE_BYTE,
STREAMTYPE_SBYTE,
STREAMTYPE_SHORT,
STREAMTYPE_USHORT,
STREAMTYPE_INT,
STREAMTYPE_UINT,
STREAMTYPE_FIXED, // Normalization ignored (16.16 format)
STREAMTYPE_HALF, // Normalization ignored
STREAMTYPE_2_10_10_10_INT,
STREAMTYPE_2_10_10_10_UINT,
Expand All @@ -44,16 +38,14 @@ namespace sw

struct StreamResource
{
Resource *resource;
const void *buffer;
unsigned int stride;
};

struct Stream : public StreamResource
{
Stream(Resource *resource = 0, const void *buffer = 0, unsigned int stride = 0)
Stream(const void *buffer = nullptr, unsigned int stride = 0)
{
this->resource = resource;
this->buffer = buffer;
this->stride = stride;
}
Expand Down Expand Up @@ -81,7 +73,6 @@ namespace sw
{
static const float4 null = {0, 0, 0, 1};

resource = 0;
buffer = &null;
stride = 0;
type = STREAMTYPE_FLOAT;
Expand Down
117 changes: 0 additions & 117 deletions src/Pipeline/VertexRoutine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,115 +376,6 @@ namespace sw
transpose4xN(v.x, v.y, v.z, v.w, stream.count);
}
break;
case STREAMTYPE_UDEC3:
{
// FIXME: Vectorize
{
Int x, y, z;

x = y = z = *Pointer<Int>(source0);

v.x.x = Float(x & 0x000003FF);
v.x.y = Float(y & 0x000FFC00);
v.x.z = Float(z & 0x3FF00000);
}

{
Int x, y, z;

x = y = z = *Pointer<Int>(source1);

v.y.x = Float(x & 0x000003FF);
v.y.y = Float(y & 0x000FFC00);
v.y.z = Float(z & 0x3FF00000);
}

{
Int x, y, z;

x = y = z = *Pointer<Int>(source2);

v.z.x = Float(x & 0x000003FF);
v.z.y = Float(y & 0x000FFC00);
v.z.z = Float(z & 0x3FF00000);
}

{
Int x, y, z;

x = y = z = *Pointer<Int>(source3);

v.w.x = Float(x & 0x000003FF);
v.w.y = Float(y & 0x000FFC00);
v.w.z = Float(z & 0x3FF00000);
}

transpose4x3(v.x, v.y, v.z, v.w);

v.y *= Float4(1.0f / 0x00000400);
v.z *= Float4(1.0f / 0x00100000);
}
break;
case STREAMTYPE_DEC3N:
{
// FIXME: Vectorize
{
Int x, y, z;

x = y = z = *Pointer<Int>(source0);

v.x.x = Float((x << 22) & 0xFFC00000);
v.x.y = Float((y << 12) & 0xFFC00000);
v.x.z = Float((z << 2) & 0xFFC00000);
}

{
Int x, y, z;

x = y = z = *Pointer<Int>(source1);

v.y.x = Float((x << 22) & 0xFFC00000);
v.y.y = Float((y << 12) & 0xFFC00000);
v.y.z = Float((z << 2) & 0xFFC00000);
}

{
Int x, y, z;

x = y = z = *Pointer<Int>(source2);

v.z.x = Float((x << 22) & 0xFFC00000);
v.z.y = Float((y << 12) & 0xFFC00000);
v.z.z = Float((z << 2) & 0xFFC00000);
}

{
Int x, y, z;

x = y = z = *Pointer<Int>(source3);

v.w.x = Float((x << 22) & 0xFFC00000);
v.w.y = Float((y << 12) & 0xFFC00000);
v.w.z = Float((z << 2) & 0xFFC00000);
}

transpose4x3(v.x, v.y, v.z, v.w);

v.x *= Float4(1.0f / 0x00400000 / 511.0f);
v.y *= Float4(1.0f / 0x00400000 / 511.0f);
v.z *= Float4(1.0f / 0x00400000 / 511.0f);
}
break;
case STREAMTYPE_FIXED:
{
v.x = Float4(*Pointer<Int4>(source0)) * *Pointer<Float4>(constants + OFFSET(Constants,unscaleFixed));
v.y = Float4(*Pointer<Int4>(source1)) * *Pointer<Float4>(constants + OFFSET(Constants,unscaleFixed));
v.z = Float4(*Pointer<Int4>(source2)) * *Pointer<Float4>(constants + OFFSET(Constants,unscaleFixed));
v.w = Float4(*Pointer<Int4>(source3)) * *Pointer<Float4>(constants + OFFSET(Constants,unscaleFixed));

transpose4xN(v.x, v.y, v.z, v.w, stream.count);
}
break;
case STREAMTYPE_HALF:
{
if(stream.count >= 1)
Expand Down Expand Up @@ -540,14 +431,6 @@ namespace sw
}
}
break;
case STREAMTYPE_INDICES:
{
v.x.x = *Pointer<Float>(source0);
v.x.y = *Pointer<Float>(source1);
v.x.z = *Pointer<Float>(source2);
v.x.w = *Pointer<Float>(source3);
}
break;
case STREAMTYPE_2_10_10_10_INT:
{
Int4 src;
Expand Down
3 changes: 2 additions & 1 deletion src/Vulkan/VkPipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,11 @@ sw::StreamType getStreamType(VkFormat format)
case VK_FORMAT_R8_UINT:
case VK_FORMAT_R8G8_UINT:
case VK_FORMAT_R8G8B8A8_UINT:
case VK_FORMAT_B8G8R8A8_UNORM:
case VK_FORMAT_A8B8G8R8_UNORM_PACK32:
case VK_FORMAT_A8B8G8R8_UINT_PACK32:
return sw::STREAMTYPE_BYTE;
case VK_FORMAT_B8G8R8A8_UNORM:
return sw::STREAMTYPE_COLOR;
case VK_FORMAT_R8_SNORM:
case VK_FORMAT_R8_SINT:
case VK_FORMAT_R8G8_SNORM:
Expand Down

0 comments on commit d318dd3

Please sign in to comment.