MCPcopy Create free account
hub / github.com/RevoSucks/BM64Recomp / RenderGeometry

Method RenderGeometry

src/ui/ui_renderer.cpp:347–404  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

345 }
346
347 void RenderGeometry(Rml::Vertex* vertices, int num_vertices, int* indices, int num_indices, Rml::TextureHandle texture, const Rml::Vector2f& translation) override {
348 if (!textures_.contains(texture)) {
349 if (texture == 0) {
350 Rml::byte white_pixel[] = { 255, 255, 255, 255 };
351 create_texture(0, white_pixel, Rml::Vector2i{ 1, 1 });
352 }
353 else if (texture == 1) {
354 Rml::byte transparent_pixel[] = { 0, 0, 0, 0 };
355 create_texture(1, transparent_pixel, Rml::Vector2i{ 1, 1 });
356 }
357 else {
358 assert(false && "Rendered without texture!");
359 }
360 }
361
362 // Copy the vertex and index data into the mapped buffers.
363 uint32_t vert_size_bytes = num_vertices * sizeof(*vertices);
364 uint32_t index_size_bytes = num_indices * sizeof(*indices);
365 uint32_t vertex_buffer_offset = allocate_dynamic_data(vertex_buffer_, vert_size_bytes);
366 uint32_t index_buffer_offset = allocate_dynamic_data(index_buffer_, index_size_bytes);
367 memcpy(vertex_buffer_.mapped_data_ + vertex_buffer_offset, vertices, vert_size_bytes);
368 memcpy(index_buffer_.mapped_data_ + index_buffer_offset, indices, index_size_bytes);
369
370 list_->setViewports(plume::RenderViewport{ 0, 0, float(window_width_), float(window_height_) });
371 if (scissor_enabled_) {
372 list_->setScissors(plume::RenderRect{
373 scissor_x_,
374 scissor_y_,
375 (scissor_width_ + scissor_x_),
376 (scissor_height_ + scissor_y_) });
377 }
378 else {
379 list_->setScissors(plume::RenderRect{ 0, 0, window_width_, window_height_ });
380 }
381
382 plume::RenderIndexBufferView index_view{index_buffer_.buffer_->at(index_buffer_offset), index_size_bytes, plume::RenderFormat::R32_UINT};
383 list_->setIndexBuffer(&index_view);
384 plume::RenderVertexBufferView vertex_view{vertex_buffer_.buffer_->at(vertex_buffer_offset), vert_size_bytes};
385 list_->setVertexBuffers(0, &vertex_view, 1, &vertex_slot_);
386
387 TextureHandle &texture_handle = textures_.at(texture);
388 if (!texture_handle.transitioned) {
389 // Prepare the texture for being read from a pixel shader.
390 list_->barriers(plume::RenderBarrierStage::GRAPHICS, plume::RenderTextureBarrier(texture_handle.texture.get(), plume::RenderTextureLayout::SHADER_READ));
391 texture_handle.transitioned = true;
392 }
393
394 list_->setGraphicsDescriptorSet(texture_handle.set.get(), 1);
395
396 RmlPushConstants constants{
397 .transform = mvp_,
398 .translation = translation
399 };
400
401 list_->setGraphicsPushConstants(0, &constants);
402
403 list_->drawIndexedInstanced(num_indices, 1, 0, 0, 0);
404 }

Callers

nothing calls this directly

Calls 2

containsMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected