From ef5360a181fd38182651b1156ec1f6752a0a2883 Mon Sep 17 00:00:00 2001 From: Sergey Kosarevsky Date: Fri, 20 Dec 2024 18:57:28 -0800 Subject: [PATCH] igl | tests | Add `RenderCommandEncoderTest::shouldDrawAPointNewBindTexture` Reviewed By: mmaurer Differential Revision: D67537486 fbshipit-source-id: 3964cbf425ac3c30f2ea95cec2fa582b2915a0aa --- src/igl/tests/RenderCommandEncoder.cpp | 34 ++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/src/igl/tests/RenderCommandEncoder.cpp b/src/igl/tests/RenderCommandEncoder.cpp index 44da4e8be4..be8b1c6f10 100644 --- a/src/igl/tests/RenderCommandEncoder.cpp +++ b/src/igl/tests/RenderCommandEncoder.cpp @@ -203,7 +203,8 @@ class RenderCommandEncoderTest : public ::testing::Test { void encodeAndSubmit( const std::function&)>& func, - bool useBindGroup = false) { + bool useBindGroup = false, + bool useNewBindTexture = false) { Result ret; auto cmdBuffer = cmdQueue_->createCommandBuffer({}, &ret); @@ -215,7 +216,8 @@ class RenderCommandEncoderTest : public ::testing::Test { if (useBindGroup) { encoder->bindBindGroup(bindGroupTexture_); } else { - encoder->bindTexture(textureUnit_, BindTarget::kFragment, texture_.get()); + useNewBindTexture ? encoder->bindTexture(textureUnit_, texture_.get()) + : encoder->bindTexture(textureUnit_, BindTarget::kFragment, texture_.get()); encoder->bindSamplerState(textureUnit_, BindTarget::kFragment, samp_.get()); } @@ -393,6 +395,34 @@ TEST_F(RenderCommandEncoderTest, shouldDrawAPoint) { verifyFrameBuffer(expectedPixels); } +TEST_F(RenderCommandEncoderTest, shouldDrawAPointNewBindTexture) { + initializeBuffers( + // clang-format off + { quarterPixel, quarterPixel, 0.0f, 1.0f }, + { 0.5, 0.5 } // clang-format on + ); + + encodeAndSubmit( + [this](const std::unique_ptr& encoder) { + encoder->bindRenderPipelineState(renderPipelineState_Point_); + encoder->draw(1); + }, + false, + true); + + auto grayColor = data::texture::TEX_RGBA_GRAY_4x4[0]; + // clang-format off + std::vector const expectedPixels { + backgroundColorHex, backgroundColorHex, backgroundColorHex, backgroundColorHex, + backgroundColorHex, backgroundColorHex, grayColor, backgroundColorHex, + backgroundColorHex, backgroundColorHex, backgroundColorHex, backgroundColorHex, + backgroundColorHex, backgroundColorHex, backgroundColorHex, backgroundColorHex, + }; + // clang-format on + + verifyFrameBuffer(expectedPixels); +} + TEST_F(RenderCommandEncoderTest, shouldDrawALine) { initializeBuffers( // clang-format off