Added support for integer and unsigned integer texture formats.

TRAC #23049 Signed-off-by: Jamie Madill Signed-off-by: Shannon Woods Author: Geoff Lang git-svn-id: https://angleproject.googlecode.com/svn/branches/es3proto@2373 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 36d0be90
...@@ -56,6 +56,96 @@ struct A8R8G8B8 ...@@ -56,6 +56,96 @@ struct A8R8G8B8
typedef A8R8G8B8 R8G8B8A8; // R8G8B8A8 type is functionally equivalent for mip purposes typedef A8R8G8B8 R8G8B8A8; // R8G8B8A8 type is functionally equivalent for mip purposes
typedef A8R8G8B8 B8G8R8A8; // B8G8R8A8 type is functionally equivalent for mip purposes typedef A8R8G8B8 B8G8R8A8; // B8G8R8A8 type is functionally equivalent for mip purposes
struct R16
{
unsigned short R;
static void average(R16 *dst, const R16 *src1, const R16 *src2)
{
dst->R = ((src1->R ^ src2->R) >> 1) + (src1->R & src2->R);
}
};
struct R16G16
{
unsigned short R;
unsigned short G;
static void average(R16G16 *dst, const R16G16 *src1, const R16G16 *src2)
{
dst->R = ((src1->R ^ src2->R) >> 1) + (src1->R & src2->R);
dst->G = ((src1->G ^ src2->G) >> 1) + (src1->G & src2->G);
}
};
struct R16G16B16A16
{
unsigned short R;
unsigned short G;
unsigned short B;
unsigned short A;
static void average(R16G16B16A16 *dst, const R16G16B16A16 *src1, const R16G16B16A16 *src2)
{
dst->R = ((src1->R ^ src2->R) >> 1) + (src1->R & src2->R);
dst->G = ((src1->G ^ src2->G) >> 1) + (src1->G & src2->G);
dst->B = ((src1->B ^ src2->B) >> 1) + (src1->B & src2->B);
dst->A = ((src1->A ^ src2->A) >> 1) + (src1->A & src2->A);
}
};
struct R32
{
unsigned int R;
static void average(R32 *dst, const R32 *src1, const R32 *src2)
{
dst->R = ((src1->R ^ src2->R) >> 1) + (src1->R & src2->R);
}
};
struct R32G32
{
unsigned int R;
unsigned int G;
static void average(R32G32 *dst, const R32G32 *src1, const R32G32 *src2)
{
dst->R = ((src1->R ^ src2->R) >> 1) + (src1->R & src2->R);
dst->G = ((src1->G ^ src2->G) >> 1) + (src1->G & src2->G);
}
};
struct R32G32B32
{
unsigned int R;
unsigned int G;
unsigned int B;
static void average(R32G32B32 *dst, const R32G32B32 *src1, const R32G32B32 *src2)
{
dst->R = ((src1->R ^ src2->R) >> 1) + (src1->R & src2->R);
dst->G = ((src1->G ^ src2->G) >> 1) + (src1->G & src2->G);
dst->B = ((src1->B ^ src2->B) >> 1) + (src1->B & src2->B);
}
};
struct R32G32B32A32
{
unsigned int R;
unsigned int G;
unsigned int B;
unsigned int A;
static void average(R32G32B32A32 *dst, const R32G32B32A32 *src1, const R32G32B32A32 *src2)
{
dst->R = ((src1->R ^ src2->R) >> 1) + (src1->R & src2->R);
dst->G = ((src1->G ^ src2->G) >> 1) + (src1->G & src2->G);
dst->B = ((src1->B ^ src2->B) >> 1) + (src1->B & src2->B);
dst->A = ((src1->A ^ src2->A) >> 1) + (src1->A & src2->A);
}
};
struct R8S struct R8S
{ {
char R; char R;
...@@ -94,6 +184,96 @@ struct R8G8B8A8S ...@@ -94,6 +184,96 @@ struct R8G8B8A8S
} }
}; };
struct R16S
{
unsigned short R;
static void average(R16S *dst, const R16S *src1, const R16S *src2)
{
dst->R = ((int)src1->R + (int)src2->R) / 2;
}
};
struct R16G16S
{
unsigned short R;
unsigned short G;
static void average(R16G16S *dst, const R16G16S *src1, const R16G16S *src2)
{
dst->R = ((int)src1->R + (int)src2->R) / 2;
dst->G = ((int)src1->G + (int)src2->G) / 2;
}
};
struct R16G16B16A16S
{
unsigned short R;
unsigned short G;
unsigned short B;
unsigned short A;
static void average(R16G16B16A16S *dst, const R16G16B16A16S *src1, const R16G16B16A16S *src2)
{
dst->R = ((int)src1->R + (int)src2->R) / 2;
dst->G = ((int)src1->G + (int)src2->G) / 2;
dst->B = ((int)src1->B + (int)src2->B) / 2;
dst->A = ((int)src1->A + (int)src2->A) / 2;
}
};
struct R32S
{
unsigned int R;
static void average(R32S *dst, const R32S *src1, const R32S *src2)
{
dst->R = ((long long)src1->R + (long long)src2->R) / 2;
}
};
struct R32G32S
{
unsigned int R;
unsigned int G;
static void average(R32G32S *dst, const R32G32S *src1, const R32G32S *src2)
{
dst->R = ((long long)src1->R + (long long)src2->R) / 2;
dst->G = ((long long)src1->G + (long long)src2->G) / 2;
}
};
struct R32G32B32S
{
unsigned int R;
unsigned int G;
unsigned int B;
static void average(R32G32B32S *dst, const R32G32B32S *src1, const R32G32B32S *src2)
{
dst->R = ((long long)src1->R + (long long)src2->R) / 2;
dst->G = ((long long)src1->G + (long long)src2->G) / 2;
dst->B = ((long long)src1->B + (long long)src2->B) / 2;
}
};
struct R32G32B32A32S
{
unsigned int R;
unsigned int G;
unsigned int B;
unsigned int A;
static void average(R32G32B32A32S *dst, const R32G32B32A32S *src1, const R32G32B32A32S *src2)
{
dst->R = ((long long)src1->R + (long long)src2->R) / 2;
dst->G = ((long long)src1->G + (long long)src2->G) / 2;
dst->B = ((long long)src1->B + (long long)src2->B) / 2;
dst->A = ((long long)src1->A + (long long)src2->A) / 2;
}
};
struct A16B16G16R16F struct A16B16G16R16F
{ {
unsigned short R; unsigned short R;
......
...@@ -216,6 +216,35 @@ void loadToNative(int width, int height, int depth, ...@@ -216,6 +216,35 @@ void loadToNative(int width, int height, int depth,
} }
} }
template <typename type, unsigned int fourthComponentBits>
void loadToNative3To4(int width, int height, int depth,
const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch,
void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch)
{
const type *source = NULL;
type *dest = NULL;
const unsigned int fourthBits = fourthComponentBits;
const type fourthValue = *reinterpret_cast<const type*>(&fourthBits);
for (int z = 0; z < depth; z++)
{
for (int y = 0; y < height; y++)
{
source = offsetDataPointer<type>(input, y, z, inputRowPitch, inputDepthPitch);
dest = offsetDataPointer<type>(output, y, z, outputRowPitch, outputDepthPitch);
for (int x = 0; x < width; x++)
{
dest[x * 4 + 0] = source[x * 3 + 0];
dest[x * 4 + 1] = source[x * 3 + 1];
dest[x * 4 + 2] = source[x * 3 + 2];
dest[x * 4 + 3] = fourthValue;
}
}
}
}
template <unsigned int componentCount> template <unsigned int componentCount>
void loadFloatDataToHalfFloat(int width, int height, int depth, void loadFloatDataToHalfFloat(int width, int height, int depth,
const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch, const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch,
......
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