summaryrefslogtreecommitdiffstats
path: root/tools/render-test
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2018-05-03 17:17:05 -0400
committerTim Foley <tfoleyNV@users.noreply.github.com>2018-05-03 14:17:05 -0700
commitc216f00f1eaff368229cb8430422972fcac801b7 (patch)
treec214700d1cbcdf590b2ecd2f50c9d152169275b8 /tools/render-test
parent367f3a78a40731da45ee12b9a18c94707f1d1429 (diff)
Fixes based on review of vulkan-first-render PR #545 (#546)
Diffstat (limited to 'tools/render-test')
-rw-r--r--tools/render-test/render-gl.cpp11
-rw-r--r--tools/render-test/render.cpp16
-rw-r--r--tools/render-test/render.h15
-rw-r--r--tools/render-test/vk-api.cpp6
-rw-r--r--tools/render-test/vk-device-queue.h5
5 files changed, 38 insertions, 15 deletions
diff --git a/tools/render-test/render-gl.cpp b/tools/render-test/render-gl.cpp
index f34f9d910..b079d3f10 100644
--- a/tools/render-test/render-gl.cpp
+++ b/tools/render-test/render-gl.cpp
@@ -262,6 +262,8 @@ public:
static void APIENTRY staticDebugCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const void* userParam);
static VertexAttributeFormat getVertexAttributeFormat(Format format);
+ static void compileTimeAsserts();
+
HDC m_hdc;
HGLRC m_glContext;
float m_clearColor[4] = { 0, 0, 0, 0 };
@@ -280,7 +282,7 @@ public:
MAP_GL_EXTENSION_FUNCS(DECLARE_GL_EXTENSION_FUNC)
#undef DECLARE_GL_EXTENSION_FUNC
- static const GlPixelFormatInfo s_pixelFormatInfos[int(GlPixelFormat::CountOf)];
+ static const GlPixelFormatInfo s_pixelFormatInfos[]; /// Maps GlPixelFormat to a format info
};
/* static */GLRenderer::GlPixelFormat GLRenderer::_getGlPixelFormat(Format format)
@@ -292,13 +294,18 @@ public:
}
}
-/* static */ const GLRenderer::GlPixelFormatInfo GLRenderer::s_pixelFormatInfos[int(GlPixelFormat::CountOf)] =
+/* static */ const GLRenderer::GlPixelFormatInfo GLRenderer::s_pixelFormatInfos[] =
{
// internalType, format, formatType
{ 0, 0, 0}, // GlPixelFormat::Unknown
{ GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE }, // GlPixelFormat::RGBA_Unorm_UInt8
};
+/* static */void GLRenderer::compileTimeAsserts()
+{
+ SLANG_COMPILE_TIME_ASSERT(SLANG_COUNT_OF(s_pixelFormatInfos) == int(GlPixelFormat::CountOf));
+}
+
Renderer* createGLRenderer()
{
return new GLRenderer();
diff --git a/tools/render-test/render.cpp b/tools/render-test/render.cpp
index 6c47a5afe..d366413ca 100644
--- a/tools/render-test/render.cpp
+++ b/tools/render-test/render.cpp
@@ -6,7 +6,7 @@
namespace renderer_test {
using namespace Slang;
-/* static */const Resource::BindFlag::Enum Resource::s_requiredBinding[int(Usage::CountOf)] =
+/* static */const Resource::BindFlag::Enum Resource::s_requiredBinding[] =
{
BindFlag::VertexBuffer, // VertexBuffer
BindFlag::IndexBuffer, // IndexBuffer
@@ -21,6 +21,12 @@ using namespace Slang;
BindFlag::Enum(BindFlag::PixelShaderResource | BindFlag::NonPixelShaderResource), // GenericRead
};
+
+/* static */void Resource::compileTimeAsserts()
+{
+ SLANG_COMPILE_TIME_ASSERT(SLANG_COUNT_OF(s_requiredBinding) == int(Usage::CountOf));
+}
+
static const Resource::DescBase s_emptyDescBase = {};
const Resource::DescBase& Resource::getDescBase() const
@@ -38,7 +44,7 @@ const Resource::DescBase& Resource::getDescBase() const
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! RendererUtil !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
-/* static */const uint8_t RendererUtil::s_formatSize[int(Format::CountOf)] =
+/* static */const uint8_t RendererUtil::s_formatSize[] =
{
0, // Unknown,
@@ -53,6 +59,12 @@ const Resource::DescBase& Resource::getDescBase() const
uint8_t(sizeof(uint32_t)), // D_Unorm24_S8,
};
+
+/* static */void RendererUtil::compileTimeAsserts()
+{
+ SLANG_COMPILE_TIME_ASSERT(SLANG_COUNT_OF(s_formatSize) == int(Format::CountOf));
+}
+
/* !!!!!!!!!!!!!!!!!!!!!!!!!!! BindingState::Desc !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
void BindingState::Desc::addSampler(const SamplerDesc& desc, const ShaderBindSet& shaderBindSet)
diff --git a/tools/render-test/render.h b/tools/render-test/render.h
index 64857dc4f..d4385979a 100644
--- a/tools/render-test/render.h
+++ b/tools/render-test/render.h
@@ -214,13 +214,15 @@ class Resource: public Slang::RefObject
bool canBind(BindFlag::Enum bindFlag) const { return getDescBase().canBind(bindFlag); }
/// For a usage gives the required binding flags
- static const BindFlag::Enum s_requiredBinding[int(Usage::CountOf)];
+ static const BindFlag::Enum s_requiredBinding[]; /// Maps Usage to bind flags required
protected:
Resource(Type type):
m_type(type)
{}
+ static void compileTimeAsserts();
+
Type m_type;
};
@@ -336,10 +338,10 @@ class TextureResource: public Resource
/// forall (depth levels)
struct Data
{
- ptrdiff_t* mipRowStrides; /// The row stride for a mip map
- int numMips; ///< The number of mip maps
- const void*const* subResources; ///< Pointers to each full mip subResource
- int numSubResources; /// The total amount of subResources. Typically = numMips * depth * arraySize
+ ptrdiff_t* mipRowStrides; ///< The row stride for a mip map
+ int numMips; ///< The number of mip maps
+ const void*const* subResources; ///< Pointers to each full mip subResource
+ int numSubResources; ///< The total amount of subResources. Typically = numMips * depth * arraySize
};
/// Get the description of the texture
@@ -598,7 +600,8 @@ struct RendererUtil
static void getIdentityProjection(ProjectionStyle style, float projMatrix[16]);
private:
- static const uint8_t s_formatSize[int(Format::CountOf)];
+ static void compileTimeAsserts();
+ static const uint8_t s_formatSize[]; // Maps Format::XXX to a size in bytes;
};
} // renderer_test
diff --git a/tools/render-test/vk-api.cpp b/tools/render-test/vk-api.cpp
index 9d721f18f..df222d8ad 100644
--- a/tools/render-test/vk-api.cpp
+++ b/tools/render-test/vk-api.cpp
@@ -89,12 +89,14 @@ Slang::Result VulkanApi::initDeviceProcs(VkDevice device)
int VulkanApi::findMemoryTypeIndex(uint32_t typeBits, VkMemoryPropertyFlags properties) const
{
+ assert(typeBits);
+
const int numMemoryTypes = int(m_deviceMemoryProperties.memoryTypeCount);
// bit holds current test bit against typeBits. Ie bit == 1 << typeBits
uint32_t bit = 1;
- for (int i = 0; (typeBits != 0) && i < numMemoryTypes; ++i, bit += bit)
+ for (int i = 0; i < numMemoryTypes; ++i, bit += bit)
{
auto const& memoryType = m_deviceMemoryProperties.memoryTypes[i];
if ((typeBits & bit) && (memoryType.propertyFlags & properties) == properties)
@@ -102,7 +104,7 @@ int VulkanApi::findMemoryTypeIndex(uint32_t typeBits, VkMemoryPropertyFlags prop
return i;
}
}
-
+
//assert(!"failed to find a usable memory type");
return -1;
}
diff --git a/tools/render-test/vk-device-queue.h b/tools/render-test/vk-device-queue.h
index ea50cbd81..8381f5166 100644
--- a/tools/render-test/vk-device-queue.h
+++ b/tools/render-test/vk-device-queue.h
@@ -30,11 +30,10 @@ struct VulkanDeviceQueue
/// Blocks until all work submitted to GPU has completed
void waitForIdle() { m_api->vkQueueWaitIdle(m_queue); }
- /// Set the graphics queue index (as set on init)
+ /// Get the graphics queue index (as set on init)
int getQueueIndex() const { return m_queueIndex; }
-
- /// Make the specified event 'current' - meaning it's semaphone must be waited on
+ /// Make the specified event 'current' - meaning it's semaphore must be waited on
VkSemaphore makeCurrent(EventType eventType);
/// Makes the event no longer required to be waited on
void makeCompleted(EventType eventType);