From 4880789e3003441732cca4471091563f36531635 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Mon, 29 Apr 2019 17:03:46 -0400 Subject: 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.Count() -> getSize() * List Add -> add First -> getFirst Last -> getLast RemoveLast -> removeLast ReleaseBuffer -> detachBuffer GetArrayView -> getArrayView * List:: 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 FreeBuffer -> _deallocateBuffer Free -> clearAndDeallocate SwapWith -> swapWith * List SetSize -> setSize Reserve -> reserve GrowToSize growToSize * UnsafeShrinkToSize -> unsafeShrinkToSize Compress -> compress FindLast -> findLastIndex FindLast -> findLastIndex Simplify Contains * List 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:: Allocate -> _allocate Init -> _init IndexOf -> indexOf * * Put #include 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. --- tools/render-test/shader-renderer-util.cpp | 46 +++++++++++++++--------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'tools/render-test/shader-renderer-util.cpp') 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 mipRowStrides; - mipRowStrides.SetSize(textureResourceDesc.numMipLevels); + mipRowStrides.setCount(textureResourceDesc.numMipLevels); List 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 _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 _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 _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 _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 _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 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 _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; - 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 _createSamplerState( BindingStateImpl::OutputBinding binding; binding.entryIndex = i; binding.resource = bufferResource; - outputBindings.Add(binding); + outputBindings.add(binding); } } break; @@ -374,7 +374,7 @@ static RefPtr _createSamplerState( BindingStateImpl::OutputBinding binding; binding.entryIndex = i; binding.resource = texture; - outputBindings.Add(binding); + outputBindings.add(binding); } } break; @@ -404,7 +404,7 @@ static RefPtr _createSamplerState( BindingStateImpl::OutputBinding binding; binding.entryIndex = i; binding.resource = texture; - outputBindings.Add(binding); + outputBindings.add(binding); } } break; -- cgit v1.2.3