mirror of
https://github.com/bailwillharr/engine.git
synced 2024-09-21 04:51:18 +00:00
Do some things
This commit is contained in:
parent
ecab0acbf4
commit
ceaa2c30f5
@ -30,6 +30,11 @@ namespace engine::gfx {
|
||||
VEC3,
|
||||
};
|
||||
|
||||
enum class TextureFilter {
|
||||
LINEAR,
|
||||
NEAREST,
|
||||
};
|
||||
|
||||
struct VertexBufferDesc {
|
||||
uint64_t size;
|
||||
};
|
||||
|
@ -37,7 +37,7 @@ namespace engine {
|
||||
gfx::Buffer* createBuffer(gfx::BufferType type, uint64_t size, const void* data);
|
||||
void destroyBuffer(const gfx::Buffer* buffer);
|
||||
|
||||
gfx::Texture* createTexture(const void* imageData, uint32_t w, uint32_t h);
|
||||
gfx::Texture* createTexture(const void* imageData, uint32_t w, uint32_t h, gfx::TextureFilter minFilter, gfx::TextureFilter magFilter);
|
||||
void destroyTexture(const gfx::Texture* texture);
|
||||
|
||||
// wait until all the active GPU queues have finished working
|
||||
|
@ -154,6 +154,17 @@ namespace engine {
|
||||
throw std::runtime_error("Unknown buffer type");
|
||||
}
|
||||
|
||||
static VkFilter getTextureFilter(gfx::TextureFilter filter)
|
||||
{
|
||||
switch(filter) {
|
||||
case gfx::TextureFilter::LINEAR:
|
||||
return VK_FILTER_LINEAR;
|
||||
case gfx::TextureFilter::NEAREST:
|
||||
return VK_FILTER_NEAREST;
|
||||
}
|
||||
throw std::runtime_error("Unknown texture filter");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// functions
|
||||
@ -1922,7 +1933,7 @@ namespace engine {
|
||||
delete buffer;
|
||||
}
|
||||
|
||||
gfx::Texture* GFXDevice::createTexture(const void* imageData, uint32_t w, uint32_t h)
|
||||
gfx::Texture* GFXDevice::createTexture(const void* imageData, uint32_t w, uint32_t h, gfx::TextureFilter minFilter, gfx::TextureFilter magFilter)
|
||||
{
|
||||
auto out = new gfx::Texture;
|
||||
|
||||
@ -2031,9 +2042,13 @@ namespace engine {
|
||||
|
||||
// create texture sampler
|
||||
{
|
||||
|
||||
VkFilter minFilterInternal = vkinternal::getTextureFilter(minFilter);
|
||||
VkFilter magFilterInternal = vkinternal::getTextureFilter(magFilter);
|
||||
|
||||
VkSamplerCreateInfo samplerInfo{ VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO };
|
||||
samplerInfo.magFilter = VK_FILTER_LINEAR;
|
||||
samplerInfo.minFilter = VK_FILTER_LINEAR;
|
||||
samplerInfo.magFilter = VK_FILTER_NEAREST;
|
||||
samplerInfo.minFilter = VK_FILTER_NEAREST;
|
||||
samplerInfo.addressModeU = VK_SAMPLER_ADDRESS_MODE_REPEAT;
|
||||
samplerInfo.addressModeV = VK_SAMPLER_ADDRESS_MODE_REPEAT;
|
||||
samplerInfo.addressModeW = VK_SAMPLER_ADDRESS_MODE_REPEAT;
|
||||
|
@ -85,7 +85,12 @@ Texture::Texture(const std::filesystem::path& resPath) : Resource(resPath, "text
|
||||
throw std::runtime_error("Currently, only RGBA textures are supported. Size: " + std::to_string(texbuf->size()));
|
||||
}
|
||||
|
||||
m_gpuTexture = gfxdev->createTexture(texbuf->data(), (uint32_t)width, (uint32_t)height);
|
||||
gfx::TextureFilter filter = gfx::TextureFilter::LINEAR;
|
||||
if (width <= 8 || height <= 8) {
|
||||
filter = gfx::TextureFilter::NEAREST;
|
||||
}
|
||||
|
||||
m_gpuTexture = gfxdev->createTexture(texbuf->data(), (uint32_t)width, (uint32_t)height, gfx::TextureFilter::LINEAR, filter);
|
||||
|
||||
DEBUG("loaded texture {} width: {} height: {} size: {}", resPath.filename().string(), width, height, texbuf->size());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user