Skip to content

Commit

Permalink
igl | tests | Add `RenderCommandEncoderTest::shouldDrawAPointNewBindT…
Browse files Browse the repository at this point in the history
…exture`

Reviewed By: mmaurer

Differential Revision: D67537486

fbshipit-source-id: 3964cbf425ac3c30f2ea95cec2fa582b2915a0aa
  • Loading branch information
corporateshark authored and facebook-github-bot committed Dec 21, 2024
1 parent 3c7dcd2 commit ef5360a
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions src/igl/tests/RenderCommandEncoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ class RenderCommandEncoderTest : public ::testing::Test {

void encodeAndSubmit(
const std::function<void(const std::unique_ptr<igl::IRenderCommandEncoder>&)>& func,
bool useBindGroup = false) {
bool useBindGroup = false,
bool useNewBindTexture = false) {
Result ret;

auto cmdBuffer = cmdQueue_->createCommandBuffer({}, &ret);
Expand All @@ -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());
}

Expand Down Expand Up @@ -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<igl::IRenderCommandEncoder>& encoder) {
encoder->bindRenderPipelineState(renderPipelineState_Point_);
encoder->draw(1);
},
false,
true);

auto grayColor = data::texture::TEX_RGBA_GRAY_4x4[0];
// clang-format off
std::vector<uint32_t> 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
Expand Down

0 comments on commit ef5360a

Please sign in to comment.