QVulkanWindow: use QVector, not QSet, for small int set
Apart from being more efficient to construct and test, for the expected very small number of entries, the example code itself shows that a sorted vector is much more useful than an unordered set. Change-Id: Ic5e38df0176ac4be08eac6a89c2e1cabab2a9020 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
This commit is contained in:
parent
6ec3a97297
commit
d3f1076d0a
@ -97,7 +97,7 @@ Renderer::Renderer(VulkanWindow *w, int initialCount)
|
|||||||
|
|
||||||
void Renderer::preInitResources()
|
void Renderer::preInitResources()
|
||||||
{
|
{
|
||||||
QSet<int> sampleCounts = m_window->supportedSampleCounts();
|
const QVector<int> sampleCounts = m_window->supportedSampleCounts();
|
||||||
if (DBG)
|
if (DBG)
|
||||||
qDebug() << "Supported sample counts:" << sampleCounts;
|
qDebug() << "Supported sample counts:" << sampleCounts;
|
||||||
if (sampleCounts.contains(4)) {
|
if (sampleCounts.contains(4)) {
|
||||||
|
@ -170,8 +170,7 @@ void VulkanRenderer::initResources()
|
|||||||
m_window->colorFormat(), m_window->depthStencilFormat());
|
m_window->colorFormat(), m_window->depthStencilFormat());
|
||||||
|
|
||||||
info += QStringLiteral("Supported sample counts:");
|
info += QStringLiteral("Supported sample counts:");
|
||||||
QList<int> sampleCounts = m_window->supportedSampleCounts().toList();
|
const QVector<int> sampleCounts = m_window->supportedSampleCounts();
|
||||||
std::sort(sampleCounts.begin(), sampleCounts.end());
|
|
||||||
for (int count : sampleCounts)
|
for (int count : sampleCounts)
|
||||||
info += QLatin1Char(' ') + QString::number(count);
|
info += QLatin1Char(' ') + QString::number(count);
|
||||||
info += QLatin1Char('\n');
|
info += QLatin1Char('\n');
|
||||||
|
@ -73,7 +73,7 @@ TriangleRenderer::TriangleRenderer(QVulkanWindow *w, bool msaa)
|
|||||||
: m_window(w)
|
: m_window(w)
|
||||||
{
|
{
|
||||||
if (msaa) {
|
if (msaa) {
|
||||||
QSet<int> counts = w->supportedSampleCounts();
|
const QVector<int> counts = w->supportedSampleCounts();
|
||||||
qDebug() << "Supported sample counts:" << counts;
|
qDebug() << "Supported sample counts:" << counts;
|
||||||
for (int s = 16; s >= 4; s /= 2) {
|
for (int s = 16; s >= 4; s /= 2) {
|
||||||
if (counts.contains(s)) {
|
if (counts.contains(s)) {
|
||||||
|
@ -512,6 +512,7 @@ static struct {
|
|||||||
VkSampleCountFlagBits mask;
|
VkSampleCountFlagBits mask;
|
||||||
int count;
|
int count;
|
||||||
} qvk_sampleCounts[] = {
|
} qvk_sampleCounts[] = {
|
||||||
|
// keep this sorted by 'count'
|
||||||
{ VK_SAMPLE_COUNT_1_BIT, 1 },
|
{ VK_SAMPLE_COUNT_1_BIT, 1 },
|
||||||
{ VK_SAMPLE_COUNT_2_BIT, 2 },
|
{ VK_SAMPLE_COUNT_2_BIT, 2 },
|
||||||
{ VK_SAMPLE_COUNT_4_BIT, 4 },
|
{ VK_SAMPLE_COUNT_4_BIT, 4 },
|
||||||
@ -523,7 +524,7 @@ static struct {
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
Returns the set of supported sample counts when using the physical device
|
Returns the set of supported sample counts when using the physical device
|
||||||
selected by setPhysicalDeviceIndex().
|
selected by setPhysicalDeviceIndex(), as a sorted vector.
|
||||||
|
|
||||||
By default QVulkanWindow uses a sample count of 1. By calling setSampleCount()
|
By default QVulkanWindow uses a sample count of 1. By calling setSampleCount()
|
||||||
with a different value (2, 4, 8, ...) from the set returned by this
|
with a different value (2, 4, 8, ...) from the set returned by this
|
||||||
@ -533,10 +534,10 @@ static struct {
|
|||||||
|
|
||||||
\sa setSampleCount()
|
\sa setSampleCount()
|
||||||
*/
|
*/
|
||||||
QSet<int> QVulkanWindow::supportedSampleCounts()
|
QVector<int> QVulkanWindow::supportedSampleCounts()
|
||||||
{
|
{
|
||||||
Q_D(const QVulkanWindow);
|
Q_D(const QVulkanWindow);
|
||||||
QSet<int> result;
|
QVector<int> result;
|
||||||
|
|
||||||
availablePhysicalDevices();
|
availablePhysicalDevices();
|
||||||
|
|
||||||
@ -555,7 +556,7 @@ QSet<int> QVulkanWindow::supportedSampleCounts()
|
|||||||
&& (depth & qvk_sampleCounts[i].mask)
|
&& (depth & qvk_sampleCounts[i].mask)
|
||||||
&& (stencil & qvk_sampleCounts[i].mask))
|
&& (stencil & qvk_sampleCounts[i].mask))
|
||||||
{
|
{
|
||||||
result.insert(qvk_sampleCounts[i].count);
|
result.append(qvk_sampleCounts[i].count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ public:
|
|||||||
|
|
||||||
void setPreferredColorFormats(const QVector<VkFormat> &formats);
|
void setPreferredColorFormats(const QVector<VkFormat> &formats);
|
||||||
|
|
||||||
QSet<int> supportedSampleCounts();
|
QVector<int> supportedSampleCounts();
|
||||||
void setSampleCount(int sampleCount);
|
void setSampleCount(int sampleCount);
|
||||||
|
|
||||||
bool isValid() const;
|
bool isValid() const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user