Manually merged PR #2710.

This commit is contained in:
Branimir Karadžić 2022-04-26 19:13:57 -07:00
parent b8fdc3f8be
commit fe8cab2522
2 changed files with 191 additions and 12 deletions

View File

@ -1,6 +1,6 @@
/* /*
* Copyright 2011-2022 Branimir Karadzic. All rights reserved. * Copyright 2011-2022 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/ */
#include "bgfx_p.h" #include "bgfx_p.h"
@ -108,17 +108,17 @@ namespace bgfx
{ 1, 0 }, // DCL_CONSTANT_BUFFER { 1, 0 }, // DCL_CONSTANT_BUFFER
{ 1, 0 }, // DCL_SAMPLER { 1, 0 }, // DCL_SAMPLER
{ 1, 1 }, // DCL_INDEX_RANGE { 1, 1 }, // DCL_INDEX_RANGE
{ 1, 0 }, // DCL_GS_OUTPUT_PRIMITIVE_TOPOLOGY { 0, 0 }, // DCL_GS_OUTPUT_PRIMITIVE_TOPOLOGY
{ 1, 0 }, // DCL_GS_INPUT_PRIMITIVE { 0, 0 }, // DCL_GS_INPUT_PRIMITIVE
{ 0, 1 }, // DCL_MAX_OUTPUT_VERTEX_COUNT { 0, 1 }, // DCL_MAX_OUTPUT_VERTEX_COUNT
{ 1, 0 }, // DCL_INPUT { 1, 0 }, // DCL_INPUT
{ 1, 1 }, // DCL_INPUT_SGV { 1, 1 }, // DCL_INPUT_SGV
{ 1, 0 }, // DCL_INPUT_SIV { 1, 1 }, // DCL_INPUT_SIV
{ 1, 0 }, // DCL_INPUT_PS { 1, 0 }, // DCL_INPUT_PS
{ 1, 1 }, // DCL_INPUT_PS_SGV { 1, 1 }, // DCL_INPUT_PS_SGV
{ 1, 1 }, // DCL_INPUT_PS_SIV { 1, 1 }, // DCL_INPUT_PS_SIV
{ 1, 0 }, // DCL_OUTPUT { 1, 0 }, // DCL_OUTPUT
{ 1, 0 }, // DCL_OUTPUT_SGV { 1, 1 }, // DCL_OUTPUT_SGV
{ 1, 1 }, // DCL_OUTPUT_SIV { 1, 1 }, // DCL_OUTPUT_SIV
{ 0, 1 }, // DCL_TEMPS { 0, 1 }, // DCL_TEMPS
{ 0, 3 }, // DCL_INDEXABLE_TEMP { 0, 3 }, // DCL_INDEXABLE_TEMP
@ -135,8 +135,8 @@ namespace bgfx
{ 0, 0 }, // HS_CONTROL_POINT_PHASE { 0, 0 }, // HS_CONTROL_POINT_PHASE
{ 0, 0 }, // HS_FORK_PHASE { 0, 0 }, // HS_FORK_PHASE
{ 0, 0 }, // HS_JOIN_PHASE { 0, 0 }, // HS_JOIN_PHASE
{ 0, 0 }, // EMIT_STREAM { 1, 0 }, // EMIT_STREAM
{ 0, 0 }, // CUT_STREAM { 1, 0 }, // CUT_STREAM
{ 1, 0 }, // EMITTHENCUT_STREAM { 1, 0 }, // EMITTHENCUT_STREAM
{ 1, 0 }, // INTERFACE_CALL { 1, 0 }, // INTERFACE_CALL
{ 0, 0 }, // BUFINFO { 0, 0 }, // BUFINFO
@ -161,7 +161,7 @@ namespace bgfx
{ 5, 0 }, // BFI { 5, 0 }, // BFI
{ 0, 0 }, // BFREV { 0, 0 }, // BFREV
{ 5, 0 }, // SWAPC { 5, 0 }, // SWAPC
{ 0, 0 }, // DCL_STREAM { 1, 0 }, // DCL_STREAM
{ 1, 0 }, // DCL_FUNCTION_BODY { 1, 0 }, // DCL_FUNCTION_BODY
{ 0, 0 }, // DCL_FUNCTION_TABLE { 0, 0 }, // DCL_FUNCTION_TABLE
{ 0, 0 }, // DCL_INTERFACE { 0, 0 }, // DCL_INTERFACE
@ -503,6 +503,69 @@ namespace bgfx
}; };
BX_STATIC_ASSERT(BX_COUNTOF(s_dxbcInterpolationName) == DxbcInterpolation::Count); BX_STATIC_ASSERT(BX_COUNTOF(s_dxbcInterpolationName) == DxbcInterpolation::Count);
const char *s_dxbcPrimitiveTopologyName[] =
{
"",
"PointList",
"LineList",
"LineStrip",
"TriangleList",
"TriangleStrip",
"",
"",
"",
"",
"LineListAdj",
"LineStripAdj",
"TriangleListAdj",
"TriangleStripAdj",
};
BX_STATIC_ASSERT(BX_COUNTOF(s_dxbcPrimitiveTopologyName) == DxbcPrimitiveTopology::Count);
const char *s_dxbcPrimitiveName[] = {
"",
"Point",
"Line",
"Triangle",
"",
"",
"LineAdj",
"TriangleAdj",
"_1ControlPointPatch",
"_2ControlPointPatch",
"_3ControlPointPatch",
"_4ControlPointPatch",
"_5ControlPointPatch",
"_6ControlPointPatch",
"_7ControlPointPatch",
"_8ControlPointPatch",
"_9ControlPointPatch",
"_10ControlPointPatch",
"_11ControlPointPatch",
"_12ControlPointPatch",
"_13ControlPointPatch",
"_14ControlPointPatch",
"_15ControlPointPatch",
"_16ControlPointPatch",
"_17ControlPointPatch",
"_18ControlPointPatch",
"_19ControlPointPatch",
"_20ControlPointPatch",
"_21ControlPointPatch",
"_22ControlPointPatch",
"_23ControlPointPatch",
"_24ControlPointPatch",
"_25ControlPointPatch",
"_26ControlPointPatch",
"_27ControlPointPatch",
"_28ControlPointPatch",
"_29ControlPointPatch",
"_30ControlPointPatch",
"_31ControlPointPatch",
"_32ControlPointPatch",
};
BX_STATIC_ASSERT(BX_COUNTOF(s_dxbcPrimitiveName) == DxbcPrimitive::Count);
// mesa/src/gallium/state_trackers/d3d1x/d3d1xshader/defs/shortfiles.txt // mesa/src/gallium/state_trackers/d3d1x/d3d1xshader/defs/shortfiles.txt
static const char* s_dxbcOperandType[] = static const char* s_dxbcOperandType[] =
{ {
@ -1149,11 +1212,30 @@ namespace bgfx
_instruction.enableShaderExtensions = 0 != (token & UINT32_C(0x00040000) ); _instruction.enableShaderExtensions = 0 != (token & UINT32_C(0x00040000) );
break; break;
case DxbcOpcode::DCL_INPUT_PS: case DxbcOpcode::DCL_GS_INPUT_PRIMITIVE:
// 0 1 2 3
// 76543210765432107654321076543210
// ........ pppppp...........
// ^----------------- Primitive
_instruction.primitive = DxbcPrimitive::Enum( (token & UINT32_C(0x0001f800) ) >> 11);
break;
case DxbcOpcode::DCL_GS_OUTPUT_PRIMITIVE_TOPOLOGY:
// 0 1 2 3
// 76543210765432107654321076543210
// ........ pppppp...........
// ^----------------- Primitive Topology
_instruction.primitiveTopology = DxbcPrimitiveTopology::Enum( (token & UINT32_C(0x0001f800) ) >> 11);
break;
case DxbcOpcode::DCL_INPUT_PS: BX_FALLTHROUGH;
case DxbcOpcode::DCL_INPUT_PS_SIV:
// 0 1 2 3 // 0 1 2 3
// 76543210765432107654321076543210 // 76543210765432107654321076543210
// ........ iiiii........... // ........ iiiii...........
// ^---------------- Interpolation // ^---------------- Interploation
_instruction.interpolation = DxbcInterpolation::Enum( (token & UINT32_C(0x0000f800) ) >> 11); _instruction.interpolation = DxbcInterpolation::Enum( (token & UINT32_C(0x0000f800) ) >> 11);
break; break;
@ -1381,7 +1463,16 @@ namespace bgfx
token |= _instruction.enableShaderExtensions ? UINT32_C(0x00040000) : 0; token |= _instruction.enableShaderExtensions ? UINT32_C(0x00040000) : 0;
break; break;
case DxbcOpcode::DCL_INPUT_PS: case DxbcOpcode::DCL_GS_INPUT_PRIMITIVE:
token |= (_instruction.primitive << 11) & UINT32_C(0x0001f800);
break;
case DxbcOpcode::DCL_GS_OUTPUT_PRIMITIVE_TOPOLOGY:
token |= (_instruction.primitiveTopology << 11) & UINT32_C(0x0001f800);
break;
case DxbcOpcode::DCL_INPUT_PS: BX_FALLTHROUGH;
case DxbcOpcode::DCL_INPUT_PS_SIV:
token |= (_instruction.interpolation << 11) & UINT32_C(0x0000f800); token |= (_instruction.interpolation << 11) & UINT32_C(0x0000f800);
break; break;
@ -1549,6 +1640,22 @@ namespace bgfx
); );
break; break;
case DxbcOpcode::DCL_GS_OUTPUT_PRIMITIVE_TOPOLOGY:
size += bx::snprintf(&_out[size], bx::uint32_imax(0, _size-size)
, "%s %s"
, getName(_instruction.opcode)
, s_dxbcPrimitiveTopologyName[_instruction.primitiveTopology]
);
break;
case DxbcOpcode::DCL_GS_INPUT_PRIMITIVE:
size += bx::snprintf(&_out[size], bx::uint32_imax(0, _size-size)
, "%s %s"
, getName(_instruction.opcode)
, s_dxbcPrimitiveName[_instruction.primitive]
);
break;
case DxbcOpcode::IF: case DxbcOpcode::IF:
size += bx::snprintf(&_out[size], bx::uint32_imax(0, _size-size) size += bx::snprintf(&_out[size], bx::uint32_imax(0, _size-size)
, "%s%s" , "%s%s"

View File

@ -1,6 +1,6 @@
/* /*
* Copyright 2011-2022 Branimir Karadzic. All rights reserved. * Copyright 2011-2022 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/ */
#ifndef BGFX_SHADER_DXBC_H #ifndef BGFX_SHADER_DXBC_H
@ -326,6 +326,72 @@ namespace bgfx
}; };
}; };
struct DxbcPrimitiveTopology
{
enum Enum
{
Unknown,
PointList,
LineList,
LineStrip,
TriangleList,
TriangleStrip,
LineListAdj = 10,
LineStripAdj,
TriangleListAdj,
TriangleStripAdj,
Count
};
};
struct DxbcPrimitive
{
enum Enum
{
Unknown,
Point,
Line,
Triangle,
LineAdj = 6,
TriangleAdj,
_1ControlPointPatch,
_2ControlPointPatch,
_3ControlPointPatch,
_4ControlPointPatch,
_5ControlPointPatch,
_6ControlPointPatch,
_7ControlPointPatch,
_8ControlPointPatch,
_9ControlPointPatch,
_10ControlPointPatch,
_11ControlPointPatch,
_12ControlPointPatch,
_13ControlPointPatch,
_14ControlPointPatch,
_15ControlPointPatch,
_16ControlPointPatch,
_17ControlPointPatch,
_18ControlPointPatch,
_19ControlPointPatch,
_20ControlPointPatch,
_21ControlPointPatch,
_22ControlPointPatch,
_23ControlPointPatch,
_24ControlPointPatch,
_25ControlPointPatch,
_26ControlPointPatch,
_27ControlPointPatch,
_28ControlPointPatch,
_29ControlPointPatch,
_30ControlPointPatch,
_31ControlPointPatch,
_32ControlPointPatch,
Count
};
};
struct DxbcResourceReturnType struct DxbcResourceReturnType
{ {
enum Enum enum Enum
@ -561,6 +627,12 @@ namespace bgfx
// //
DxbcInterpolation::Enum interpolation; DxbcInterpolation::Enum interpolation;
//
DxbcPrimitiveTopology::Enum primitiveTopology;
//
DxbcPrimitive::Enum primitive;
// //
bool shadow; bool shadow;
bool mono; bool mono;