2023-02-28 01:15:26 +00:00
|
|
|
// AUTOGENERATED COPYRIGHT HEADER START
|
2023-09-30 03:16:02 +00:00
|
|
|
// Copyright (C) 2017-2023 Michael Fabian 'Xaymar' Dirks <info@xaymar.com>
|
2023-02-28 01:15:26 +00:00
|
|
|
// AUTOGENERATED COPYRIGHT HEADER END
|
2017-09-17 20:35:48 +00:00
|
|
|
|
|
|
|
#pragma once
|
2020-04-02 15:02:01 +00:00
|
|
|
#include "common.hpp"
|
2022-11-28 08:11:55 +00:00
|
|
|
#include "gfx/gfx-util.hpp"
|
2019-01-14 10:23:21 +00:00
|
|
|
#include "gs-effect.hpp"
|
|
|
|
#include "gs-rendertarget.hpp"
|
|
|
|
#include "gs-texture.hpp"
|
|
|
|
#include "gs-vertexbuffer.hpp"
|
2017-09-17 20:35:48 +00:00
|
|
|
|
2020-04-25 06:15:20 +00:00
|
|
|
/* gs::mipmapper is an attempt at adding dynamic mip-map generation to a software
|
|
|
|
* which only supports static mip-maps. It is effectively an incredibly bad hack
|
|
|
|
* instead of a proper solution - can break any time and likely already has.
|
|
|
|
*
|
|
|
|
* Needless to say, dynamic mip-map generation costs a lot of GPU time, especially
|
|
|
|
* when things need to be synchronized. In the ideal case we would just render
|
|
|
|
* straight to the mip level, but this is not possible in DirectX 11 and OpenGL.
|
|
|
|
*
|
|
|
|
* So instead we render to a render target and copy from there to the actual
|
|
|
|
* resource. Super wasteful, but what else can we actually do?
|
|
|
|
*/
|
|
|
|
|
2021-06-08 02:38:24 +00:00
|
|
|
namespace streamfx::obs::gs {
|
2018-09-27 04:09:43 +00:00
|
|
|
class mipmapper {
|
2021-11-09 10:34:27 +00:00
|
|
|
std::unique_ptr<streamfx::obs::gs::rendertarget> _rt;
|
|
|
|
streamfx::obs::gs::effect _effect;
|
2022-11-28 08:11:55 +00:00
|
|
|
std::shared_ptr<streamfx::gfx::util> _gfx_util;
|
2018-09-27 04:09:43 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
~mipmapper();
|
|
|
|
mipmapper();
|
2017-09-17 20:35:48 +00:00
|
|
|
|
2021-11-09 10:34:27 +00:00
|
|
|
uint32_t calculate_max_mip_level(uint32_t width, uint32_t height);
|
|
|
|
|
2021-06-08 02:38:24 +00:00
|
|
|
void rebuild(std::shared_ptr<streamfx::obs::gs::texture> source,
|
|
|
|
std::shared_ptr<streamfx::obs::gs::texture> target);
|
2017-09-17 20:35:48 +00:00
|
|
|
};
|
2021-06-08 02:38:24 +00:00
|
|
|
} // namespace streamfx::obs::gs
|