summaryrefslogtreecommitdiff
path: root/tools/gfx-unit-test/texture-types-tests.cpp
diff options
context:
space:
mode:
authorlucy96chen <47800040+lucy96chen@users.noreply.github.com>2022-04-14 10:00:35 -0700
committerGitHub <noreply@github.com>2022-04-14 10:00:35 -0700
commitac81614974700806e8257b8483a0ba97b925971a (patch)
tree129a0aa5120bbc523389e667d2ae5ab65ae5f693 /tools/gfx-unit-test/texture-types-tests.cpp
parent5ffd3048df2d7faf30ca8192c117d73e908212cd (diff)
GFX renaming work part 1 (#2183)
* Added new typedefs for Size, Offset, Count, and Index; Replaced numerous instances of size_t in slang-gfx.h, render-d3d12, render-vk, and renderer-shared with either Size or Offset; Fixed compiler warnings for mismatched numerical types * Renamed Index and Count to GfxIndex and GfxCount, changed to 32 bit from 64 bit
Diffstat (limited to 'tools/gfx-unit-test/texture-types-tests.cpp')
-rw-r--r--tools/gfx-unit-test/texture-types-tests.cpp55
1 files changed, 8 insertions, 47 deletions
diff --git a/tools/gfx-unit-test/texture-types-tests.cpp b/tools/gfx-unit-test/texture-types-tests.cpp
index 5fdeb2622..94f7a764f 100644
--- a/tools/gfx-unit-test/texture-types-tests.cpp
+++ b/tools/gfx-unit-test/texture-types-tests.cpp
@@ -10,50 +10,11 @@
#include <d3d12.h>
#endif
-#include <stdlib.h>
-#include <stdio.h>
-
-#define STB_IMAGE_WRITE_IMPLEMENTATION
-#include "external/stb/stb_image_write.h"
-
using namespace Slang;
using namespace gfx;
namespace gfx_test
{
- Slang::Result writeImage(
- const char* filename,
- ISlangBlob* pixels,
- uint32_t width,
- uint32_t height,
- size_t rowPitch = 0)
- {
- int stbResult = 0;
- if (rowPitch == 0)
- {
- stbResult = stbi_write_hdr(filename, width, height, 4, (float*)pixels->getBufferPointer());
- }
- else
- {
- List<float> data;
- for (Int y = 0; y < height; ++y)
- {
- for (Int x = 0; x < width; ++x)
- {
- for (Int c = 0; c < 4; ++c)
- {
- auto rowPtr = (char*)pixels->getBufferPointer() + y * rowPitch;
- auto channelPtr = (float*)rowPtr + x * 4 + c;
- data.add(*channelPtr);
- }
- }
- }
- stbResult = stbi_write_hdr(filename, width, height, 4, data.getBuffer());
- }
-
- return stbResult ? SLANG_OK : SLANG_FAIL;
- }
-
struct BaseTextureViewTest
{
IDevice* device;
@@ -303,14 +264,14 @@ namespace gfx_test
ValidationTextureData textureResults;
textureResults.extents = textureInfo->extents;
textureResults.textureData = textureValues;
- textureResults.strides.x = pixelSize;
- textureResults.strides.y = rowPitch;
+ textureResults.strides.x = (uint32_t)pixelSize;
+ textureResults.strides.y = (uint32_t)rowPitch;
textureResults.strides.z = textureResults.extents.height * textureResults.strides.y;
ValidationTextureData originalData;
originalData.extents = textureInfo->extents;
originalData.textureData = textureInfo->subresourceDatas.getBuffer();
- originalData.strides.x = pixelSize;
+ originalData.strides.x = (uint32_t)pixelSize;
originalData.strides.y = textureInfo->extents.width * originalData.strides.x;
originalData.strides.z = textureInfo->extents.height * originalData.strides.y;
@@ -530,9 +491,9 @@ namespace gfx_test
auto rootObject = renderEncoder->bindPipeline(pipelineState);
gfx::Viewport viewport = {};
- viewport.maxZ = textureInfo->extents.depth;
- viewport.extentX = textureInfo->extents.width;
- viewport.extentY = textureInfo->extents.height;
+ viewport.maxZ = (float)textureInfo->extents.depth;
+ viewport.extentX = (float)textureInfo->extents.width;
+ viewport.extentY = (float)textureInfo->extents.height;
renderEncoder->setViewportAndScissor(viewport);
renderEncoder->setVertexBuffer(0, vertexBuffer);
@@ -617,8 +578,8 @@ namespace gfx_test
ValidationTextureData textureResults;
textureResults.extents = textureInfo->extents;
textureResults.textureData = textureValues;
- textureResults.strides.x = pixelSize;
- textureResults.strides.y = rowPitch;
+ textureResults.strides.x = (uint32_t)pixelSize;
+ textureResults.strides.y = (uint32_t)rowPitch;
textureResults.strides.z = textureResults.extents.height * textureResults.strides.y;
validateTextureValues(textureResults);