0
0
mirror of https://github.com/obsproject/obs-studio.git synced 2024-09-19 20:32:15 +02:00

move around some graphics stuff and put in copyright comments

This commit is contained in:
jp9000 2013-10-04 12:13:59 -07:00
parent ec86c3eaf7
commit 543d2481f1
8 changed files with 133 additions and 14 deletions

View File

@ -18,11 +18,6 @@
#include "util/base.h"
#include "GS_D3D11SubSystem.hpp"
static inline bool IsPow2(uint32_t num)
{
return num >= 2 && (num & (num-1)) == 0;
}
static inline uint32_t numActualLevels(uint32_t levels, uint32_t width,
uint32_t height)
{
@ -162,15 +157,6 @@ gs_texture_2d::gs_texture_2d(device_t device, uint32_t width, uint32_t height,
isRenderTarget ((flags & GS_RENDERTARGET) != 0),
genMipmaps ((flags & GS_BUILDMIPMAPS) != 0)
{
bool hasMips = genMipmaps || levels != 1;
if (hasMips && (!IsPow2(width) || !IsPow2(height))) {
blog(LOG_WARNING, "Cannot use mipmaps with a "
"non-power-of-two texture. Disabling "
"mipmaps for this texture.");
genMipmaps = false;
this->levels = 1;
}
InitTexture(data);
InitResourceView();

View File

@ -1,3 +1,20 @@
/******************************************************************************
Copyright (C) 2013 by Hugh Bailey <obs.jim@gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
#ifndef GS_GLEXPORTS
#define GS_GLEXPORTS

View File

@ -1,3 +1,20 @@
/******************************************************************************
Copyright (C) 2013 by Hugh Bailey <obs.jim@gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
#ifndef GL_HELPERS_H
#define GL_HELPERS_H

View File

@ -1,3 +1,20 @@
/******************************************************************************
Copyright (C) 2013 by Hugh Bailey <obs.jim@gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
#include "gl-subsystem.h"
#include "gl-exports.h"

View File

@ -103,6 +103,7 @@ struct gs_texture_2d {
uint32_t width;
uint32_t height;
bool gen_mipmaps;
};
struct gs_texture_cube {

View File

@ -1,3 +1,20 @@
/******************************************************************************
Copyright (C) 2013 by Hugh Bailey <obs.jim@gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
#include "gl-subsystem.h"
static inline bool upload_texture_data(struct gs_texture_2d *tex, void **data)
@ -20,6 +37,7 @@ texture_t device_create_texture(device_t device, uint32_t width,
struct gs_texture_2d *tex = bmalloc(sizeof(struct gs_texture_2d));
memset(tex, 0, sizeof(struct gs_texture_2d));
tex->base.device = device;
tex->base.type = GS_TEXTURE_2D;
tex->base.format = color_format;
tex->base.gl_format = convert_gs_format(color_format);

View File

@ -1,3 +1,20 @@
/******************************************************************************
Copyright (C) 2013 by Hugh Bailey <obs.jim@gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
#define WIN32_LEAN_AND_MEAN
#include <windows.h>

View File

@ -725,11 +725,36 @@ uint32_t gs_getheight(void)
return graphics->exports.device_getheight(graphics->device);
}
static inline bool is_pow2(uint32_t size)
{
return size >= 2 && (size & (size-1)) == 0;
}
texture_t gs_create_texture(uint32_t width, uint32_t height,
enum gs_color_format color_format, uint32_t levels, void **data,
uint32_t flags)
{
graphics_t graphics = thread_graphics;
bool pow2tex = is_pow2(width) && is_pow2(height);
bool uses_mipmaps = (flags & GS_BUILDMIPMAPS || levels != 1);
if (uses_mipmaps && !pow2tex) {
blog(LOG_WARNING, "Cannot use mipmaps with a "
"non-power-of-two texture. Disabling "
"mipmaps for this texture.");
uses_mipmaps = false;
flags &= ~GS_BUILDMIPMAPS;
levels = 1;
}
if (uses_mipmaps && flags & GS_RENDERTARGET) {
blog(LOG_WARNING, "Cannot use mipmaps with render targets. "
"Disabling mipmaps for this texture.");
flags &= ~GS_BUILDMIPMAPS;
levels = 1;
}
return graphics->exports.device_create_texture(graphics->device,
width, height, color_format, levels, data, flags);
}
@ -739,6 +764,27 @@ texture_t gs_create_cubetexture(uint32_t size,
void **data, uint32_t flags)
{
graphics_t graphics = thread_graphics;
bool pow2tex = is_pow2(size);
bool uses_mipmaps = (flags & GS_BUILDMIPMAPS || levels != 1);
if (uses_mipmaps && !pow2tex) {
blog(LOG_WARNING, "Cannot use mipmaps with a "
"non-power-of-two texture. Disabling "
"mipmaps for this texture.");
uses_mipmaps = false;
flags &= ~GS_BUILDMIPMAPS;
levels = 1;
}
if (uses_mipmaps && flags & GS_RENDERTARGET) {
blog(LOG_WARNING, "Cannot use mipmaps with render targets. "
"Disabling mipmaps for this texture.");
flags &= ~GS_BUILDMIPMAPS;
levels = 1;
data = NULL;
}
return graphics->exports.device_create_cubetexture(graphics->device,
size, color_format, levels, data, flags);
}