Fixed DX9 lack of non-normalized UINT16 vertex decl type.
This commit is contained in:
Родитель
074bf5a232
Коммит
e0eca362ad
|
@ -22,8 +22,8 @@ struct PosNormalTangentTexcoordVertex
|
|||
float m_z;
|
||||
uint32_t m_normal;
|
||||
uint32_t m_tangent;
|
||||
float m_u;
|
||||
float m_v;
|
||||
uint16_t m_u;
|
||||
uint16_t m_v;
|
||||
};
|
||||
|
||||
static bgfx::VertexDecl s_PosNormalTangentTexcoordDecl;
|
||||
|
@ -55,30 +55,30 @@ uint32_t packF4u(float _x, float _y = 0.0f, float _z = 0.0f, float _w = 0.0f)
|
|||
|
||||
static PosNormalTangentTexcoordVertex s_cubeVertices[24] =
|
||||
{
|
||||
{-1.0f, 1.0f, 1.0f, packF4u( 0.0f, 0.0f, 1.0f), 0, 0.0f, 0.0f },
|
||||
{ 1.0f, 1.0f, 1.0f, packF4u( 0.0f, 0.0f, 1.0f), 0, 1.0f, 0.0f },
|
||||
{-1.0f, -1.0f, 1.0f, packF4u( 0.0f, 0.0f, 1.0f), 0, 0.0f, 1.0f },
|
||||
{ 1.0f, -1.0f, 1.0f, packF4u( 0.0f, 0.0f, 1.0f), 0, 1.0f, 1.0f },
|
||||
{-1.0f, 1.0f, -1.0f, packF4u( 0.0f, 0.0f, -1.0f), 0, 0.0f, 0.0f },
|
||||
{ 1.0f, 1.0f, -1.0f, packF4u( 0.0f, 0.0f, -1.0f), 0, 1.0f, 0.0f },
|
||||
{-1.0f, -1.0f, -1.0f, packF4u( 0.0f, 0.0f, -1.0f), 0, 0.0f, 1.0f },
|
||||
{ 1.0f, -1.0f, -1.0f, packF4u( 0.0f, 0.0f, -1.0f), 0, 1.0f, 1.0f },
|
||||
{-1.0f, 1.0f, 1.0f, packF4u( 0.0f, 1.0f, 0.0f), 0, 0.0f, 0.0f },
|
||||
{ 1.0f, 1.0f, 1.0f, packF4u( 0.0f, 1.0f, 0.0f), 0, 1.0f, 0.0f },
|
||||
{-1.0f, 1.0f, -1.0f, packF4u( 0.0f, 1.0f, 0.0f), 0, 0.0f, 1.0f },
|
||||
{ 1.0f, 1.0f, -1.0f, packF4u( 0.0f, 1.0f, 0.0f), 0, 1.0f, 1.0f },
|
||||
{-1.0f, -1.0f, 1.0f, packF4u( 0.0f, -1.0f, 0.0f), 0, 0.0f, 0.0f },
|
||||
{ 1.0f, -1.0f, 1.0f, packF4u( 0.0f, -1.0f, 0.0f), 0, 1.0f, 0.0f },
|
||||
{-1.0f, -1.0f, -1.0f, packF4u( 0.0f, -1.0f, 0.0f), 0, 0.0f, 1.0f },
|
||||
{ 1.0f, -1.0f, -1.0f, packF4u( 0.0f, -1.0f, 0.0f), 0, 1.0f, 1.0f },
|
||||
{ 1.0f, -1.0f, 1.0f, packF4u( 1.0f, 0.0f, 0.0f), 0, 0.0f, 0.0f },
|
||||
{ 1.0f, 1.0f, 1.0f, packF4u( 1.0f, 0.0f, 0.0f), 0, 1.0f, 0.0f },
|
||||
{ 1.0f, -1.0f, -1.0f, packF4u( 1.0f, 0.0f, 0.0f), 0, 0.0f, 1.0f },
|
||||
{ 1.0f, 1.0f, -1.0f, packF4u( 1.0f, 0.0f, 0.0f), 0, 1.0f, 1.0f },
|
||||
{-1.0f, -1.0f, 1.0f, packF4u(-1.0f, 0.0f, 0.0f), 0, 0.0f, 0.0f },
|
||||
{-1.0f, 1.0f, 1.0f, packF4u(-1.0f, 0.0f, 0.0f), 0, 1.0f, 0.0f },
|
||||
{-1.0f, -1.0f, -1.0f, packF4u(-1.0f, 0.0f, 0.0f), 0, 0.0f, 1.0f },
|
||||
{-1.0f, 1.0f, -1.0f, packF4u(-1.0f, 0.0f, 0.0f), 0, 1.0f, 1.0f },
|
||||
{-1.0f, 1.0f, 1.0f, packF4u( 0.0f, 0.0f, 1.0f), 0, 0, 0 },
|
||||
{ 1.0f, 1.0f, 1.0f, packF4u( 0.0f, 0.0f, 1.0f), 0, 0x7fff, 0 },
|
||||
{-1.0f, -1.0f, 1.0f, packF4u( 0.0f, 0.0f, 1.0f), 0, 0, 0x7fff },
|
||||
{ 1.0f, -1.0f, 1.0f, packF4u( 0.0f, 0.0f, 1.0f), 0, 0x7fff, 0x7fff },
|
||||
{-1.0f, 1.0f, -1.0f, packF4u( 0.0f, 0.0f, -1.0f), 0, 0, 0 },
|
||||
{ 1.0f, 1.0f, -1.0f, packF4u( 0.0f, 0.0f, -1.0f), 0, 0x7fff, 0 },
|
||||
{-1.0f, -1.0f, -1.0f, packF4u( 0.0f, 0.0f, -1.0f), 0, 0, 0x7fff },
|
||||
{ 1.0f, -1.0f, -1.0f, packF4u( 0.0f, 0.0f, -1.0f), 0, 0x7fff, 0x7fff },
|
||||
{-1.0f, 1.0f, 1.0f, packF4u( 0.0f, 1.0f, 0.0f), 0, 0, 0 },
|
||||
{ 1.0f, 1.0f, 1.0f, packF4u( 0.0f, 1.0f, 0.0f), 0, 0x7fff, 0 },
|
||||
{-1.0f, 1.0f, -1.0f, packF4u( 0.0f, 1.0f, 0.0f), 0, 0, 0x7fff },
|
||||
{ 1.0f, 1.0f, -1.0f, packF4u( 0.0f, 1.0f, 0.0f), 0, 0x7fff, 0x7fff },
|
||||
{-1.0f, -1.0f, 1.0f, packF4u( 0.0f, -1.0f, 0.0f), 0, 0, 0 },
|
||||
{ 1.0f, -1.0f, 1.0f, packF4u( 0.0f, -1.0f, 0.0f), 0, 0x7fff, 0 },
|
||||
{-1.0f, -1.0f, -1.0f, packF4u( 0.0f, -1.0f, 0.0f), 0, 0, 0x7fff },
|
||||
{ 1.0f, -1.0f, -1.0f, packF4u( 0.0f, -1.0f, 0.0f), 0, 0x7fff, 0x7fff },
|
||||
{ 1.0f, -1.0f, 1.0f, packF4u( 1.0f, 0.0f, 0.0f), 0, 0, 0 },
|
||||
{ 1.0f, 1.0f, 1.0f, packF4u( 1.0f, 0.0f, 0.0f), 0, 0x7fff, 0 },
|
||||
{ 1.0f, -1.0f, -1.0f, packF4u( 1.0f, 0.0f, 0.0f), 0, 0, 0x7fff },
|
||||
{ 1.0f, 1.0f, -1.0f, packF4u( 1.0f, 0.0f, 0.0f), 0, 0x7fff, 0x7fff },
|
||||
{-1.0f, -1.0f, 1.0f, packF4u(-1.0f, 0.0f, 0.0f), 0, 0, 0 },
|
||||
{-1.0f, 1.0f, 1.0f, packF4u(-1.0f, 0.0f, 0.0f), 0, 0x7fff, 0 },
|
||||
{-1.0f, -1.0f, -1.0f, packF4u(-1.0f, 0.0f, 0.0f), 0, 0, 0x7fff },
|
||||
{-1.0f, 1.0f, -1.0f, packF4u(-1.0f, 0.0f, 0.0f), 0, 0x7fff, 0x7fff },
|
||||
};
|
||||
|
||||
static const uint16_t s_cubeIndices[36] =
|
||||
|
@ -299,7 +299,7 @@ int _main_(int _argc, char** _argv)
|
|||
s_PosNormalTangentTexcoordDecl.add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float);
|
||||
s_PosNormalTangentTexcoordDecl.add(bgfx::Attrib::Normal, 4, bgfx::AttribType::Uint8, true, true);
|
||||
s_PosNormalTangentTexcoordDecl.add(bgfx::Attrib::Tangent, 4, bgfx::AttribType::Uint8, true, true);
|
||||
s_PosNormalTangentTexcoordDecl.add(bgfx::Attrib::TexCoord0, 2, bgfx::AttribType::Float);
|
||||
s_PosNormalTangentTexcoordDecl.add(bgfx::Attrib::TexCoord0, 2, bgfx::AttribType::Int16, true, true);
|
||||
s_PosNormalTangentTexcoordDecl.end();
|
||||
|
||||
const bgfx::Memory* mem;
|
||||
|
|
|
@ -284,7 +284,7 @@ namespace bgfx
|
|||
enum Enum
|
||||
{
|
||||
Uint8,
|
||||
Uint16,
|
||||
Int16,
|
||||
Half,
|
||||
Float,
|
||||
|
||||
|
@ -450,6 +450,14 @@ namespace bgfx
|
|||
|
||||
/// Add attribute to VertexDecl.
|
||||
///
|
||||
/// @param _attrib Attribute semantics.
|
||||
/// @param _num Number of elements 1, 2, 3 or 4.
|
||||
/// @param _type Element type.
|
||||
/// @param _normalized Value is normalized for vertex shader.
|
||||
/// @param _asInt Packaging rule for vertexPack, vertexUnpack, and
|
||||
/// vertexConvert for AttribType::Uint8 and AttribType::Int16.
|
||||
/// Unpacking code must be implemented inside vertex shader.
|
||||
///
|
||||
/// NOTE:
|
||||
/// Must be called between begin/end.
|
||||
void add(Attrib::Enum _attrib, uint8_t _num, AttribType::Enum _type, bool _normalized = false, bool _asInt = false);
|
||||
|
|
|
@ -194,10 +194,10 @@ namespace bgfx
|
|||
{ DXGI_FORMAT_R8G8B8A8_UINT, DXGI_FORMAT_R8G8B8A8_UNORM },
|
||||
},
|
||||
{
|
||||
{ DXGI_FORMAT_R16_UINT, DXGI_FORMAT_R16_UNORM },
|
||||
{ DXGI_FORMAT_R16G16_UINT, DXGI_FORMAT_R16G16_UNORM },
|
||||
{ DXGI_FORMAT_R16G16B16A16_UINT, DXGI_FORMAT_R16G16B16A16_UNORM },
|
||||
{ DXGI_FORMAT_R16G16B16A16_UINT, DXGI_FORMAT_R16G16B16A16_UNORM },
|
||||
{ DXGI_FORMAT_R16_SINT, DXGI_FORMAT_R16_SNORM },
|
||||
{ DXGI_FORMAT_R16G16_SINT, DXGI_FORMAT_R16G16_SNORM },
|
||||
{ DXGI_FORMAT_R16G16B16A16_SINT, DXGI_FORMAT_R16G16B16A16_SNORM },
|
||||
{ DXGI_FORMAT_R16G16B16A16_SINT, DXGI_FORMAT_R16G16B16A16_SNORM },
|
||||
},
|
||||
{
|
||||
{ DXGI_FORMAT_R16_FLOAT, DXGI_FORMAT_R16_FLOAT },
|
||||
|
|
|
@ -534,7 +534,7 @@ namespace bgfx
|
|||
static const GLenum s_attribType[AttribType::Count] =
|
||||
{
|
||||
GL_UNSIGNED_BYTE,
|
||||
GL_UNSIGNED_SHORT,
|
||||
GL_SHORT,
|
||||
GL_HALF_FLOAT,
|
||||
GL_FLOAT,
|
||||
};
|
||||
|
|
|
@ -207,7 +207,7 @@ namespace bgfx
|
|||
}
|
||||
break;
|
||||
|
||||
case AttribType::Uint16:
|
||||
case AttribType::Int16:
|
||||
{
|
||||
uint16_t* packed = (uint16_t*)data;
|
||||
if (_inputNormalized)
|
||||
|
@ -216,20 +216,20 @@ namespace bgfx
|
|||
{
|
||||
switch (num)
|
||||
{
|
||||
default: *packed++ = uint16_t(*_input++ * 32767.0f + 32768.0f);
|
||||
case 3: *packed++ = uint16_t(*_input++ * 32767.0f + 32768.0f);
|
||||
case 2: *packed++ = uint16_t(*_input++ * 32767.0f + 32768.0f);
|
||||
case 1: *packed++ = uint16_t(*_input++ * 32767.0f + 32768.0f);
|
||||
default: *packed++ = uint16_t(*_input++ * 32767.0f);
|
||||
case 3: *packed++ = uint16_t(*_input++ * 32767.0f);
|
||||
case 2: *packed++ = uint16_t(*_input++ * 32767.0f);
|
||||
case 1: *packed++ = uint16_t(*_input++ * 32767.0f);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (num)
|
||||
{
|
||||
default: *packed++ = uint16_t(*_input++ * 65535.0f);
|
||||
case 3: *packed++ = uint16_t(*_input++ * 65535.0f);
|
||||
case 2: *packed++ = uint16_t(*_input++ * 65535.0f);
|
||||
case 1: *packed++ = uint16_t(*_input++ * 65535.0f);
|
||||
default: *packed++ = uint16_t(*_input++ * 65535.0f - 32768.0f);
|
||||
case 3: *packed++ = uint16_t(*_input++ * 65535.0f - 32768.0f);
|
||||
case 2: *packed++ = uint16_t(*_input++ * 65535.0f - 32768.0f);
|
||||
case 1: *packed++ = uint16_t(*_input++ * 65535.0f - 32768.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -311,27 +311,27 @@ namespace bgfx
|
|||
}
|
||||
break;
|
||||
|
||||
case AttribType::Uint16:
|
||||
case AttribType::Int16:
|
||||
{
|
||||
uint16_t* packed = (uint16_t*)data;
|
||||
if (asInt)
|
||||
{
|
||||
switch (num)
|
||||
{
|
||||
default: *_output++ = (float(*packed++) - 32768.0f)*1.0f/32767.0f;
|
||||
case 3: *_output++ = (float(*packed++) - 32768.0f)*1.0f/32767.0f;
|
||||
case 2: *_output++ = (float(*packed++) - 32768.0f)*1.0f/32767.0f;
|
||||
case 1: *_output++ = (float(*packed++) - 32768.0f)*1.0f/32767.0f;
|
||||
default: *_output++ = float(*packed++)*1.0f/32767.0f;
|
||||
case 3: *_output++ = float(*packed++)*1.0f/32767.0f;
|
||||
case 2: *_output++ = float(*packed++)*1.0f/32767.0f;
|
||||
case 1: *_output++ = float(*packed++)*1.0f/32767.0f;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (num)
|
||||
{
|
||||
default: *_output++ = float(*packed++)*1.0f/65535.0f;
|
||||
case 3: *_output++ = float(*packed++)*1.0f/65535.0f;
|
||||
case 2: *_output++ = float(*packed++)*1.0f/65535.0f;
|
||||
case 1: *_output++ = float(*packed++)*1.0f/65535.0f;
|
||||
default: *_output++ = (float(*packed++) + 32768.0f)*1.0f/65535.0f;
|
||||
case 3: *_output++ = (float(*packed++) + 32768.0f)*1.0f/65535.0f;
|
||||
case 2: *_output++ = (float(*packed++) + 32768.0f)*1.0f/65535.0f;
|
||||
case 1: *_output++ = (float(*packed++) + 32768.0f)*1.0f/65535.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче