Reviewed-by: Bruce Cherniak <[email protected]> > On Dec 7, 2016, at 7:16 PM, Tim Rowley <[email protected]> wrote: > > v2: use fmul(1/65536) instead of fdiv(65535) > --- > .../drivers/swr/rasterizer/common/formats.cpp | 104 ++++++++++++++------- > .../drivers/swr/rasterizer/common/formats.h | 7 +- > .../drivers/swr/rasterizer/core/format_traits.h | 90 +++++++++++++++++- > .../drivers/swr/rasterizer/jitter/fetch_jit.cpp | 12 +++ > src/gallium/drivers/swr/swr_screen.cpp | 9 ++ > 5 files changed, 188 insertions(+), 34 deletions(-) > > diff --git a/src/gallium/drivers/swr/rasterizer/common/formats.cpp > b/src/gallium/drivers/swr/rasterizer/common/formats.cpp > index b3a95f2..aba4c3f 100644 > --- a/src/gallium/drivers/swr/rasterizer/common/formats.cpp > +++ b/src/gallium/drivers/swr/rasterizer/common/formats.cpp > @@ -449,16 +449,26 @@ const SWR_FORMAT_INFO gFormatInfo[] = { > { 0.0f, 0.0f, 0.0f, 0.0f }, > 1, 1 > }, > - // padding (0x20) > + // R32G32B32A32_SFIXED (0x20) > { > - nullptr, > - { SWR_TYPE_UNKNOWN, SWR_TYPE_UNKNOWN, SWR_TYPE_UNKNOWN, > SWR_TYPE_UNKNOWN }, > - { 0, 0, 0, 0 },{ 0, 0, 0, 0 },{ 0, 0, 0, 0 }, > - 0, 0, 0, false, false, false, false, > - { false, false, false, false }, > - { 0.0f, 0.0f, 0.0f, 0.0f }, > - 1, 1 > + "R32G32B32A32_SFIXED", > + { SWR_TYPE_SFIXED, SWR_TYPE_SFIXED, SWR_TYPE_SFIXED, SWR_TYPE_SFIXED > }, > + { 0, 0, 0, 0x3f800000 }, // Defaults for missing components > + { 0, 1, 2, 3 }, // Swizzle > + { 32, 32, 32, 32 }, // Bits per component > + 128, // Bits per element > + 16, // Bytes per element > + 4, // Num components > + false, // isSRGB > + false, // isBC > + false, // isSubsampled > + false, // isLuminance > + { false, false, false, false }, // Is normalized? > + { 1.0f, 1.0f, 1.0f, 1.0f }, // To float scale factor > + 1, // bcWidth > + 1, // bcHeight > }, > + > // padding (0x21) > { > nullptr, > @@ -979,16 +989,26 @@ const SWR_FORMAT_INFO gFormatInfo[] = { > { 0.0f, 0.0f, 0.0f, 0.0f }, > 1, 1 > }, > - // padding (0x50) > + // R32G32B32_SFIXED (0x50) > { > - nullptr, > - { SWR_TYPE_UNKNOWN, SWR_TYPE_UNKNOWN, SWR_TYPE_UNKNOWN, > SWR_TYPE_UNKNOWN }, > - { 0, 0, 0, 0 },{ 0, 0, 0, 0 },{ 0, 0, 0, 0 }, > - 0, 0, 0, false, false, false, false, > - { false, false, false, false }, > - { 0.0f, 0.0f, 0.0f, 0.0f }, > - 1, 1 > + "R32G32B32_SFIXED", > + { SWR_TYPE_SFIXED, SWR_TYPE_SFIXED, SWR_TYPE_SFIXED, > SWR_TYPE_UNKNOWN }, > + { 0, 0, 0, 0x3f800000 }, // Defaults for missing components > + { 0, 1, 2, 0 }, // Swizzle > + { 32, 32, 32, 0 }, // Bits per component > + 96, // Bits per element > + 12, // Bytes per element > + 3, // Num components > + false, // isSRGB > + false, // isBC > + false, // isSubsampled > + false, // isLuminance > + { false, false, false, false }, // Is normalized? > + { 1.0f, 1.0f, 1.0f, 0 }, // To float scale factor > + 1, // bcWidth > + 1, // bcHeight > }, > + > // padding (0x51) > { > nullptr, > @@ -1969,16 +1989,26 @@ const SWR_FORMAT_INFO gFormatInfo[] = { > { 0.0f, 0.0f, 0.0f, 0.0f }, > 1, 1 > }, > - // padding (0xA0) > + // R32G32_SFIXED (0xA0) > { > - nullptr, > - { SWR_TYPE_UNKNOWN, SWR_TYPE_UNKNOWN, SWR_TYPE_UNKNOWN, > SWR_TYPE_UNKNOWN }, > - { 0, 0, 0, 0 },{ 0, 0, 0, 0 },{ 0, 0, 0, 0 }, > - 0, 0, 0, false, false, false, false, > - { false, false, false, false }, > - { 0.0f, 0.0f, 0.0f, 0.0f }, > - 1, 1 > + "R32G32_SFIXED", > + { SWR_TYPE_SFIXED, SWR_TYPE_SFIXED, SWR_TYPE_UNKNOWN, > SWR_TYPE_UNKNOWN }, > + { 0, 0, 0, 0x3f800000 }, // Defaults for missing components > + { 0, 1, 0, 0 }, // Swizzle > + { 32, 32, 0, 0 }, // Bits per component > + 64, // Bits per element > + 8, // Bytes per element > + 2, // Num components > + false, // isSRGB > + false, // isBC > + false, // isSubsampled > + false, // isLuminance > + { false, false, false, false }, // Is normalized? > + { 1.0f, 1.0f, 0, 0 }, // To float scale factor > + 1, // bcWidth > + 1, // bcHeight > }, > + > // padding (0xA1) > { > nullptr, > @@ -5909,16 +5939,26 @@ const SWR_FORMAT_INFO gFormatInfo[] = { > 1, // bcHeight > }, > > - // padding (0x1B2) > + // R32_SFIXED (0x1B2) > { > - nullptr, > - { SWR_TYPE_UNKNOWN, SWR_TYPE_UNKNOWN, SWR_TYPE_UNKNOWN, > SWR_TYPE_UNKNOWN }, > - { 0, 0, 0, 0 },{ 0, 0, 0, 0 },{ 0, 0, 0, 0 }, > - 0, 0, 0, false, false, false, false, > - { false, false, false, false }, > - { 0.0f, 0.0f, 0.0f, 0.0f }, > - 1, 1 > + "R32_SFIXED", > + { SWR_TYPE_SFIXED, SWR_TYPE_UNKNOWN, SWR_TYPE_UNKNOWN, > SWR_TYPE_UNKNOWN }, > + { 0, 0, 0, 0x3f800000 }, // Defaults for missing components > + { 0, 0, 0, 0 }, // Swizzle > + { 32, 0, 0, 0 }, // Bits per component > + 32, // Bits per element > + 4, // Bytes per element > + 1, // Num components > + false, // isSRGB > + false, // isBC > + false, // isSubsampled > + false, // isLuminance > + { false, false, false, false }, // Is normalized? > + { 1.0f, 0, 0, 0 }, // To float scale factor > + 1, // bcWidth > + 1, // bcHeight > }, > + > // R10G10B10A2_SNORM (0x1B3) > { > "R10G10B10A2_SNORM", > diff --git a/src/gallium/drivers/swr/rasterizer/common/formats.h > b/src/gallium/drivers/swr/rasterizer/common/formats.h > index dd5b499..3d686d3 100644 > --- a/src/gallium/drivers/swr/rasterizer/common/formats.h > +++ b/src/gallium/drivers/swr/rasterizer/common/formats.h > @@ -20,7 +20,7 @@ > * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS > * IN THE SOFTWARE. > * > -* @file formats.h > +* @file gen_formats.h > * > * @brief auto-generated file > * > @@ -46,6 +46,7 @@ enum SWR_TYPE > SWR_TYPE_FLOAT, > SWR_TYPE_SSCALED, > SWR_TYPE_USCALED, > + SWR_TYPE_SFIXED, > }; > > ////////////////////////////////////////////////////////////////////////// > @@ -59,11 +60,13 @@ enum SWR_FORMAT > R32G32B32X32_FLOAT = 0x6, > R32G32B32A32_SSCALED = 0x7, > R32G32B32A32_USCALED = 0x8, > + R32G32B32A32_SFIXED = 0x20, > R32G32B32_FLOAT = 0x40, > R32G32B32_SINT = 0x41, > R32G32B32_UINT = 0x42, > R32G32B32_SSCALED = 0x45, > R32G32B32_USCALED = 0x46, > + R32G32B32_SFIXED = 0x50, > R16G16B16A16_UNORM = 0x80, > R16G16B16A16_SNORM = 0x81, > R16G16B16A16_SINT = 0x82, > @@ -83,6 +86,7 @@ enum SWR_FORMAT > R16G16B16A16_USCALED = 0x94, > R32G32_SSCALED = 0x95, > R32G32_USCALED = 0x96, > + R32G32_SFIXED = 0xA0, > B8G8R8A8_UNORM = 0xC0, > B8G8R8A8_UNORM_SRGB = 0xC1, > R10G10B10A2_UNORM = 0xC2, > @@ -203,6 +207,7 @@ enum SWR_FORMAT > R8G8B8_UNORM_SRGB = 0x1A8, > R16G16B16_UINT = 0x1B0, > R16G16B16_SINT = 0x1B1, > + R32_SFIXED = 0x1B2, > R10G10B10A2_SNORM = 0x1B3, > R10G10B10A2_USCALED = 0x1B4, > R10G10B10A2_SSCALED = 0x1B5, > diff --git a/src/gallium/drivers/swr/rasterizer/core/format_traits.h > b/src/gallium/drivers/swr/rasterizer/core/format_traits.h > index d55ee1f..59d4e7d 100644 > --- a/src/gallium/drivers/swr/rasterizer/core/format_traits.h > +++ b/src/gallium/drivers/swr/rasterizer/core/format_traits.h > @@ -20,7 +20,7 @@ > * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS > * IN THE SOFTWARE. > * > -* @file format_traits.h > +* @file gen_format_traits.h > * > * @brief Format Traits. auto-generated file > * > @@ -200,6 +200,28 @@ template<> struct FormatTraits<R32G32B32A32_USCALED> : > }; > > ////////////////////////////////////////////////////////////////////////// > +/// FormatTraits<R32G32B32A32_SFIXED> - Format traits specialization for > R32G32B32A32_SFIXED > +////////////////////////////////////////////////////////////////////////// > +template<> struct FormatTraits<R32G32B32A32_SFIXED> : > + ComponentTraits<SWR_TYPE_SFIXED, 32, SWR_TYPE_SFIXED, 32, > SWR_TYPE_SFIXED, 32, SWR_TYPE_SFIXED, 32>, > + FormatSwizzle<0, 1, 2, 3>, > + Defaults<0, 0, 0, 0x3f800000> > +{ > + static const uint32_t bpp{ 128 }; > + static const uint32_t numComps{ 4 }; > + static const bool hasAlpha{ true }; > + static const uint32_t alphaComp{ 3 }; > + static const bool isSRGB{ false }; > + static const bool isBC{ false }; > + static const bool isSubsampled{ false }; > + static const uint32_t bcWidth{ 1 }; > + static const uint32_t bcHeight{ 1 }; > + > + typedef Transpose32_32_32_32 TransposeT; > + typedef Format4<32, 32, 32, 32> FormatT; > +}; > + > +////////////////////////////////////////////////////////////////////////// > /// FormatTraits<R32G32B32_FLOAT> - Format traits specialization for > R32G32B32_FLOAT > ////////////////////////////////////////////////////////////////////////// > template<> struct FormatTraits<R32G32B32_FLOAT> : > @@ -310,6 +332,28 @@ template<> struct FormatTraits<R32G32B32_USCALED> : > }; > > ////////////////////////////////////////////////////////////////////////// > +/// FormatTraits<R32G32B32_SFIXED> - Format traits specialization for > R32G32B32_SFIXED > +////////////////////////////////////////////////////////////////////////// > +template<> struct FormatTraits<R32G32B32_SFIXED> : > + ComponentTraits<SWR_TYPE_SFIXED, 32, SWR_TYPE_SFIXED, 32, > SWR_TYPE_SFIXED, 32>, > + FormatSwizzle<0, 1, 2>, > + Defaults<0, 0, 0, 0x3f800000> > +{ > + static const uint32_t bpp{ 96 }; > + static const uint32_t numComps{ 3 }; > + static const bool hasAlpha{ false }; > + static const uint32_t alphaComp{ 0 }; > + static const bool isSRGB{ false }; > + static const bool isBC{ false }; > + static const bool isSubsampled{ false }; > + static const uint32_t bcWidth{ 1 }; > + static const uint32_t bcHeight{ 1 }; > + > + typedef Transpose32_32_32 TransposeT; > + typedef Format3<32, 32, 32> FormatT; > +}; > + > +////////////////////////////////////////////////////////////////////////// > /// FormatTraits<R16G16B16A16_UNORM> - Format traits specialization for > R16G16B16A16_UNORM > ////////////////////////////////////////////////////////////////////////// > template<> struct FormatTraits<R16G16B16A16_UNORM> : > @@ -728,6 +772,28 @@ template<> struct FormatTraits<R32G32_USCALED> : > }; > > ////////////////////////////////////////////////////////////////////////// > +/// FormatTraits<R32G32_SFIXED> - Format traits specialization for > R32G32_SFIXED > +////////////////////////////////////////////////////////////////////////// > +template<> struct FormatTraits<R32G32_SFIXED> : > + ComponentTraits<SWR_TYPE_SFIXED, 32, SWR_TYPE_SFIXED, 32>, > + FormatSwizzle<0, 1>, > + Defaults<0, 0, 0, 0x3f800000> > +{ > + static const uint32_t bpp{ 64 }; > + static const uint32_t numComps{ 2 }; > + static const bool hasAlpha{ false }; > + static const uint32_t alphaComp{ 0 }; > + static const bool isSRGB{ false }; > + static const bool isBC{ false }; > + static const bool isSubsampled{ false }; > + static const uint32_t bcWidth{ 1 }; > + static const uint32_t bcHeight{ 1 }; > + > + typedef Transpose32_32 TransposeT; > + typedef Format2<32, 32> FormatT; > +}; > + > +////////////////////////////////////////////////////////////////////////// > /// FormatTraits<B8G8R8A8_UNORM> - Format traits specialization for > B8G8R8A8_UNORM > ////////////////////////////////////////////////////////////////////////// > template<> struct FormatTraits<B8G8R8A8_UNORM> : > @@ -3368,6 +3434,28 @@ template<> struct FormatTraits<R16G16B16_SINT> : > }; > > ////////////////////////////////////////////////////////////////////////// > +/// FormatTraits<R32_SFIXED> - Format traits specialization for R32_SFIXED > +////////////////////////////////////////////////////////////////////////// > +template<> struct FormatTraits<R32_SFIXED> : > + ComponentTraits<SWR_TYPE_SFIXED, 32>, > + FormatSwizzle<0>, > + Defaults<0, 0, 0, 0x3f800000> > +{ > + static const uint32_t bpp{ 32 }; > + static const uint32_t numComps{ 1 }; > + static const bool hasAlpha{ false }; > + static const uint32_t alphaComp{ 0 }; > + static const bool isSRGB{ false }; > + static const bool isBC{ false }; > + static const bool isSubsampled{ false }; > + static const uint32_t bcWidth{ 1 }; > + static const uint32_t bcHeight{ 1 }; > + > + typedef TransposeSingleComponent<32> TransposeT; > + typedef Format1<32> FormatT; > +}; > + > +////////////////////////////////////////////////////////////////////////// > /// FormatTraits<R10G10B10A2_SNORM> - Format traits specialization for > R10G10B10A2_SNORM > ////////////////////////////////////////////////////////////////////////// > template<> struct FormatTraits<R10G10B10A2_SNORM> : > diff --git a/src/gallium/drivers/swr/rasterizer/jitter/fetch_jit.cpp > b/src/gallium/drivers/swr/rasterizer/jitter/fetch_jit.cpp > index bdd818b..c5936e5 100644 > --- a/src/gallium/drivers/swr/rasterizer/jitter/fetch_jit.cpp > +++ b/src/gallium/drivers/swr/rasterizer/jitter/fetch_jit.cpp > @@ -46,6 +46,7 @@ enum ConversionType > CONVERT_NORMALIZED, > CONVERT_USCALED, > CONVERT_SSCALED, > + CONVERT_SFIXED, > }; > > ////////////////////////////////////////////////////////////////////////// > @@ -424,6 +425,9 @@ void FetchJit::JitLoadVertices(const FETCH_COMPILE_STATE > &fetchState, Value* str > case SWR_TYPE_SSCALED: > vec = SI_TO_FP(vec, VectorType::get(mFP32Ty, 4)); > break; > + case SWR_TYPE_SFIXED: > + vec = FMUL(SI_TO_FP(vec, VectorType::get(mFP32Ty, 4)), > VBROADCAST(C(1/65536.0f))); > + break; > case SWR_TYPE_UNKNOWN: > case SWR_TYPE_UNUSED: > SWR_ASSERT(false, "Unsupported type %d!", info.type[0]); > @@ -943,6 +947,10 @@ void FetchJit::JitGatherVertices(const > FETCH_COMPILE_STATE &fetchState, > conversionType = CONVERT_SSCALED; > extendCastType = Instruction::CastOps::SIToFP; > break; > + case SWR_TYPE_SFIXED: > + conversionType = CONVERT_SFIXED; > + extendCastType = Instruction::CastOps::SExt; > + break; > default: > break; > } > @@ -1034,6 +1042,10 @@ void FetchJit::JitGatherVertices(const > FETCH_COMPILE_STATE &fetchState, > { > pGather = SI_TO_FP(pGather, mSimdFP32Ty); > } > + else if (conversionType == CONVERT_SFIXED) > + { > + pGather = FMUL(SI_TO_FP(pGather, > mSimdFP32Ty), VBROADCAST(C(1/65536.0f))); > + } > > vVertexElements[currentVertexElement++] = > pGather; > // e.g. result of a single 8x32bit integer > gather for 32bit components > diff --git a/src/gallium/drivers/swr/swr_screen.cpp > b/src/gallium/drivers/swr/swr_screen.cpp > index b5c2cd3..7a46d09 100644 > --- a/src/gallium/drivers/swr/swr_screen.cpp > +++ b/src/gallium/drivers/swr/swr_screen.cpp > @@ -531,6 +531,15 @@ mesa_to_swr_format(enum pipe_format format) > {PIPE_FORMAT_R8G8B8_SINT, R8G8B8_SINT}, > {PIPE_FORMAT_R8G8B8A8_SINT, R8G8B8A8_SINT}, > > + /* These formats are valid for vertex data, but should not be used > + * for render targets. > + */ > + > + {PIPE_FORMAT_R32_FIXED, R32_SFIXED}, > + {PIPE_FORMAT_R32G32_FIXED, R32G32_SFIXED}, > + {PIPE_FORMAT_R32G32B32_FIXED, R32G32B32_SFIXED}, > + {PIPE_FORMAT_R32G32B32A32_FIXED, R32G32B32A32_SFIXED}, > + > /* These formats have entries in SWR but don't have Load/StoreTile > * implementations. That means these aren't renderable, and thus having > * a mapping entry here is detrimental. > -- > 2.7.4 > > _______________________________________________ > mesa-dev mailing list > [email protected] > https://lists.freedesktop.org/mailman/listinfo/mesa-dev
_______________________________________________ mesa-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/mesa-dev
