obs-studio/libobs-d3d11/d3d11-subsystem.hpp

851 lines
21 KiB
C++
Raw Normal View History

2013-09-30 19:37:13 -07:00
/******************************************************************************
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 2 of the License, or
2013-09-30 19:37:13 -07:00
(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/>.
******************************************************************************/
#pragma once
#include <util/AlignedNew.hpp>
#include <util/windows/win-version.h>
2013-09-30 19:37:13 -07:00
#include <vector>
#include <string>
#include <memory>
2013-09-30 19:37:13 -07:00
#include <windows.h>
#include <dxgi.h>
#include <dxgi1_2.h>
2013-09-30 19:37:13 -07:00
#include <d3d11.h>
#include <d3dcompiler.h>
#include <util/base.h>
#include <graphics/matrix4.h>
#include <graphics/graphics.h>
#include <graphics/device-exports.h>
#include <util/windows/ComPtr.hpp>
#include <util/windows/HRError.hpp>
2013-09-30 19:37:13 -07:00
// #define DISASSEMBLE_SHADERS
2013-09-30 19:37:13 -07:00
struct shader_var;
struct shader_sampler;
struct gs_vertex_shader;
using namespace std;
/*
* Just to clarify, all structs, and all public. These are exporting only
* via encapsulated C bindings, not C++ bindings, so the whole concept of
* "public" and "private" does not matter at all for this subproject.
*/
static inline uint32_t GetWinVer()
{
struct win_version_info ver;
get_win_ver(&ver);
2013-09-30 19:37:13 -07:00
return (ver.major << 8) | ver.minor;
2013-09-30 19:37:13 -07:00
}
static inline DXGI_FORMAT ConvertGSTextureFormat(gs_color_format format)
{
switch (format) {
case GS_UNKNOWN: return DXGI_FORMAT_UNKNOWN;
2013-09-30 19:37:13 -07:00
case GS_A8: return DXGI_FORMAT_A8_UNORM;
case GS_R8: return DXGI_FORMAT_R8_UNORM;
case GS_RGBA: return DXGI_FORMAT_R8G8B8A8_UNORM;
case GS_BGRX: return DXGI_FORMAT_B8G8R8X8_UNORM;
case GS_BGRA: return DXGI_FORMAT_B8G8R8A8_UNORM;
case GS_R10G10B10A2: return DXGI_FORMAT_R10G10B10A2_UNORM;
case GS_RGBA16: return DXGI_FORMAT_R16G16B16A16_UNORM;
case GS_R16: return DXGI_FORMAT_R16_UNORM;
case GS_RGBA16F: return DXGI_FORMAT_R16G16B16A16_FLOAT;
case GS_RGBA32F: return DXGI_FORMAT_R32G32B32A32_FLOAT;
case GS_RG16F: return DXGI_FORMAT_R16G16_FLOAT;
case GS_RG32F: return DXGI_FORMAT_R32G32_FLOAT;
case GS_R16F: return DXGI_FORMAT_R16_FLOAT;
case GS_R32F: return DXGI_FORMAT_R32_FLOAT;
case GS_DXT1: return DXGI_FORMAT_BC1_UNORM;
case GS_DXT3: return DXGI_FORMAT_BC2_UNORM;
case GS_DXT5: return DXGI_FORMAT_BC3_UNORM;
}
return DXGI_FORMAT_UNKNOWN;
2013-09-30 19:37:13 -07:00
}
static inline gs_color_format ConvertDXGITextureFormat(DXGI_FORMAT format)
{
switch ((unsigned long)format) {
case DXGI_FORMAT_A8_UNORM: return GS_A8;
case DXGI_FORMAT_R8_UNORM: return GS_R8;
case DXGI_FORMAT_R8G8B8A8_UNORM: return GS_RGBA;
case DXGI_FORMAT_B8G8R8X8_UNORM: return GS_BGRX;
case DXGI_FORMAT_B8G8R8A8_UNORM: return GS_BGRA;
case DXGI_FORMAT_R10G10B10A2_UNORM: return GS_R10G10B10A2;
case DXGI_FORMAT_R16G16B16A16_UNORM: return GS_RGBA16;
case DXGI_FORMAT_R16_UNORM: return GS_R16;
case DXGI_FORMAT_R16G16B16A16_FLOAT: return GS_RGBA16F;
case DXGI_FORMAT_R32G32B32A32_FLOAT: return GS_RGBA32F;
case DXGI_FORMAT_R16G16_FLOAT: return GS_RG16F;
case DXGI_FORMAT_R32G32_FLOAT: return GS_RG32F;
case DXGI_FORMAT_R16_FLOAT: return GS_R16F;
case DXGI_FORMAT_R32_FLOAT: return GS_R32F;
case DXGI_FORMAT_BC1_UNORM: return GS_DXT1;
case DXGI_FORMAT_BC2_UNORM: return GS_DXT3;
case DXGI_FORMAT_BC3_UNORM: return GS_DXT5;
}
return GS_UNKNOWN;
}
2013-09-30 19:37:13 -07:00
static inline DXGI_FORMAT ConvertGSZStencilFormat(gs_zstencil_format format)
{
switch (format) {
case GS_ZS_NONE: return DXGI_FORMAT_UNKNOWN;
2013-09-30 19:37:13 -07:00
case GS_Z16: return DXGI_FORMAT_D16_UNORM;
case GS_Z24_S8: return DXGI_FORMAT_D24_UNORM_S8_UINT;
case GS_Z32F: return DXGI_FORMAT_D32_FLOAT;
case GS_Z32F_S8X24: return DXGI_FORMAT_D32_FLOAT_S8X24_UINT;
}
return DXGI_FORMAT_UNKNOWN;
2013-09-30 19:37:13 -07:00
}
static inline D3D11_COMPARISON_FUNC ConvertGSDepthTest(gs_depth_test test)
{
switch (test) {
case GS_NEVER: return D3D11_COMPARISON_NEVER;
case GS_LESS: return D3D11_COMPARISON_LESS;
case GS_LEQUAL: return D3D11_COMPARISON_LESS_EQUAL;
case GS_EQUAL: return D3D11_COMPARISON_EQUAL;
case GS_GEQUAL: return D3D11_COMPARISON_GREATER_EQUAL;
case GS_GREATER: return D3D11_COMPARISON_GREATER;
case GS_NOTEQUAL: return D3D11_COMPARISON_NOT_EQUAL;
case GS_ALWAYS: return D3D11_COMPARISON_ALWAYS;
}
return D3D11_COMPARISON_NEVER;
2013-09-30 19:37:13 -07:00
}
(API Change) Improve graphics API consistency Summary: - Prefix all graphics subsystem names with gs_ or GS_ - Unsquish funciton names (for example _setfloat to _set_float) - Changed create functions to be more consistent with the rest of the API elsewhere. For exmaple, instead of gs_create_texture/gs_texture_destroy, it's now gs_texture_create/gs_texture_destroy - Renamed gs_stencil_op enum to gs_stencil_op_type From: To: ----------------------------------------------------------- tvertarray gs_tvertarray vb_data gs_vb_data vbdata_create gs_vbdata_create vbdata_destroy gs_vbdata_destroy shader_param gs_shader_param gs_effect gs_effect effect_technique gs_effect_technique effect_pass gs_effect_pass effect_param gs_effect_param texture_t gs_texture_t stagesurf_t gs_stagesurf_t zstencil_t gs_zstencil_t vertbuffer_t gs_vertbuffer_t indexbuffer_t gs_indexbuffer_t samplerstate_t gs_samplerstate_t swapchain_t gs_swapchain_t texrender_t gs_texrender_t shader_t gs_shader_t sparam_t gs_sparam_t effect_t gs_effect_t technique_t gs_technique_t eparam_t gs_eparam_t device_t gs_device_t graphics_t graphics_t shader_param_type gs_shader_param_type SHADER_PARAM_UNKNOWN GS_SHADER_PARAM_UNKNOWN SHADER_PARAM_BOOL GS_SHADER_PARAM_BOOL SHADER_PARAM_FLOAT GS_SHADER_PARAM_FLOAT SHADER_PARAM_INT GS_SHADER_PARAM_INT SHADER_PARAM_STRING GS_SHADER_PARAM_STRING SHADER_PARAM_VEC2 GS_SHADER_PARAM_VEC2 SHADER_PARAM_VEC3 GS_SHADER_PARAM_VEC3 SHADER_PARAM_VEC4 GS_SHADER_PARAM_VEC4 SHADER_PARAM_MATRIX4X4 GS_SHADER_PARAM_MATRIX4X4 SHADER_PARAM_TEXTURE GS_SHADER_PARAM_TEXTURE shader_param_info gs_shader_param_info shader_type gs_shader_type SHADER_VERTEX GS_SHADER_VERTEX SHADER_PIXEL GS_SHADER_PIXEL shader_destroy gs_shader_destroy shader_numparams gs_shader_get_num_params shader_getparambyidx gs_shader_get_param_by_idx shader_getparambyname gs_shader_get_param_by_name shader_getviewprojmatrix gs_shader_get_viewproj_matrix shader_getworldmatrix gs_shader_get_world_matrix shader_getparaminfo gs_shader_get_param_info shader_setbool gs_shader_set_bool shader_setfloat gs_shader_set_float shader_setint gs_shader_set_int shader_setmatrix3 gs_shader_setmatrix3 shader_setmatrix4 gs_shader_set_matrix4 shader_setvec2 gs_shader_set_vec2 shader_setvec3 gs_shader_set_vec3 shader_setvec4 gs_shader_set_vec4 shader_settexture gs_shader_set_texture shader_setval gs_shader_set_val shader_setdefault gs_shader_set_default effect_property_type gs_effect_property_type EFFECT_NONE GS_EFFECT_NONE EFFECT_BOOL GS_EFFECT_BOOL EFFECT_FLOAT GS_EFFECT_FLOAT EFFECT_COLOR GS_EFFECT_COLOR EFFECT_TEXTURE GS_EFFECT_TEXTURE effect_param_info gs_effect_param_info effect_destroy gs_effect_destroy effect_gettechnique gs_effect_get_technique technique_begin gs_technique_begin technique_end gs_technique_end technique_beginpass gs_technique_begin_pass technique_beginpassbyname gs_technique_begin_pass_by_name technique_endpass gs_technique_end_pass effect_numparams gs_effect_get_num_params effect_getparambyidx gs_effect_get_param_by_idx effect_getparambyname gs_effect_get_param_by_name effect_updateparams gs_effect_update_params effect_getviewprojmatrix gs_effect_get_viewproj_matrix effect_getworldmatrix gs_effect_get_world_matrix effect_getparaminfo gs_effect_get_param_info effect_setbool gs_effect_set_bool effect_setfloat gs_effect_set_float effect_setint gs_effect_set_int effect_setmatrix4 gs_effect_set_matrix4 effect_setvec2 gs_effect_set_vec2 effect_setvec3 gs_effect_set_vec3 effect_setvec4 gs_effect_set_vec4 effect_settexture gs_effect_set_texture effect_setval gs_effect_set_val effect_setdefault gs_effect_set_default texrender_create gs_texrender_create texrender_destroy gs_texrender_destroy texrender_begin gs_texrender_begin texrender_end gs_texrender_end texrender_reset gs_texrender_reset texrender_gettexture gs_texrender_get_texture GS_BUILDMIPMAPS GS_BUILD_MIPMAPS GS_RENDERTARGET GS_RENDER_TARGET gs_device_name gs_get_device_name gs_device_type gs_get_device_type gs_entercontext gs_enter_context gs_leavecontext gs_leave_context gs_getcontext gs_get_context gs_renderstart gs_render_start gs_renderstop gs_render_stop gs_rendersave gs_render_save gs_getinput gs_get_input gs_geteffect gs_get_effect gs_create_effect_from_file gs_effect_create_from_file gs_create_effect gs_effect_create gs_create_vertexshader_from_file gs_vertexshader_create_from_file gs_create_pixelshader_from_file gs_pixelshader_create_from_file gs_create_texture_from_file gs_texture_create_from_file gs_resetviewport gs_reset_viewport gs_set2dmode gs_set_2d_mode gs_set3dmode gs_set_3d_mode gs_create_swapchain gs_swapchain_create gs_getsize gs_get_size gs_getwidth gs_get_width gs_getheight gs_get_height gs_create_texture gs_texture_create gs_create_cubetexture gs_cubetexture_create gs_create_volumetexture gs_voltexture_create gs_create_zstencil gs_zstencil_create gs_create_stagesurface gs_stagesurface_create gs_create_samplerstate gs_samplerstate_create gs_create_vertexshader gs_vertexshader_create gs_create_pixelshader gs_pixelshader_create gs_create_vertexbuffer gs_vertexbuffer_create gs_create_indexbuffer gs_indexbuffer_create gs_gettexturetype gs_get_texture_type gs_load_defaultsamplerstate gs_load_default_samplerstate gs_getvertexshader gs_get_vertex_shader gs_getpixelshader gs_get_pixel_shader gs_getrendertarget gs_get_render_target gs_getzstenciltarget gs_get_zstencil_target gs_setrendertarget gs_set_render_target gs_setcuberendertarget gs_set_cube_render_target gs_beginscene gs_begin_scene gs_draw gs_draw gs_endscene gs_end_scene gs_setcullmode gs_set_cull_mode gs_getcullmode gs_get_cull_mode gs_enable_depthtest gs_enable_depth_test gs_enable_stenciltest gs_enable_stencil_test gs_enable_stencilwrite gs_enable_stencil_write gs_blendfunction gs_blend_function gs_depthfunction gs_depth_function gs_stencilfunction gs_stencil_function gs_stencilop gs_stencil_op gs_setviewport gs_set_viewport gs_getviewport gs_get_viewport gs_setscissorrect gs_set_scissor_rect gs_create_texture_from_iosurface gs_texture_create_from_iosurface gs_create_gdi_texture gs_texture_create_gdi gs_is_compressed_format gs_is_compressed_format gs_num_total_levels gs_get_total_levels texture_setimage gs_texture_set_image cubetexture_setimage gs_cubetexture_set_image swapchain_destroy gs_swapchain_destroy texture_destroy gs_texture_destroy texture_getwidth gs_texture_get_width texture_getheight gs_texture_get_height texture_getcolorformat gs_texture_get_color_format texture_map gs_texture_map texture_unmap gs_texture_unmap texture_isrect gs_texture_is_rect texture_getobj gs_texture_get_obj cubetexture_destroy gs_cubetexture_destroy cubetexture_getsize gs_cubetexture_get_size cubetexture_getcolorformat gs_cubetexture_get_color_format volumetexture_destroy gs_voltexture_destroy volumetexture_getwidth gs_voltexture_get_width volumetexture_getheight gs_voltexture_get_height volumetexture_getdepth gs_voltexture_getdepth volumetexture_getcolorformat gs_voltexture_get_color_format stagesurface_destroy gs_stagesurface_destroy stagesurface_getwidth gs_stagesurface_get_width stagesurface_getheight gs_stagesurface_get_height stagesurface_getcolorformat gs_stagesurface_get_color_format stagesurface_map gs_stagesurface_map stagesurface_unmap gs_stagesurface_unmap zstencil_destroy gs_zstencil_destroy samplerstate_destroy gs_samplerstate_destroy vertexbuffer_destroy gs_vertexbuffer_destroy vertexbuffer_flush gs_vertexbuffer_flush vertexbuffer_getdata gs_vertexbuffer_get_data indexbuffer_destroy gs_indexbuffer_destroy indexbuffer_flush gs_indexbuffer_flush indexbuffer_getdata gs_indexbuffer_get_data indexbuffer_numindices gs_indexbuffer_get_num_indices indexbuffer_gettype gs_indexbuffer_get_type texture_rebind_iosurface gs_texture_rebind_iosurface texture_get_dc gs_texture_get_dc texture_release_dc gs_texture_release_dc
2014-08-07 23:42:07 -07:00
static inline D3D11_STENCIL_OP ConvertGSStencilOp(gs_stencil_op_type op)
2013-09-30 19:37:13 -07:00
{
switch (op) {
case GS_KEEP: return D3D11_STENCIL_OP_KEEP;
case GS_ZERO: return D3D11_STENCIL_OP_ZERO;
case GS_REPLACE: return D3D11_STENCIL_OP_REPLACE;
case GS_INCR: return D3D11_STENCIL_OP_INCR;
case GS_DECR: return D3D11_STENCIL_OP_DECR;
case GS_INVERT: return D3D11_STENCIL_OP_INVERT;
}
return D3D11_STENCIL_OP_KEEP;
2013-09-30 19:37:13 -07:00
}
static inline D3D11_BLEND ConvertGSBlendType(gs_blend_type type)
{
switch (type) {
case GS_BLEND_ZERO: return D3D11_BLEND_ZERO;
case GS_BLEND_ONE: return D3D11_BLEND_ONE;
case GS_BLEND_SRCCOLOR: return D3D11_BLEND_SRC_COLOR;
case GS_BLEND_INVSRCCOLOR: return D3D11_BLEND_INV_SRC_COLOR;
case GS_BLEND_SRCALPHA: return D3D11_BLEND_SRC_ALPHA;
case GS_BLEND_INVSRCALPHA: return D3D11_BLEND_INV_SRC_ALPHA;
case GS_BLEND_DSTCOLOR: return D3D11_BLEND_DEST_COLOR;
case GS_BLEND_INVDSTCOLOR: return D3D11_BLEND_INV_DEST_COLOR;
case GS_BLEND_DSTALPHA: return D3D11_BLEND_DEST_ALPHA;
case GS_BLEND_INVDSTALPHA: return D3D11_BLEND_INV_DEST_ALPHA;
case GS_BLEND_SRCALPHASAT: return D3D11_BLEND_SRC_ALPHA_SAT;
}
return D3D11_BLEND_ONE;
2013-09-30 19:37:13 -07:00
}
static inline D3D11_CULL_MODE ConvertGSCullMode(gs_cull_mode mode)
{
switch (mode) {
case GS_BACK: return D3D11_CULL_BACK;
case GS_FRONT: return D3D11_CULL_FRONT;
case GS_NEITHER: return D3D11_CULL_NONE;
}
return D3D11_CULL_BACK;
2013-09-30 19:37:13 -07:00
}
static inline D3D11_PRIMITIVE_TOPOLOGY ConvertGSTopology(gs_draw_mode mode)
{
switch (mode) {
case GS_POINTS: return D3D11_PRIMITIVE_TOPOLOGY_POINTLIST;
case GS_LINES: return D3D11_PRIMITIVE_TOPOLOGY_LINELIST;
case GS_LINESTRIP: return D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP;
case GS_TRIS: return D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST;
case GS_TRISTRIP: return D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP;
}
return D3D11_PRIMITIVE_TOPOLOGY_POINTLIST;
2013-09-30 19:37:13 -07:00
}
/* exception-safe RAII wrapper for vertex buffer data (NOTE: not copy-safe) */
struct VBDataPtr {
(API Change) Improve graphics API consistency Summary: - Prefix all graphics subsystem names with gs_ or GS_ - Unsquish funciton names (for example _setfloat to _set_float) - Changed create functions to be more consistent with the rest of the API elsewhere. For exmaple, instead of gs_create_texture/gs_texture_destroy, it's now gs_texture_create/gs_texture_destroy - Renamed gs_stencil_op enum to gs_stencil_op_type From: To: ----------------------------------------------------------- tvertarray gs_tvertarray vb_data gs_vb_data vbdata_create gs_vbdata_create vbdata_destroy gs_vbdata_destroy shader_param gs_shader_param gs_effect gs_effect effect_technique gs_effect_technique effect_pass gs_effect_pass effect_param gs_effect_param texture_t gs_texture_t stagesurf_t gs_stagesurf_t zstencil_t gs_zstencil_t vertbuffer_t gs_vertbuffer_t indexbuffer_t gs_indexbuffer_t samplerstate_t gs_samplerstate_t swapchain_t gs_swapchain_t texrender_t gs_texrender_t shader_t gs_shader_t sparam_t gs_sparam_t effect_t gs_effect_t technique_t gs_technique_t eparam_t gs_eparam_t device_t gs_device_t graphics_t graphics_t shader_param_type gs_shader_param_type SHADER_PARAM_UNKNOWN GS_SHADER_PARAM_UNKNOWN SHADER_PARAM_BOOL GS_SHADER_PARAM_BOOL SHADER_PARAM_FLOAT GS_SHADER_PARAM_FLOAT SHADER_PARAM_INT GS_SHADER_PARAM_INT SHADER_PARAM_STRING GS_SHADER_PARAM_STRING SHADER_PARAM_VEC2 GS_SHADER_PARAM_VEC2 SHADER_PARAM_VEC3 GS_SHADER_PARAM_VEC3 SHADER_PARAM_VEC4 GS_SHADER_PARAM_VEC4 SHADER_PARAM_MATRIX4X4 GS_SHADER_PARAM_MATRIX4X4 SHADER_PARAM_TEXTURE GS_SHADER_PARAM_TEXTURE shader_param_info gs_shader_param_info shader_type gs_shader_type SHADER_VERTEX GS_SHADER_VERTEX SHADER_PIXEL GS_SHADER_PIXEL shader_destroy gs_shader_destroy shader_numparams gs_shader_get_num_params shader_getparambyidx gs_shader_get_param_by_idx shader_getparambyname gs_shader_get_param_by_name shader_getviewprojmatrix gs_shader_get_viewproj_matrix shader_getworldmatrix gs_shader_get_world_matrix shader_getparaminfo gs_shader_get_param_info shader_setbool gs_shader_set_bool shader_setfloat gs_shader_set_float shader_setint gs_shader_set_int shader_setmatrix3 gs_shader_setmatrix3 shader_setmatrix4 gs_shader_set_matrix4 shader_setvec2 gs_shader_set_vec2 shader_setvec3 gs_shader_set_vec3 shader_setvec4 gs_shader_set_vec4 shader_settexture gs_shader_set_texture shader_setval gs_shader_set_val shader_setdefault gs_shader_set_default effect_property_type gs_effect_property_type EFFECT_NONE GS_EFFECT_NONE EFFECT_BOOL GS_EFFECT_BOOL EFFECT_FLOAT GS_EFFECT_FLOAT EFFECT_COLOR GS_EFFECT_COLOR EFFECT_TEXTURE GS_EFFECT_TEXTURE effect_param_info gs_effect_param_info effect_destroy gs_effect_destroy effect_gettechnique gs_effect_get_technique technique_begin gs_technique_begin technique_end gs_technique_end technique_beginpass gs_technique_begin_pass technique_beginpassbyname gs_technique_begin_pass_by_name technique_endpass gs_technique_end_pass effect_numparams gs_effect_get_num_params effect_getparambyidx gs_effect_get_param_by_idx effect_getparambyname gs_effect_get_param_by_name effect_updateparams gs_effect_update_params effect_getviewprojmatrix gs_effect_get_viewproj_matrix effect_getworldmatrix gs_effect_get_world_matrix effect_getparaminfo gs_effect_get_param_info effect_setbool gs_effect_set_bool effect_setfloat gs_effect_set_float effect_setint gs_effect_set_int effect_setmatrix4 gs_effect_set_matrix4 effect_setvec2 gs_effect_set_vec2 effect_setvec3 gs_effect_set_vec3 effect_setvec4 gs_effect_set_vec4 effect_settexture gs_effect_set_texture effect_setval gs_effect_set_val effect_setdefault gs_effect_set_default texrender_create gs_texrender_create texrender_destroy gs_texrender_destroy texrender_begin gs_texrender_begin texrender_end gs_texrender_end texrender_reset gs_texrender_reset texrender_gettexture gs_texrender_get_texture GS_BUILDMIPMAPS GS_BUILD_MIPMAPS GS_RENDERTARGET GS_RENDER_TARGET gs_device_name gs_get_device_name gs_device_type gs_get_device_type gs_entercontext gs_enter_context gs_leavecontext gs_leave_context gs_getcontext gs_get_context gs_renderstart gs_render_start gs_renderstop gs_render_stop gs_rendersave gs_render_save gs_getinput gs_get_input gs_geteffect gs_get_effect gs_create_effect_from_file gs_effect_create_from_file gs_create_effect gs_effect_create gs_create_vertexshader_from_file gs_vertexshader_create_from_file gs_create_pixelshader_from_file gs_pixelshader_create_from_file gs_create_texture_from_file gs_texture_create_from_file gs_resetviewport gs_reset_viewport gs_set2dmode gs_set_2d_mode gs_set3dmode gs_set_3d_mode gs_create_swapchain gs_swapchain_create gs_getsize gs_get_size gs_getwidth gs_get_width gs_getheight gs_get_height gs_create_texture gs_texture_create gs_create_cubetexture gs_cubetexture_create gs_create_volumetexture gs_voltexture_create gs_create_zstencil gs_zstencil_create gs_create_stagesurface gs_stagesurface_create gs_create_samplerstate gs_samplerstate_create gs_create_vertexshader gs_vertexshader_create gs_create_pixelshader gs_pixelshader_create gs_create_vertexbuffer gs_vertexbuffer_create gs_create_indexbuffer gs_indexbuffer_create gs_gettexturetype gs_get_texture_type gs_load_defaultsamplerstate gs_load_default_samplerstate gs_getvertexshader gs_get_vertex_shader gs_getpixelshader gs_get_pixel_shader gs_getrendertarget gs_get_render_target gs_getzstenciltarget gs_get_zstencil_target gs_setrendertarget gs_set_render_target gs_setcuberendertarget gs_set_cube_render_target gs_beginscene gs_begin_scene gs_draw gs_draw gs_endscene gs_end_scene gs_setcullmode gs_set_cull_mode gs_getcullmode gs_get_cull_mode gs_enable_depthtest gs_enable_depth_test gs_enable_stenciltest gs_enable_stencil_test gs_enable_stencilwrite gs_enable_stencil_write gs_blendfunction gs_blend_function gs_depthfunction gs_depth_function gs_stencilfunction gs_stencil_function gs_stencilop gs_stencil_op gs_setviewport gs_set_viewport gs_getviewport gs_get_viewport gs_setscissorrect gs_set_scissor_rect gs_create_texture_from_iosurface gs_texture_create_from_iosurface gs_create_gdi_texture gs_texture_create_gdi gs_is_compressed_format gs_is_compressed_format gs_num_total_levels gs_get_total_levels texture_setimage gs_texture_set_image cubetexture_setimage gs_cubetexture_set_image swapchain_destroy gs_swapchain_destroy texture_destroy gs_texture_destroy texture_getwidth gs_texture_get_width texture_getheight gs_texture_get_height texture_getcolorformat gs_texture_get_color_format texture_map gs_texture_map texture_unmap gs_texture_unmap texture_isrect gs_texture_is_rect texture_getobj gs_texture_get_obj cubetexture_destroy gs_cubetexture_destroy cubetexture_getsize gs_cubetexture_get_size cubetexture_getcolorformat gs_cubetexture_get_color_format volumetexture_destroy gs_voltexture_destroy volumetexture_getwidth gs_voltexture_get_width volumetexture_getheight gs_voltexture_get_height volumetexture_getdepth gs_voltexture_getdepth volumetexture_getcolorformat gs_voltexture_get_color_format stagesurface_destroy gs_stagesurface_destroy stagesurface_getwidth gs_stagesurface_get_width stagesurface_getheight gs_stagesurface_get_height stagesurface_getcolorformat gs_stagesurface_get_color_format stagesurface_map gs_stagesurface_map stagesurface_unmap gs_stagesurface_unmap zstencil_destroy gs_zstencil_destroy samplerstate_destroy gs_samplerstate_destroy vertexbuffer_destroy gs_vertexbuffer_destroy vertexbuffer_flush gs_vertexbuffer_flush vertexbuffer_getdata gs_vertexbuffer_get_data indexbuffer_destroy gs_indexbuffer_destroy indexbuffer_flush gs_indexbuffer_flush indexbuffer_getdata gs_indexbuffer_get_data indexbuffer_numindices gs_indexbuffer_get_num_indices indexbuffer_gettype gs_indexbuffer_get_type texture_rebind_iosurface gs_texture_rebind_iosurface texture_get_dc gs_texture_get_dc texture_release_dc gs_texture_release_dc
2014-08-07 23:42:07 -07:00
gs_vb_data *data;
2013-09-30 19:37:13 -07:00
(API Change) Improve graphics API consistency Summary: - Prefix all graphics subsystem names with gs_ or GS_ - Unsquish funciton names (for example _setfloat to _set_float) - Changed create functions to be more consistent with the rest of the API elsewhere. For exmaple, instead of gs_create_texture/gs_texture_destroy, it's now gs_texture_create/gs_texture_destroy - Renamed gs_stencil_op enum to gs_stencil_op_type From: To: ----------------------------------------------------------- tvertarray gs_tvertarray vb_data gs_vb_data vbdata_create gs_vbdata_create vbdata_destroy gs_vbdata_destroy shader_param gs_shader_param gs_effect gs_effect effect_technique gs_effect_technique effect_pass gs_effect_pass effect_param gs_effect_param texture_t gs_texture_t stagesurf_t gs_stagesurf_t zstencil_t gs_zstencil_t vertbuffer_t gs_vertbuffer_t indexbuffer_t gs_indexbuffer_t samplerstate_t gs_samplerstate_t swapchain_t gs_swapchain_t texrender_t gs_texrender_t shader_t gs_shader_t sparam_t gs_sparam_t effect_t gs_effect_t technique_t gs_technique_t eparam_t gs_eparam_t device_t gs_device_t graphics_t graphics_t shader_param_type gs_shader_param_type SHADER_PARAM_UNKNOWN GS_SHADER_PARAM_UNKNOWN SHADER_PARAM_BOOL GS_SHADER_PARAM_BOOL SHADER_PARAM_FLOAT GS_SHADER_PARAM_FLOAT SHADER_PARAM_INT GS_SHADER_PARAM_INT SHADER_PARAM_STRING GS_SHADER_PARAM_STRING SHADER_PARAM_VEC2 GS_SHADER_PARAM_VEC2 SHADER_PARAM_VEC3 GS_SHADER_PARAM_VEC3 SHADER_PARAM_VEC4 GS_SHADER_PARAM_VEC4 SHADER_PARAM_MATRIX4X4 GS_SHADER_PARAM_MATRIX4X4 SHADER_PARAM_TEXTURE GS_SHADER_PARAM_TEXTURE shader_param_info gs_shader_param_info shader_type gs_shader_type SHADER_VERTEX GS_SHADER_VERTEX SHADER_PIXEL GS_SHADER_PIXEL shader_destroy gs_shader_destroy shader_numparams gs_shader_get_num_params shader_getparambyidx gs_shader_get_param_by_idx shader_getparambyname gs_shader_get_param_by_name shader_getviewprojmatrix gs_shader_get_viewproj_matrix shader_getworldmatrix gs_shader_get_world_matrix shader_getparaminfo gs_shader_get_param_info shader_setbool gs_shader_set_bool shader_setfloat gs_shader_set_float shader_setint gs_shader_set_int shader_setmatrix3 gs_shader_setmatrix3 shader_setmatrix4 gs_shader_set_matrix4 shader_setvec2 gs_shader_set_vec2 shader_setvec3 gs_shader_set_vec3 shader_setvec4 gs_shader_set_vec4 shader_settexture gs_shader_set_texture shader_setval gs_shader_set_val shader_setdefault gs_shader_set_default effect_property_type gs_effect_property_type EFFECT_NONE GS_EFFECT_NONE EFFECT_BOOL GS_EFFECT_BOOL EFFECT_FLOAT GS_EFFECT_FLOAT EFFECT_COLOR GS_EFFECT_COLOR EFFECT_TEXTURE GS_EFFECT_TEXTURE effect_param_info gs_effect_param_info effect_destroy gs_effect_destroy effect_gettechnique gs_effect_get_technique technique_begin gs_technique_begin technique_end gs_technique_end technique_beginpass gs_technique_begin_pass technique_beginpassbyname gs_technique_begin_pass_by_name technique_endpass gs_technique_end_pass effect_numparams gs_effect_get_num_params effect_getparambyidx gs_effect_get_param_by_idx effect_getparambyname gs_effect_get_param_by_name effect_updateparams gs_effect_update_params effect_getviewprojmatrix gs_effect_get_viewproj_matrix effect_getworldmatrix gs_effect_get_world_matrix effect_getparaminfo gs_effect_get_param_info effect_setbool gs_effect_set_bool effect_setfloat gs_effect_set_float effect_setint gs_effect_set_int effect_setmatrix4 gs_effect_set_matrix4 effect_setvec2 gs_effect_set_vec2 effect_setvec3 gs_effect_set_vec3 effect_setvec4 gs_effect_set_vec4 effect_settexture gs_effect_set_texture effect_setval gs_effect_set_val effect_setdefault gs_effect_set_default texrender_create gs_texrender_create texrender_destroy gs_texrender_destroy texrender_begin gs_texrender_begin texrender_end gs_texrender_end texrender_reset gs_texrender_reset texrender_gettexture gs_texrender_get_texture GS_BUILDMIPMAPS GS_BUILD_MIPMAPS GS_RENDERTARGET GS_RENDER_TARGET gs_device_name gs_get_device_name gs_device_type gs_get_device_type gs_entercontext gs_enter_context gs_leavecontext gs_leave_context gs_getcontext gs_get_context gs_renderstart gs_render_start gs_renderstop gs_render_stop gs_rendersave gs_render_save gs_getinput gs_get_input gs_geteffect gs_get_effect gs_create_effect_from_file gs_effect_create_from_file gs_create_effect gs_effect_create gs_create_vertexshader_from_file gs_vertexshader_create_from_file gs_create_pixelshader_from_file gs_pixelshader_create_from_file gs_create_texture_from_file gs_texture_create_from_file gs_resetviewport gs_reset_viewport gs_set2dmode gs_set_2d_mode gs_set3dmode gs_set_3d_mode gs_create_swapchain gs_swapchain_create gs_getsize gs_get_size gs_getwidth gs_get_width gs_getheight gs_get_height gs_create_texture gs_texture_create gs_create_cubetexture gs_cubetexture_create gs_create_volumetexture gs_voltexture_create gs_create_zstencil gs_zstencil_create gs_create_stagesurface gs_stagesurface_create gs_create_samplerstate gs_samplerstate_create gs_create_vertexshader gs_vertexshader_create gs_create_pixelshader gs_pixelshader_create gs_create_vertexbuffer gs_vertexbuffer_create gs_create_indexbuffer gs_indexbuffer_create gs_gettexturetype gs_get_texture_type gs_load_defaultsamplerstate gs_load_default_samplerstate gs_getvertexshader gs_get_vertex_shader gs_getpixelshader gs_get_pixel_shader gs_getrendertarget gs_get_render_target gs_getzstenciltarget gs_get_zstencil_target gs_setrendertarget gs_set_render_target gs_setcuberendertarget gs_set_cube_render_target gs_beginscene gs_begin_scene gs_draw gs_draw gs_endscene gs_end_scene gs_setcullmode gs_set_cull_mode gs_getcullmode gs_get_cull_mode gs_enable_depthtest gs_enable_depth_test gs_enable_stenciltest gs_enable_stencil_test gs_enable_stencilwrite gs_enable_stencil_write gs_blendfunction gs_blend_function gs_depthfunction gs_depth_function gs_stencilfunction gs_stencil_function gs_stencilop gs_stencil_op gs_setviewport gs_set_viewport gs_getviewport gs_get_viewport gs_setscissorrect gs_set_scissor_rect gs_create_texture_from_iosurface gs_texture_create_from_iosurface gs_create_gdi_texture gs_texture_create_gdi gs_is_compressed_format gs_is_compressed_format gs_num_total_levels gs_get_total_levels texture_setimage gs_texture_set_image cubetexture_setimage gs_cubetexture_set_image swapchain_destroy gs_swapchain_destroy texture_destroy gs_texture_destroy texture_getwidth gs_texture_get_width texture_getheight gs_texture_get_height texture_getcolorformat gs_texture_get_color_format texture_map gs_texture_map texture_unmap gs_texture_unmap texture_isrect gs_texture_is_rect texture_getobj gs_texture_get_obj cubetexture_destroy gs_cubetexture_destroy cubetexture_getsize gs_cubetexture_get_size cubetexture_getcolorformat gs_cubetexture_get_color_format volumetexture_destroy gs_voltexture_destroy volumetexture_getwidth gs_voltexture_get_width volumetexture_getheight gs_voltexture_get_height volumetexture_getdepth gs_voltexture_getdepth volumetexture_getcolorformat gs_voltexture_get_color_format stagesurface_destroy gs_stagesurface_destroy stagesurface_getwidth gs_stagesurface_get_width stagesurface_getheight gs_stagesurface_get_height stagesurface_getcolorformat gs_stagesurface_get_color_format stagesurface_map gs_stagesurface_map stagesurface_unmap gs_stagesurface_unmap zstencil_destroy gs_zstencil_destroy samplerstate_destroy gs_samplerstate_destroy vertexbuffer_destroy gs_vertexbuffer_destroy vertexbuffer_flush gs_vertexbuffer_flush vertexbuffer_getdata gs_vertexbuffer_get_data indexbuffer_destroy gs_indexbuffer_destroy indexbuffer_flush gs_indexbuffer_flush indexbuffer_getdata gs_indexbuffer_get_data indexbuffer_numindices gs_indexbuffer_get_num_indices indexbuffer_gettype gs_indexbuffer_get_type texture_rebind_iosurface gs_texture_rebind_iosurface texture_get_dc gs_texture_get_dc texture_release_dc gs_texture_release_dc
2014-08-07 23:42:07 -07:00
inline VBDataPtr(gs_vb_data *data) : data(data) {}
inline ~VBDataPtr() {gs_vbdata_destroy(data);}
2013-09-30 19:37:13 -07:00
};
enum class gs_type {
gs_vertex_buffer,
gs_index_buffer,
gs_texture_2d,
gs_zstencil_buffer,
gs_stage_surface,
gs_sampler_state,
gs_vertex_shader,
gs_pixel_shader,
gs_duplicator,
gs_swap_chain,
};
struct gs_obj {
gs_device_t *device;
gs_type obj_type;
gs_obj *next;
gs_obj **prev_next;
inline gs_obj() :
device(nullptr),
next(nullptr),
prev_next(nullptr)
{}
gs_obj(gs_device_t *device, gs_type type);
virtual ~gs_obj();
};
struct gs_vertex_buffer : gs_obj {
2013-09-30 19:37:13 -07:00
ComPtr<ID3D11Buffer> vertexBuffer;
ComPtr<ID3D11Buffer> normalBuffer;
ComPtr<ID3D11Buffer> colorBuffer;
ComPtr<ID3D11Buffer> tangentBuffer;
vector<ComPtr<ID3D11Buffer>> uvBuffers;
bool dynamic;
VBDataPtr vbd;
size_t numVerts;
vector<size_t> uvSizes;
void FlushBuffer(ID3D11Buffer *buffer, void *array,
size_t elementSize);
void MakeBufferList(gs_vertex_shader *shader,
vector<ID3D11Buffer*> &buffers,
vector<uint32_t> &strides);
void InitBuffer(const size_t elementSize,
2013-09-30 19:37:13 -07:00
const size_t numVerts, void *array,
ID3D11Buffer **buffer);
void BuildBuffers();
inline void Release()
{
vertexBuffer.Release();
normalBuffer.Release();
colorBuffer.Release();
tangentBuffer.Release();
uvBuffers.clear();
}
libobs-d3d11: Rebuild device and assets if device removed/reset Due to an NVIDIA driver bug with the Windows 10 Anniversary Update, there are an increasingly large number of reports of "Device Removed" errors and TDRs. When this happens, OBS stops outputting all data because all graphics functions are failing, and it appears to just "freeze up" for users. To temporarily alleviate this issue while waiting for it to be fixed, the D3D subsystem can be rebuilt when that happens, all assets can be reloaded to ensure that it can continue functioning (with a minor hiccup in playback). To allow rebuilding the entire D3D subsystem, all objects that contain D3D references must be part of a linked list (with a few exceptions) so we can quickly traverse them all whenever needed, and all data for those resources (static resources primarily, such as shaders, textures, index buffers, vertex buffers) must be stored in RAM so they can be recreated whenever needed. Then if D3D reports a "device removed" or "device reset" error, all D3D references must first be fully released with no stray references; the linked list must be fully traversed until all references are released. Then, the linked list must once again be traversed again, and all those D3D objects must be recreated with the same data and descriptors (which are now saved in each object). Finally, all states need to be reset. After that's complete, the device is able to continue functioning almost as it was before, although the output to recording/stream may get a few green frames due to texture data being reset. This will temporarily alleviate the "Device Removed" issue while waiting for a fix from NVIDIA.
2016-11-03 07:41:23 -07:00
inline void Rebuild();
gs_vertex_buffer(gs_device_t *device, struct gs_vb_data *data,
(API Change) Improve graphics API consistency Summary: - Prefix all graphics subsystem names with gs_ or GS_ - Unsquish funciton names (for example _setfloat to _set_float) - Changed create functions to be more consistent with the rest of the API elsewhere. For exmaple, instead of gs_create_texture/gs_texture_destroy, it's now gs_texture_create/gs_texture_destroy - Renamed gs_stencil_op enum to gs_stencil_op_type From: To: ----------------------------------------------------------- tvertarray gs_tvertarray vb_data gs_vb_data vbdata_create gs_vbdata_create vbdata_destroy gs_vbdata_destroy shader_param gs_shader_param gs_effect gs_effect effect_technique gs_effect_technique effect_pass gs_effect_pass effect_param gs_effect_param texture_t gs_texture_t stagesurf_t gs_stagesurf_t zstencil_t gs_zstencil_t vertbuffer_t gs_vertbuffer_t indexbuffer_t gs_indexbuffer_t samplerstate_t gs_samplerstate_t swapchain_t gs_swapchain_t texrender_t gs_texrender_t shader_t gs_shader_t sparam_t gs_sparam_t effect_t gs_effect_t technique_t gs_technique_t eparam_t gs_eparam_t device_t gs_device_t graphics_t graphics_t shader_param_type gs_shader_param_type SHADER_PARAM_UNKNOWN GS_SHADER_PARAM_UNKNOWN SHADER_PARAM_BOOL GS_SHADER_PARAM_BOOL SHADER_PARAM_FLOAT GS_SHADER_PARAM_FLOAT SHADER_PARAM_INT GS_SHADER_PARAM_INT SHADER_PARAM_STRING GS_SHADER_PARAM_STRING SHADER_PARAM_VEC2 GS_SHADER_PARAM_VEC2 SHADER_PARAM_VEC3 GS_SHADER_PARAM_VEC3 SHADER_PARAM_VEC4 GS_SHADER_PARAM_VEC4 SHADER_PARAM_MATRIX4X4 GS_SHADER_PARAM_MATRIX4X4 SHADER_PARAM_TEXTURE GS_SHADER_PARAM_TEXTURE shader_param_info gs_shader_param_info shader_type gs_shader_type SHADER_VERTEX GS_SHADER_VERTEX SHADER_PIXEL GS_SHADER_PIXEL shader_destroy gs_shader_destroy shader_numparams gs_shader_get_num_params shader_getparambyidx gs_shader_get_param_by_idx shader_getparambyname gs_shader_get_param_by_name shader_getviewprojmatrix gs_shader_get_viewproj_matrix shader_getworldmatrix gs_shader_get_world_matrix shader_getparaminfo gs_shader_get_param_info shader_setbool gs_shader_set_bool shader_setfloat gs_shader_set_float shader_setint gs_shader_set_int shader_setmatrix3 gs_shader_setmatrix3 shader_setmatrix4 gs_shader_set_matrix4 shader_setvec2 gs_shader_set_vec2 shader_setvec3 gs_shader_set_vec3 shader_setvec4 gs_shader_set_vec4 shader_settexture gs_shader_set_texture shader_setval gs_shader_set_val shader_setdefault gs_shader_set_default effect_property_type gs_effect_property_type EFFECT_NONE GS_EFFECT_NONE EFFECT_BOOL GS_EFFECT_BOOL EFFECT_FLOAT GS_EFFECT_FLOAT EFFECT_COLOR GS_EFFECT_COLOR EFFECT_TEXTURE GS_EFFECT_TEXTURE effect_param_info gs_effect_param_info effect_destroy gs_effect_destroy effect_gettechnique gs_effect_get_technique technique_begin gs_technique_begin technique_end gs_technique_end technique_beginpass gs_technique_begin_pass technique_beginpassbyname gs_technique_begin_pass_by_name technique_endpass gs_technique_end_pass effect_numparams gs_effect_get_num_params effect_getparambyidx gs_effect_get_param_by_idx effect_getparambyname gs_effect_get_param_by_name effect_updateparams gs_effect_update_params effect_getviewprojmatrix gs_effect_get_viewproj_matrix effect_getworldmatrix gs_effect_get_world_matrix effect_getparaminfo gs_effect_get_param_info effect_setbool gs_effect_set_bool effect_setfloat gs_effect_set_float effect_setint gs_effect_set_int effect_setmatrix4 gs_effect_set_matrix4 effect_setvec2 gs_effect_set_vec2 effect_setvec3 gs_effect_set_vec3 effect_setvec4 gs_effect_set_vec4 effect_settexture gs_effect_set_texture effect_setval gs_effect_set_val effect_setdefault gs_effect_set_default texrender_create gs_texrender_create texrender_destroy gs_texrender_destroy texrender_begin gs_texrender_begin texrender_end gs_texrender_end texrender_reset gs_texrender_reset texrender_gettexture gs_texrender_get_texture GS_BUILDMIPMAPS GS_BUILD_MIPMAPS GS_RENDERTARGET GS_RENDER_TARGET gs_device_name gs_get_device_name gs_device_type gs_get_device_type gs_entercontext gs_enter_context gs_leavecontext gs_leave_context gs_getcontext gs_get_context gs_renderstart gs_render_start gs_renderstop gs_render_stop gs_rendersave gs_render_save gs_getinput gs_get_input gs_geteffect gs_get_effect gs_create_effect_from_file gs_effect_create_from_file gs_create_effect gs_effect_create gs_create_vertexshader_from_file gs_vertexshader_create_from_file gs_create_pixelshader_from_file gs_pixelshader_create_from_file gs_create_texture_from_file gs_texture_create_from_file gs_resetviewport gs_reset_viewport gs_set2dmode gs_set_2d_mode gs_set3dmode gs_set_3d_mode gs_create_swapchain gs_swapchain_create gs_getsize gs_get_size gs_getwidth gs_get_width gs_getheight gs_get_height gs_create_texture gs_texture_create gs_create_cubetexture gs_cubetexture_create gs_create_volumetexture gs_voltexture_create gs_create_zstencil gs_zstencil_create gs_create_stagesurface gs_stagesurface_create gs_create_samplerstate gs_samplerstate_create gs_create_vertexshader gs_vertexshader_create gs_create_pixelshader gs_pixelshader_create gs_create_vertexbuffer gs_vertexbuffer_create gs_create_indexbuffer gs_indexbuffer_create gs_gettexturetype gs_get_texture_type gs_load_defaultsamplerstate gs_load_default_samplerstate gs_getvertexshader gs_get_vertex_shader gs_getpixelshader gs_get_pixel_shader gs_getrendertarget gs_get_render_target gs_getzstenciltarget gs_get_zstencil_target gs_setrendertarget gs_set_render_target gs_setcuberendertarget gs_set_cube_render_target gs_beginscene gs_begin_scene gs_draw gs_draw gs_endscene gs_end_scene gs_setcullmode gs_set_cull_mode gs_getcullmode gs_get_cull_mode gs_enable_depthtest gs_enable_depth_test gs_enable_stenciltest gs_enable_stencil_test gs_enable_stencilwrite gs_enable_stencil_write gs_blendfunction gs_blend_function gs_depthfunction gs_depth_function gs_stencilfunction gs_stencil_function gs_stencilop gs_stencil_op gs_setviewport gs_set_viewport gs_getviewport gs_get_viewport gs_setscissorrect gs_set_scissor_rect gs_create_texture_from_iosurface gs_texture_create_from_iosurface gs_create_gdi_texture gs_texture_create_gdi gs_is_compressed_format gs_is_compressed_format gs_num_total_levels gs_get_total_levels texture_setimage gs_texture_set_image cubetexture_setimage gs_cubetexture_set_image swapchain_destroy gs_swapchain_destroy texture_destroy gs_texture_destroy texture_getwidth gs_texture_get_width texture_getheight gs_texture_get_height texture_getcolorformat gs_texture_get_color_format texture_map gs_texture_map texture_unmap gs_texture_unmap texture_isrect gs_texture_is_rect texture_getobj gs_texture_get_obj cubetexture_destroy gs_cubetexture_destroy cubetexture_getsize gs_cubetexture_get_size cubetexture_getcolorformat gs_cubetexture_get_color_format volumetexture_destroy gs_voltexture_destroy volumetexture_getwidth gs_voltexture_get_width volumetexture_getheight gs_voltexture_get_height volumetexture_getdepth gs_voltexture_getdepth volumetexture_getcolorformat gs_voltexture_get_color_format stagesurface_destroy gs_stagesurface_destroy stagesurface_getwidth gs_stagesurface_get_width stagesurface_getheight gs_stagesurface_get_height stagesurface_getcolorformat gs_stagesurface_get_color_format stagesurface_map gs_stagesurface_map stagesurface_unmap gs_stagesurface_unmap zstencil_destroy gs_zstencil_destroy samplerstate_destroy gs_samplerstate_destroy vertexbuffer_destroy gs_vertexbuffer_destroy vertexbuffer_flush gs_vertexbuffer_flush vertexbuffer_getdata gs_vertexbuffer_get_data indexbuffer_destroy gs_indexbuffer_destroy indexbuffer_flush gs_indexbuffer_flush indexbuffer_getdata gs_indexbuffer_get_data indexbuffer_numindices gs_indexbuffer_get_num_indices indexbuffer_gettype gs_indexbuffer_get_type texture_rebind_iosurface gs_texture_rebind_iosurface texture_get_dc gs_texture_get_dc texture_release_dc gs_texture_release_dc
2014-08-07 23:42:07 -07:00
uint32_t flags);
2013-09-30 19:37:13 -07:00
};
/* exception-safe RAII wrapper for index buffer data (NOTE: not copy-safe) */
struct DataPtr {
void *data;
inline DataPtr(void *data) : data(data) {}
inline ~DataPtr() {bfree(data);}
};
struct gs_index_buffer : gs_obj {
2013-09-30 19:37:13 -07:00
ComPtr<ID3D11Buffer> indexBuffer;
bool dynamic;
gs_index_type type;
size_t indexSize;
size_t num;
DataPtr indices;
D3D11_BUFFER_DESC bd = {};
D3D11_SUBRESOURCE_DATA srd = {};
2013-09-30 19:37:13 -07:00
void InitBuffer();
libobs-d3d11: Rebuild device and assets if device removed/reset Due to an NVIDIA driver bug with the Windows 10 Anniversary Update, there are an increasingly large number of reports of "Device Removed" errors and TDRs. When this happens, OBS stops outputting all data because all graphics functions are failing, and it appears to just "freeze up" for users. To temporarily alleviate this issue while waiting for it to be fixed, the D3D subsystem can be rebuilt when that happens, all assets can be reloaded to ensure that it can continue functioning (with a minor hiccup in playback). To allow rebuilding the entire D3D subsystem, all objects that contain D3D references must be part of a linked list (with a few exceptions) so we can quickly traverse them all whenever needed, and all data for those resources (static resources primarily, such as shaders, textures, index buffers, vertex buffers) must be stored in RAM so they can be recreated whenever needed. Then if D3D reports a "device removed" or "device reset" error, all D3D references must first be fully released with no stray references; the linked list must be fully traversed until all references are released. Then, the linked list must once again be traversed again, and all those D3D objects must be recreated with the same data and descriptors (which are now saved in each object). Finally, all states need to be reset. After that's complete, the device is able to continue functioning almost as it was before, although the output to recording/stream may get a few green frames due to texture data being reset. This will temporarily alleviate the "Device Removed" issue while waiting for a fix from NVIDIA.
2016-11-03 07:41:23 -07:00
inline void Rebuild(ID3D11Device *dev);
inline void Release() {indexBuffer.Release();}
gs_index_buffer(gs_device_t *device, enum gs_index_type type,
2013-09-30 19:37:13 -07:00
void *indices, size_t num, uint32_t flags);
};
struct gs_texture : gs_obj {
2013-09-30 19:37:13 -07:00
gs_texture_type type;
uint32_t levels;
gs_color_format format;
2013-09-30 19:37:13 -07:00
ComPtr<ID3D11ShaderResourceView> shaderRes;
D3D11_SHADER_RESOURCE_VIEW_DESC resourceDesc = {};
2013-09-30 19:37:13 -07:00
libobs-d3d11: Rebuild device and assets if device removed/reset Due to an NVIDIA driver bug with the Windows 10 Anniversary Update, there are an increasingly large number of reports of "Device Removed" errors and TDRs. When this happens, OBS stops outputting all data because all graphics functions are failing, and it appears to just "freeze up" for users. To temporarily alleviate this issue while waiting for it to be fixed, the D3D subsystem can be rebuilt when that happens, all assets can be reloaded to ensure that it can continue functioning (with a minor hiccup in playback). To allow rebuilding the entire D3D subsystem, all objects that contain D3D references must be part of a linked list (with a few exceptions) so we can quickly traverse them all whenever needed, and all data for those resources (static resources primarily, such as shaders, textures, index buffers, vertex buffers) must be stored in RAM so they can be recreated whenever needed. Then if D3D reports a "device removed" or "device reset" error, all D3D references must first be fully released with no stray references; the linked list must be fully traversed until all references are released. Then, the linked list must once again be traversed again, and all those D3D objects must be recreated with the same data and descriptors (which are now saved in each object). Finally, all states need to be reset. After that's complete, the device is able to continue functioning almost as it was before, although the output to recording/stream may get a few green frames due to texture data being reset. This will temporarily alleviate the "Device Removed" issue while waiting for a fix from NVIDIA.
2016-11-03 07:41:23 -07:00
inline void Rebuild(ID3D11Device *dev);
inline gs_texture(gs_texture_type type, uint32_t levels,
gs_color_format format)
: type (type),
levels (levels),
format (format)
2013-09-30 19:37:13 -07:00
{
}
inline gs_texture(gs_device *device, gs_type obj_type,
gs_texture_type type)
: gs_obj (device, obj_type),
type (type)
{
}
inline gs_texture(gs_device *device, gs_type obj_type,
gs_texture_type type,
uint32_t levels, gs_color_format format)
: gs_obj (device, obj_type),
type (type),
levels (levels),
format (format)
{
}
2013-09-30 19:37:13 -07:00
};
struct gs_texture_2d : gs_texture {
ComPtr<ID3D11Texture2D> texture;
ComPtr<ID3D11RenderTargetView> renderTarget[6];
ComPtr<IDXGISurface1> gdiSurface;
uint32_t width = 0, height = 0;
DXGI_FORMAT dxgiFormat = DXGI_FORMAT_UNKNOWN;
bool isRenderTarget = false;
bool isGDICompatible = false;
bool isDynamic = false;
bool isShared = false;
bool genMipmaps = false;
uint32_t sharedHandle = 0;
2013-09-30 19:37:13 -07:00
vector<vector<uint8_t>> data;
vector<D3D11_SUBRESOURCE_DATA> srd;
D3D11_TEXTURE2D_DESC td = {};
void InitSRD(vector<D3D11_SUBRESOURCE_DATA> &srd);
void InitTexture(const uint8_t **data);
2013-09-30 19:37:13 -07:00
void InitResourceView();
void InitRenderTargets();
void BackupTexture(const uint8_t **data);
2013-09-30 19:37:13 -07:00
void RebuildSharedTextureFallback();
libobs-d3d11: Rebuild device and assets if device removed/reset Due to an NVIDIA driver bug with the Windows 10 Anniversary Update, there are an increasingly large number of reports of "Device Removed" errors and TDRs. When this happens, OBS stops outputting all data because all graphics functions are failing, and it appears to just "freeze up" for users. To temporarily alleviate this issue while waiting for it to be fixed, the D3D subsystem can be rebuilt when that happens, all assets can be reloaded to ensure that it can continue functioning (with a minor hiccup in playback). To allow rebuilding the entire D3D subsystem, all objects that contain D3D references must be part of a linked list (with a few exceptions) so we can quickly traverse them all whenever needed, and all data for those resources (static resources primarily, such as shaders, textures, index buffers, vertex buffers) must be stored in RAM so they can be recreated whenever needed. Then if D3D reports a "device removed" or "device reset" error, all D3D references must first be fully released with no stray references; the linked list must be fully traversed until all references are released. Then, the linked list must once again be traversed again, and all those D3D objects must be recreated with the same data and descriptors (which are now saved in each object). Finally, all states need to be reset. After that's complete, the device is able to continue functioning almost as it was before, although the output to recording/stream may get a few green frames due to texture data being reset. This will temporarily alleviate the "Device Removed" issue while waiting for a fix from NVIDIA.
2016-11-03 07:41:23 -07:00
inline void Rebuild(ID3D11Device *dev);
inline void Release()
{
texture.Release();
for (auto &rt : renderTarget)
rt.Release();
gdiSurface.Release();
shaderRes.Release();
}
2013-09-30 19:37:13 -07:00
inline gs_texture_2d()
: gs_texture (GS_TEXTURE_2D, 0, GS_UNKNOWN)
2013-09-30 19:37:13 -07:00
{
}
gs_texture_2d(gs_device_t *device, uint32_t width, uint32_t height,
gs_color_format colorFormat, uint32_t levels,
const uint8_t **data, uint32_t flags,
gs_texture_type type, bool gdiCompatible, bool shared);
gs_texture_2d(gs_device_t *device, uint32_t handle);
2013-09-30 19:37:13 -07:00
};
struct gs_zstencil_buffer : gs_obj {
2013-09-30 19:37:13 -07:00
ComPtr<ID3D11Texture2D> texture;
ComPtr<ID3D11DepthStencilView> view;
uint32_t width, height;
gs_zstencil_format format;
DXGI_FORMAT dxgiFormat;
D3D11_TEXTURE2D_DESC td = {};
D3D11_DEPTH_STENCIL_VIEW_DESC dsvd = {};
2013-09-30 19:37:13 -07:00
void InitBuffer();
libobs-d3d11: Rebuild device and assets if device removed/reset Due to an NVIDIA driver bug with the Windows 10 Anniversary Update, there are an increasingly large number of reports of "Device Removed" errors and TDRs. When this happens, OBS stops outputting all data because all graphics functions are failing, and it appears to just "freeze up" for users. To temporarily alleviate this issue while waiting for it to be fixed, the D3D subsystem can be rebuilt when that happens, all assets can be reloaded to ensure that it can continue functioning (with a minor hiccup in playback). To allow rebuilding the entire D3D subsystem, all objects that contain D3D references must be part of a linked list (with a few exceptions) so we can quickly traverse them all whenever needed, and all data for those resources (static resources primarily, such as shaders, textures, index buffers, vertex buffers) must be stored in RAM so they can be recreated whenever needed. Then if D3D reports a "device removed" or "device reset" error, all D3D references must first be fully released with no stray references; the linked list must be fully traversed until all references are released. Then, the linked list must once again be traversed again, and all those D3D objects must be recreated with the same data and descriptors (which are now saved in each object). Finally, all states need to be reset. After that's complete, the device is able to continue functioning almost as it was before, although the output to recording/stream may get a few green frames due to texture data being reset. This will temporarily alleviate the "Device Removed" issue while waiting for a fix from NVIDIA.
2016-11-03 07:41:23 -07:00
inline void Rebuild(ID3D11Device *dev);
inline void Release()
{
texture.Release();
view.Release();
}
2013-09-30 19:37:13 -07:00
inline gs_zstencil_buffer()
: width (0),
2013-09-30 19:37:13 -07:00
height (0),
dxgiFormat (DXGI_FORMAT_UNKNOWN)
{
}
gs_zstencil_buffer(gs_device_t *device, uint32_t width, uint32_t height,
2013-09-30 19:37:13 -07:00
gs_zstencil_format format);
};
struct gs_stage_surface : gs_obj {
2013-09-30 19:37:13 -07:00
ComPtr<ID3D11Texture2D> texture;
D3D11_TEXTURE2D_DESC td = {};
2013-09-30 19:37:13 -07:00
uint32_t width, height;
gs_color_format format;
DXGI_FORMAT dxgiFormat;
libobs-d3d11: Rebuild device and assets if device removed/reset Due to an NVIDIA driver bug with the Windows 10 Anniversary Update, there are an increasingly large number of reports of "Device Removed" errors and TDRs. When this happens, OBS stops outputting all data because all graphics functions are failing, and it appears to just "freeze up" for users. To temporarily alleviate this issue while waiting for it to be fixed, the D3D subsystem can be rebuilt when that happens, all assets can be reloaded to ensure that it can continue functioning (with a minor hiccup in playback). To allow rebuilding the entire D3D subsystem, all objects that contain D3D references must be part of a linked list (with a few exceptions) so we can quickly traverse them all whenever needed, and all data for those resources (static resources primarily, such as shaders, textures, index buffers, vertex buffers) must be stored in RAM so they can be recreated whenever needed. Then if D3D reports a "device removed" or "device reset" error, all D3D references must first be fully released with no stray references; the linked list must be fully traversed until all references are released. Then, the linked list must once again be traversed again, and all those D3D objects must be recreated with the same data and descriptors (which are now saved in each object). Finally, all states need to be reset. After that's complete, the device is able to continue functioning almost as it was before, although the output to recording/stream may get a few green frames due to texture data being reset. This will temporarily alleviate the "Device Removed" issue while waiting for a fix from NVIDIA.
2016-11-03 07:41:23 -07:00
inline void Rebuild(ID3D11Device *dev);
inline void Release()
{
texture.Release();
}
gs_stage_surface(gs_device_t *device, uint32_t width, uint32_t height,
2013-09-30 19:37:13 -07:00
gs_color_format colorFormat);
};
struct gs_sampler_state : gs_obj {
2013-09-30 19:37:13 -07:00
ComPtr<ID3D11SamplerState> state;
D3D11_SAMPLER_DESC sd = {};
2013-09-30 19:37:13 -07:00
gs_sampler_info info;
libobs-d3d11: Rebuild device and assets if device removed/reset Due to an NVIDIA driver bug with the Windows 10 Anniversary Update, there are an increasingly large number of reports of "Device Removed" errors and TDRs. When this happens, OBS stops outputting all data because all graphics functions are failing, and it appears to just "freeze up" for users. To temporarily alleviate this issue while waiting for it to be fixed, the D3D subsystem can be rebuilt when that happens, all assets can be reloaded to ensure that it can continue functioning (with a minor hiccup in playback). To allow rebuilding the entire D3D subsystem, all objects that contain D3D references must be part of a linked list (with a few exceptions) so we can quickly traverse them all whenever needed, and all data for those resources (static resources primarily, such as shaders, textures, index buffers, vertex buffers) must be stored in RAM so they can be recreated whenever needed. Then if D3D reports a "device removed" or "device reset" error, all D3D references must first be fully released with no stray references; the linked list must be fully traversed until all references are released. Then, the linked list must once again be traversed again, and all those D3D objects must be recreated with the same data and descriptors (which are now saved in each object). Finally, all states need to be reset. After that's complete, the device is able to continue functioning almost as it was before, although the output to recording/stream may get a few green frames due to texture data being reset. This will temporarily alleviate the "Device Removed" issue while waiting for a fix from NVIDIA.
2016-11-03 07:41:23 -07:00
inline void Rebuild(ID3D11Device *dev);
inline void Release() {state.Release();}
gs_sampler_state(gs_device_t *device, const gs_sampler_info *info);
2013-09-30 19:37:13 -07:00
};
(API Change) Improve graphics API consistency Summary: - Prefix all graphics subsystem names with gs_ or GS_ - Unsquish funciton names (for example _setfloat to _set_float) - Changed create functions to be more consistent with the rest of the API elsewhere. For exmaple, instead of gs_create_texture/gs_texture_destroy, it's now gs_texture_create/gs_texture_destroy - Renamed gs_stencil_op enum to gs_stencil_op_type From: To: ----------------------------------------------------------- tvertarray gs_tvertarray vb_data gs_vb_data vbdata_create gs_vbdata_create vbdata_destroy gs_vbdata_destroy shader_param gs_shader_param gs_effect gs_effect effect_technique gs_effect_technique effect_pass gs_effect_pass effect_param gs_effect_param texture_t gs_texture_t stagesurf_t gs_stagesurf_t zstencil_t gs_zstencil_t vertbuffer_t gs_vertbuffer_t indexbuffer_t gs_indexbuffer_t samplerstate_t gs_samplerstate_t swapchain_t gs_swapchain_t texrender_t gs_texrender_t shader_t gs_shader_t sparam_t gs_sparam_t effect_t gs_effect_t technique_t gs_technique_t eparam_t gs_eparam_t device_t gs_device_t graphics_t graphics_t shader_param_type gs_shader_param_type SHADER_PARAM_UNKNOWN GS_SHADER_PARAM_UNKNOWN SHADER_PARAM_BOOL GS_SHADER_PARAM_BOOL SHADER_PARAM_FLOAT GS_SHADER_PARAM_FLOAT SHADER_PARAM_INT GS_SHADER_PARAM_INT SHADER_PARAM_STRING GS_SHADER_PARAM_STRING SHADER_PARAM_VEC2 GS_SHADER_PARAM_VEC2 SHADER_PARAM_VEC3 GS_SHADER_PARAM_VEC3 SHADER_PARAM_VEC4 GS_SHADER_PARAM_VEC4 SHADER_PARAM_MATRIX4X4 GS_SHADER_PARAM_MATRIX4X4 SHADER_PARAM_TEXTURE GS_SHADER_PARAM_TEXTURE shader_param_info gs_shader_param_info shader_type gs_shader_type SHADER_VERTEX GS_SHADER_VERTEX SHADER_PIXEL GS_SHADER_PIXEL shader_destroy gs_shader_destroy shader_numparams gs_shader_get_num_params shader_getparambyidx gs_shader_get_param_by_idx shader_getparambyname gs_shader_get_param_by_name shader_getviewprojmatrix gs_shader_get_viewproj_matrix shader_getworldmatrix gs_shader_get_world_matrix shader_getparaminfo gs_shader_get_param_info shader_setbool gs_shader_set_bool shader_setfloat gs_shader_set_float shader_setint gs_shader_set_int shader_setmatrix3 gs_shader_setmatrix3 shader_setmatrix4 gs_shader_set_matrix4 shader_setvec2 gs_shader_set_vec2 shader_setvec3 gs_shader_set_vec3 shader_setvec4 gs_shader_set_vec4 shader_settexture gs_shader_set_texture shader_setval gs_shader_set_val shader_setdefault gs_shader_set_default effect_property_type gs_effect_property_type EFFECT_NONE GS_EFFECT_NONE EFFECT_BOOL GS_EFFECT_BOOL EFFECT_FLOAT GS_EFFECT_FLOAT EFFECT_COLOR GS_EFFECT_COLOR EFFECT_TEXTURE GS_EFFECT_TEXTURE effect_param_info gs_effect_param_info effect_destroy gs_effect_destroy effect_gettechnique gs_effect_get_technique technique_begin gs_technique_begin technique_end gs_technique_end technique_beginpass gs_technique_begin_pass technique_beginpassbyname gs_technique_begin_pass_by_name technique_endpass gs_technique_end_pass effect_numparams gs_effect_get_num_params effect_getparambyidx gs_effect_get_param_by_idx effect_getparambyname gs_effect_get_param_by_name effect_updateparams gs_effect_update_params effect_getviewprojmatrix gs_effect_get_viewproj_matrix effect_getworldmatrix gs_effect_get_world_matrix effect_getparaminfo gs_effect_get_param_info effect_setbool gs_effect_set_bool effect_setfloat gs_effect_set_float effect_setint gs_effect_set_int effect_setmatrix4 gs_effect_set_matrix4 effect_setvec2 gs_effect_set_vec2 effect_setvec3 gs_effect_set_vec3 effect_setvec4 gs_effect_set_vec4 effect_settexture gs_effect_set_texture effect_setval gs_effect_set_val effect_setdefault gs_effect_set_default texrender_create gs_texrender_create texrender_destroy gs_texrender_destroy texrender_begin gs_texrender_begin texrender_end gs_texrender_end texrender_reset gs_texrender_reset texrender_gettexture gs_texrender_get_texture GS_BUILDMIPMAPS GS_BUILD_MIPMAPS GS_RENDERTARGET GS_RENDER_TARGET gs_device_name gs_get_device_name gs_device_type gs_get_device_type gs_entercontext gs_enter_context gs_leavecontext gs_leave_context gs_getcontext gs_get_context gs_renderstart gs_render_start gs_renderstop gs_render_stop gs_rendersave gs_render_save gs_getinput gs_get_input gs_geteffect gs_get_effect gs_create_effect_from_file gs_effect_create_from_file gs_create_effect gs_effect_create gs_create_vertexshader_from_file gs_vertexshader_create_from_file gs_create_pixelshader_from_file gs_pixelshader_create_from_file gs_create_texture_from_file gs_texture_create_from_file gs_resetviewport gs_reset_viewport gs_set2dmode gs_set_2d_mode gs_set3dmode gs_set_3d_mode gs_create_swapchain gs_swapchain_create gs_getsize gs_get_size gs_getwidth gs_get_width gs_getheight gs_get_height gs_create_texture gs_texture_create gs_create_cubetexture gs_cubetexture_create gs_create_volumetexture gs_voltexture_create gs_create_zstencil gs_zstencil_create gs_create_stagesurface gs_stagesurface_create gs_create_samplerstate gs_samplerstate_create gs_create_vertexshader gs_vertexshader_create gs_create_pixelshader gs_pixelshader_create gs_create_vertexbuffer gs_vertexbuffer_create gs_create_indexbuffer gs_indexbuffer_create gs_gettexturetype gs_get_texture_type gs_load_defaultsamplerstate gs_load_default_samplerstate gs_getvertexshader gs_get_vertex_shader gs_getpixelshader gs_get_pixel_shader gs_getrendertarget gs_get_render_target gs_getzstenciltarget gs_get_zstencil_target gs_setrendertarget gs_set_render_target gs_setcuberendertarget gs_set_cube_render_target gs_beginscene gs_begin_scene gs_draw gs_draw gs_endscene gs_end_scene gs_setcullmode gs_set_cull_mode gs_getcullmode gs_get_cull_mode gs_enable_depthtest gs_enable_depth_test gs_enable_stenciltest gs_enable_stencil_test gs_enable_stencilwrite gs_enable_stencil_write gs_blendfunction gs_blend_function gs_depthfunction gs_depth_function gs_stencilfunction gs_stencil_function gs_stencilop gs_stencil_op gs_setviewport gs_set_viewport gs_getviewport gs_get_viewport gs_setscissorrect gs_set_scissor_rect gs_create_texture_from_iosurface gs_texture_create_from_iosurface gs_create_gdi_texture gs_texture_create_gdi gs_is_compressed_format gs_is_compressed_format gs_num_total_levels gs_get_total_levels texture_setimage gs_texture_set_image cubetexture_setimage gs_cubetexture_set_image swapchain_destroy gs_swapchain_destroy texture_destroy gs_texture_destroy texture_getwidth gs_texture_get_width texture_getheight gs_texture_get_height texture_getcolorformat gs_texture_get_color_format texture_map gs_texture_map texture_unmap gs_texture_unmap texture_isrect gs_texture_is_rect texture_getobj gs_texture_get_obj cubetexture_destroy gs_cubetexture_destroy cubetexture_getsize gs_cubetexture_get_size cubetexture_getcolorformat gs_cubetexture_get_color_format volumetexture_destroy gs_voltexture_destroy volumetexture_getwidth gs_voltexture_get_width volumetexture_getheight gs_voltexture_get_height volumetexture_getdepth gs_voltexture_getdepth volumetexture_getcolorformat gs_voltexture_get_color_format stagesurface_destroy gs_stagesurface_destroy stagesurface_getwidth gs_stagesurface_get_width stagesurface_getheight gs_stagesurface_get_height stagesurface_getcolorformat gs_stagesurface_get_color_format stagesurface_map gs_stagesurface_map stagesurface_unmap gs_stagesurface_unmap zstencil_destroy gs_zstencil_destroy samplerstate_destroy gs_samplerstate_destroy vertexbuffer_destroy gs_vertexbuffer_destroy vertexbuffer_flush gs_vertexbuffer_flush vertexbuffer_getdata gs_vertexbuffer_get_data indexbuffer_destroy gs_indexbuffer_destroy indexbuffer_flush gs_indexbuffer_flush indexbuffer_getdata gs_indexbuffer_get_data indexbuffer_numindices gs_indexbuffer_get_num_indices indexbuffer_gettype gs_indexbuffer_get_type texture_rebind_iosurface gs_texture_rebind_iosurface texture_get_dc gs_texture_get_dc texture_release_dc gs_texture_release_dc
2014-08-07 23:42:07 -07:00
struct gs_shader_param {
string name;
gs_shader_param_type type;
2013-09-30 19:37:13 -07:00
uint32_t textureID;
struct gs_sampler_state *nextSampler = nullptr;
2013-09-30 19:37:13 -07:00
int arrayCount;
2013-09-30 19:37:13 -07:00
size_t pos;
vector<uint8_t> curValue;
vector<uint8_t> defaultValue;
bool changed;
2013-09-30 19:37:13 -07:00
(API Change) Improve graphics API consistency Summary: - Prefix all graphics subsystem names with gs_ or GS_ - Unsquish funciton names (for example _setfloat to _set_float) - Changed create functions to be more consistent with the rest of the API elsewhere. For exmaple, instead of gs_create_texture/gs_texture_destroy, it's now gs_texture_create/gs_texture_destroy - Renamed gs_stencil_op enum to gs_stencil_op_type From: To: ----------------------------------------------------------- tvertarray gs_tvertarray vb_data gs_vb_data vbdata_create gs_vbdata_create vbdata_destroy gs_vbdata_destroy shader_param gs_shader_param gs_effect gs_effect effect_technique gs_effect_technique effect_pass gs_effect_pass effect_param gs_effect_param texture_t gs_texture_t stagesurf_t gs_stagesurf_t zstencil_t gs_zstencil_t vertbuffer_t gs_vertbuffer_t indexbuffer_t gs_indexbuffer_t samplerstate_t gs_samplerstate_t swapchain_t gs_swapchain_t texrender_t gs_texrender_t shader_t gs_shader_t sparam_t gs_sparam_t effect_t gs_effect_t technique_t gs_technique_t eparam_t gs_eparam_t device_t gs_device_t graphics_t graphics_t shader_param_type gs_shader_param_type SHADER_PARAM_UNKNOWN GS_SHADER_PARAM_UNKNOWN SHADER_PARAM_BOOL GS_SHADER_PARAM_BOOL SHADER_PARAM_FLOAT GS_SHADER_PARAM_FLOAT SHADER_PARAM_INT GS_SHADER_PARAM_INT SHADER_PARAM_STRING GS_SHADER_PARAM_STRING SHADER_PARAM_VEC2 GS_SHADER_PARAM_VEC2 SHADER_PARAM_VEC3 GS_SHADER_PARAM_VEC3 SHADER_PARAM_VEC4 GS_SHADER_PARAM_VEC4 SHADER_PARAM_MATRIX4X4 GS_SHADER_PARAM_MATRIX4X4 SHADER_PARAM_TEXTURE GS_SHADER_PARAM_TEXTURE shader_param_info gs_shader_param_info shader_type gs_shader_type SHADER_VERTEX GS_SHADER_VERTEX SHADER_PIXEL GS_SHADER_PIXEL shader_destroy gs_shader_destroy shader_numparams gs_shader_get_num_params shader_getparambyidx gs_shader_get_param_by_idx shader_getparambyname gs_shader_get_param_by_name shader_getviewprojmatrix gs_shader_get_viewproj_matrix shader_getworldmatrix gs_shader_get_world_matrix shader_getparaminfo gs_shader_get_param_info shader_setbool gs_shader_set_bool shader_setfloat gs_shader_set_float shader_setint gs_shader_set_int shader_setmatrix3 gs_shader_setmatrix3 shader_setmatrix4 gs_shader_set_matrix4 shader_setvec2 gs_shader_set_vec2 shader_setvec3 gs_shader_set_vec3 shader_setvec4 gs_shader_set_vec4 shader_settexture gs_shader_set_texture shader_setval gs_shader_set_val shader_setdefault gs_shader_set_default effect_property_type gs_effect_property_type EFFECT_NONE GS_EFFECT_NONE EFFECT_BOOL GS_EFFECT_BOOL EFFECT_FLOAT GS_EFFECT_FLOAT EFFECT_COLOR GS_EFFECT_COLOR EFFECT_TEXTURE GS_EFFECT_TEXTURE effect_param_info gs_effect_param_info effect_destroy gs_effect_destroy effect_gettechnique gs_effect_get_technique technique_begin gs_technique_begin technique_end gs_technique_end technique_beginpass gs_technique_begin_pass technique_beginpassbyname gs_technique_begin_pass_by_name technique_endpass gs_technique_end_pass effect_numparams gs_effect_get_num_params effect_getparambyidx gs_effect_get_param_by_idx effect_getparambyname gs_effect_get_param_by_name effect_updateparams gs_effect_update_params effect_getviewprojmatrix gs_effect_get_viewproj_matrix effect_getworldmatrix gs_effect_get_world_matrix effect_getparaminfo gs_effect_get_param_info effect_setbool gs_effect_set_bool effect_setfloat gs_effect_set_float effect_setint gs_effect_set_int effect_setmatrix4 gs_effect_set_matrix4 effect_setvec2 gs_effect_set_vec2 effect_setvec3 gs_effect_set_vec3 effect_setvec4 gs_effect_set_vec4 effect_settexture gs_effect_set_texture effect_setval gs_effect_set_val effect_setdefault gs_effect_set_default texrender_create gs_texrender_create texrender_destroy gs_texrender_destroy texrender_begin gs_texrender_begin texrender_end gs_texrender_end texrender_reset gs_texrender_reset texrender_gettexture gs_texrender_get_texture GS_BUILDMIPMAPS GS_BUILD_MIPMAPS GS_RENDERTARGET GS_RENDER_TARGET gs_device_name gs_get_device_name gs_device_type gs_get_device_type gs_entercontext gs_enter_context gs_leavecontext gs_leave_context gs_getcontext gs_get_context gs_renderstart gs_render_start gs_renderstop gs_render_stop gs_rendersave gs_render_save gs_getinput gs_get_input gs_geteffect gs_get_effect gs_create_effect_from_file gs_effect_create_from_file gs_create_effect gs_effect_create gs_create_vertexshader_from_file gs_vertexshader_create_from_file gs_create_pixelshader_from_file gs_pixelshader_create_from_file gs_create_texture_from_file gs_texture_create_from_file gs_resetviewport gs_reset_viewport gs_set2dmode gs_set_2d_mode gs_set3dmode gs_set_3d_mode gs_create_swapchain gs_swapchain_create gs_getsize gs_get_size gs_getwidth gs_get_width gs_getheight gs_get_height gs_create_texture gs_texture_create gs_create_cubetexture gs_cubetexture_create gs_create_volumetexture gs_voltexture_create gs_create_zstencil gs_zstencil_create gs_create_stagesurface gs_stagesurface_create gs_create_samplerstate gs_samplerstate_create gs_create_vertexshader gs_vertexshader_create gs_create_pixelshader gs_pixelshader_create gs_create_vertexbuffer gs_vertexbuffer_create gs_create_indexbuffer gs_indexbuffer_create gs_gettexturetype gs_get_texture_type gs_load_defaultsamplerstate gs_load_default_samplerstate gs_getvertexshader gs_get_vertex_shader gs_getpixelshader gs_get_pixel_shader gs_getrendertarget gs_get_render_target gs_getzstenciltarget gs_get_zstencil_target gs_setrendertarget gs_set_render_target gs_setcuberendertarget gs_set_cube_render_target gs_beginscene gs_begin_scene gs_draw gs_draw gs_endscene gs_end_scene gs_setcullmode gs_set_cull_mode gs_getcullmode gs_get_cull_mode gs_enable_depthtest gs_enable_depth_test gs_enable_stenciltest gs_enable_stencil_test gs_enable_stencilwrite gs_enable_stencil_write gs_blendfunction gs_blend_function gs_depthfunction gs_depth_function gs_stencilfunction gs_stencil_function gs_stencilop gs_stencil_op gs_setviewport gs_set_viewport gs_getviewport gs_get_viewport gs_setscissorrect gs_set_scissor_rect gs_create_texture_from_iosurface gs_texture_create_from_iosurface gs_create_gdi_texture gs_texture_create_gdi gs_is_compressed_format gs_is_compressed_format gs_num_total_levels gs_get_total_levels texture_setimage gs_texture_set_image cubetexture_setimage gs_cubetexture_set_image swapchain_destroy gs_swapchain_destroy texture_destroy gs_texture_destroy texture_getwidth gs_texture_get_width texture_getheight gs_texture_get_height texture_getcolorformat gs_texture_get_color_format texture_map gs_texture_map texture_unmap gs_texture_unmap texture_isrect gs_texture_is_rect texture_getobj gs_texture_get_obj cubetexture_destroy gs_cubetexture_destroy cubetexture_getsize gs_cubetexture_get_size cubetexture_getcolorformat gs_cubetexture_get_color_format volumetexture_destroy gs_voltexture_destroy volumetexture_getwidth gs_voltexture_get_width volumetexture_getheight gs_voltexture_get_height volumetexture_getdepth gs_voltexture_getdepth volumetexture_getcolorformat gs_voltexture_get_color_format stagesurface_destroy gs_stagesurface_destroy stagesurface_getwidth gs_stagesurface_get_width stagesurface_getheight gs_stagesurface_get_height stagesurface_getcolorformat gs_stagesurface_get_color_format stagesurface_map gs_stagesurface_map stagesurface_unmap gs_stagesurface_unmap zstencil_destroy gs_zstencil_destroy samplerstate_destroy gs_samplerstate_destroy vertexbuffer_destroy gs_vertexbuffer_destroy vertexbuffer_flush gs_vertexbuffer_flush vertexbuffer_getdata gs_vertexbuffer_get_data indexbuffer_destroy gs_indexbuffer_destroy indexbuffer_flush gs_indexbuffer_flush indexbuffer_getdata gs_indexbuffer_get_data indexbuffer_numindices gs_indexbuffer_get_num_indices indexbuffer_gettype gs_indexbuffer_get_type texture_rebind_iosurface gs_texture_rebind_iosurface texture_get_dc gs_texture_get_dc texture_release_dc gs_texture_release_dc
2014-08-07 23:42:07 -07:00
gs_shader_param(shader_var &var, uint32_t &texCounter);
2013-09-30 19:37:13 -07:00
};
struct ShaderError {
ComPtr<ID3D10Blob> errors;
HRESULT hr;
inline ShaderError(const ComPtr<ID3D10Blob> &errors, HRESULT hr)
: errors (errors),
hr (hr)
{
}
};
struct gs_shader : gs_obj {
(API Change) Improve graphics API consistency Summary: - Prefix all graphics subsystem names with gs_ or GS_ - Unsquish funciton names (for example _setfloat to _set_float) - Changed create functions to be more consistent with the rest of the API elsewhere. For exmaple, instead of gs_create_texture/gs_texture_destroy, it's now gs_texture_create/gs_texture_destroy - Renamed gs_stencil_op enum to gs_stencil_op_type From: To: ----------------------------------------------------------- tvertarray gs_tvertarray vb_data gs_vb_data vbdata_create gs_vbdata_create vbdata_destroy gs_vbdata_destroy shader_param gs_shader_param gs_effect gs_effect effect_technique gs_effect_technique effect_pass gs_effect_pass effect_param gs_effect_param texture_t gs_texture_t stagesurf_t gs_stagesurf_t zstencil_t gs_zstencil_t vertbuffer_t gs_vertbuffer_t indexbuffer_t gs_indexbuffer_t samplerstate_t gs_samplerstate_t swapchain_t gs_swapchain_t texrender_t gs_texrender_t shader_t gs_shader_t sparam_t gs_sparam_t effect_t gs_effect_t technique_t gs_technique_t eparam_t gs_eparam_t device_t gs_device_t graphics_t graphics_t shader_param_type gs_shader_param_type SHADER_PARAM_UNKNOWN GS_SHADER_PARAM_UNKNOWN SHADER_PARAM_BOOL GS_SHADER_PARAM_BOOL SHADER_PARAM_FLOAT GS_SHADER_PARAM_FLOAT SHADER_PARAM_INT GS_SHADER_PARAM_INT SHADER_PARAM_STRING GS_SHADER_PARAM_STRING SHADER_PARAM_VEC2 GS_SHADER_PARAM_VEC2 SHADER_PARAM_VEC3 GS_SHADER_PARAM_VEC3 SHADER_PARAM_VEC4 GS_SHADER_PARAM_VEC4 SHADER_PARAM_MATRIX4X4 GS_SHADER_PARAM_MATRIX4X4 SHADER_PARAM_TEXTURE GS_SHADER_PARAM_TEXTURE shader_param_info gs_shader_param_info shader_type gs_shader_type SHADER_VERTEX GS_SHADER_VERTEX SHADER_PIXEL GS_SHADER_PIXEL shader_destroy gs_shader_destroy shader_numparams gs_shader_get_num_params shader_getparambyidx gs_shader_get_param_by_idx shader_getparambyname gs_shader_get_param_by_name shader_getviewprojmatrix gs_shader_get_viewproj_matrix shader_getworldmatrix gs_shader_get_world_matrix shader_getparaminfo gs_shader_get_param_info shader_setbool gs_shader_set_bool shader_setfloat gs_shader_set_float shader_setint gs_shader_set_int shader_setmatrix3 gs_shader_setmatrix3 shader_setmatrix4 gs_shader_set_matrix4 shader_setvec2 gs_shader_set_vec2 shader_setvec3 gs_shader_set_vec3 shader_setvec4 gs_shader_set_vec4 shader_settexture gs_shader_set_texture shader_setval gs_shader_set_val shader_setdefault gs_shader_set_default effect_property_type gs_effect_property_type EFFECT_NONE GS_EFFECT_NONE EFFECT_BOOL GS_EFFECT_BOOL EFFECT_FLOAT GS_EFFECT_FLOAT EFFECT_COLOR GS_EFFECT_COLOR EFFECT_TEXTURE GS_EFFECT_TEXTURE effect_param_info gs_effect_param_info effect_destroy gs_effect_destroy effect_gettechnique gs_effect_get_technique technique_begin gs_technique_begin technique_end gs_technique_end technique_beginpass gs_technique_begin_pass technique_beginpassbyname gs_technique_begin_pass_by_name technique_endpass gs_technique_end_pass effect_numparams gs_effect_get_num_params effect_getparambyidx gs_effect_get_param_by_idx effect_getparambyname gs_effect_get_param_by_name effect_updateparams gs_effect_update_params effect_getviewprojmatrix gs_effect_get_viewproj_matrix effect_getworldmatrix gs_effect_get_world_matrix effect_getparaminfo gs_effect_get_param_info effect_setbool gs_effect_set_bool effect_setfloat gs_effect_set_float effect_setint gs_effect_set_int effect_setmatrix4 gs_effect_set_matrix4 effect_setvec2 gs_effect_set_vec2 effect_setvec3 gs_effect_set_vec3 effect_setvec4 gs_effect_set_vec4 effect_settexture gs_effect_set_texture effect_setval gs_effect_set_val effect_setdefault gs_effect_set_default texrender_create gs_texrender_create texrender_destroy gs_texrender_destroy texrender_begin gs_texrender_begin texrender_end gs_texrender_end texrender_reset gs_texrender_reset texrender_gettexture gs_texrender_get_texture GS_BUILDMIPMAPS GS_BUILD_MIPMAPS GS_RENDERTARGET GS_RENDER_TARGET gs_device_name gs_get_device_name gs_device_type gs_get_device_type gs_entercontext gs_enter_context gs_leavecontext gs_leave_context gs_getcontext gs_get_context gs_renderstart gs_render_start gs_renderstop gs_render_stop gs_rendersave gs_render_save gs_getinput gs_get_input gs_geteffect gs_get_effect gs_create_effect_from_file gs_effect_create_from_file gs_create_effect gs_effect_create gs_create_vertexshader_from_file gs_vertexshader_create_from_file gs_create_pixelshader_from_file gs_pixelshader_create_from_file gs_create_texture_from_file gs_texture_create_from_file gs_resetviewport gs_reset_viewport gs_set2dmode gs_set_2d_mode gs_set3dmode gs_set_3d_mode gs_create_swapchain gs_swapchain_create gs_getsize gs_get_size gs_getwidth gs_get_width gs_getheight gs_get_height gs_create_texture gs_texture_create gs_create_cubetexture gs_cubetexture_create gs_create_volumetexture gs_voltexture_create gs_create_zstencil gs_zstencil_create gs_create_stagesurface gs_stagesurface_create gs_create_samplerstate gs_samplerstate_create gs_create_vertexshader gs_vertexshader_create gs_create_pixelshader gs_pixelshader_create gs_create_vertexbuffer gs_vertexbuffer_create gs_create_indexbuffer gs_indexbuffer_create gs_gettexturetype gs_get_texture_type gs_load_defaultsamplerstate gs_load_default_samplerstate gs_getvertexshader gs_get_vertex_shader gs_getpixelshader gs_get_pixel_shader gs_getrendertarget gs_get_render_target gs_getzstenciltarget gs_get_zstencil_target gs_setrendertarget gs_set_render_target gs_setcuberendertarget gs_set_cube_render_target gs_beginscene gs_begin_scene gs_draw gs_draw gs_endscene gs_end_scene gs_setcullmode gs_set_cull_mode gs_getcullmode gs_get_cull_mode gs_enable_depthtest gs_enable_depth_test gs_enable_stenciltest gs_enable_stencil_test gs_enable_stencilwrite gs_enable_stencil_write gs_blendfunction gs_blend_function gs_depthfunction gs_depth_function gs_stencilfunction gs_stencil_function gs_stencilop gs_stencil_op gs_setviewport gs_set_viewport gs_getviewport gs_get_viewport gs_setscissorrect gs_set_scissor_rect gs_create_texture_from_iosurface gs_texture_create_from_iosurface gs_create_gdi_texture gs_texture_create_gdi gs_is_compressed_format gs_is_compressed_format gs_num_total_levels gs_get_total_levels texture_setimage gs_texture_set_image cubetexture_setimage gs_cubetexture_set_image swapchain_destroy gs_swapchain_destroy texture_destroy gs_texture_destroy texture_getwidth gs_texture_get_width texture_getheight gs_texture_get_height texture_getcolorformat gs_texture_get_color_format texture_map gs_texture_map texture_unmap gs_texture_unmap texture_isrect gs_texture_is_rect texture_getobj gs_texture_get_obj cubetexture_destroy gs_cubetexture_destroy cubetexture_getsize gs_cubetexture_get_size cubetexture_getcolorformat gs_cubetexture_get_color_format volumetexture_destroy gs_voltexture_destroy volumetexture_getwidth gs_voltexture_get_width volumetexture_getheight gs_voltexture_get_height volumetexture_getdepth gs_voltexture_getdepth volumetexture_getcolorformat gs_voltexture_get_color_format stagesurface_destroy gs_stagesurface_destroy stagesurface_getwidth gs_stagesurface_get_width stagesurface_getheight gs_stagesurface_get_height stagesurface_getcolorformat gs_stagesurface_get_color_format stagesurface_map gs_stagesurface_map stagesurface_unmap gs_stagesurface_unmap zstencil_destroy gs_zstencil_destroy samplerstate_destroy gs_samplerstate_destroy vertexbuffer_destroy gs_vertexbuffer_destroy vertexbuffer_flush gs_vertexbuffer_flush vertexbuffer_getdata gs_vertexbuffer_get_data indexbuffer_destroy gs_indexbuffer_destroy indexbuffer_flush gs_indexbuffer_flush indexbuffer_getdata gs_indexbuffer_get_data indexbuffer_numindices gs_indexbuffer_get_num_indices indexbuffer_gettype gs_indexbuffer_get_type texture_rebind_iosurface gs_texture_rebind_iosurface texture_get_dc gs_texture_get_dc texture_release_dc gs_texture_release_dc
2014-08-07 23:42:07 -07:00
gs_shader_type type;
vector<gs_shader_param> params;
ComPtr<ID3D11Buffer> constants;
size_t constantSize;
2013-09-30 19:37:13 -07:00
D3D11_BUFFER_DESC bd = {};
vector<uint8_t> data;
(API Change) Improve graphics API consistency Summary: - Prefix all graphics subsystem names with gs_ or GS_ - Unsquish funciton names (for example _setfloat to _set_float) - Changed create functions to be more consistent with the rest of the API elsewhere. For exmaple, instead of gs_create_texture/gs_texture_destroy, it's now gs_texture_create/gs_texture_destroy - Renamed gs_stencil_op enum to gs_stencil_op_type From: To: ----------------------------------------------------------- tvertarray gs_tvertarray vb_data gs_vb_data vbdata_create gs_vbdata_create vbdata_destroy gs_vbdata_destroy shader_param gs_shader_param gs_effect gs_effect effect_technique gs_effect_technique effect_pass gs_effect_pass effect_param gs_effect_param texture_t gs_texture_t stagesurf_t gs_stagesurf_t zstencil_t gs_zstencil_t vertbuffer_t gs_vertbuffer_t indexbuffer_t gs_indexbuffer_t samplerstate_t gs_samplerstate_t swapchain_t gs_swapchain_t texrender_t gs_texrender_t shader_t gs_shader_t sparam_t gs_sparam_t effect_t gs_effect_t technique_t gs_technique_t eparam_t gs_eparam_t device_t gs_device_t graphics_t graphics_t shader_param_type gs_shader_param_type SHADER_PARAM_UNKNOWN GS_SHADER_PARAM_UNKNOWN SHADER_PARAM_BOOL GS_SHADER_PARAM_BOOL SHADER_PARAM_FLOAT GS_SHADER_PARAM_FLOAT SHADER_PARAM_INT GS_SHADER_PARAM_INT SHADER_PARAM_STRING GS_SHADER_PARAM_STRING SHADER_PARAM_VEC2 GS_SHADER_PARAM_VEC2 SHADER_PARAM_VEC3 GS_SHADER_PARAM_VEC3 SHADER_PARAM_VEC4 GS_SHADER_PARAM_VEC4 SHADER_PARAM_MATRIX4X4 GS_SHADER_PARAM_MATRIX4X4 SHADER_PARAM_TEXTURE GS_SHADER_PARAM_TEXTURE shader_param_info gs_shader_param_info shader_type gs_shader_type SHADER_VERTEX GS_SHADER_VERTEX SHADER_PIXEL GS_SHADER_PIXEL shader_destroy gs_shader_destroy shader_numparams gs_shader_get_num_params shader_getparambyidx gs_shader_get_param_by_idx shader_getparambyname gs_shader_get_param_by_name shader_getviewprojmatrix gs_shader_get_viewproj_matrix shader_getworldmatrix gs_shader_get_world_matrix shader_getparaminfo gs_shader_get_param_info shader_setbool gs_shader_set_bool shader_setfloat gs_shader_set_float shader_setint gs_shader_set_int shader_setmatrix3 gs_shader_setmatrix3 shader_setmatrix4 gs_shader_set_matrix4 shader_setvec2 gs_shader_set_vec2 shader_setvec3 gs_shader_set_vec3 shader_setvec4 gs_shader_set_vec4 shader_settexture gs_shader_set_texture shader_setval gs_shader_set_val shader_setdefault gs_shader_set_default effect_property_type gs_effect_property_type EFFECT_NONE GS_EFFECT_NONE EFFECT_BOOL GS_EFFECT_BOOL EFFECT_FLOAT GS_EFFECT_FLOAT EFFECT_COLOR GS_EFFECT_COLOR EFFECT_TEXTURE GS_EFFECT_TEXTURE effect_param_info gs_effect_param_info effect_destroy gs_effect_destroy effect_gettechnique gs_effect_get_technique technique_begin gs_technique_begin technique_end gs_technique_end technique_beginpass gs_technique_begin_pass technique_beginpassbyname gs_technique_begin_pass_by_name technique_endpass gs_technique_end_pass effect_numparams gs_effect_get_num_params effect_getparambyidx gs_effect_get_param_by_idx effect_getparambyname gs_effect_get_param_by_name effect_updateparams gs_effect_update_params effect_getviewprojmatrix gs_effect_get_viewproj_matrix effect_getworldmatrix gs_effect_get_world_matrix effect_getparaminfo gs_effect_get_param_info effect_setbool gs_effect_set_bool effect_setfloat gs_effect_set_float effect_setint gs_effect_set_int effect_setmatrix4 gs_effect_set_matrix4 effect_setvec2 gs_effect_set_vec2 effect_setvec3 gs_effect_set_vec3 effect_setvec4 gs_effect_set_vec4 effect_settexture gs_effect_set_texture effect_setval gs_effect_set_val effect_setdefault gs_effect_set_default texrender_create gs_texrender_create texrender_destroy gs_texrender_destroy texrender_begin gs_texrender_begin texrender_end gs_texrender_end texrender_reset gs_texrender_reset texrender_gettexture gs_texrender_get_texture GS_BUILDMIPMAPS GS_BUILD_MIPMAPS GS_RENDERTARGET GS_RENDER_TARGET gs_device_name gs_get_device_name gs_device_type gs_get_device_type gs_entercontext gs_enter_context gs_leavecontext gs_leave_context gs_getcontext gs_get_context gs_renderstart gs_render_start gs_renderstop gs_render_stop gs_rendersave gs_render_save gs_getinput gs_get_input gs_geteffect gs_get_effect gs_create_effect_from_file gs_effect_create_from_file gs_create_effect gs_effect_create gs_create_vertexshader_from_file gs_vertexshader_create_from_file gs_create_pixelshader_from_file gs_pixelshader_create_from_file gs_create_texture_from_file gs_texture_create_from_file gs_resetviewport gs_reset_viewport gs_set2dmode gs_set_2d_mode gs_set3dmode gs_set_3d_mode gs_create_swapchain gs_swapchain_create gs_getsize gs_get_size gs_getwidth gs_get_width gs_getheight gs_get_height gs_create_texture gs_texture_create gs_create_cubetexture gs_cubetexture_create gs_create_volumetexture gs_voltexture_create gs_create_zstencil gs_zstencil_create gs_create_stagesurface gs_stagesurface_create gs_create_samplerstate gs_samplerstate_create gs_create_vertexshader gs_vertexshader_create gs_create_pixelshader gs_pixelshader_create gs_create_vertexbuffer gs_vertexbuffer_create gs_create_indexbuffer gs_indexbuffer_create gs_gettexturetype gs_get_texture_type gs_load_defaultsamplerstate gs_load_default_samplerstate gs_getvertexshader gs_get_vertex_shader gs_getpixelshader gs_get_pixel_shader gs_getrendertarget gs_get_render_target gs_getzstenciltarget gs_get_zstencil_target gs_setrendertarget gs_set_render_target gs_setcuberendertarget gs_set_cube_render_target gs_beginscene gs_begin_scene gs_draw gs_draw gs_endscene gs_end_scene gs_setcullmode gs_set_cull_mode gs_getcullmode gs_get_cull_mode gs_enable_depthtest gs_enable_depth_test gs_enable_stenciltest gs_enable_stencil_test gs_enable_stencilwrite gs_enable_stencil_write gs_blendfunction gs_blend_function gs_depthfunction gs_depth_function gs_stencilfunction gs_stencil_function gs_stencilop gs_stencil_op gs_setviewport gs_set_viewport gs_getviewport gs_get_viewport gs_setscissorrect gs_set_scissor_rect gs_create_texture_from_iosurface gs_texture_create_from_iosurface gs_create_gdi_texture gs_texture_create_gdi gs_is_compressed_format gs_is_compressed_format gs_num_total_levels gs_get_total_levels texture_setimage gs_texture_set_image cubetexture_setimage gs_cubetexture_set_image swapchain_destroy gs_swapchain_destroy texture_destroy gs_texture_destroy texture_getwidth gs_texture_get_width texture_getheight gs_texture_get_height texture_getcolorformat gs_texture_get_color_format texture_map gs_texture_map texture_unmap gs_texture_unmap texture_isrect gs_texture_is_rect texture_getobj gs_texture_get_obj cubetexture_destroy gs_cubetexture_destroy cubetexture_getsize gs_cubetexture_get_size cubetexture_getcolorformat gs_cubetexture_get_color_format volumetexture_destroy gs_voltexture_destroy volumetexture_getwidth gs_voltexture_get_width volumetexture_getheight gs_voltexture_get_height volumetexture_getdepth gs_voltexture_getdepth volumetexture_getcolorformat gs_voltexture_get_color_format stagesurface_destroy gs_stagesurface_destroy stagesurface_getwidth gs_stagesurface_get_width stagesurface_getheight gs_stagesurface_get_height stagesurface_getcolorformat gs_stagesurface_get_color_format stagesurface_map gs_stagesurface_map stagesurface_unmap gs_stagesurface_unmap zstencil_destroy gs_zstencil_destroy samplerstate_destroy gs_samplerstate_destroy vertexbuffer_destroy gs_vertexbuffer_destroy vertexbuffer_flush gs_vertexbuffer_flush vertexbuffer_getdata gs_vertexbuffer_get_data indexbuffer_destroy gs_indexbuffer_destroy indexbuffer_flush gs_indexbuffer_flush indexbuffer_getdata gs_indexbuffer_get_data indexbuffer_numindices gs_indexbuffer_get_num_indices indexbuffer_gettype gs_indexbuffer_get_type texture_rebind_iosurface gs_texture_rebind_iosurface texture_get_dc gs_texture_get_dc texture_release_dc gs_texture_release_dc
2014-08-07 23:42:07 -07:00
inline void UpdateParam(vector<uint8_t> &constData,
gs_shader_param &param, bool &upload);
2013-09-30 19:37:13 -07:00
void UploadParams();
void BuildConstantBuffer();
void Compile(const char *shaderStr, const char *file,
const char *target, ID3D10Blob **shader);
inline gs_shader(gs_device_t *device, gs_type obj_type,
gs_shader_type type)
: gs_obj (device, obj_type),
2013-09-30 19:37:13 -07:00
type (type),
constantSize (0)
{
}
virtual ~gs_shader() {}
};
struct ShaderSampler {
string name;
gs_sampler_state sampler;
inline ShaderSampler(const char *name, gs_device_t *device,
2013-09-30 19:37:13 -07:00
gs_sampler_info *info)
: name (name),
sampler (device, info)
{
}
};
struct gs_vertex_shader : gs_shader {
ComPtr<ID3D11VertexShader> shader;
ComPtr<ID3D11InputLayout> layout;
(API Change) Improve graphics API consistency Summary: - Prefix all graphics subsystem names with gs_ or GS_ - Unsquish funciton names (for example _setfloat to _set_float) - Changed create functions to be more consistent with the rest of the API elsewhere. For exmaple, instead of gs_create_texture/gs_texture_destroy, it's now gs_texture_create/gs_texture_destroy - Renamed gs_stencil_op enum to gs_stencil_op_type From: To: ----------------------------------------------------------- tvertarray gs_tvertarray vb_data gs_vb_data vbdata_create gs_vbdata_create vbdata_destroy gs_vbdata_destroy shader_param gs_shader_param gs_effect gs_effect effect_technique gs_effect_technique effect_pass gs_effect_pass effect_param gs_effect_param texture_t gs_texture_t stagesurf_t gs_stagesurf_t zstencil_t gs_zstencil_t vertbuffer_t gs_vertbuffer_t indexbuffer_t gs_indexbuffer_t samplerstate_t gs_samplerstate_t swapchain_t gs_swapchain_t texrender_t gs_texrender_t shader_t gs_shader_t sparam_t gs_sparam_t effect_t gs_effect_t technique_t gs_technique_t eparam_t gs_eparam_t device_t gs_device_t graphics_t graphics_t shader_param_type gs_shader_param_type SHADER_PARAM_UNKNOWN GS_SHADER_PARAM_UNKNOWN SHADER_PARAM_BOOL GS_SHADER_PARAM_BOOL SHADER_PARAM_FLOAT GS_SHADER_PARAM_FLOAT SHADER_PARAM_INT GS_SHADER_PARAM_INT SHADER_PARAM_STRING GS_SHADER_PARAM_STRING SHADER_PARAM_VEC2 GS_SHADER_PARAM_VEC2 SHADER_PARAM_VEC3 GS_SHADER_PARAM_VEC3 SHADER_PARAM_VEC4 GS_SHADER_PARAM_VEC4 SHADER_PARAM_MATRIX4X4 GS_SHADER_PARAM_MATRIX4X4 SHADER_PARAM_TEXTURE GS_SHADER_PARAM_TEXTURE shader_param_info gs_shader_param_info shader_type gs_shader_type SHADER_VERTEX GS_SHADER_VERTEX SHADER_PIXEL GS_SHADER_PIXEL shader_destroy gs_shader_destroy shader_numparams gs_shader_get_num_params shader_getparambyidx gs_shader_get_param_by_idx shader_getparambyname gs_shader_get_param_by_name shader_getviewprojmatrix gs_shader_get_viewproj_matrix shader_getworldmatrix gs_shader_get_world_matrix shader_getparaminfo gs_shader_get_param_info shader_setbool gs_shader_set_bool shader_setfloat gs_shader_set_float shader_setint gs_shader_set_int shader_setmatrix3 gs_shader_setmatrix3 shader_setmatrix4 gs_shader_set_matrix4 shader_setvec2 gs_shader_set_vec2 shader_setvec3 gs_shader_set_vec3 shader_setvec4 gs_shader_set_vec4 shader_settexture gs_shader_set_texture shader_setval gs_shader_set_val shader_setdefault gs_shader_set_default effect_property_type gs_effect_property_type EFFECT_NONE GS_EFFECT_NONE EFFECT_BOOL GS_EFFECT_BOOL EFFECT_FLOAT GS_EFFECT_FLOAT EFFECT_COLOR GS_EFFECT_COLOR EFFECT_TEXTURE GS_EFFECT_TEXTURE effect_param_info gs_effect_param_info effect_destroy gs_effect_destroy effect_gettechnique gs_effect_get_technique technique_begin gs_technique_begin technique_end gs_technique_end technique_beginpass gs_technique_begin_pass technique_beginpassbyname gs_technique_begin_pass_by_name technique_endpass gs_technique_end_pass effect_numparams gs_effect_get_num_params effect_getparambyidx gs_effect_get_param_by_idx effect_getparambyname gs_effect_get_param_by_name effect_updateparams gs_effect_update_params effect_getviewprojmatrix gs_effect_get_viewproj_matrix effect_getworldmatrix gs_effect_get_world_matrix effect_getparaminfo gs_effect_get_param_info effect_setbool gs_effect_set_bool effect_setfloat gs_effect_set_float effect_setint gs_effect_set_int effect_setmatrix4 gs_effect_set_matrix4 effect_setvec2 gs_effect_set_vec2 effect_setvec3 gs_effect_set_vec3 effect_setvec4 gs_effect_set_vec4 effect_settexture gs_effect_set_texture effect_setval gs_effect_set_val effect_setdefault gs_effect_set_default texrender_create gs_texrender_create texrender_destroy gs_texrender_destroy texrender_begin gs_texrender_begin texrender_end gs_texrender_end texrender_reset gs_texrender_reset texrender_gettexture gs_texrender_get_texture GS_BUILDMIPMAPS GS_BUILD_MIPMAPS GS_RENDERTARGET GS_RENDER_TARGET gs_device_name gs_get_device_name gs_device_type gs_get_device_type gs_entercontext gs_enter_context gs_leavecontext gs_leave_context gs_getcontext gs_get_context gs_renderstart gs_render_start gs_renderstop gs_render_stop gs_rendersave gs_render_save gs_getinput gs_get_input gs_geteffect gs_get_effect gs_create_effect_from_file gs_effect_create_from_file gs_create_effect gs_effect_create gs_create_vertexshader_from_file gs_vertexshader_create_from_file gs_create_pixelshader_from_file gs_pixelshader_create_from_file gs_create_texture_from_file gs_texture_create_from_file gs_resetviewport gs_reset_viewport gs_set2dmode gs_set_2d_mode gs_set3dmode gs_set_3d_mode gs_create_swapchain gs_swapchain_create gs_getsize gs_get_size gs_getwidth gs_get_width gs_getheight gs_get_height gs_create_texture gs_texture_create gs_create_cubetexture gs_cubetexture_create gs_create_volumetexture gs_voltexture_create gs_create_zstencil gs_zstencil_create gs_create_stagesurface gs_stagesurface_create gs_create_samplerstate gs_samplerstate_create gs_create_vertexshader gs_vertexshader_create gs_create_pixelshader gs_pixelshader_create gs_create_vertexbuffer gs_vertexbuffer_create gs_create_indexbuffer gs_indexbuffer_create gs_gettexturetype gs_get_texture_type gs_load_defaultsamplerstate gs_load_default_samplerstate gs_getvertexshader gs_get_vertex_shader gs_getpixelshader gs_get_pixel_shader gs_getrendertarget gs_get_render_target gs_getzstenciltarget gs_get_zstencil_target gs_setrendertarget gs_set_render_target gs_setcuberendertarget gs_set_cube_render_target gs_beginscene gs_begin_scene gs_draw gs_draw gs_endscene gs_end_scene gs_setcullmode gs_set_cull_mode gs_getcullmode gs_get_cull_mode gs_enable_depthtest gs_enable_depth_test gs_enable_stenciltest gs_enable_stencil_test gs_enable_stencilwrite gs_enable_stencil_write gs_blendfunction gs_blend_function gs_depthfunction gs_depth_function gs_stencilfunction gs_stencil_function gs_stencilop gs_stencil_op gs_setviewport gs_set_viewport gs_getviewport gs_get_viewport gs_setscissorrect gs_set_scissor_rect gs_create_texture_from_iosurface gs_texture_create_from_iosurface gs_create_gdi_texture gs_texture_create_gdi gs_is_compressed_format gs_is_compressed_format gs_num_total_levels gs_get_total_levels texture_setimage gs_texture_set_image cubetexture_setimage gs_cubetexture_set_image swapchain_destroy gs_swapchain_destroy texture_destroy gs_texture_destroy texture_getwidth gs_texture_get_width texture_getheight gs_texture_get_height texture_getcolorformat gs_texture_get_color_format texture_map gs_texture_map texture_unmap gs_texture_unmap texture_isrect gs_texture_is_rect texture_getobj gs_texture_get_obj cubetexture_destroy gs_cubetexture_destroy cubetexture_getsize gs_cubetexture_get_size cubetexture_getcolorformat gs_cubetexture_get_color_format volumetexture_destroy gs_voltexture_destroy volumetexture_getwidth gs_voltexture_get_width volumetexture_getheight gs_voltexture_get_height volumetexture_getdepth gs_voltexture_getdepth volumetexture_getcolorformat gs_voltexture_get_color_format stagesurface_destroy gs_stagesurface_destroy stagesurface_getwidth gs_stagesurface_get_width stagesurface_getheight gs_stagesurface_get_height stagesurface_getcolorformat gs_stagesurface_get_color_format stagesurface_map gs_stagesurface_map stagesurface_unmap gs_stagesurface_unmap zstencil_destroy gs_zstencil_destroy samplerstate_destroy gs_samplerstate_destroy vertexbuffer_destroy gs_vertexbuffer_destroy vertexbuffer_flush gs_vertexbuffer_flush vertexbuffer_getdata gs_vertexbuffer_get_data indexbuffer_destroy gs_indexbuffer_destroy indexbuffer_flush gs_indexbuffer_flush indexbuffer_getdata gs_indexbuffer_get_data indexbuffer_numindices gs_indexbuffer_get_num_indices indexbuffer_gettype gs_indexbuffer_get_type texture_rebind_iosurface gs_texture_rebind_iosurface texture_get_dc gs_texture_get_dc texture_release_dc gs_texture_release_dc
2014-08-07 23:42:07 -07:00
gs_shader_param *world, *viewProj;
2013-09-30 19:37:13 -07:00
vector<D3D11_INPUT_ELEMENT_DESC> layoutData;
2013-09-30 19:37:13 -07:00
bool hasNormals;
bool hasColors;
bool hasTangents;
uint32_t nTexUnits;
libobs-d3d11: Rebuild device and assets if device removed/reset Due to an NVIDIA driver bug with the Windows 10 Anniversary Update, there are an increasingly large number of reports of "Device Removed" errors and TDRs. When this happens, OBS stops outputting all data because all graphics functions are failing, and it appears to just "freeze up" for users. To temporarily alleviate this issue while waiting for it to be fixed, the D3D subsystem can be rebuilt when that happens, all assets can be reloaded to ensure that it can continue functioning (with a minor hiccup in playback). To allow rebuilding the entire D3D subsystem, all objects that contain D3D references must be part of a linked list (with a few exceptions) so we can quickly traverse them all whenever needed, and all data for those resources (static resources primarily, such as shaders, textures, index buffers, vertex buffers) must be stored in RAM so they can be recreated whenever needed. Then if D3D reports a "device removed" or "device reset" error, all D3D references must first be fully released with no stray references; the linked list must be fully traversed until all references are released. Then, the linked list must once again be traversed again, and all those D3D objects must be recreated with the same data and descriptors (which are now saved in each object). Finally, all states need to be reset. After that's complete, the device is able to continue functioning almost as it was before, although the output to recording/stream may get a few green frames due to texture data being reset. This will temporarily alleviate the "Device Removed" issue while waiting for a fix from NVIDIA.
2016-11-03 07:41:23 -07:00
inline void Rebuild(ID3D11Device *dev);
inline void Release()
{
shader.Release();
layout.Release();
constants.Release();
}
2013-09-30 19:37:13 -07:00
inline uint32_t NumBuffersExpected() const
{
uint32_t count = nTexUnits+1;
if (hasNormals) count++;
if (hasColors) count++;
if (hasTangents) count++;
return count;
}
void GetBuffersExpected(const vector<D3D11_INPUT_ELEMENT_DESC> &inputs);
gs_vertex_shader(gs_device_t *device, const char *file,
2013-09-30 19:37:13 -07:00
const char *shaderString);
};
struct gs_duplicator : gs_obj {
ComPtr<IDXGIOutputDuplication> duplicator;
gs_texture_2d *texture;
int idx;
long refs;
bool updated;
void Start();
inline void Release()
{
duplicator.Release();
}
gs_duplicator(gs_device_t *device, int monitor_idx);
~gs_duplicator();
};
2013-09-30 19:37:13 -07:00
struct gs_pixel_shader : gs_shader {
ComPtr<ID3D11PixelShader> shader;
vector<unique_ptr<ShaderSampler>> samplers;
2013-09-30 19:37:13 -07:00
libobs-d3d11: Rebuild device and assets if device removed/reset Due to an NVIDIA driver bug with the Windows 10 Anniversary Update, there are an increasingly large number of reports of "Device Removed" errors and TDRs. When this happens, OBS stops outputting all data because all graphics functions are failing, and it appears to just "freeze up" for users. To temporarily alleviate this issue while waiting for it to be fixed, the D3D subsystem can be rebuilt when that happens, all assets can be reloaded to ensure that it can continue functioning (with a minor hiccup in playback). To allow rebuilding the entire D3D subsystem, all objects that contain D3D references must be part of a linked list (with a few exceptions) so we can quickly traverse them all whenever needed, and all data for those resources (static resources primarily, such as shaders, textures, index buffers, vertex buffers) must be stored in RAM so they can be recreated whenever needed. Then if D3D reports a "device removed" or "device reset" error, all D3D references must first be fully released with no stray references; the linked list must be fully traversed until all references are released. Then, the linked list must once again be traversed again, and all those D3D objects must be recreated with the same data and descriptors (which are now saved in each object). Finally, all states need to be reset. After that's complete, the device is able to continue functioning almost as it was before, although the output to recording/stream may get a few green frames due to texture data being reset. This will temporarily alleviate the "Device Removed" issue while waiting for a fix from NVIDIA.
2016-11-03 07:41:23 -07:00
inline void Rebuild(ID3D11Device *dev);
inline void Release()
{
shader.Release();
constants.Release();
}
2013-09-30 19:37:13 -07:00
inline void GetSamplerStates(ID3D11SamplerState **states)
{
size_t i;
for (i = 0; i < samplers.size(); i++)
states[i] = samplers[i]->sampler.state;
for (; i < GS_MAX_TEXTURES; i++)
2013-09-30 19:37:13 -07:00
states[i] = NULL;
}
gs_pixel_shader(gs_device_t *device, const char *file,
2013-09-30 19:37:13 -07:00
const char *shaderString);
};
struct gs_swap_chain : gs_obj {
2013-09-30 19:37:13 -07:00
uint32_t numBuffers;
HWND hwnd;
gs_init_data initData;
DXGI_SWAP_CHAIN_DESC swapDesc = {};
2013-09-30 19:37:13 -07:00
gs_texture_2d target;
gs_zstencil_buffer zs;
ComPtr<IDXGISwapChain> swap;
void InitTarget(uint32_t cx, uint32_t cy);
void InitZStencilBuffer(uint32_t cx, uint32_t cy);
void Resize(uint32_t cx, uint32_t cy);
void Init();
2013-09-30 19:37:13 -07:00
libobs-d3d11: Rebuild device and assets if device removed/reset Due to an NVIDIA driver bug with the Windows 10 Anniversary Update, there are an increasingly large number of reports of "Device Removed" errors and TDRs. When this happens, OBS stops outputting all data because all graphics functions are failing, and it appears to just "freeze up" for users. To temporarily alleviate this issue while waiting for it to be fixed, the D3D subsystem can be rebuilt when that happens, all assets can be reloaded to ensure that it can continue functioning (with a minor hiccup in playback). To allow rebuilding the entire D3D subsystem, all objects that contain D3D references must be part of a linked list (with a few exceptions) so we can quickly traverse them all whenever needed, and all data for those resources (static resources primarily, such as shaders, textures, index buffers, vertex buffers) must be stored in RAM so they can be recreated whenever needed. Then if D3D reports a "device removed" or "device reset" error, all D3D references must first be fully released with no stray references; the linked list must be fully traversed until all references are released. Then, the linked list must once again be traversed again, and all those D3D objects must be recreated with the same data and descriptors (which are now saved in each object). Finally, all states need to be reset. After that's complete, the device is able to continue functioning almost as it was before, although the output to recording/stream may get a few green frames due to texture data being reset. This will temporarily alleviate the "Device Removed" issue while waiting for a fix from NVIDIA.
2016-11-03 07:41:23 -07:00
inline void Rebuild(ID3D11Device *dev);
inline void Release()
{
target.Release();
zs.Release();
swap.Release();
}
gs_swap_chain(gs_device *device, const gs_init_data *data);
2013-09-30 19:37:13 -07:00
};
struct BlendState {
bool blendEnabled;
gs_blend_type srcFactorC;
gs_blend_type destFactorC;
gs_blend_type srcFactorA;
gs_blend_type destFactorA;
2013-09-30 19:37:13 -07:00
bool redEnabled;
bool greenEnabled;
bool blueEnabled;
bool alphaEnabled;
inline BlendState()
: blendEnabled (true),
srcFactorC (GS_BLEND_SRCALPHA),
destFactorC (GS_BLEND_INVSRCALPHA),
srcFactorA (GS_BLEND_ONE),
destFactorA (GS_BLEND_ONE),
2013-09-30 19:37:13 -07:00
redEnabled (true),
greenEnabled (true),
blueEnabled (true),
alphaEnabled (true)
{
}
inline BlendState(const BlendState &state)
{
memcpy(this, &state, sizeof(BlendState));
}
};
struct SavedBlendState : BlendState {
ComPtr<ID3D11BlendState> state;
D3D11_BLEND_DESC bd;
2013-09-30 19:37:13 -07:00
libobs-d3d11: Rebuild device and assets if device removed/reset Due to an NVIDIA driver bug with the Windows 10 Anniversary Update, there are an increasingly large number of reports of "Device Removed" errors and TDRs. When this happens, OBS stops outputting all data because all graphics functions are failing, and it appears to just "freeze up" for users. To temporarily alleviate this issue while waiting for it to be fixed, the D3D subsystem can be rebuilt when that happens, all assets can be reloaded to ensure that it can continue functioning (with a minor hiccup in playback). To allow rebuilding the entire D3D subsystem, all objects that contain D3D references must be part of a linked list (with a few exceptions) so we can quickly traverse them all whenever needed, and all data for those resources (static resources primarily, such as shaders, textures, index buffers, vertex buffers) must be stored in RAM so they can be recreated whenever needed. Then if D3D reports a "device removed" or "device reset" error, all D3D references must first be fully released with no stray references; the linked list must be fully traversed until all references are released. Then, the linked list must once again be traversed again, and all those D3D objects must be recreated with the same data and descriptors (which are now saved in each object). Finally, all states need to be reset. After that's complete, the device is able to continue functioning almost as it was before, although the output to recording/stream may get a few green frames due to texture data being reset. This will temporarily alleviate the "Device Removed" issue while waiting for a fix from NVIDIA.
2016-11-03 07:41:23 -07:00
inline void Rebuild(ID3D11Device *dev);
inline void Release()
{
state.Release();
}
inline SavedBlendState(const BlendState &val, D3D11_BLEND_DESC &desc)
: BlendState(val), bd(desc)
2013-09-30 19:37:13 -07:00
{
}
};
struct StencilSide {
gs_depth_test test;
(API Change) Improve graphics API consistency Summary: - Prefix all graphics subsystem names with gs_ or GS_ - Unsquish funciton names (for example _setfloat to _set_float) - Changed create functions to be more consistent with the rest of the API elsewhere. For exmaple, instead of gs_create_texture/gs_texture_destroy, it's now gs_texture_create/gs_texture_destroy - Renamed gs_stencil_op enum to gs_stencil_op_type From: To: ----------------------------------------------------------- tvertarray gs_tvertarray vb_data gs_vb_data vbdata_create gs_vbdata_create vbdata_destroy gs_vbdata_destroy shader_param gs_shader_param gs_effect gs_effect effect_technique gs_effect_technique effect_pass gs_effect_pass effect_param gs_effect_param texture_t gs_texture_t stagesurf_t gs_stagesurf_t zstencil_t gs_zstencil_t vertbuffer_t gs_vertbuffer_t indexbuffer_t gs_indexbuffer_t samplerstate_t gs_samplerstate_t swapchain_t gs_swapchain_t texrender_t gs_texrender_t shader_t gs_shader_t sparam_t gs_sparam_t effect_t gs_effect_t technique_t gs_technique_t eparam_t gs_eparam_t device_t gs_device_t graphics_t graphics_t shader_param_type gs_shader_param_type SHADER_PARAM_UNKNOWN GS_SHADER_PARAM_UNKNOWN SHADER_PARAM_BOOL GS_SHADER_PARAM_BOOL SHADER_PARAM_FLOAT GS_SHADER_PARAM_FLOAT SHADER_PARAM_INT GS_SHADER_PARAM_INT SHADER_PARAM_STRING GS_SHADER_PARAM_STRING SHADER_PARAM_VEC2 GS_SHADER_PARAM_VEC2 SHADER_PARAM_VEC3 GS_SHADER_PARAM_VEC3 SHADER_PARAM_VEC4 GS_SHADER_PARAM_VEC4 SHADER_PARAM_MATRIX4X4 GS_SHADER_PARAM_MATRIX4X4 SHADER_PARAM_TEXTURE GS_SHADER_PARAM_TEXTURE shader_param_info gs_shader_param_info shader_type gs_shader_type SHADER_VERTEX GS_SHADER_VERTEX SHADER_PIXEL GS_SHADER_PIXEL shader_destroy gs_shader_destroy shader_numparams gs_shader_get_num_params shader_getparambyidx gs_shader_get_param_by_idx shader_getparambyname gs_shader_get_param_by_name shader_getviewprojmatrix gs_shader_get_viewproj_matrix shader_getworldmatrix gs_shader_get_world_matrix shader_getparaminfo gs_shader_get_param_info shader_setbool gs_shader_set_bool shader_setfloat gs_shader_set_float shader_setint gs_shader_set_int shader_setmatrix3 gs_shader_setmatrix3 shader_setmatrix4 gs_shader_set_matrix4 shader_setvec2 gs_shader_set_vec2 shader_setvec3 gs_shader_set_vec3 shader_setvec4 gs_shader_set_vec4 shader_settexture gs_shader_set_texture shader_setval gs_shader_set_val shader_setdefault gs_shader_set_default effect_property_type gs_effect_property_type EFFECT_NONE GS_EFFECT_NONE EFFECT_BOOL GS_EFFECT_BOOL EFFECT_FLOAT GS_EFFECT_FLOAT EFFECT_COLOR GS_EFFECT_COLOR EFFECT_TEXTURE GS_EFFECT_TEXTURE effect_param_info gs_effect_param_info effect_destroy gs_effect_destroy effect_gettechnique gs_effect_get_technique technique_begin gs_technique_begin technique_end gs_technique_end technique_beginpass gs_technique_begin_pass technique_beginpassbyname gs_technique_begin_pass_by_name technique_endpass gs_technique_end_pass effect_numparams gs_effect_get_num_params effect_getparambyidx gs_effect_get_param_by_idx effect_getparambyname gs_effect_get_param_by_name effect_updateparams gs_effect_update_params effect_getviewprojmatrix gs_effect_get_viewproj_matrix effect_getworldmatrix gs_effect_get_world_matrix effect_getparaminfo gs_effect_get_param_info effect_setbool gs_effect_set_bool effect_setfloat gs_effect_set_float effect_setint gs_effect_set_int effect_setmatrix4 gs_effect_set_matrix4 effect_setvec2 gs_effect_set_vec2 effect_setvec3 gs_effect_set_vec3 effect_setvec4 gs_effect_set_vec4 effect_settexture gs_effect_set_texture effect_setval gs_effect_set_val effect_setdefault gs_effect_set_default texrender_create gs_texrender_create texrender_destroy gs_texrender_destroy texrender_begin gs_texrender_begin texrender_end gs_texrender_end texrender_reset gs_texrender_reset texrender_gettexture gs_texrender_get_texture GS_BUILDMIPMAPS GS_BUILD_MIPMAPS GS_RENDERTARGET GS_RENDER_TARGET gs_device_name gs_get_device_name gs_device_type gs_get_device_type gs_entercontext gs_enter_context gs_leavecontext gs_leave_context gs_getcontext gs_get_context gs_renderstart gs_render_start gs_renderstop gs_render_stop gs_rendersave gs_render_save gs_getinput gs_get_input gs_geteffect gs_get_effect gs_create_effect_from_file gs_effect_create_from_file gs_create_effect gs_effect_create gs_create_vertexshader_from_file gs_vertexshader_create_from_file gs_create_pixelshader_from_file gs_pixelshader_create_from_file gs_create_texture_from_file gs_texture_create_from_file gs_resetviewport gs_reset_viewport gs_set2dmode gs_set_2d_mode gs_set3dmode gs_set_3d_mode gs_create_swapchain gs_swapchain_create gs_getsize gs_get_size gs_getwidth gs_get_width gs_getheight gs_get_height gs_create_texture gs_texture_create gs_create_cubetexture gs_cubetexture_create gs_create_volumetexture gs_voltexture_create gs_create_zstencil gs_zstencil_create gs_create_stagesurface gs_stagesurface_create gs_create_samplerstate gs_samplerstate_create gs_create_vertexshader gs_vertexshader_create gs_create_pixelshader gs_pixelshader_create gs_create_vertexbuffer gs_vertexbuffer_create gs_create_indexbuffer gs_indexbuffer_create gs_gettexturetype gs_get_texture_type gs_load_defaultsamplerstate gs_load_default_samplerstate gs_getvertexshader gs_get_vertex_shader gs_getpixelshader gs_get_pixel_shader gs_getrendertarget gs_get_render_target gs_getzstenciltarget gs_get_zstencil_target gs_setrendertarget gs_set_render_target gs_setcuberendertarget gs_set_cube_render_target gs_beginscene gs_begin_scene gs_draw gs_draw gs_endscene gs_end_scene gs_setcullmode gs_set_cull_mode gs_getcullmode gs_get_cull_mode gs_enable_depthtest gs_enable_depth_test gs_enable_stenciltest gs_enable_stencil_test gs_enable_stencilwrite gs_enable_stencil_write gs_blendfunction gs_blend_function gs_depthfunction gs_depth_function gs_stencilfunction gs_stencil_function gs_stencilop gs_stencil_op gs_setviewport gs_set_viewport gs_getviewport gs_get_viewport gs_setscissorrect gs_set_scissor_rect gs_create_texture_from_iosurface gs_texture_create_from_iosurface gs_create_gdi_texture gs_texture_create_gdi gs_is_compressed_format gs_is_compressed_format gs_num_total_levels gs_get_total_levels texture_setimage gs_texture_set_image cubetexture_setimage gs_cubetexture_set_image swapchain_destroy gs_swapchain_destroy texture_destroy gs_texture_destroy texture_getwidth gs_texture_get_width texture_getheight gs_texture_get_height texture_getcolorformat gs_texture_get_color_format texture_map gs_texture_map texture_unmap gs_texture_unmap texture_isrect gs_texture_is_rect texture_getobj gs_texture_get_obj cubetexture_destroy gs_cubetexture_destroy cubetexture_getsize gs_cubetexture_get_size cubetexture_getcolorformat gs_cubetexture_get_color_format volumetexture_destroy gs_voltexture_destroy volumetexture_getwidth gs_voltexture_get_width volumetexture_getheight gs_voltexture_get_height volumetexture_getdepth gs_voltexture_getdepth volumetexture_getcolorformat gs_voltexture_get_color_format stagesurface_destroy gs_stagesurface_destroy stagesurface_getwidth gs_stagesurface_get_width stagesurface_getheight gs_stagesurface_get_height stagesurface_getcolorformat gs_stagesurface_get_color_format stagesurface_map gs_stagesurface_map stagesurface_unmap gs_stagesurface_unmap zstencil_destroy gs_zstencil_destroy samplerstate_destroy gs_samplerstate_destroy vertexbuffer_destroy gs_vertexbuffer_destroy vertexbuffer_flush gs_vertexbuffer_flush vertexbuffer_getdata gs_vertexbuffer_get_data indexbuffer_destroy gs_indexbuffer_destroy indexbuffer_flush gs_indexbuffer_flush indexbuffer_getdata gs_indexbuffer_get_data indexbuffer_numindices gs_indexbuffer_get_num_indices indexbuffer_gettype gs_indexbuffer_get_type texture_rebind_iosurface gs_texture_rebind_iosurface texture_get_dc gs_texture_get_dc texture_release_dc gs_texture_release_dc
2014-08-07 23:42:07 -07:00
gs_stencil_op_type fail;
gs_stencil_op_type zfail;
gs_stencil_op_type zpass;
2013-09-30 19:37:13 -07:00
inline StencilSide()
: test (GS_ALWAYS),
fail (GS_KEEP),
zfail (GS_KEEP),
zpass (GS_KEEP)
{
}
};
struct ZStencilState {
bool depthEnabled;
bool depthWriteEnabled;
gs_depth_test depthFunc;
bool stencilEnabled;
bool stencilWriteEnabled;
StencilSide stencilFront;
StencilSide stencilBack;
inline ZStencilState()
: depthEnabled (true),
depthWriteEnabled (true),
depthFunc (GS_LESS),
stencilEnabled (false),
stencilWriteEnabled (true)
{
}
inline ZStencilState(const ZStencilState &state)
{
memcpy(this, &state, sizeof(ZStencilState));
}
};
struct SavedZStencilState : ZStencilState {
ComPtr<ID3D11DepthStencilState> state;
D3D11_DEPTH_STENCIL_DESC dsd;
2013-09-30 19:37:13 -07:00
libobs-d3d11: Rebuild device and assets if device removed/reset Due to an NVIDIA driver bug with the Windows 10 Anniversary Update, there are an increasingly large number of reports of "Device Removed" errors and TDRs. When this happens, OBS stops outputting all data because all graphics functions are failing, and it appears to just "freeze up" for users. To temporarily alleviate this issue while waiting for it to be fixed, the D3D subsystem can be rebuilt when that happens, all assets can be reloaded to ensure that it can continue functioning (with a minor hiccup in playback). To allow rebuilding the entire D3D subsystem, all objects that contain D3D references must be part of a linked list (with a few exceptions) so we can quickly traverse them all whenever needed, and all data for those resources (static resources primarily, such as shaders, textures, index buffers, vertex buffers) must be stored in RAM so they can be recreated whenever needed. Then if D3D reports a "device removed" or "device reset" error, all D3D references must first be fully released with no stray references; the linked list must be fully traversed until all references are released. Then, the linked list must once again be traversed again, and all those D3D objects must be recreated with the same data and descriptors (which are now saved in each object). Finally, all states need to be reset. After that's complete, the device is able to continue functioning almost as it was before, although the output to recording/stream may get a few green frames due to texture data being reset. This will temporarily alleviate the "Device Removed" issue while waiting for a fix from NVIDIA.
2016-11-03 07:41:23 -07:00
inline void Rebuild(ID3D11Device *dev);
inline void Release()
{
state.Release();
}
inline SavedZStencilState(const ZStencilState &val,
D3D11_DEPTH_STENCIL_DESC desc)
: ZStencilState (val),
dsd (desc)
2013-09-30 19:37:13 -07:00
{
}
};
struct RasterState {
gs_cull_mode cullMode;
bool scissorEnabled;
inline RasterState()
: cullMode (GS_BACK),
scissorEnabled (false)
{
}
inline RasterState(const RasterState &state)
{
memcpy(this, &state, sizeof(RasterState));
}
};
struct SavedRasterState : RasterState {
ComPtr<ID3D11RasterizerState> state;
D3D11_RASTERIZER_DESC rd;
2013-09-30 19:37:13 -07:00
libobs-d3d11: Rebuild device and assets if device removed/reset Due to an NVIDIA driver bug with the Windows 10 Anniversary Update, there are an increasingly large number of reports of "Device Removed" errors and TDRs. When this happens, OBS stops outputting all data because all graphics functions are failing, and it appears to just "freeze up" for users. To temporarily alleviate this issue while waiting for it to be fixed, the D3D subsystem can be rebuilt when that happens, all assets can be reloaded to ensure that it can continue functioning (with a minor hiccup in playback). To allow rebuilding the entire D3D subsystem, all objects that contain D3D references must be part of a linked list (with a few exceptions) so we can quickly traverse them all whenever needed, and all data for those resources (static resources primarily, such as shaders, textures, index buffers, vertex buffers) must be stored in RAM so they can be recreated whenever needed. Then if D3D reports a "device removed" or "device reset" error, all D3D references must first be fully released with no stray references; the linked list must be fully traversed until all references are released. Then, the linked list must once again be traversed again, and all those D3D objects must be recreated with the same data and descriptors (which are now saved in each object). Finally, all states need to be reset. After that's complete, the device is able to continue functioning almost as it was before, although the output to recording/stream may get a few green frames due to texture data being reset. This will temporarily alleviate the "Device Removed" issue while waiting for a fix from NVIDIA.
2016-11-03 07:41:23 -07:00
inline void Rebuild(ID3D11Device *dev);
inline void Release()
{
state.Release();
}
inline SavedRasterState(const RasterState &val,
D3D11_RASTERIZER_DESC &desc)
: RasterState (val),
rd (desc)
2013-09-30 19:37:13 -07:00
{
}
};
struct mat4float {
float mat[16];
};
struct gs_device {
ComPtr<IDXGIFactory1> factory;
ComPtr<IDXGIAdapter1> adapter;
2013-09-30 19:37:13 -07:00
ComPtr<ID3D11Device> device;
ComPtr<ID3D11DeviceContext> context;
uint32_t adpIdx = 0;
2013-09-30 19:37:13 -07:00
gs_texture_2d *curRenderTarget = nullptr;
gs_zstencil_buffer *curZStencilBuffer = nullptr;
int curRenderSide = 0;
gs_texture *curTextures[GS_MAX_TEXTURES];
gs_sampler_state *curSamplers[GS_MAX_TEXTURES];
gs_vertex_buffer *curVertexBuffer = nullptr;
gs_index_buffer *curIndexBuffer = nullptr;
gs_vertex_shader *curVertexShader = nullptr;
gs_pixel_shader *curPixelShader = nullptr;
gs_swap_chain *curSwapChain = nullptr;
2013-09-30 19:37:13 -07:00
gs_vertex_buffer *lastVertexBuffer = nullptr;
gs_vertex_shader *lastVertexShader = nullptr;
bool zstencilStateChanged = true;
bool rasterStateChanged = true;
bool blendStateChanged = true;
2013-09-30 19:37:13 -07:00
ZStencilState zstencilState;
RasterState rasterState;
BlendState blendState;
vector<SavedZStencilState> zstencilStates;
vector<SavedRasterState> rasterStates;
vector<SavedBlendState> blendStates;
ID3D11DepthStencilState *curDepthStencilState = nullptr;
ID3D11RasterizerState *curRasterState = nullptr;
ID3D11BlendState *curBlendState = nullptr;
2013-09-30 19:37:13 -07:00
D3D11_PRIMITIVE_TOPOLOGY curToplogy;
pD3DCompile d3dCompile = nullptr;
#ifdef DISASSEMBLE_SHADERS
pD3DDisassemble d3dDisassemble = nullptr;
#endif
2013-09-30 19:37:13 -07:00
gs_rect viewport;
vector<mat4float> projStack;
matrix4 curProjMatrix;
matrix4 curViewMatrix;
matrix4 curViewProjMatrix;
gs_obj *first_obj = nullptr;
void InitCompiler();
void InitFactory(uint32_t adapterIdx);
void InitDevice(uint32_t adapterIdx);
2013-09-30 19:37:13 -07:00
ID3D11DepthStencilState *AddZStencilState();
ID3D11RasterizerState *AddRasterState();
ID3D11BlendState *AddBlendState();
void UpdateZStencilState();
void UpdateRasterState();
void UpdateBlendState();
void LoadVertexBufferData();
inline void CopyTex(ID3D11Texture2D *dst,
uint32_t dst_x, uint32_t dst_y,
gs_texture_t *src, uint32_t src_x, uint32_t src_y,
uint32_t src_w, uint32_t src_h);
2013-09-30 19:37:13 -07:00
void UpdateViewProjMatrix();
libobs-d3d11: Rebuild device and assets if device removed/reset Due to an NVIDIA driver bug with the Windows 10 Anniversary Update, there are an increasingly large number of reports of "Device Removed" errors and TDRs. When this happens, OBS stops outputting all data because all graphics functions are failing, and it appears to just "freeze up" for users. To temporarily alleviate this issue while waiting for it to be fixed, the D3D subsystem can be rebuilt when that happens, all assets can be reloaded to ensure that it can continue functioning (with a minor hiccup in playback). To allow rebuilding the entire D3D subsystem, all objects that contain D3D references must be part of a linked list (with a few exceptions) so we can quickly traverse them all whenever needed, and all data for those resources (static resources primarily, such as shaders, textures, index buffers, vertex buffers) must be stored in RAM so they can be recreated whenever needed. Then if D3D reports a "device removed" or "device reset" error, all D3D references must first be fully released with no stray references; the linked list must be fully traversed until all references are released. Then, the linked list must once again be traversed again, and all those D3D objects must be recreated with the same data and descriptors (which are now saved in each object). Finally, all states need to be reset. After that's complete, the device is able to continue functioning almost as it was before, although the output to recording/stream may get a few green frames due to texture data being reset. This will temporarily alleviate the "Device Removed" issue while waiting for a fix from NVIDIA.
2016-11-03 07:41:23 -07:00
void RebuildDevice();
gs_device(uint32_t adapterIdx);
~gs_device();
2013-09-30 19:37:13 -07:00
};