From 0033e86b2c812bfb8ea3a2f45a7b3fc02600f646 Mon Sep 17 00:00:00 2001 From: Tim Rowley Date: Fri, 31 Mar 2017 20:33:43 -0500 Subject: [PATCH] swr: [rasterizer core] Multisample sample position setup change Reviewed-by: Bruce Cherniak --- .../swr/rasterizer/codegen/gen_backends.py | 25 +++-- .../swr/rasterizer/core/multisample.cpp | 44 ++++----- .../drivers/swr/rasterizer/core/multisample.h | 98 ++++++++++--------- 3 files changed, 92 insertions(+), 75 deletions(-) diff --git a/src/gallium/drivers/swr/rasterizer/codegen/gen_backends.py b/src/gallium/drivers/swr/rasterizer/codegen/gen_backends.py index 242ab7a73e9..d9e938a80bb 100644 --- a/src/gallium/drivers/swr/rasterizer/codegen/gen_backends.py +++ b/src/gallium/drivers/swr/rasterizer/codegen/gen_backends.py @@ -38,14 +38,24 @@ def main(args=sys.argv[1:]): parser.add_argument('--cpp', help="Generate cpp file(s)", action='store_true', default=False) parser.add_argument('--cmake', help="Generate cmake file", action='store_true', default=False) - args = parser.parse_args(args); + class backendStrs : + def __init__(self) : + self.outFileName = 'gen_BackendPixelRate%s.cpp' + self.functionTableName = 'gBackendPixelRateTable' + self.funcInstanceHeader = ' = BackendPixelRate>;' + tempStr += backend.funcInstanceHeader + ','.join(map(str, output_combinations[x])) + '>>;' #append the line of c++ code in the list of output lines output_list.append(tempStr) @@ -72,8 +82,8 @@ def main(args=sys.argv[1:]): # generate .cpp files if args.cpp: - baseCppName = os.path.join(args.outdir, 'gen_BackendPixelRate%s.cpp') - templateCpp = os.path.join(thisDir, 'templates', 'gen_backend.cpp') + baseCppName = os.path.join(args.outdir, backend.outFileName) + templateCpp = os.path.join(thisDir, 'templates', backend.template) for fileNum in range(numFiles): filename = baseCppName % str(fileNum) @@ -88,12 +98,13 @@ def main(args=sys.argv[1:]): # generate gen_backend.cmake file if args.cmake: templateCmake = os.path.join(thisDir, 'templates', 'gen_backend.cmake') - cmakeFile = os.path.join(args.outdir, 'gen_backends.cmake') + cmakeFile = os.path.join(args.outdir, backend.cmakeFileName) #print('Generating', cmakeFile) MakoTemplateWriter.to_file( templateCmake, cmakeFile, cmdline=sys.argv, + srcVar=backend.cmakeSrcVar, numFiles=numFiles, baseCppName='${RASTY_GEN_SRC_DIR}/backends/' + os.path.basename(baseCppName)) diff --git a/src/gallium/drivers/swr/rasterizer/core/multisample.cpp b/src/gallium/drivers/swr/rasterizer/core/multisample.cpp index 88a0ef76144..8b20f7a10bd 100644 --- a/src/gallium/drivers/swr/rasterizer/core/multisample.cpp +++ b/src/gallium/drivers/swr/rasterizer/core/multisample.cpp @@ -25,28 +25,24 @@ ******************************************************************************/ #include "multisample.h" -const uint32_t MultisampleTraits::samplePosXi {0x80}; -const uint32_t MultisampleTraits::samplePosYi {0x80}; -const uint32_t MultisampleTraits::samplePosXi[2] {0xC0, 0x40}; -const uint32_t MultisampleTraits::samplePosYi[2] {0xC0, 0x40}; -const uint32_t MultisampleTraits::samplePosXi[4] {0x60, 0xE0, 0x20, 0xA0}; -const uint32_t MultisampleTraits::samplePosYi[4] {0x20, 0x60, 0xA0, 0xE0}; -const uint32_t MultisampleTraits::samplePosXi[8] {0x90, 0x70, 0xD0, 0x50, 0x30, 0x10, 0xB0, 0xF0}; -const uint32_t MultisampleTraits::samplePosYi[8] {0x50, 0xB0, 0x90, 0x30, 0xD0, 0x70, 0xF0, 0x10}; -const uint32_t MultisampleTraits::samplePosXi[16] -{0x90, 0x70, 0x50, 0xC0, 0x30, 0xA0, 0xD0, 0xB0, 0x60, 0x80, 0x40, 0x20, 0x00, 0xF0, 0xE0, 0x10}; -const uint32_t MultisampleTraits::samplePosYi[16] -{0x90, 0x50, 0xA0, 0x70, 0x60, 0xD0, 0xB0, 0x30, 0xE0, 0x10, 0x20, 0xC0, 0x80, 0x40, 0xF0, 0x00}; +constexpr uint32_t MultisampleTraits::samplePosXi[1]; +constexpr uint32_t MultisampleTraits::samplePosYi[1]; +constexpr uint32_t MultisampleTraits::samplePosXi[2]; +constexpr uint32_t MultisampleTraits::samplePosYi[2]; +constexpr uint32_t MultisampleTraits::samplePosXi[4]; +constexpr uint32_t MultisampleTraits::samplePosYi[4]; +constexpr uint32_t MultisampleTraits::samplePosXi[8]; +constexpr uint32_t MultisampleTraits::samplePosYi[8]; +constexpr uint32_t MultisampleTraits::samplePosXi[16]; +constexpr uint32_t MultisampleTraits::samplePosYi[16]; -const float MultisampleTraits::samplePosX{0.5f}; -const float MultisampleTraits::samplePosY{0.5f}; -const float MultisampleTraits::samplePosX[2]{0.75f, 0.25f}; -const float MultisampleTraits::samplePosY[2]{0.75f, 0.25f}; -const float MultisampleTraits::samplePosX[4]{0.375f, 0.875, 0.125, 0.625}; -const float MultisampleTraits::samplePosY[4]{0.125, 0.375, 0.625, 0.875}; -const float MultisampleTraits::samplePosX[8]{0.5625, 0.4375, 0.8125, 0.3125, 0.1875, 0.0625, 0.6875, 0.9375}; -const float MultisampleTraits::samplePosY[8]{0.3125, 0.6875, 0.5625, 0.1875, 0.8125, 0.4375, 0.9375, 0.0625}; -const float MultisampleTraits::samplePosX[16] -{0.5625, 0.4375, 0.3125, 0.7500, 0.1875, 0.6250, 0.8125, 0.6875, 0.3750, 0.5000, 0.2500, 0.1250, 0.0000, 0.9375, 0.8750, 0.0625}; -const float MultisampleTraits::samplePosY[16] -{0.5625, 0.3125, 0.6250, 0.4375, 0.3750, 0.8125, 0.6875, 0.1875, 0.8750, 0.0625, 0.1250, 0.7500, 0.5000, 0.2500, 0.9375, 0.0000}; +constexpr float MultisampleTraits::samplePosX[1]; +constexpr float MultisampleTraits::samplePosY[1]; +constexpr float MultisampleTraits::samplePosX[2]; +constexpr float MultisampleTraits::samplePosY[2]; +constexpr float MultisampleTraits::samplePosX[4]; +constexpr float MultisampleTraits::samplePosY[4]; +constexpr float MultisampleTraits::samplePosX[8]; +constexpr float MultisampleTraits::samplePosY[8]; +constexpr float MultisampleTraits::samplePosX[16]; +constexpr float MultisampleTraits::samplePosY[16]; diff --git a/src/gallium/drivers/swr/rasterizer/core/multisample.h b/src/gallium/drivers/swr/rasterizer/core/multisample.h index dc2dde9e2b0..19a5a80715e 100644 --- a/src/gallium/drivers/swr/rasterizer/core/multisample.h +++ b/src/gallium/drivers/swr/rasterizer/core/multisample.h @@ -71,17 +71,17 @@ struct MultisampleTraits template<> struct MultisampleTraits { - INLINE static float X(uint32_t sampleNum) {return samplePosX;}; - INLINE static float Y(uint32_t sampleNum) {return samplePosY;}; + INLINE static float X(uint32_t sampleNum) {return samplePosX[sampleNum];}; + INLINE static float Y(uint32_t sampleNum) {return samplePosY[sampleNum];}; INLINE static simdscalari FullSampleMask(){return _simd_set1_epi32(0x1);}; - static const uint32_t samplePosXi; - static const uint32_t samplePosYi; - static const float samplePosX; - static const float samplePosY; static const uint32_t numSamples = 1; + static const uint32_t numCoverageSamples = 1; static const SWR_MULTISAMPLE_COUNT sampleCount = SWR_MULTISAMPLE_1X; - static const uint32_t numCoverageSamples = 1; + static constexpr uint32_t samplePosXi[1] = { 0x80 }; + static constexpr uint32_t samplePosYi[1] = { 0x80 }; + static constexpr float samplePosX[1] = { 0.5f }; + static constexpr float samplePosY[1] = { 0.5f }; }; template<> @@ -92,10 +92,12 @@ struct MultisampleTraits INLINE static simdscalari FullSampleMask(){return _simd_set1_epi32(0x1);}; static const uint32_t numSamples = 1; - static const float samplePosX; - static const float samplePosY; - static const SWR_MULTISAMPLE_COUNT sampleCount = SWR_MULTISAMPLE_1X; static const uint32_t numCoverageSamples = 1; + static const SWR_MULTISAMPLE_COUNT sampleCount = SWR_MULTISAMPLE_1X; + static constexpr uint32_t samplePosXi[1] = { 0x80 }; + static constexpr uint32_t samplePosYi[1] = { 0x80 }; + static constexpr float samplePosX[1] = { 0.5f }; + static constexpr float samplePosY[1] = { 0.5f }; }; template<> @@ -109,13 +111,13 @@ struct MultisampleTraits return mask; } - static const uint32_t samplePosXi[2]; - static const uint32_t samplePosYi[2]; - static const float samplePosX[2]; - static const float samplePosY[2]; static const uint32_t numSamples = 2; - static const SWR_MULTISAMPLE_COUNT sampleCount = SWR_MULTISAMPLE_2X; static const uint32_t numCoverageSamples = 2; + static const SWR_MULTISAMPLE_COUNT sampleCount = SWR_MULTISAMPLE_2X; + static constexpr uint32_t samplePosXi[2] = { 0xC0, 0x40 }; + static constexpr uint32_t samplePosYi[2] = { 0xC0, 0x40 }; + static constexpr float samplePosX[2] = {0.75f, 0.25f}; + static constexpr float samplePosY[2] = {0.75f, 0.25f}; }; template<> @@ -129,10 +131,12 @@ struct MultisampleTraits return mask; } static const uint32_t numSamples = 2; - static const float samplePosX[2]; - static const float samplePosY[2]; - static const SWR_MULTISAMPLE_COUNT sampleCount = SWR_MULTISAMPLE_2X; static const uint32_t numCoverageSamples = 1; + static const SWR_MULTISAMPLE_COUNT sampleCount = SWR_MULTISAMPLE_2X; + static constexpr uint32_t samplePosXi[2] = { 0x80 , 0x80 }; + static constexpr uint32_t samplePosYi[2] = { 0x80 , 0x80 }; + static constexpr float samplePosX[2] = { 0.5f, 0.5f }; + static constexpr float samplePosY[2] = { 0.5f, 0.5f }; }; template<> @@ -146,13 +150,13 @@ struct MultisampleTraits return mask; } - static const uint32_t samplePosXi[4]; - static const uint32_t samplePosYi[4]; - static const float samplePosX[4]; - static const float samplePosY[4]; static const uint32_t numSamples = 4; - static const SWR_MULTISAMPLE_COUNT sampleCount = SWR_MULTISAMPLE_4X; static const uint32_t numCoverageSamples = 4; + static const SWR_MULTISAMPLE_COUNT sampleCount = SWR_MULTISAMPLE_4X; + static constexpr uint32_t samplePosXi[4] = { 0x60, 0xE0, 0x20, 0xA0 }; + static constexpr uint32_t samplePosYi[4] = { 0x20, 0x60, 0xA0, 0xE0 }; + static constexpr float samplePosX[4] = { 0.375f, 0.875f, 0.125f, 0.625f }; + static constexpr float samplePosY[4] = { 0.125f, 0.375f, 0.625f, 0.875f }; }; template<> @@ -167,10 +171,12 @@ struct MultisampleTraits } static const uint32_t numSamples = 4; - static const float samplePosX[4]; - static const float samplePosY[4]; - static const SWR_MULTISAMPLE_COUNT sampleCount = SWR_MULTISAMPLE_4X; static const uint32_t numCoverageSamples = 1; + static const SWR_MULTISAMPLE_COUNT sampleCount = SWR_MULTISAMPLE_4X; + static constexpr uint32_t samplePosXi[4] = { 0x80, 0x80, 0x80, 0x80 }; + static constexpr uint32_t samplePosYi[4] = { 0x80, 0x80, 0x80, 0x80 }; + static constexpr float samplePosX[4] = { 0.5f, 0.5f, 0.5f, 0.5f }; + static constexpr float samplePosY[4] = { 0.5f, 0.5f, 0.5f, 0.5f }; }; template<> @@ -184,13 +190,13 @@ struct MultisampleTraits return mask; } - static const uint32_t samplePosXi[8]; - static const uint32_t samplePosYi[8]; - static const float samplePosX[8]; - static const float samplePosY[8]; static const uint32_t numSamples = 8; - static const SWR_MULTISAMPLE_COUNT sampleCount = SWR_MULTISAMPLE_8X; static const uint32_t numCoverageSamples = 8; + static const SWR_MULTISAMPLE_COUNT sampleCount = SWR_MULTISAMPLE_8X; + static constexpr uint32_t samplePosXi[8] = { 0x90, 0x70, 0xD0, 0x50, 0x30, 0x10, 0xB0, 0xF0 }; + static constexpr uint32_t samplePosYi[8] = { 0x50, 0xB0, 0x90, 0x30, 0xD0, 0x70, 0xF0, 0x10 }; + static constexpr float samplePosX[8] = { 0.5625f, 0.4375f, 0.8125f, 0.3125f, 0.1875f, 0.0625f, 0.6875f, 0.9375f }; + static constexpr float samplePosY[8] = { 0.3125f, 0.6875f, 0.5625f, 0.1875f, 0.8125f, 0.4375f, 0.9375f, 0.0625f }; }; template<> @@ -204,10 +210,12 @@ struct MultisampleTraits return mask; } static const uint32_t numSamples = 8; - static const float samplePosX[8]; - static const float samplePosY[8]; - static const SWR_MULTISAMPLE_COUNT sampleCount = SWR_MULTISAMPLE_8X; static const uint32_t numCoverageSamples = 1; + static const SWR_MULTISAMPLE_COUNT sampleCount = SWR_MULTISAMPLE_8X; + static constexpr uint32_t samplePosXi[8] = { 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }; + static constexpr uint32_t samplePosYi[8] = { 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }; + static constexpr float samplePosX[8] = { 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f }; + static constexpr float samplePosY[8] = { 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f }; }; template<> @@ -221,13 +229,13 @@ struct MultisampleTraits return mask; } - static const uint32_t samplePosXi[16]; - static const uint32_t samplePosYi[16]; - static const float samplePosX[16]; - static const float samplePosY[16]; static const uint32_t numSamples = 16; - static const SWR_MULTISAMPLE_COUNT sampleCount = SWR_MULTISAMPLE_16X; static const uint32_t numCoverageSamples = 16; + static const SWR_MULTISAMPLE_COUNT sampleCount = SWR_MULTISAMPLE_16X; + static constexpr uint32_t samplePosXi[16] = { 0x90, 0x70, 0x50, 0xC0, 0x30, 0xA0, 0xD0, 0xB0, 0x60, 0x80, 0x40, 0x20, 0x00, 0xF0, 0xE0, 0x10 }; + static constexpr uint32_t samplePosYi[16] = { 0x90, 0x50, 0xA0, 0x70, 0x60, 0xD0, 0xB0, 0x30, 0xE0, 0x10, 0x20, 0xC0, 0x80, 0x40, 0xF0, 0x00 }; + static constexpr float samplePosX[16] = { 0.5625f, 0.4375f, 0.3125f, 0.7500f, 0.1875f, 0.6250f, 0.8125f, 0.6875f, 0.3750f, 0.5000f, 0.2500f, 0.1250f, 0.0000f, 0.9375f, 0.8750f, 0.0625f }; + static constexpr float samplePosY[16] = { 0.5625f, 0.3125f, 0.6250f, 0.4375f, 0.3750f, 0.8125f, 0.6875f, 0.1875f, 0.8750f, 0.0625f, 0.1250f, 0.7500f, 0.5000f, 0.2500f, 0.9375f, 0.0000f }; }; template<> @@ -241,10 +249,12 @@ struct MultisampleTraits return mask; } static const uint32_t numSamples = 16; - static const float samplePosX[16]; - static const float samplePosY[16]; - static const SWR_MULTISAMPLE_COUNT sampleCount = SWR_MULTISAMPLE_16X; static const uint32_t numCoverageSamples = 1; + static const SWR_MULTISAMPLE_COUNT sampleCount = SWR_MULTISAMPLE_16X; + static constexpr uint32_t samplePosXi[16] = { 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }; + static constexpr uint32_t samplePosYi[16] = { 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }; + static constexpr float samplePosX[16] = { 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f }; + static constexpr float samplePosY[16] = { 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f }; }; INLINE @@ -255,8 +265,8 @@ bool isNonStandardPattern(const SWR_MULTISAMPLE_COUNT sampleCount, const SWR_MUL switch(sampleCount) { case SWR_MULTISAMPLE_1X: - standardPosX = &MultisampleTraits::samplePosXi; - standardPosY = &MultisampleTraits::samplePosYi; + standardPosX = MultisampleTraits::samplePosXi; + standardPosY = MultisampleTraits::samplePosYi; break; case SWR_MULTISAMPLE_2X: standardPosX = MultisampleTraits::samplePosXi; -- 2.30.2