mirror of
https://github.com/Zelda64Recomp/Zelda64Recomp.git
synced 2026-04-28 05:01:39 +00:00
Use RT64's texture laoding instead.
This commit is contained in:
parent
8c167f06f8
commit
090fb5f5f1
2 changed files with 23 additions and 18 deletions
|
|
@ -39,6 +39,8 @@ endif()
|
||||||
|
|
||||||
set(RT64_STATIC TRUE)
|
set(RT64_STATIC TRUE)
|
||||||
set(RT64_SDL_WINDOW_VULKAN TRUE)
|
set(RT64_SDL_WINDOW_VULKAN TRUE)
|
||||||
|
add_compile_definitions(HLSL_CPU)
|
||||||
|
|
||||||
add_subdirectory(${CMAKE_SOURCE_DIR}/lib/rt64 ${CMAKE_BINARY_DIR}/rt64)
|
add_subdirectory(${CMAKE_SOURCE_DIR}/lib/rt64 ${CMAKE_BINARY_DIR}/rt64)
|
||||||
|
|
||||||
# set(BUILD_SHARED_LIBS_SAVED "${BUILD_SHARED_LIBS}")
|
# set(BUILD_SHARED_LIBS_SAVED "${BUILD_SHARED_LIBS}")
|
||||||
|
|
|
||||||
|
|
@ -8,10 +8,9 @@
|
||||||
|
|
||||||
#include <concurrentqueue.h>
|
#include <concurrentqueue.h>
|
||||||
|
|
||||||
#include "stb/stb_image.h"
|
|
||||||
|
|
||||||
#include "rt64_render_hooks.h"
|
#include "rt64_render_hooks.h"
|
||||||
#include "rt64_render_interface_builders.h"
|
#include "rt64_render_interface_builders.h"
|
||||||
|
#include "rt64_texture_cache.h"
|
||||||
|
|
||||||
#include "RmlUi/Core/RenderInterfaceCompatibility.h"
|
#include "RmlUi/Core/RenderInterfaceCompatibility.h"
|
||||||
|
|
||||||
|
|
@ -404,25 +403,29 @@ public:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr uint32_t PNG_MAGIC = 0x474E5089;
|
// TODO: This data copy can be avoided when RT64::TextureCache::loadTextureFromBytes's function is updated to only take a pointer and size as the input.
|
||||||
uint32_t magicNumber = *reinterpret_cast<const uint32_t *>(it->second.data());
|
std::vector<uint8_t> data_copy(it->second.data(), it->second.data() + it->second.size());
|
||||||
if (magicNumber == PNG_MAGIC) {
|
std::unique_ptr<RT64::RenderBuffer> texture_buffer;
|
||||||
int width, height;
|
copy_command_list_->begin();
|
||||||
stbi_uc *stbi_data = stbi_load_from_memory((const stbi_uc *)(it->second.data()), it->second.size(), &width, &height, nullptr, 4);
|
RT64::Texture *texture = RT64::TextureCache::loadTextureFromBytes(device_, copy_command_list_.get(), data_copy, texture_buffer);
|
||||||
if (stbi_data == nullptr) {
|
copy_command_list_->end();
|
||||||
return false;
|
copy_command_queue_->executeCommandLists(copy_command_list_.get(), copy_command_fence_.get());
|
||||||
}
|
copy_command_queue_->waitForCommandFence(copy_command_fence_.get());
|
||||||
|
|
||||||
texture_dimensions.x = width;
|
if (texture == nullptr) {
|
||||||
texture_dimensions.y = height;
|
|
||||||
|
|
||||||
bool texture_generated = GenerateTexture(texture_handle, stbi_data, texture_dimensions);
|
|
||||||
stbi_image_free(stbi_data);
|
|
||||||
return texture_generated;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
texture_handle = texture_count_++;
|
||||||
|
texture_dimensions.x = texture->width;
|
||||||
|
texture_dimensions.y = texture->height;
|
||||||
|
|
||||||
|
std::unique_ptr<RT64::RenderDescriptorSet> set = texture_set_builder_->create(device_);
|
||||||
|
set->setTexture(gTexture_descriptor_index, texture->texture.get(), RT64::RenderTextureLayout::SHADER_READ);
|
||||||
|
textures_.emplace(texture_handle, TextureHandle{ std::move(texture->texture), std::move(set), false });
|
||||||
|
delete texture;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GenerateTexture(Rml::TextureHandle& texture_handle, const Rml::byte* source, const Rml::Vector2i& source_dimensions) override {
|
bool GenerateTexture(Rml::TextureHandle& texture_handle, const Rml::byte* source, const Rml::Vector2i& source_dimensions) override {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue