[Mesa-dev] [PATCH 02/12] swr: [rasterizer core] Multisample sample position setup change
Tim Rowley
timothy.o.rowley at intel.com
Mon Apr 10 16:45:23 UTC 2017
---
.../drivers/swr/rasterizer/codegen/gen_backends.py | 25 ++++--
.../drivers/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 242ab7a..d9e938a 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<SwrBackendTraits<'
+ self.template = 'gen_backend.cpp'
+ self.cmakeFileName = 'gen_backends.cmake'
+ self.cmakeSrcVar = 'GEN_BACKEND_SOURCES'
+
+ backend = backendStrs()
+
output_list = []
for x in args.dim:
output_list.append(list(range(x)))
- # generate all permutations possible for template paremeter inputs
+ # generate all permutations possible for template parameter inputs
output_combinations = list(itertools.product(*output_list))
output_list = []
@@ -53,12 +63,12 @@ def main(args=sys.argv[1:]):
for x in range(len(output_combinations)):
# separate each template peram into its own list member
new_list = [output_combinations[x][i] for i in range(len(output_combinations[x]))]
- tempStr = 'gBackendPixelRateTable'
+ tempStr = backend.functionTableName
#print each list member as an index in the multidimensional array
for i in new_list:
tempStr += '[' + str(i) + ']'
#map each entry in the permuation as its own string member, store as the template instantiation string
- tempStr += " = BackendPixelRate<SwrBackendTraits<" + ','.join(map(str, output_combinations[x])) + '>>;'
+ 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 88a0ef7..8b20f7a 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<SWR_MULTISAMPLE_1X>::samplePosXi {0x80};
-const uint32_t MultisampleTraits<SWR_MULTISAMPLE_1X>::samplePosYi {0x80};
-const uint32_t MultisampleTraits<SWR_MULTISAMPLE_2X>::samplePosXi[2] {0xC0, 0x40};
-const uint32_t MultisampleTraits<SWR_MULTISAMPLE_2X>::samplePosYi[2] {0xC0, 0x40};
-const uint32_t MultisampleTraits<SWR_MULTISAMPLE_4X>::samplePosXi[4] {0x60, 0xE0, 0x20, 0xA0};
-const uint32_t MultisampleTraits<SWR_MULTISAMPLE_4X>::samplePosYi[4] {0x20, 0x60, 0xA0, 0xE0};
-const uint32_t MultisampleTraits<SWR_MULTISAMPLE_8X>::samplePosXi[8] {0x90, 0x70, 0xD0, 0x50, 0x30, 0x10, 0xB0, 0xF0};
-const uint32_t MultisampleTraits<SWR_MULTISAMPLE_8X>::samplePosYi[8] {0x50, 0xB0, 0x90, 0x30, 0xD0, 0x70, 0xF0, 0x10};
-const uint32_t MultisampleTraits<SWR_MULTISAMPLE_16X>::samplePosXi[16]
-{0x90, 0x70, 0x50, 0xC0, 0x30, 0xA0, 0xD0, 0xB0, 0x60, 0x80, 0x40, 0x20, 0x00, 0xF0, 0xE0, 0x10};
-const uint32_t MultisampleTraits<SWR_MULTISAMPLE_16X>::samplePosYi[16]
-{0x90, 0x50, 0xA0, 0x70, 0x60, 0xD0, 0xB0, 0x30, 0xE0, 0x10, 0x20, 0xC0, 0x80, 0x40, 0xF0, 0x00};
+constexpr uint32_t MultisampleTraits<SWR_MULTISAMPLE_1X>::samplePosXi[1];
+constexpr uint32_t MultisampleTraits<SWR_MULTISAMPLE_1X>::samplePosYi[1];
+constexpr uint32_t MultisampleTraits<SWR_MULTISAMPLE_2X>::samplePosXi[2];
+constexpr uint32_t MultisampleTraits<SWR_MULTISAMPLE_2X>::samplePosYi[2];
+constexpr uint32_t MultisampleTraits<SWR_MULTISAMPLE_4X>::samplePosXi[4];
+constexpr uint32_t MultisampleTraits<SWR_MULTISAMPLE_4X>::samplePosYi[4];
+constexpr uint32_t MultisampleTraits<SWR_MULTISAMPLE_8X>::samplePosXi[8];
+constexpr uint32_t MultisampleTraits<SWR_MULTISAMPLE_8X>::samplePosYi[8];
+constexpr uint32_t MultisampleTraits<SWR_MULTISAMPLE_16X>::samplePosXi[16];
+constexpr uint32_t MultisampleTraits<SWR_MULTISAMPLE_16X>::samplePosYi[16];
-const float MultisampleTraits<SWR_MULTISAMPLE_1X>::samplePosX{0.5f};
-const float MultisampleTraits<SWR_MULTISAMPLE_1X>::samplePosY{0.5f};
-const float MultisampleTraits<SWR_MULTISAMPLE_2X>::samplePosX[2]{0.75f, 0.25f};
-const float MultisampleTraits<SWR_MULTISAMPLE_2X>::samplePosY[2]{0.75f, 0.25f};
-const float MultisampleTraits<SWR_MULTISAMPLE_4X>::samplePosX[4]{0.375f, 0.875, 0.125, 0.625};
-const float MultisampleTraits<SWR_MULTISAMPLE_4X>::samplePosY[4]{0.125, 0.375, 0.625, 0.875};
-const float MultisampleTraits<SWR_MULTISAMPLE_8X>::samplePosX[8]{0.5625, 0.4375, 0.8125, 0.3125, 0.1875, 0.0625, 0.6875, 0.9375};
-const float MultisampleTraits<SWR_MULTISAMPLE_8X>::samplePosY[8]{0.3125, 0.6875, 0.5625, 0.1875, 0.8125, 0.4375, 0.9375, 0.0625};
-const float MultisampleTraits<SWR_MULTISAMPLE_16X>::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<SWR_MULTISAMPLE_16X>::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<SWR_MULTISAMPLE_1X>::samplePosX[1];
+constexpr float MultisampleTraits<SWR_MULTISAMPLE_1X>::samplePosY[1];
+constexpr float MultisampleTraits<SWR_MULTISAMPLE_2X>::samplePosX[2];
+constexpr float MultisampleTraits<SWR_MULTISAMPLE_2X>::samplePosY[2];
+constexpr float MultisampleTraits<SWR_MULTISAMPLE_4X>::samplePosX[4];
+constexpr float MultisampleTraits<SWR_MULTISAMPLE_4X>::samplePosY[4];
+constexpr float MultisampleTraits<SWR_MULTISAMPLE_8X>::samplePosX[8];
+constexpr float MultisampleTraits<SWR_MULTISAMPLE_8X>::samplePosY[8];
+constexpr float MultisampleTraits<SWR_MULTISAMPLE_16X>::samplePosX[16];
+constexpr float MultisampleTraits<SWR_MULTISAMPLE_16X>::samplePosY[16];
diff --git a/src/gallium/drivers/swr/rasterizer/core/multisample.h b/src/gallium/drivers/swr/rasterizer/core/multisample.h
index dc2dde9..19a5a80 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<SWR_MULTISAMPLE_1X, false>
{
- 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<SWR_MULTISAMPLE_1X, true>
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<SWR_MULTISAMPLE_2X, false>
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<SWR_MULTISAMPLE_2X, true>
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<SWR_MULTISAMPLE_4X, false>
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<SWR_MULTISAMPLE_4X, true>
}
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<SWR_MULTISAMPLE_8X, false>
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<SWR_MULTISAMPLE_8X, true>
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<SWR_MULTISAMPLE_16X, false>
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<SWR_MULTISAMPLE_16X, true>
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<SWR_MULTISAMPLE_1X>::samplePosXi;
- standardPosY = &MultisampleTraits<SWR_MULTISAMPLE_1X>::samplePosYi;
+ standardPosX = MultisampleTraits<SWR_MULTISAMPLE_1X>::samplePosXi;
+ standardPosY = MultisampleTraits<SWR_MULTISAMPLE_1X>::samplePosYi;
break;
case SWR_MULTISAMPLE_2X:
standardPosX = MultisampleTraits<SWR_MULTISAMPLE_2X>::samplePosXi;
--
2.7.4
More information about the mesa-dev
mailing list