summaryrefslogtreecommitdiff
path: root/tools/render-test
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2019-04-29 17:03:46 -0400
committerTim Foley <tfoleyNV@users.noreply.github.com>2019-04-29 14:03:46 -0700
commit4880789e3003441732cca4471091563f36531635 (patch)
tree8e0d3ed58a561373b35729d24787afe6b39732e3 /tools/render-test
parentded340beb4b5197b559626acc39920abb2d39e77 (diff)
String/List closer to conventions, and use Index type (#959)
* List made members m_ Tweaked types to closer match conventions. * Use asserts for checking conditions on List. Other small improvements. * List<T>.Count() -> getSize() * List<T> Add -> add First -> getFirst Last -> getLast RemoveLast -> removeLast ReleaseBuffer -> detachBuffer GetArrayView -> getArrayView * List<T>:: AddRange -> addRange Capacity -> getCapacity Insert -> insert InsertRange -> insertRange AddRange -> addRange RemoveRange -> removeRange RemoveAt -> removeAt Remove -> remove Reverse -> reverse FastRemove -> fastRemove FastRemoveAt -> fastRemoveAt Clear -> clear * List<T> FreeBuffer -> _deallocateBuffer Free -> clearAndDeallocate SwapWith -> swapWith * List<T> SetSize -> setSize Reserve -> reserve GrowToSize growToSize * UnsafeShrinkToSize -> unsafeShrinkToSize Compress -> compress FindLast -> findLastIndex FindLast -> findLastIndex Simplify Contains * List<T> Removed m_allocator (wasn't used) Swap -> swapElements Sort -> sort Contains -> contains ForEach -> forEach QuickSort -> quickSort InsertionSort -> insertionSort BinarySearch -> binarySearch Max -> calcMax Min -> calcMin * Initializer::Initialize -> initialize List<T>:: Allocate -> _allocate Init -> _init IndexOf -> indexOf * * Put #include <assert.h> in common.h, and remove unneeded inclusions * Small refactor of ArrayView - remove stride as not used * getSize -> getCount setSize -> setCount unsafeShrinkToSize->unsafeShrinkToCount growToSize -> growToCount m_size -> m_count * Some tidy up around Allocator. * Use Index type on List. * Refactor of IntSet. First tentative look at using Index. * Made Index an Int Did preliminary fixes. Made String use Index. * Partial refactor of String. * String::Buffer -> getBuffer ToWString -> toWString * Small improvements to String. String:: Buffer() -> getBuffer() Equals() -> equals * Try to use Index where appropriate. * Fix warnings on windows x86 builds.
Diffstat (limited to 'tools/render-test')
-rw-r--r--tools/render-test/options.cpp12
-rw-r--r--tools/render-test/render-test-main.cpp16
-rw-r--r--tools/render-test/shader-input-layout.cpp50
-rw-r--r--tools/render-test/shader-renderer-util.cpp46
-rw-r--r--tools/render-test/slang-support.cpp24
5 files changed, 74 insertions, 74 deletions
diff --git a/tools/render-test/options.cpp b/tools/render-test/options.cpp
index 2277a6ad7..17ba864f7 100644
--- a/tools/render-test/options.cpp
+++ b/tools/render-test/options.cpp
@@ -72,7 +72,7 @@ SlangResult parseOptions(int argc, const char*const* argv, Slang::WriterHelper s
char const* arg = *argCursor++;
if( arg[0] != '-' )
{
- positionalArgs.Add(arg);
+ positionalArgs.add(arg);
continue;
}
@@ -80,7 +80,7 @@ SlangResult parseOptions(int argc, const char*const* argv, Slang::WriterHelper s
{
while(argCursor != argEnd)
{
- positionalArgs.Add(*argCursor++);
+ positionalArgs.add(*argCursor++);
}
break;
}
@@ -116,7 +116,7 @@ SlangResult parseOptions(int argc, const char*const* argv, Slang::WriterHelper s
for (const auto& value : values)
{
- gOptions.renderFeatures.Add(value);
+ gOptions.renderFeatures.add(value);
}
}
else if( strcmp(arg, "-xslang") == 0 )
@@ -200,14 +200,14 @@ SlangResult parseOptions(int argc, const char*const* argv, Slang::WriterHelper s
gOptions.rendererType = (gOptions.rendererType == RendererType::Unknown) ? gOptions.targetLanguageRendererType : gOptions.rendererType;
// first positional argument is source shader path
- if(positionalArgs.Count())
+ if(positionalArgs.getCount())
{
gOptions.sourcePath = positionalArgs[0];
- positionalArgs.RemoveAt(0);
+ positionalArgs.removeAt(0);
}
// any remaining arguments represent an error
- if(positionalArgs.Count() != 0)
+ if(positionalArgs.getCount() != 0)
{
stdError.print("unexpected arguments\n");
return SLANG_FAIL;
diff --git a/tools/render-test/render-test-main.cpp b/tools/render-test/render-test-main.cpp
index 34e041473..f82e03ad5 100644
--- a/tools/render-test/render-test-main.cpp
+++ b/tools/render-test/render-test-main.cpp
@@ -351,8 +351,8 @@ Result RenderTestApp::initializeShaders(ShaderCompiler* shaderCompiler)
fseek(sourceFile, 0, SEEK_SET);
List<char> sourceText;
- sourceText.SetSize(sourceSize + 1);
- fread(sourceText.Buffer(), sourceSize, 1, sourceFile);
+ sourceText.setCount(sourceSize + 1);
+ fread(sourceText.getBuffer(), sourceSize, 1, sourceFile);
fclose(sourceFile);
sourceText[sourceSize] = 0;
@@ -366,12 +366,12 @@ Result RenderTestApp::initializeShaders(ShaderCompiler* shaderCompiler)
m_shaderInputLayout.numRenderTargets = 0;
break;
}
- m_shaderInputLayout.Parse(sourceText.Buffer());
+ m_shaderInputLayout.Parse(sourceText.getBuffer());
ShaderCompileRequest::SourceInfo sourceInfo;
sourceInfo.path = sourcePath;
- sourceInfo.dataBegin = sourceText.Buffer();
- sourceInfo.dataEnd = sourceText.Buffer() + sourceSize;
+ sourceInfo.dataBegin = sourceText.getBuffer();
+ sourceInfo.dataEnd = sourceText.getBuffer() + sourceSize;
ShaderCompileRequest compileRequest;
compileRequest.source = sourceInfo;
@@ -558,7 +558,7 @@ SLANG_TEST_TOOL_API SlangResult innerMain(Slang::StdWriters* stdWriters, SlangSe
StringBuilder rendererName;
rendererName << "[" << RendererUtil::toText(gOptions.rendererType) << "] ";
- if (gOptions.adapter.Length())
+ if (gOptions.adapter.getLength())
{
rendererName << "'" << gOptions.adapter << "'";
}
@@ -568,7 +568,7 @@ SLANG_TEST_TOOL_API SlangResult innerMain(Slang::StdWriters* stdWriters, SlangSe
{
if (!gOptions.onlyStartup)
{
- fprintf(stderr, "Unable to create renderer %s\n", rendererName.Buffer());
+ fprintf(stderr, "Unable to create renderer %s\n", rendererName.getBuffer());
}
return SLANG_FAIL;
}
@@ -584,7 +584,7 @@ SLANG_TEST_TOOL_API SlangResult innerMain(Slang::StdWriters* stdWriters, SlangSe
{
if (!gOptions.onlyStartup)
{
- fprintf(stderr, "Unable to initialize renderer %s\n", rendererName.Buffer());
+ fprintf(stderr, "Unable to initialize renderer %s\n", rendererName.getBuffer());
}
return res;
}
diff --git a/tools/render-test/shader-input-layout.cpp b/tools/render-test/shader-input-layout.cpp
index 6d51a1980..644b0889e 100644
--- a/tools/render-test/shader-input-layout.cpp
+++ b/tools/render-test/shader-input-layout.cpp
@@ -8,17 +8,17 @@ namespace renderer_test
using namespace Slang;
void ShaderInputLayout::Parse(const char * source)
{
- entries.Clear();
- globalGenericTypeArguments.Clear();
- entryPointGenericTypeArguments.Clear();
- globalExistentialTypeArguments.Clear();
- entryPointExistentialTypeArguments.Clear();
+ entries.clear();
+ globalGenericTypeArguments.clear();
+ entryPointGenericTypeArguments.clear();
+ globalExistentialTypeArguments.clear();
+ entryPointExistentialTypeArguments.clear();
auto lines = Split(source, '\n');
for (auto & line : lines)
{
- if (line.StartsWith("//TEST_INPUT:"))
+ if (line.startsWith("//TEST_INPUT:"))
{
- auto lineContent = line.SubString(13, line.Length() - 13);
+ auto lineContent = line.subString(13, line.getLength() - 13);
TokenReader parser(lineContent);
try
{
@@ -28,7 +28,7 @@ namespace renderer_test
StringBuilder typeExp;
while (!parser.IsEnd())
typeExp << parser.ReadToken().Content;
- entryPointGenericTypeArguments.Add(typeExp);
+ entryPointGenericTypeArguments.add(typeExp);
}
else if (parser.LookAhead("global_type"))
{
@@ -36,7 +36,7 @@ namespace renderer_test
StringBuilder typeExp;
while (!parser.IsEnd())
typeExp << parser.ReadToken().Content;
- globalGenericTypeArguments.Add(typeExp);
+ globalGenericTypeArguments.add(typeExp);
}
else if (parser.LookAhead("globalExistentialType"))
{
@@ -44,7 +44,7 @@ namespace renderer_test
StringBuilder typeExp;
while (!parser.IsEnd())
typeExp << parser.ReadToken().Content;
- globalExistentialTypeArguments.Add(typeExp);
+ globalExistentialTypeArguments.add(typeExp);
}
else if (parser.LookAhead("entryPointExistentialType"))
{
@@ -52,7 +52,7 @@ namespace renderer_test
StringBuilder typeExp;
while (!parser.IsEnd())
typeExp << parser.ReadToken().Content;
- entryPointExistentialTypeArguments.Add(typeExp);
+ entryPointExistentialTypeArguments.add(typeExp);
}
else
{
@@ -183,12 +183,12 @@ namespace renderer_test
{
if (parser.NextToken().Type == TokenType::IntLiteral)
{
- entry.bufferData.Add(parser.ReadUInt());
+ entry.bufferData.add(parser.ReadUInt());
}
else
{
auto floatNum = parser.ReadFloat();
- entry.bufferData.Add(*(unsigned int*)&floatNum);
+ entry.bufferData.add(*(unsigned int*)&floatNum);
}
}
parser.Read("]");
@@ -254,7 +254,7 @@ namespace renderer_test
parser.Read("(");
while (!parser.IsEnd() && !parser.LookAhead(")"))
{
- entry.glslBinding.Add(parser.ReadInt());
+ entry.glslBinding.add(parser.ReadInt());
if (parser.LookAhead(","))
parser.Read(",");
else
@@ -271,7 +271,7 @@ namespace renderer_test
parser.Read(",");
}
}
- entries.Add(entry);
+ entries.add(entry);
}
}
catch (TextFormatException)
@@ -302,19 +302,19 @@ namespace renderer_test
List<List<unsigned int>>& dstBuffer = output.dataBuffer;
- int numMips = int(work.dataBuffer.Count());
- dstBuffer.SetSize(numMips);
+ Index numMips = work.dataBuffer.getCount();
+ dstBuffer.setCount(numMips);
for (int i = 0; i < numMips; ++i)
{
- const int numPixels = int(work.dataBuffer[i].Count());
- const unsigned int* srcPixels = work.dataBuffer[i].Buffer();
+ const Index numPixels = work.dataBuffer[i].getCount();
+ const unsigned int* srcPixels = work.dataBuffer[i].getBuffer();
- dstBuffer[i].SetSize(numPixels);
+ dstBuffer[i].setCount(numPixels);
- float* dstPixels = (float*)dstBuffer[i].Buffer();
+ float* dstPixels = (float*)dstBuffer[i].getBuffer();
- for (int j = 0; j < numPixels; ++j)
+ for (Index j = 0; j < numPixels; ++j)
{
// Copy out red
const unsigned int srcPixel = srcPixels[j];
@@ -344,7 +344,7 @@ namespace renderer_test
output.arraySize = arraySize;
output.textureSize = inputDesc.size;
output.mipLevels = Math::Log2Floor(output.textureSize) + 1;
- output.dataBuffer.SetSize(output.mipLevels * output.arraySize);
+ output.dataBuffer.setCount(output.mipLevels * output.arraySize);
auto iteratePixels = [&](int dimension, int size, unsigned int * buffer, auto f)
{
if (dimension == 1)
@@ -372,9 +372,9 @@ namespace renderer_test
bufferLen *= size;
else if (inputDesc.dimension == 3)
bufferLen *= size*size;
- dataBuffer[slice].SetSize(bufferLen);
+ dataBuffer[slice].setCount(bufferLen);
- iteratePixels(inputDesc.dimension, size, dataBuffer[slice].Buffer(), [&](int x, int y, int z) -> unsigned int
+ iteratePixels(inputDesc.dimension, size, dataBuffer[slice].getBuffer(), [&](int x, int y, int z) -> unsigned int
{
if (inputDesc.content == InputTextureContent::Zero)
{
diff --git a/tools/render-test/shader-renderer-util.cpp b/tools/render-test/shader-renderer-util.cpp
index 13effdd08..e13958f50 100644
--- a/tools/render-test/shader-renderer-util.cpp
+++ b/tools/render-test/shader-renderer-util.cpp
@@ -66,9 +66,9 @@ void BindingStateImpl::apply(Renderer* renderer, PipelineType pipelineType)
TextureResource::Data initData;
List<ptrdiff_t> mipRowStrides;
- mipRowStrides.SetSize(textureResourceDesc.numMipLevels);
+ mipRowStrides.setCount(textureResourceDesc.numMipLevels);
List<const void*> subResources;
- subResources.SetSize(numSubResources);
+ subResources.setCount(numSubResources);
// Set up the src row strides
for (int i = 0; i < textureResourceDesc.numMipLevels; i++)
@@ -80,19 +80,19 @@ void BindingStateImpl::apply(Renderer* renderer, PipelineType pipelineType)
// Set up pointers the the data
{
int subResourceIndex = 0;
- const int numGen = int(texData.dataBuffer.Count());
+ const int numGen = int(texData.dataBuffer.getCount());
for (int i = 0; i < numSubResources; i++)
{
- subResources[i] = texData.dataBuffer[subResourceIndex].Buffer();
+ subResources[i] = texData.dataBuffer[subResourceIndex].getBuffer();
// Wrap around
subResourceIndex = (subResourceIndex + 1 >= numGen) ? 0 : (subResourceIndex + 1);
}
}
- initData.mipRowStrides = mipRowStrides.Buffer();
+ initData.mipRowStrides = mipRowStrides.getBuffer();
initData.numMips = textureResourceDesc.numMipLevels;
initData.numSubResources = numSubResources;
- initData.subResources = subResources.Buffer();
+ initData.subResources = subResources.getBuffer();
textureOut = renderer->createTextureResource(Resource::Usage::GenericRead, textureResourceDesc, &initData);
@@ -175,7 +175,7 @@ static RefPtr<SamplerState> _createSamplerState(
}
case BindingStyle::OpenGl:
{
- const int count = int(entry.glslBinding.Count());
+ const int count = int(entry.glslBinding.getCount());
if (count <= 0)
{
@@ -184,7 +184,7 @@ static RefPtr<SamplerState> _createSamplerState(
int baseIndex = entry.glslBinding[0];
// Make sure they are contiguous
- for (int i = 1; i < int(entry.glslBinding.Count()); ++i)
+ for (Index i = 1; i < int(entry.glslBinding.getCount()); ++i)
{
if (baseIndex + i != entry.glslBinding[i])
{
@@ -205,8 +205,8 @@ static RefPtr<SamplerState> _createSamplerState(
/* static */Result ShaderRendererUtil::createBindingState(const ShaderInputLayout& layout, Renderer* renderer, BufferResource* addedConstantBuffer, BindingStateImpl** outBindingState)
{
- auto srcEntries = layout.entries.Buffer();
- auto numEntries = int(layout.entries.Count());
+ auto srcEntries = layout.entries.getBuffer();
+ auto numEntries = layout.entries.getCount();
const int textureBindFlags = Resource::BindFlag::NonPixelShaderResource | Resource::BindFlag::PixelShaderResource;
@@ -217,10 +217,10 @@ static RefPtr<SamplerState> _createSamplerState(
DescriptorSetLayout::SlotRangeDesc slotRangeDesc;
slotRangeDesc.type = DescriptorSlotType::UniformBuffer;
- slotRangeDescs.Add(slotRangeDesc);
+ slotRangeDescs.add(slotRangeDesc);
}
- for (int i = 0; i < numEntries; i++)
+ for (Index i = 0; i < numEntries; i++)
{
const ShaderInputLayoutEntry& srcEntry = srcEntries[i];
@@ -279,23 +279,23 @@ static RefPtr<SamplerState> _createSamplerState(
assert(!"Unhandled type");
return SLANG_FAIL;
}
- slotRangeDescs.Add(slotRangeDesc);
+ slotRangeDescs.add(slotRangeDesc);
}
DescriptorSetLayout::Desc descriptorSetLayoutDesc;
- descriptorSetLayoutDesc.slotRangeCount = slotRangeDescs.Count();
- descriptorSetLayoutDesc.slotRanges = slotRangeDescs.Buffer();
+ descriptorSetLayoutDesc.slotRangeCount = slotRangeDescs.getCount();
+ descriptorSetLayoutDesc.slotRanges = slotRangeDescs.getBuffer();
auto descriptorSetLayout = renderer->createDescriptorSetLayout(descriptorSetLayoutDesc);
if(!descriptorSetLayout) return SLANG_FAIL;
List<PipelineLayout::DescriptorSetDesc> pipelineDescriptorSets;
- pipelineDescriptorSets.Add(PipelineLayout::DescriptorSetDesc(descriptorSetLayout));
+ pipelineDescriptorSets.add(PipelineLayout::DescriptorSetDesc(descriptorSetLayout));
PipelineLayout::Desc pipelineLayoutDesc;
pipelineLayoutDesc.renderTargetCount = layout.numRenderTargets;
- pipelineLayoutDesc.descriptorSetCount = pipelineDescriptorSets.Count();
- pipelineLayoutDesc.descriptorSets = pipelineDescriptorSets.Buffer();
+ pipelineLayoutDesc.descriptorSetCount = pipelineDescriptorSets.getCount();
+ pipelineLayoutDesc.descriptorSets = pipelineDescriptorSets.getBuffer();
auto pipelineLayout = renderer->createPipelineLayout(pipelineLayoutDesc);
if(!pipelineLayout) return SLANG_FAIL;
@@ -320,10 +320,10 @@ static RefPtr<SamplerState> _createSamplerState(
case ShaderInputType::Buffer:
{
const InputBufferDesc& srcBuffer = srcEntry.bufferDesc;
- const size_t bufferSize = srcEntry.bufferData.Count() * sizeof(uint32_t);
+ const size_t bufferSize = srcEntry.bufferData.getCount() * sizeof(uint32_t);
RefPtr<BufferResource> bufferResource;
- SLANG_RETURN_ON_FAIL(createBufferResource(srcEntry.bufferDesc, srcEntry.isOutput, bufferSize, srcEntry.bufferData.Buffer(), renderer, bufferResource));
+ SLANG_RETURN_ON_FAIL(createBufferResource(srcEntry.bufferDesc, srcEntry.isOutput, bufferSize, srcEntry.bufferData.getBuffer(), renderer, bufferResource));
switch(srcBuffer.type)
{
@@ -349,7 +349,7 @@ static RefPtr<SamplerState> _createSamplerState(
BindingStateImpl::OutputBinding binding;
binding.entryIndex = i;
binding.resource = bufferResource;
- outputBindings.Add(binding);
+ outputBindings.add(binding);
}
}
break;
@@ -374,7 +374,7 @@ static RefPtr<SamplerState> _createSamplerState(
BindingStateImpl::OutputBinding binding;
binding.entryIndex = i;
binding.resource = texture;
- outputBindings.Add(binding);
+ outputBindings.add(binding);
}
}
break;
@@ -404,7 +404,7 @@ static RefPtr<SamplerState> _createSamplerState(
BindingStateImpl::OutputBinding binding;
binding.entryIndex = i;
binding.resource = texture;
- outputBindings.Add(binding);
+ outputBindings.add(binding);
}
}
break;
diff --git a/tools/render-test/slang-support.cpp b/tools/render-test/slang-support.cpp
index 06f5eaba1..77f1436b1 100644
--- a/tools/render-test/slang-support.cpp
+++ b/tools/render-test/slang-support.cpp
@@ -95,28 +95,28 @@ RefPtr<ShaderProgram> ShaderCompiler::compileProgram(
Slang::List<const char*> rawGlobalTypeNames;
for (auto typeName : request.globalGenericTypeArguments)
- rawGlobalTypeNames.Add(typeName.Buffer());
+ rawGlobalTypeNames.add(typeName.getBuffer());
spSetGlobalGenericArgs(
slangRequest,
- (int)rawGlobalTypeNames.Count(),
- rawGlobalTypeNames.Buffer());
+ (int)rawGlobalTypeNames.getCount(),
+ rawGlobalTypeNames.getBuffer());
Slang::List<const char*> rawEntryPointTypeNames;
for (auto typeName : request.entryPointGenericTypeArguments)
- rawEntryPointTypeNames.Add(typeName.Buffer());
+ rawEntryPointTypeNames.add(typeName.getBuffer());
- const int globalExistentialTypeCount = int(request.globalExistentialTypeArguments.Count());
+ const int globalExistentialTypeCount = int(request.globalExistentialTypeArguments.getCount());
for(int ii = 0; ii < globalExistentialTypeCount; ++ii )
{
- spSetTypeNameForGlobalExistentialTypeParam(slangRequest, ii, request.globalExistentialTypeArguments[ii].Buffer());
+ spSetTypeNameForGlobalExistentialTypeParam(slangRequest, ii, request.globalExistentialTypeArguments[ii].getBuffer());
}
- const int entryPointExistentialTypeCount = int(request.entryPointExistentialTypeArguments.Count());
+ const int entryPointExistentialTypeCount = int(request.entryPointExistentialTypeArguments.getCount());
auto setEntryPointExistentialTypeArgs = [&](int entryPoint)
{
for( int ii = 0; ii < entryPointExistentialTypeCount; ++ii )
{
- spSetTypeNameForEntryPointExistentialTypeParam(slangRequest, entryPoint, ii, request.entryPointExistentialTypeArguments[ii].Buffer());
+ spSetTypeNameForEntryPointExistentialTypeParam(slangRequest, entryPoint, ii, request.entryPointExistentialTypeArguments[ii].getBuffer());
}
};
@@ -125,8 +125,8 @@ RefPtr<ShaderProgram> ShaderCompiler::compileProgram(
int computeEntryPoint = spAddEntryPointEx(slangRequest, computeTranslationUnit,
computeEntryPointName,
SLANG_STAGE_COMPUTE,
- (int)rawEntryPointTypeNames.Count(),
- rawEntryPointTypeNames.Buffer());
+ (int)rawEntryPointTypeNames.getCount(),
+ rawEntryPointTypeNames.getBuffer());
setEntryPointExistentialTypeArgs(computeEntryPoint);
@@ -156,8 +156,8 @@ RefPtr<ShaderProgram> ShaderCompiler::compileProgram(
}
else
{
- int vertexEntryPoint = spAddEntryPointEx(slangRequest, vertexTranslationUnit, vertexEntryPointName, SLANG_STAGE_VERTEX, (int)rawEntryPointTypeNames.Count(), rawEntryPointTypeNames.Buffer());
- int fragmentEntryPoint = spAddEntryPointEx(slangRequest, fragmentTranslationUnit, fragmentEntryPointName, SLANG_STAGE_FRAGMENT, (int)rawEntryPointTypeNames.Count(), rawEntryPointTypeNames.Buffer());
+ int vertexEntryPoint = spAddEntryPointEx(slangRequest, vertexTranslationUnit, vertexEntryPointName, SLANG_STAGE_VERTEX, (int)rawEntryPointTypeNames.getCount(), rawEntryPointTypeNames.getBuffer());
+ int fragmentEntryPoint = spAddEntryPointEx(slangRequest, fragmentTranslationUnit, fragmentEntryPointName, SLANG_STAGE_FRAGMENT, (int)rawEntryPointTypeNames.getCount(), rawEntryPointTypeNames.getBuffer());
setEntryPointExistentialTypeArgs(vertexEntryPoint);
setEntryPointExistentialTypeArgs(fragmentEntryPoint);