Skip to content

Commit 9c332f7

Browse files
committed
Update blit uniform by direct mapping
1 parent 3354a4d commit 9c332f7

4 files changed

Lines changed: 3 additions & 11 deletions

File tree

demo/android/app/src/main/cpp/native_engine.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ void NativeEngine::draw_frame() {
3030

3131
auto surface = pf_swapchain->get_surface_texture();
3232

33-
pf_blit->update_uniform(encoder);
34-
3533
// Swap chain render pass.
3634
{
3735
encoder->begin_render_pass(pf_swapchain->get_render_pass(), surface, Pathfinder::ColorF(0.2, 0.2, 0.2, 1.0));

demo/native/main.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ int main() {
6565

6666
auto encoder = device->create_command_encoder("main encoder");
6767

68-
blit->update_uniform(encoder);
69-
7068
// Swap chain render pass.
7169
{
7270
auto surface_texture = swap_chain->get_surface_texture();

pathfinder/utils/blit.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void Blit::set_texture(const std::shared_ptr<Texture> &new_texture) {
5050
});
5151
}
5252

53-
void Blit::update_uniform(const std::shared_ptr<CommandEncoder> &encoder) {
53+
void Blit::draw(const std::shared_ptr<CommandEncoder> &encoder) {
5454
if (!uniform_buffer_) {
5555
auto descriptor =
5656
BufferDescriptor{BufferType::Uniform, 4 * sizeof(float), MemoryProperty::HostVisibleAndCoherent};
@@ -62,13 +62,11 @@ void Blit::update_uniform(const std::shared_ptr<CommandEncoder> &encoder) {
6262
flip_y = -1.0f;
6363
}
6464

65-
encoder->write_buffer(uniform_buffer_, 0, sizeof(float), &flip_y);
65+
uniform_buffer_->upload_via_mapping(sizeof(float), 0, &flip_y);
6666

6767
descriptor_set_->add_or_update({Descriptor::uniform(0, uniform_buffer_)});
6868
}
69-
}
7069

71-
void Blit::draw(const std::shared_ptr<CommandEncoder> &encoder) const {
7270
encoder->bind_render_pipeline(pipeline_);
7371

7472
encoder->bind_descriptor_set(descriptor_set_);

pathfinder/utils/blit.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ class Blit {
1414

1515
void set_texture(const std::shared_ptr<Texture> &new_texture);
1616

17-
void update_uniform(const std::shared_ptr<CommandEncoder> &encoder);
18-
19-
void draw(const std::shared_ptr<CommandEncoder> &encoder) const;
17+
void draw(const std::shared_ptr<CommandEncoder> &encoder);
2018

2119
private:
2220
std::shared_ptr<Device> device_;

0 commit comments

Comments
 (0)