2023-02-28 01:15:26 +00:00
|
|
|
// AUTOGENERATED COPYRIGHT HEADER START
|
|
|
|
// Copyright (C) 2019-2023 Michael Fabian 'Xaymar' Dirks <info@xaymar.com>
|
|
|
|
// AUTOGENERATED COPYRIGHT HEADER END
|
2018-01-19 04:06:42 +00:00
|
|
|
|
2019-01-14 10:23:21 +00:00
|
|
|
#include "gs-sampler.hpp"
|
2022-08-29 10:29:44 +00:00
|
|
|
|
|
|
|
#include "warning-disable.hpp"
|
2019-09-04 00:59:04 +00:00
|
|
|
#include <stdexcept>
|
2022-08-29 10:29:44 +00:00
|
|
|
#include "warning-enable.hpp"
|
2018-01-19 04:06:42 +00:00
|
|
|
|
2021-06-08 02:38:24 +00:00
|
|
|
streamfx::obs::gs::sampler::sampler()
|
2018-11-07 14:24:25 +00:00
|
|
|
{
|
2019-08-24 10:59:32 +00:00
|
|
|
_dirty = true;
|
2019-08-04 14:20:26 +00:00
|
|
|
_sampler_info = {GS_FILTER_LINEAR, GS_ADDRESS_WRAP, GS_ADDRESS_WRAP, GS_ADDRESS_WRAP, 1, 0};
|
|
|
|
_sampler_state = nullptr;
|
2018-01-19 04:06:42 +00:00
|
|
|
}
|
|
|
|
|
2021-06-08 02:38:24 +00:00
|
|
|
streamfx::obs::gs::sampler::~sampler()
|
2018-11-07 14:24:25 +00:00
|
|
|
{
|
2019-08-04 14:20:26 +00:00
|
|
|
if (_sampler_state)
|
|
|
|
gs_samplerstate_destroy(_sampler_state);
|
2018-01-19 04:06:42 +00:00
|
|
|
}
|
|
|
|
|
2021-06-08 02:38:24 +00:00
|
|
|
void streamfx::obs::gs::sampler::set_filter(gs_sample_filter v)
|
2018-11-07 14:24:25 +00:00
|
|
|
{
|
2019-08-24 10:59:32 +00:00
|
|
|
_dirty = true;
|
2019-08-04 14:20:26 +00:00
|
|
|
_sampler_info.filter = v;
|
2018-01-19 04:06:42 +00:00
|
|
|
}
|
|
|
|
|
2021-06-08 02:38:24 +00:00
|
|
|
gs_sample_filter streamfx::obs::gs::sampler::get_filter()
|
2018-11-07 14:24:25 +00:00
|
|
|
{
|
2019-08-04 14:20:26 +00:00
|
|
|
return _sampler_info.filter;
|
2018-01-19 04:06:42 +00:00
|
|
|
}
|
|
|
|
|
2021-06-08 02:38:24 +00:00
|
|
|
void streamfx::obs::gs::sampler::set_address_mode_u(gs_address_mode v)
|
2018-11-07 14:24:25 +00:00
|
|
|
{
|
2019-08-24 10:59:32 +00:00
|
|
|
_dirty = true;
|
2019-08-04 14:20:26 +00:00
|
|
|
_sampler_info.address_u = v;
|
2018-01-19 04:06:42 +00:00
|
|
|
}
|
|
|
|
|
2021-06-08 02:38:24 +00:00
|
|
|
gs_address_mode streamfx::obs::gs::sampler::get_address_mode_u()
|
2018-11-07 14:24:25 +00:00
|
|
|
{
|
2019-08-04 14:20:26 +00:00
|
|
|
return _sampler_info.address_u;
|
2018-01-19 04:06:42 +00:00
|
|
|
}
|
|
|
|
|
2021-06-08 02:38:24 +00:00
|
|
|
void streamfx::obs::gs::sampler::set_address_mode_v(gs_address_mode v)
|
2018-11-07 14:24:25 +00:00
|
|
|
{
|
2019-08-24 10:59:32 +00:00
|
|
|
_dirty = true;
|
2019-08-04 14:20:26 +00:00
|
|
|
_sampler_info.address_v = v;
|
2018-01-19 04:06:42 +00:00
|
|
|
}
|
|
|
|
|
2021-06-08 02:38:24 +00:00
|
|
|
gs_address_mode streamfx::obs::gs::sampler::get_address_mode_v()
|
2018-11-07 14:24:25 +00:00
|
|
|
{
|
2019-08-04 14:20:26 +00:00
|
|
|
return _sampler_info.address_v;
|
2018-01-19 04:06:42 +00:00
|
|
|
}
|
|
|
|
|
2021-06-08 02:38:24 +00:00
|
|
|
void streamfx::obs::gs::sampler::set_address_mode_w(gs_address_mode v)
|
2018-11-07 14:24:25 +00:00
|
|
|
{
|
2019-08-24 10:59:32 +00:00
|
|
|
_dirty = true;
|
2019-08-04 14:20:26 +00:00
|
|
|
_sampler_info.address_w = v;
|
2018-01-19 04:06:42 +00:00
|
|
|
}
|
|
|
|
|
2021-06-08 02:38:24 +00:00
|
|
|
gs_address_mode streamfx::obs::gs::sampler::get_address_mode_w()
|
2018-11-07 14:24:25 +00:00
|
|
|
{
|
2019-08-04 14:20:26 +00:00
|
|
|
return _sampler_info.address_w;
|
2018-01-19 04:06:42 +00:00
|
|
|
}
|
|
|
|
|
2021-06-08 02:38:24 +00:00
|
|
|
void streamfx::obs::gs::sampler::set_max_anisotropy(int32_t v)
|
2018-11-07 14:24:25 +00:00
|
|
|
{
|
2019-08-24 10:59:32 +00:00
|
|
|
_dirty = true;
|
2019-08-04 14:20:26 +00:00
|
|
|
_sampler_info.max_anisotropy = v;
|
2018-01-19 04:06:42 +00:00
|
|
|
}
|
|
|
|
|
2021-06-08 02:38:24 +00:00
|
|
|
int32_t streamfx::obs::gs::sampler::get_max_anisotropy()
|
2018-11-07 14:24:25 +00:00
|
|
|
{
|
2019-08-04 14:20:26 +00:00
|
|
|
return _sampler_info.max_anisotropy;
|
2018-01-19 04:06:42 +00:00
|
|
|
}
|
|
|
|
|
2021-06-08 02:38:24 +00:00
|
|
|
void streamfx::obs::gs::sampler::set_border_color(uint32_t v)
|
2018-11-07 14:24:25 +00:00
|
|
|
{
|
2019-08-24 10:59:32 +00:00
|
|
|
_dirty = true;
|
2019-08-04 14:20:26 +00:00
|
|
|
_sampler_info.border_color = v;
|
2018-01-19 04:06:42 +00:00
|
|
|
}
|
|
|
|
|
2021-06-08 02:38:24 +00:00
|
|
|
void streamfx::obs::gs::sampler::set_border_color(uint8_t r, uint8_t g, uint8_t b, uint8_t a)
|
2018-11-07 14:24:25 +00:00
|
|
|
{
|
2019-08-24 10:59:32 +00:00
|
|
|
_dirty = true;
|
2020-08-10 01:29:05 +00:00
|
|
|
_sampler_info.border_color = (static_cast<uint32_t>(a) << 24) | (static_cast<uint32_t>(r) << 16)
|
|
|
|
| (static_cast<uint32_t>(g) << 8) | static_cast<uint32_t>(b);
|
2018-01-19 04:06:42 +00:00
|
|
|
}
|
|
|
|
|
2021-06-08 02:38:24 +00:00
|
|
|
uint32_t streamfx::obs::gs::sampler::get_border_color()
|
2018-11-07 14:24:25 +00:00
|
|
|
{
|
2019-08-04 14:20:26 +00:00
|
|
|
return _sampler_info.border_color;
|
2018-01-19 04:06:42 +00:00
|
|
|
}
|
|
|
|
|
2021-06-08 02:38:24 +00:00
|
|
|
uint8_t streamfx::obs::gs::sampler::get_border_color(bool r, bool g, bool b, bool a)
|
2018-11-07 14:24:25 +00:00
|
|
|
{
|
2018-01-19 04:06:42 +00:00
|
|
|
if (a)
|
2019-08-04 14:20:26 +00:00
|
|
|
return (_sampler_info.border_color >> 24) & 0xFF;
|
2018-01-19 04:06:42 +00:00
|
|
|
if (r)
|
2019-08-04 14:20:26 +00:00
|
|
|
return (_sampler_info.border_color >> 16) & 0xFF;
|
2018-01-19 04:06:42 +00:00
|
|
|
if (g)
|
2019-08-04 14:20:26 +00:00
|
|
|
return (_sampler_info.border_color >> 8) & 0xFF;
|
2018-01-19 04:06:42 +00:00
|
|
|
if (b)
|
2019-08-04 14:20:26 +00:00
|
|
|
return _sampler_info.border_color & 0xFF;
|
2018-01-19 04:06:42 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-06-08 02:38:24 +00:00
|
|
|
gs_sampler_state* streamfx::obs::gs::sampler::refresh()
|
2018-11-07 14:24:25 +00:00
|
|
|
{
|
2019-08-04 14:20:26 +00:00
|
|
|
gs_samplerstate_destroy(_sampler_state);
|
|
|
|
_sampler_state = gs_samplerstate_create(&_sampler_info);
|
2019-08-24 10:59:32 +00:00
|
|
|
_dirty = false;
|
2019-08-04 14:20:26 +00:00
|
|
|
return _sampler_state;
|
2018-01-19 04:06:42 +00:00
|
|
|
}
|
|
|
|
|
2021-06-08 02:38:24 +00:00
|
|
|
gs_sampler_state* streamfx::obs::gs::sampler::get_object()
|
2018-11-07 14:24:25 +00:00
|
|
|
{
|
2019-08-04 14:20:26 +00:00
|
|
|
if (_dirty)
|
2018-03-20 11:43:37 +00:00
|
|
|
return refresh();
|
2019-08-04 14:20:26 +00:00
|
|
|
return _sampler_state;
|
2018-01-19 04:06:42 +00:00
|
|
|
}
|