(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_dcmaster
parent
50ec8b0d55
commit
5780f3f177
|
@ -37,7 +37,7 @@ void gs_index_buffer::InitBuffer()
|
|||
throw HRError("Failed to create buffer", hr);
|
||||
}
|
||||
|
||||
gs_index_buffer::gs_index_buffer(device_t device, enum gs_index_type type,
|
||||
gs_index_buffer::gs_index_buffer(gs_device_t device, enum gs_index_type type,
|
||||
void *indices, size_t num, uint32_t flags)
|
||||
: device (device),
|
||||
type (type),
|
||||
|
|
|
@ -59,7 +59,7 @@ static inline D3D11_FILTER ConvertGSFilter( gs_sample_filter filter)
|
|||
return D3D11_FILTER_MIN_MAG_MIP_POINT;
|
||||
}
|
||||
|
||||
gs_sampler_state::gs_sampler_state(device_t device, gs_sampler_info *info)
|
||||
gs_sampler_state::gs_sampler_state(gs_device_t device, gs_sampler_info *info)
|
||||
: device (device),
|
||||
info (*info)
|
||||
{
|
||||
|
|
|
@ -38,9 +38,9 @@ void gs_vertex_shader::GetBuffersExpected(
|
|||
}
|
||||
}
|
||||
|
||||
gs_vertex_shader::gs_vertex_shader(device_t device, const char *file,
|
||||
gs_vertex_shader::gs_vertex_shader(gs_device_t device, const char *file,
|
||||
const char *shaderString)
|
||||
: gs_shader (device, SHADER_VERTEX),
|
||||
: gs_shader (device, GS_SHADER_VERTEX),
|
||||
hasNormals (false),
|
||||
hasColors (false),
|
||||
hasTangents (false),
|
||||
|
@ -72,13 +72,13 @@ gs_vertex_shader::gs_vertex_shader(device_t device, const char *file,
|
|||
if (FAILED(hr))
|
||||
throw HRError("Failed to create input layout", hr);
|
||||
|
||||
viewProj = shader_getparambyname(this, "ViewProj");
|
||||
world = shader_getparambyname(this, "World");
|
||||
viewProj = gs_shader_get_param_by_name(this, "ViewProj");
|
||||
world = gs_shader_get_param_by_name(this, "World");
|
||||
}
|
||||
|
||||
gs_pixel_shader::gs_pixel_shader(device_t device, const char *file,
|
||||
gs_pixel_shader::gs_pixel_shader(gs_device_t device, const char *file,
|
||||
const char *shaderString)
|
||||
: gs_shader(device, SHADER_PIXEL)
|
||||
: gs_shader(device, GS_SHADER_PIXEL)
|
||||
{
|
||||
ShaderProcessor processor(device);
|
||||
ComPtr<ID3D10Blob> shaderBlob;
|
||||
|
@ -125,17 +125,17 @@ gs_pixel_shader::gs_pixel_shader(device_t device, const char *file,
|
|||
void gs_shader::BuildConstantBuffer()
|
||||
{
|
||||
for (size_t i = 0; i < params.size(); i++) {
|
||||
shader_param ¶m = params[i];
|
||||
gs_shader_param ¶m = params[i];
|
||||
size_t size = 0;
|
||||
|
||||
switch (param.type) {
|
||||
case SHADER_PARAM_BOOL:
|
||||
case SHADER_PARAM_INT:
|
||||
case SHADER_PARAM_FLOAT: size = sizeof(float); break;
|
||||
case SHADER_PARAM_VEC2: size = sizeof(vec2); break;
|
||||
case SHADER_PARAM_VEC3: size = sizeof(float)*3; break;
|
||||
case SHADER_PARAM_VEC4: size = sizeof(vec4); break;
|
||||
case SHADER_PARAM_MATRIX4X4: size = sizeof(float)*4*4;
|
||||
case GS_SHADER_PARAM_BOOL:
|
||||
case GS_SHADER_PARAM_INT:
|
||||
case GS_SHADER_PARAM_FLOAT: size = sizeof(float); break;
|
||||
case GS_SHADER_PARAM_VEC2: size = sizeof(vec2); break;
|
||||
case GS_SHADER_PARAM_VEC3: size = sizeof(float)*3; break;
|
||||
case GS_SHADER_PARAM_VEC4: size = sizeof(vec4); break;
|
||||
case GS_SHADER_PARAM_MATRIX4X4: size = sizeof(float)*4*4;
|
||||
}
|
||||
|
||||
/* checks to see if this constant needs to start at a new
|
||||
|
@ -168,7 +168,7 @@ void gs_shader::BuildConstantBuffer()
|
|||
}
|
||||
|
||||
for (size_t i = 0; i < params.size(); i++)
|
||||
shader_setdefault(¶ms[i]);
|
||||
gs_shader_set_default(¶ms[i]);
|
||||
}
|
||||
|
||||
void gs_shader::Compile(const char *shaderString, const char *file,
|
||||
|
@ -193,9 +193,9 @@ void gs_shader::Compile(const char *shaderString, const char *file,
|
|||
}
|
||||
|
||||
inline void gs_shader::UpdateParam(vector<uint8_t> &constData,
|
||||
shader_param ¶m, bool &upload)
|
||||
gs_shader_param ¶m, bool &upload)
|
||||
{
|
||||
if (param.type != SHADER_PARAM_TEXTURE) {
|
||||
if (param.type != GS_SHADER_PARAM_TEXTURE) {
|
||||
if (!param.curValue.size())
|
||||
throw "Not all shader parameters were set";
|
||||
|
||||
|
@ -216,9 +216,9 @@ inline void gs_shader::UpdateParam(vector<uint8_t> &constData,
|
|||
upload = true;
|
||||
param.changed = false;
|
||||
}
|
||||
} else if (param.curValue.size() == sizeof(texture_t)) {
|
||||
texture_t tex;
|
||||
memcpy(&tex, param.curValue.data(), sizeof(texture_t));
|
||||
} else if (param.curValue.size() == sizeof(gs_texture_t)) {
|
||||
gs_texture_t tex;
|
||||
memcpy(&tex, param.curValue.data(), sizeof(gs_texture_t));
|
||||
device_load_texture(device, tex, param.textureID);
|
||||
}
|
||||
}
|
||||
|
@ -250,25 +250,25 @@ void gs_shader::UploadParams()
|
|||
}
|
||||
}
|
||||
|
||||
void shader_destroy(shader_t shader)
|
||||
void gs_shader_destroy(gs_shader_t shader)
|
||||
{
|
||||
delete shader;
|
||||
}
|
||||
|
||||
int shader_numparams(shader_t shader)
|
||||
int gs_shader_get_num_params(gs_shader_t shader)
|
||||
{
|
||||
return (int)shader->params.size();
|
||||
}
|
||||
|
||||
sparam_t shader_getparambyidx(shader_t shader, uint32_t param)
|
||||
gs_sparam_t gs_shader_get_param_by_idx(gs_shader_t shader, uint32_t param)
|
||||
{
|
||||
return &shader->params[param];
|
||||
}
|
||||
|
||||
sparam_t shader_getparambyname(shader_t shader, const char *name)
|
||||
gs_sparam_t gs_shader_get_param_by_name(gs_shader_t shader, const char *name)
|
||||
{
|
||||
for (size_t i = 0; i < shader->params.size(); i++) {
|
||||
shader_param ¶m = shader->params[i];
|
||||
gs_shader_param ¶m = shader->params[i];
|
||||
if (strcmp(param.name.c_str(), name) == 0)
|
||||
return ¶m;
|
||||
}
|
||||
|
@ -276,23 +276,24 @@ sparam_t shader_getparambyname(shader_t shader, const char *name)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
sparam_t shader_getviewprojmatrix(shader_t shader)
|
||||
gs_sparam_t gs_shader_get_viewproj_matrix(gs_shader_t shader)
|
||||
{
|
||||
if (shader->type != SHADER_VERTEX)
|
||||
if (shader->type != GS_SHADER_VERTEX)
|
||||
return NULL;
|
||||
|
||||
return static_cast<gs_vertex_shader*>(shader)->viewProj;
|
||||
}
|
||||
|
||||
sparam_t shader_getworldmatrix(shader_t shader)
|
||||
gs_sparam_t gs_shader_get_world_matrix(gs_shader_t shader)
|
||||
{
|
||||
if (shader->type != SHADER_VERTEX)
|
||||
if (shader->type != GS_SHADER_VERTEX)
|
||||
return NULL;
|
||||
|
||||
return static_cast<gs_vertex_shader*>(shader)->world;
|
||||
}
|
||||
|
||||
void shader_getparaminfo(sparam_t param, struct shader_param_info *info)
|
||||
void gs_shader_get_param_info(gs_sparam_t param,
|
||||
struct gs_shader_param_info *info)
|
||||
{
|
||||
if (!param)
|
||||
return;
|
||||
|
@ -301,8 +302,8 @@ void shader_getparaminfo(sparam_t param, struct shader_param_info *info)
|
|||
info->type = param->type;
|
||||
}
|
||||
|
||||
static inline void shader_setval_inline(shader_param *param, const void *data,
|
||||
size_t size)
|
||||
static inline void shader_setval_inline(gs_shader_param *param,
|
||||
const void *data, size_t size)
|
||||
{
|
||||
assert(param);
|
||||
if (!param)
|
||||
|
@ -318,59 +319,59 @@ static inline void shader_setval_inline(shader_param *param, const void *data,
|
|||
}
|
||||
}
|
||||
|
||||
void shader_setbool(sparam_t param, bool val)
|
||||
void gs_shader_set_bool(gs_sparam_t param, bool val)
|
||||
{
|
||||
shader_setval_inline(param, &val, sizeof(bool));
|
||||
}
|
||||
|
||||
void shader_setfloat(sparam_t param, float val)
|
||||
void gs_shader_set_float(gs_sparam_t param, float val)
|
||||
{
|
||||
shader_setval_inline(param, &val, sizeof(float));
|
||||
}
|
||||
|
||||
void shader_setint(sparam_t param, int val)
|
||||
void gs_shader_set_int(gs_sparam_t param, int val)
|
||||
{
|
||||
shader_setval_inline(param, &val, sizeof(int));
|
||||
}
|
||||
|
||||
void shader_setmatrix3(sparam_t param, const struct matrix3 *val)
|
||||
void gs_shader_setmatrix3(gs_sparam_t param, const struct matrix3 *val)
|
||||
{
|
||||
struct matrix4 mat;
|
||||
matrix4_from_matrix3(&mat, val);
|
||||
shader_setval_inline(param, &mat, sizeof(matrix4));
|
||||
}
|
||||
|
||||
void shader_setmatrix4(sparam_t param, const struct matrix4 *val)
|
||||
void gs_shader_set_matrix4(gs_sparam_t param, const struct matrix4 *val)
|
||||
{
|
||||
shader_setval_inline(param, val, sizeof(matrix4));
|
||||
}
|
||||
|
||||
void shader_setvec2(sparam_t param, const struct vec2 *val)
|
||||
void gs_shader_set_vec2(gs_sparam_t param, const struct vec2 *val)
|
||||
{
|
||||
shader_setval_inline(param, val, sizeof(vec2));
|
||||
}
|
||||
|
||||
void shader_setvec3(sparam_t param, const struct vec3 *val)
|
||||
void gs_shader_set_vec3(gs_sparam_t param, const struct vec3 *val)
|
||||
{
|
||||
shader_setval_inline(param, val, sizeof(float) * 3);
|
||||
}
|
||||
|
||||
void shader_setvec4(sparam_t param, const struct vec4 *val)
|
||||
void gs_shader_set_vec4(gs_sparam_t param, const struct vec4 *val)
|
||||
{
|
||||
shader_setval_inline(param, val, sizeof(vec4));
|
||||
}
|
||||
|
||||
void shader_settexture(sparam_t param, texture_t val)
|
||||
void gs_shader_set_texture(gs_sparam_t param, gs_texture_t val)
|
||||
{
|
||||
shader_setval_inline(param, &val, sizeof(texture_t));
|
||||
shader_setval_inline(param, &val, sizeof(gs_texture_t));
|
||||
}
|
||||
|
||||
void shader_setval(sparam_t param, const void *val, size_t size)
|
||||
void gs_shader_set_val(gs_sparam_t param, const void *val, size_t size)
|
||||
{
|
||||
shader_setval_inline(param, val, size);
|
||||
}
|
||||
|
||||
void shader_setdefault(sparam_t param)
|
||||
void gs_shader_set_default(gs_sparam_t param)
|
||||
{
|
||||
if (param->defaultValue.size())
|
||||
shader_setval_inline(param, param->defaultValue.data(),
|
||||
|
|
|
@ -146,7 +146,7 @@ void ShaderProcessor::BuildInputLayout(
|
|||
BuildInputLayoutFromVars(&parser, &func->params.da, layout);
|
||||
}
|
||||
|
||||
shader_param::shader_param(shader_var &var, uint32_t &texCounter)
|
||||
gs_shader_param::gs_shader_param(shader_var &var, uint32_t &texCounter)
|
||||
: type (get_shader_param_type(var.type)),
|
||||
name (var.name),
|
||||
textureID (texCounter),
|
||||
|
@ -156,23 +156,23 @@ shader_param::shader_param(shader_var &var, uint32_t &texCounter)
|
|||
defaultValue.resize(var.default_val.num);
|
||||
memcpy(defaultValue.data(), var.default_val.array, var.default_val.num);
|
||||
|
||||
if (type == SHADER_PARAM_TEXTURE)
|
||||
if (type == GS_SHADER_PARAM_TEXTURE)
|
||||
texCounter++;
|
||||
else
|
||||
textureID = 0;
|
||||
}
|
||||
|
||||
static inline void AddParam(shader_var &var, vector<shader_param> ¶ms,
|
||||
static inline void AddParam(shader_var &var, vector<gs_shader_param> ¶ms,
|
||||
uint32_t &texCounter)
|
||||
{
|
||||
if (var.var_type != SHADER_VAR_UNIFORM ||
|
||||
strcmp(var.type, "sampler") == 0)
|
||||
return;
|
||||
|
||||
params.push_back(shader_param(var, texCounter));
|
||||
params.push_back(gs_shader_param(var, texCounter));
|
||||
}
|
||||
|
||||
void ShaderProcessor::BuildParams(vector<shader_param> ¶ms)
|
||||
void ShaderProcessor::BuildParams(vector<gs_shader_param> ¶ms)
|
||||
{
|
||||
uint32_t texCounter = 0;
|
||||
|
||||
|
@ -180,7 +180,7 @@ void ShaderProcessor::BuildParams(vector<shader_param> ¶ms)
|
|||
AddParam(parser.params.array[i], params, texCounter);
|
||||
}
|
||||
|
||||
static inline void AddSampler(device_t device, shader_sampler &sampler,
|
||||
static inline void AddSampler(gs_device_t device, shader_sampler &sampler,
|
||||
vector<ShaderSampler> &samplers)
|
||||
{
|
||||
gs_sampler_info si;
|
||||
|
|
|
@ -25,16 +25,16 @@ struct ShaderParser : shader_parser {
|
|||
};
|
||||
|
||||
struct ShaderProcessor {
|
||||
device_t device;
|
||||
gs_device_t device;
|
||||
ShaderParser parser;
|
||||
|
||||
void BuildInputLayout(vector<D3D11_INPUT_ELEMENT_DESC> &inputs);
|
||||
void BuildParams(vector<shader_param> ¶ms);
|
||||
void BuildParams(vector<gs_shader_param> ¶ms);
|
||||
void BuildSamplers(vector<ShaderSampler> &samplers);
|
||||
void BuildString(string &outputString);
|
||||
void Process(const char *shader_string, const char *file);
|
||||
|
||||
inline ShaderProcessor(device_t device) : device(device)
|
||||
inline ShaderProcessor(gs_device_t device) : device(device)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
#include "d3d11-subsystem.hpp"
|
||||
|
||||
gs_stage_surface::gs_stage_surface(device_t device, uint32_t width,
|
||||
gs_stage_surface::gs_stage_surface(gs_device_t device, uint32_t width,
|
||||
uint32_t height, gs_color_format colorFormat)
|
||||
: device (device),
|
||||
width (width),
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -108,7 +108,7 @@ static inline D3D11_COMPARISON_FUNC ConvertGSDepthTest(gs_depth_test test)
|
|||
return D3D11_COMPARISON_NEVER;
|
||||
}
|
||||
|
||||
static inline D3D11_STENCIL_OP ConvertGSStencilOp(gs_stencil_op op)
|
||||
static inline D3D11_STENCIL_OP ConvertGSStencilOp(gs_stencil_op_type op)
|
||||
{
|
||||
switch (op) {
|
||||
case GS_KEEP: return D3D11_STENCIL_OP_KEEP;
|
||||
|
@ -167,12 +167,12 @@ static inline D3D11_PRIMITIVE_TOPOLOGY ConvertGSTopology(gs_draw_mode mode)
|
|||
|
||||
/* exception-safe RAII wrapper for vertex buffer data (NOTE: not copy-safe) */
|
||||
struct VBDataPtr {
|
||||
vb_data *data;
|
||||
gs_vb_data *data;
|
||||
|
||||
inline void Clear() {vbdata_destroy(data); data = nullptr;}
|
||||
inline void Clear() {gs_vbdata_destroy(data); data = nullptr;}
|
||||
|
||||
inline VBDataPtr(vb_data *data) : data(data) {}
|
||||
inline ~VBDataPtr() {vbdata_destroy(data);}
|
||||
inline VBDataPtr(gs_vb_data *data) : data(data) {}
|
||||
inline ~VBDataPtr() {gs_vbdata_destroy(data);}
|
||||
};
|
||||
|
||||
struct gs_vertex_buffer {
|
||||
|
@ -182,7 +182,7 @@ struct gs_vertex_buffer {
|
|||
ComPtr<ID3D11Buffer> tangentBuffer;
|
||||
vector<ComPtr<ID3D11Buffer>> uvBuffers;
|
||||
|
||||
device_t device;
|
||||
gs_device_t device;
|
||||
bool dynamic;
|
||||
VBDataPtr vbd;
|
||||
size_t numVerts;
|
||||
|
@ -199,7 +199,8 @@ struct gs_vertex_buffer {
|
|||
const size_t numVerts, void *array,
|
||||
ID3D11Buffer **buffer);
|
||||
|
||||
gs_vertex_buffer(device_t device, struct vb_data *data, uint32_t flags);
|
||||
gs_vertex_buffer(gs_device_t device, struct gs_vb_data *data,
|
||||
uint32_t flags);
|
||||
};
|
||||
|
||||
/* exception-safe RAII wrapper for index buffer data (NOTE: not copy-safe) */
|
||||
|
@ -212,7 +213,7 @@ struct DataPtr {
|
|||
|
||||
struct gs_index_buffer {
|
||||
ComPtr<ID3D11Buffer> indexBuffer;
|
||||
device_t device;
|
||||
gs_device_t device;
|
||||
bool dynamic;
|
||||
gs_index_type type;
|
||||
size_t indexSize;
|
||||
|
@ -221,7 +222,7 @@ struct gs_index_buffer {
|
|||
|
||||
void InitBuffer();
|
||||
|
||||
gs_index_buffer(device_t device, enum gs_index_type type,
|
||||
gs_index_buffer(gs_device_t device, enum gs_index_type type,
|
||||
void *indices, size_t num, uint32_t flags);
|
||||
};
|
||||
|
||||
|
@ -278,7 +279,7 @@ struct gs_texture_2d : gs_texture {
|
|||
{
|
||||
}
|
||||
|
||||
gs_texture_2d(device_t device, uint32_t width, uint32_t height,
|
||||
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);
|
||||
|
@ -303,7 +304,7 @@ struct gs_zstencil_buffer {
|
|||
{
|
||||
}
|
||||
|
||||
gs_zstencil_buffer(device_t device, uint32_t width, uint32_t height,
|
||||
gs_zstencil_buffer(gs_device_t device, uint32_t width, uint32_t height,
|
||||
gs_zstencil_format format);
|
||||
};
|
||||
|
||||
|
@ -315,21 +316,21 @@ struct gs_stage_surface {
|
|||
gs_color_format format;
|
||||
DXGI_FORMAT dxgiFormat;
|
||||
|
||||
gs_stage_surface(device_t device, uint32_t width, uint32_t height,
|
||||
gs_stage_surface(gs_device_t device, uint32_t width, uint32_t height,
|
||||
gs_color_format colorFormat);
|
||||
};
|
||||
|
||||
struct gs_sampler_state {
|
||||
ComPtr<ID3D11SamplerState> state;
|
||||
device_t device;
|
||||
gs_device_t device;
|
||||
gs_sampler_info info;
|
||||
|
||||
gs_sampler_state(device_t device, gs_sampler_info *info);
|
||||
gs_sampler_state(gs_device_t device, gs_sampler_info *info);
|
||||
};
|
||||
|
||||
struct shader_param {
|
||||
struct gs_shader_param {
|
||||
string name;
|
||||
shader_param_type type;
|
||||
gs_shader_param_type type;
|
||||
|
||||
uint32_t textureID;
|
||||
|
||||
|
@ -341,7 +342,7 @@ struct shader_param {
|
|||
vector<uint8_t> defaultValue;
|
||||
bool changed;
|
||||
|
||||
shader_param(shader_var &var, uint32_t &texCounter);
|
||||
gs_shader_param(shader_var &var, uint32_t &texCounter);
|
||||
};
|
||||
|
||||
struct ShaderError {
|
||||
|
@ -356,21 +357,21 @@ struct ShaderError {
|
|||
};
|
||||
|
||||
struct gs_shader {
|
||||
device_t device;
|
||||
shader_type type;
|
||||
vector<shader_param> params;
|
||||
gs_device_t device;
|
||||
gs_shader_type type;
|
||||
vector<gs_shader_param> params;
|
||||
ComPtr<ID3D11Buffer> constants;
|
||||
size_t constantSize;
|
||||
|
||||
inline void UpdateParam(vector<uint8_t> &constData, shader_param ¶m,
|
||||
bool &upload);
|
||||
inline void UpdateParam(vector<uint8_t> &constData,
|
||||
gs_shader_param ¶m, bool &upload);
|
||||
void UploadParams();
|
||||
|
||||
void BuildConstantBuffer();
|
||||
void Compile(const char *shaderStr, const char *file,
|
||||
const char *target, ID3D10Blob **shader);
|
||||
|
||||
inline gs_shader(device_t device, shader_type type)
|
||||
inline gs_shader(gs_device_t device, gs_shader_type type)
|
||||
: device (device),
|
||||
type (type),
|
||||
constantSize (0)
|
||||
|
@ -384,7 +385,7 @@ struct ShaderSampler {
|
|||
string name;
|
||||
gs_sampler_state sampler;
|
||||
|
||||
inline ShaderSampler(const char *name, device_t device,
|
||||
inline ShaderSampler(const char *name, gs_device_t device,
|
||||
gs_sampler_info *info)
|
||||
: name (name),
|
||||
sampler (device, info)
|
||||
|
@ -396,7 +397,7 @@ struct gs_vertex_shader : gs_shader {
|
|||
ComPtr<ID3D11VertexShader> shader;
|
||||
ComPtr<ID3D11InputLayout> layout;
|
||||
|
||||
shader_param *world, *viewProj;
|
||||
gs_shader_param *world, *viewProj;
|
||||
|
||||
bool hasNormals;
|
||||
bool hasColors;
|
||||
|
@ -415,7 +416,7 @@ struct gs_vertex_shader : gs_shader {
|
|||
|
||||
void GetBuffersExpected(const vector<D3D11_INPUT_ELEMENT_DESC> &inputs);
|
||||
|
||||
gs_vertex_shader(device_t device, const char *file,
|
||||
gs_vertex_shader(gs_device_t device, const char *file,
|
||||
const char *shaderString);
|
||||
};
|
||||
|
||||
|
@ -432,7 +433,7 @@ struct gs_pixel_shader : gs_shader {
|
|||
states[i] = NULL;
|
||||
}
|
||||
|
||||
gs_pixel_shader(device_t device, const char *file,
|
||||
gs_pixel_shader(gs_device_t device, const char *file,
|
||||
const char *shaderString);
|
||||
};
|
||||
|
||||
|
@ -497,9 +498,9 @@ struct SavedBlendState : BlendState {
|
|||
|
||||
struct StencilSide {
|
||||
gs_depth_test test;
|
||||
gs_stencil_op fail;
|
||||
gs_stencil_op zfail;
|
||||
gs_stencil_op zpass;
|
||||
gs_stencil_op_type fail;
|
||||
gs_stencil_op_type zfail;
|
||||
gs_stencil_op_type zpass;
|
||||
|
||||
inline StencilSide()
|
||||
: test (GS_ALWAYS),
|
||||
|
@ -623,7 +624,7 @@ struct gs_device {
|
|||
void UpdateBlendState();
|
||||
|
||||
inline void CopyTex(ID3D11Texture2D *dst, uint32_t dst_x, uint32_t dst_y,
|
||||
texture_t src, uint32_t src_x, uint32_t src_y,
|
||||
gs_texture_t src, uint32_t src_x, uint32_t src_y,
|
||||
uint32_t src_w, uint32_t src_h);
|
||||
|
||||
void UpdateViewProjMatrix();
|
||||
|
|
|
@ -27,7 +27,7 @@ void gs_texture_2d::InitSRD(vector<D3D11_SUBRESOURCE_DATA> &srd,
|
|||
uint32_t actual_levels = levels;
|
||||
|
||||
if (!actual_levels)
|
||||
actual_levels = gs_num_total_levels(width, height);
|
||||
actual_levels = gs_get_total_levels(width, height);
|
||||
|
||||
rowSizeBytes /= 8;
|
||||
|
||||
|
@ -141,7 +141,7 @@ void gs_texture_2d::InitRenderTargets()
|
|||
}
|
||||
}
|
||||
|
||||
gs_texture_2d::gs_texture_2d(device_t device, uint32_t width, uint32_t height,
|
||||
gs_texture_2d::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)
|
||||
|
@ -152,8 +152,8 @@ gs_texture_2d::gs_texture_2d(device_t device, uint32_t width, uint32_t height,
|
|||
isGDICompatible (gdiCompatible),
|
||||
isShared (shared),
|
||||
isDynamic ((flags & GS_DYNAMIC) != 0),
|
||||
isRenderTarget ((flags & GS_RENDERTARGET) != 0),
|
||||
genMipmaps ((flags & GS_BUILDMIPMAPS) != 0)
|
||||
isRenderTarget ((flags & GS_RENDER_TARGET) != 0),
|
||||
genMipmaps ((flags & GS_BUILD_MIPMAPS) != 0)
|
||||
{
|
||||
InitTexture(data);
|
||||
InitResourceView();
|
||||
|
|
|
@ -93,7 +93,7 @@ inline void gs_vertex_buffer::InitBuffer(const size_t elementSize,
|
|||
throw HRError("Failed to create buffer", hr);
|
||||
}
|
||||
|
||||
gs_vertex_buffer::gs_vertex_buffer(device_t device, struct vb_data *data,
|
||||
gs_vertex_buffer::gs_vertex_buffer(gs_device_t device, struct gs_vb_data *data,
|
||||
uint32_t flags)
|
||||
: device (device),
|
||||
vbd (data),
|
||||
|
@ -121,7 +121,7 @@ gs_vertex_buffer::gs_vertex_buffer(device_t device, struct vb_data *data,
|
|||
colorBuffer.Assign());
|
||||
|
||||
for (size_t i = 0; i < data->num_tex; i++) {
|
||||
struct tvertarray *tverts = data->tvarray+i;
|
||||
struct gs_tvertarray *tverts = data->tvarray+i;
|
||||
|
||||
if (tverts->width != 2 && tverts->width != 4)
|
||||
throw "Invalid texture vertex size specified";
|
||||
|
|
|
@ -47,7 +47,7 @@ void gs_zstencil_buffer::InitBuffer()
|
|||
throw HRError("Failed to create depth stencil view", hr);
|
||||
}
|
||||
|
||||
gs_zstencil_buffer::gs_zstencil_buffer(device_t device,
|
||||
gs_zstencil_buffer::gs_zstencil_buffer(gs_device_t device,
|
||||
uint32_t width, uint32_t height,
|
||||
gs_zstencil_format format)
|
||||
: device (device),
|
||||
|
|
|
@ -96,7 +96,7 @@ static NSOpenGLContext *gl_context_create(struct gs_init_data *info)
|
|||
return context;
|
||||
}
|
||||
|
||||
static bool gl_init_default_swap(struct gl_platform *plat, device_t dev,
|
||||
static bool gl_init_default_swap(struct gl_platform *plat, gs_device_t dev,
|
||||
struct gs_init_data *info)
|
||||
{
|
||||
if(!(plat->context = gl_context_create(info)))
|
||||
|
@ -109,7 +109,7 @@ static bool gl_init_default_swap(struct gl_platform *plat, device_t dev,
|
|||
return plat->swap.wi != NULL;
|
||||
}
|
||||
|
||||
struct gl_platform *gl_platform_create(device_t device,
|
||||
struct gl_platform *gl_platform_create(gs_device_t device,
|
||||
struct gs_init_data *info)
|
||||
{
|
||||
struct gl_platform *plat = bzalloc(sizeof(struct gl_platform));
|
||||
|
@ -186,24 +186,24 @@ void gl_windowinfo_destroy(struct gl_windowinfo *wi)
|
|||
bfree(wi);
|
||||
}
|
||||
|
||||
void gl_update(device_t device)
|
||||
void gl_update(gs_device_t device)
|
||||
{
|
||||
[device->plat->context update];
|
||||
}
|
||||
|
||||
void device_entercontext(device_t device)
|
||||
void device_enter_context(gs_device_t device)
|
||||
{
|
||||
[device->plat->context makeCurrentContext];
|
||||
}
|
||||
|
||||
void device_leavecontext(device_t device)
|
||||
void device_leave_context(gs_device_t device)
|
||||
{
|
||||
UNUSED_PARAMETER(device);
|
||||
|
||||
[NSOpenGLContext clearCurrentContext];
|
||||
}
|
||||
|
||||
void device_load_swapchain(device_t device, swapchain_t swap)
|
||||
void device_load_swapchain(gs_device_t device, gs_swapchain_t swap)
|
||||
{
|
||||
if(!swap)
|
||||
swap = &device->plat->swap;
|
||||
|
@ -215,7 +215,7 @@ void device_load_swapchain(device_t device, swapchain_t swap)
|
|||
[device->plat->context setView:swap->wi->view];
|
||||
}
|
||||
|
||||
void device_present(device_t device)
|
||||
void device_present(gs_device_t device)
|
||||
{
|
||||
[device->plat->context flushBuffer];
|
||||
}
|
||||
|
@ -227,7 +227,8 @@ void gl_getclientsize(struct gs_swap_chain *swap, uint32_t *width,
|
|||
if(height) *height = swap->info.cy;
|
||||
}
|
||||
|
||||
texture_t texture_create_from_iosurface(device_t device, void *iosurf)
|
||||
gs_texture_t device_texture_create_from_iosurface(gs_device_t device,
|
||||
void *iosurf)
|
||||
{
|
||||
IOSurfaceRef ref = (IOSurfaceRef)iosurf;
|
||||
struct gs_texture_2d *tex = bzalloc(sizeof(struct gs_texture_2d));
|
||||
|
@ -270,7 +271,7 @@ texture_t texture_create_from_iosurface(device_t device, void *iosurf)
|
|||
|
||||
if(err != kCGLNoError) {
|
||||
blog(LOG_ERROR, "CGLTexImageIOSurface2D: %u, %s"
|
||||
" (texture_create_from_iosurface)",
|
||||
" (device_texture_create_from_iosurface)",
|
||||
err, CGLErrorString(err));
|
||||
|
||||
gl_success("CGLTexImageIOSurface2D");
|
||||
|
@ -284,15 +285,15 @@ texture_t texture_create_from_iosurface(device_t device, void *iosurf)
|
|||
if (!gl_bind_texture(tex->base.gl_target, 0))
|
||||
goto fail;
|
||||
|
||||
return (texture_t)tex;
|
||||
return (gs_texture_t)tex;
|
||||
|
||||
fail:
|
||||
texture_destroy((texture_t)tex);
|
||||
blog(LOG_ERROR, "texture_create_from_iosurface (GL) failed");
|
||||
gs_texture_destroy((gs_texture_t)tex);
|
||||
blog(LOG_ERROR, "device_texture_create_from_iosurface (GL) failed");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool texture_rebind_iosurface(texture_t texture, void *iosurf)
|
||||
bool gs_texture_rebind_iosurface(gs_texture_t texture, void *iosurf)
|
||||
{
|
||||
if (!texture)
|
||||
return false;
|
||||
|
@ -326,7 +327,7 @@ bool texture_rebind_iosurface(texture_t texture, void *iosurf)
|
|||
|
||||
if(err != kCGLNoError) {
|
||||
blog(LOG_ERROR, "CGLTexImageIOSurface2D: %u, %s"
|
||||
" (texture_rebind_iosurface)",
|
||||
" (gs_texture_rebind_iosurface)",
|
||||
err, CGLErrorString(err));
|
||||
|
||||
gl_success("CGLTexImageIOSurface2D");
|
||||
|
|
|
@ -33,7 +33,7 @@ static inline bool init_ib(struct gs_index_buffer *ib)
|
|||
return success;
|
||||
}
|
||||
|
||||
indexbuffer_t device_create_indexbuffer(device_t device,
|
||||
gs_indexbuffer_t device_indexbuffer_create(gs_device_t device,
|
||||
enum gs_index_type type, void *indices, size_t num,
|
||||
uint32_t flags)
|
||||
{
|
||||
|
@ -51,15 +51,15 @@ indexbuffer_t device_create_indexbuffer(device_t device,
|
|||
GL_UNSIGNED_SHORT;
|
||||
|
||||
if (!init_ib(ib)) {
|
||||
blog(LOG_ERROR, "device_create_indexbuffer (GL) failed");
|
||||
indexbuffer_destroy(ib);
|
||||
blog(LOG_ERROR, "device_indexbuffer_create (GL) failed");
|
||||
gs_indexbuffer_destroy(ib);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return ib;
|
||||
}
|
||||
|
||||
void indexbuffer_destroy(indexbuffer_t ib)
|
||||
void gs_indexbuffer_destroy(gs_indexbuffer_t ib)
|
||||
{
|
||||
if (ib) {
|
||||
if (ib->buffer)
|
||||
|
@ -70,7 +70,7 @@ void indexbuffer_destroy(indexbuffer_t ib)
|
|||
}
|
||||
}
|
||||
|
||||
void indexbuffer_flush(indexbuffer_t ib)
|
||||
void gs_indexbuffer_flush(gs_indexbuffer_t ib)
|
||||
{
|
||||
if (!ib->dynamic) {
|
||||
blog(LOG_ERROR, "Index buffer is not dynamic");
|
||||
|
@ -83,25 +83,25 @@ void indexbuffer_flush(indexbuffer_t ib)
|
|||
return;
|
||||
|
||||
fail:
|
||||
blog(LOG_ERROR, "indexbuffer_flush (GL) failed");
|
||||
blog(LOG_ERROR, "gs_indexbuffer_flush (GL) failed");
|
||||
}
|
||||
|
||||
void *indexbuffer_getdata(indexbuffer_t ib)
|
||||
void *gs_indexbuffer_get_data(gs_indexbuffer_t ib)
|
||||
{
|
||||
return ib->data;
|
||||
}
|
||||
|
||||
size_t indexbuffer_numindices(indexbuffer_t ib)
|
||||
size_t gs_indexbuffer_get_num_indices(gs_indexbuffer_t ib)
|
||||
{
|
||||
return ib->num;
|
||||
}
|
||||
|
||||
enum gs_index_type indexbuffer_gettype(indexbuffer_t ib)
|
||||
enum gs_index_type gs_indexbuffer_get_type(gs_indexbuffer_t ib)
|
||||
{
|
||||
return ib->type;
|
||||
}
|
||||
|
||||
void device_load_indexbuffer(device_t device, indexbuffer_t ib)
|
||||
void device_load_indexbuffer(gs_device_t device, gs_indexbuffer_t ib)
|
||||
{
|
||||
if (ib == device->cur_index_buffer)
|
||||
return;
|
||||
|
|
|
@ -25,12 +25,12 @@
|
|||
#include "gl-subsystem.h"
|
||||
#include "gl-shaderparser.h"
|
||||
|
||||
static inline void shader_param_init(struct shader_param *param)
|
||||
static inline void shader_param_init(struct gs_shader_param *param)
|
||||
{
|
||||
memset(param, 0, sizeof(struct shader_param));
|
||||
memset(param, 0, sizeof(struct gs_shader_param));
|
||||
}
|
||||
|
||||
static inline void shader_param_free(struct shader_param *param)
|
||||
static inline void shader_param_free(struct gs_shader_param *param)
|
||||
{
|
||||
bfree(param->name);
|
||||
da_free(param->cur_value);
|
||||
|
@ -63,14 +63,14 @@ static void gl_get_program_info(GLuint program, const char *file,
|
|||
static bool gl_add_param(struct gs_shader *shader, struct shader_var *var,
|
||||
GLint *texture_id)
|
||||
{
|
||||
struct shader_param param = {0};
|
||||
struct gs_shader_param param = {0};
|
||||
|
||||
param.array_count = var->array_count;
|
||||
param.name = bstrdup(var->name);
|
||||
param.shader = shader;
|
||||
param.type = get_shader_param_type(var->type);
|
||||
|
||||
if (param.type == SHADER_PARAM_TEXTURE) {
|
||||
if (param.type == GS_SHADER_PARAM_TEXTURE) {
|
||||
param.sampler_id = var->gl_sampler_id;
|
||||
param.texture_id = (*texture_id)++;
|
||||
} else {
|
||||
|
@ -84,7 +84,7 @@ static bool gl_add_param(struct gs_shader *shader, struct shader_var *var,
|
|||
if (!gl_success("glGetUniformLocation"))
|
||||
goto fail;
|
||||
|
||||
if (param.type == SHADER_PARAM_TEXTURE) {
|
||||
if (param.type == GS_SHADER_PARAM_TEXTURE) {
|
||||
glProgramUniform1i(shader->program, param.param,
|
||||
param.texture_id);
|
||||
if (!gl_success("glProgramUniform1i"))
|
||||
|
@ -109,8 +109,8 @@ static inline bool gl_add_params(struct gs_shader *shader,
|
|||
if (!gl_add_param(shader, glsp->parser.params.array+i, &tex_id))
|
||||
return false;
|
||||
|
||||
shader->viewproj = shader_getparambyname(shader, "ViewProj");
|
||||
shader->world = shader_getparambyname(shader, "World");
|
||||
shader->viewproj = gs_shader_get_param_by_name(shader, "ViewProj");
|
||||
shader->world = gs_shader_get_param_by_name(shader, "World");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -118,11 +118,11 @@ static inline bool gl_add_params(struct gs_shader *shader,
|
|||
static inline void gl_add_sampler(struct gs_shader *shader,
|
||||
struct shader_sampler *sampler)
|
||||
{
|
||||
samplerstate_t new_sampler;
|
||||
gs_samplerstate_t new_sampler;
|
||||
struct gs_sampler_info info;
|
||||
|
||||
shader_sampler_convert(sampler, &info);
|
||||
new_sampler = device_create_samplerstate(shader->device, &info);
|
||||
new_sampler = device_samplerstate_create(shader->device, &info);
|
||||
|
||||
da_push_back(shader->samplers, &new_sampler);
|
||||
}
|
||||
|
@ -235,7 +235,7 @@ static bool gl_shader_init(struct gs_shader *shader,
|
|||
if (success)
|
||||
success = gl_add_params(shader, glsp);
|
||||
/* Only vertex shaders actually require input attributes */
|
||||
if (success && shader->type == SHADER_VERTEX)
|
||||
if (success && shader->type == GS_SHADER_VERTEX)
|
||||
success = gl_process_attribs(shader, glsp);
|
||||
if (success)
|
||||
gl_add_samplers(shader, glsp);
|
||||
|
@ -243,8 +243,9 @@ static bool gl_shader_init(struct gs_shader *shader,
|
|||
return success;
|
||||
}
|
||||
|
||||
static struct gs_shader *shader_create(device_t device, enum shader_type type,
|
||||
const char *shader_str, const char *file, char **error_string)
|
||||
static struct gs_shader *shader_create(gs_device_t device,
|
||||
enum gs_shader_type type, const char *shader_str,
|
||||
const char *file, char **error_string)
|
||||
{
|
||||
struct gs_shader *shader = bzalloc(sizeof(struct gs_shader));
|
||||
struct gl_shader_parser glsp;
|
||||
|
@ -260,7 +261,7 @@ static struct gs_shader *shader_create(device_t device, enum shader_type type,
|
|||
success = gl_shader_init(shader, &glsp, file, error_string);
|
||||
|
||||
if (!success) {
|
||||
shader_destroy(shader);
|
||||
gs_shader_destroy(shader);
|
||||
shader = NULL;
|
||||
}
|
||||
|
||||
|
@ -268,29 +269,31 @@ static struct gs_shader *shader_create(device_t device, enum shader_type type,
|
|||
return shader;
|
||||
}
|
||||
|
||||
shader_t device_create_vertexshader(device_t device,
|
||||
gs_shader_t device_vertexshader_create(gs_device_t device,
|
||||
const char *shader, const char *file,
|
||||
char **error_string)
|
||||
{
|
||||
struct gs_shader *ptr;
|
||||
ptr = shader_create(device, SHADER_VERTEX, shader, file, error_string);
|
||||
ptr = shader_create(device, GS_SHADER_VERTEX, shader, file,
|
||||
error_string);
|
||||
if (!ptr)
|
||||
blog(LOG_ERROR, "device_create_vertexshader (GL) failed");
|
||||
blog(LOG_ERROR, "device_vertexshader_create (GL) failed");
|
||||
return ptr;
|
||||
}
|
||||
|
||||
shader_t device_create_pixelshader(device_t device,
|
||||
gs_shader_t device_pixelshader_create(gs_device_t device,
|
||||
const char *shader, const char *file,
|
||||
char **error_string)
|
||||
{
|
||||
struct gs_shader *ptr;
|
||||
ptr = shader_create(device, SHADER_PIXEL, shader, file, error_string);
|
||||
ptr = shader_create(device, GS_SHADER_PIXEL, shader, file,
|
||||
error_string);
|
||||
if (!ptr)
|
||||
blog(LOG_ERROR, "device_create_pixelshader (GL) failed");
|
||||
blog(LOG_ERROR, "device_pixelshader_create (GL) failed");
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void shader_destroy(shader_t shader)
|
||||
void gs_shader_destroy(gs_shader_t shader)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
|
@ -298,7 +301,7 @@ void shader_destroy(shader_t shader)
|
|||
return;
|
||||
|
||||
for (i = 0; i < shader->samplers.num; i++)
|
||||
samplerstate_destroy(shader->samplers.array[i]);
|
||||
gs_samplerstate_destroy(shader->samplers.array[i]);
|
||||
|
||||
for (i = 0; i < shader->params.num; i++)
|
||||
shader_param_free(shader->params.array+i);
|
||||
|
@ -314,22 +317,22 @@ void shader_destroy(shader_t shader)
|
|||
bfree(shader);
|
||||
}
|
||||
|
||||
int shader_numparams(shader_t shader)
|
||||
int gs_shader_get_num_params(gs_shader_t shader)
|
||||
{
|
||||
return (int)shader->params.num;
|
||||
}
|
||||
|
||||
sparam_t shader_getparambyidx(shader_t shader, uint32_t param)
|
||||
gs_sparam_t gs_shader_get_param_by_idx(gs_shader_t shader, uint32_t param)
|
||||
{
|
||||
assert(param < shader->params.num);
|
||||
return shader->params.array+param;
|
||||
}
|
||||
|
||||
sparam_t shader_getparambyname(shader_t shader, const char *name)
|
||||
gs_sparam_t gs_shader_get_param_by_name(gs_shader_t shader, const char *name)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < shader->params.num; i++) {
|
||||
struct shader_param *param = shader->params.array+i;
|
||||
struct gs_shader_param *param = shader->params.array+i;
|
||||
|
||||
if (strcmp(param->name, name) == 0)
|
||||
return param;
|
||||
|
@ -338,44 +341,45 @@ sparam_t shader_getparambyname(shader_t shader, const char *name)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
sparam_t shader_getviewprojmatrix(shader_t shader)
|
||||
gs_sparam_t gs_shader_get_viewproj_matrix(gs_shader_t shader)
|
||||
{
|
||||
return shader->viewproj;
|
||||
}
|
||||
|
||||
sparam_t shader_getworldmatrix(shader_t shader)
|
||||
gs_sparam_t gs_shader_get_world_matrix(gs_shader_t shader)
|
||||
{
|
||||
return shader->world;
|
||||
}
|
||||
|
||||
void shader_getparaminfo(sparam_t param, struct shader_param_info *info)
|
||||
void gs_shader_get_param_info(gs_sparam_t param,
|
||||
struct gs_shader_param_info *info)
|
||||
{
|
||||
info->type = param->type;
|
||||
info->name = param->name;
|
||||
}
|
||||
|
||||
void shader_setbool(sparam_t param, bool val)
|
||||
void gs_shader_set_bool(gs_sparam_t param, bool val)
|
||||
{
|
||||
struct gs_shader *shader = param->shader;
|
||||
glProgramUniform1i(shader->program, param->param, (GLint)val);
|
||||
gl_success("glProgramUniform1i");
|
||||
}
|
||||
|
||||
void shader_setfloat(sparam_t param, float val)
|
||||
void gs_shader_set_float(gs_sparam_t param, float val)
|
||||
{
|
||||
struct gs_shader *shader = param->shader;
|
||||
glProgramUniform1f(shader->program, param->param, val);
|
||||
gl_success("glProgramUniform1f");
|
||||
}
|
||||
|
||||
void shader_setint(sparam_t param, int val)
|
||||
void gs_shader_set_int(gs_sparam_t param, int val)
|
||||
{
|
||||
struct gs_shader *shader = param->shader;
|
||||
glProgramUniform1i(shader->program, param->param, val);
|
||||
gl_success("glProgramUniform1i");
|
||||
}
|
||||
|
||||
void shader_setmatrix3(sparam_t param, const struct matrix3 *val)
|
||||
void gs_shader_setmatrix3(gs_sparam_t param, const struct matrix3 *val)
|
||||
{
|
||||
struct gs_shader *shader = param->shader;
|
||||
struct matrix4 mat;
|
||||
|
@ -386,7 +390,7 @@ void shader_setmatrix3(sparam_t param, const struct matrix3 *val)
|
|||
gl_success("glProgramUniformMatrix4fv");
|
||||
}
|
||||
|
||||
void shader_setmatrix4(sparam_t param, const struct matrix4 *val)
|
||||
void gs_shader_set_matrix4(gs_sparam_t param, const struct matrix4 *val)
|
||||
{
|
||||
struct gs_shader *shader = param->shader;
|
||||
glProgramUniformMatrix4fv(shader->program, param->param, 1,
|
||||
|
@ -394,58 +398,58 @@ void shader_setmatrix4(sparam_t param, const struct matrix4 *val)
|
|||
gl_success("glProgramUniformMatrix4fv");
|
||||
}
|
||||
|
||||
void shader_setvec2(sparam_t param, const struct vec2 *val)
|
||||
void gs_shader_set_vec2(gs_sparam_t param, const struct vec2 *val)
|
||||
{
|
||||
struct gs_shader *shader = param->shader;
|
||||
glProgramUniform2fv(shader->program, param->param, 1, val->ptr);
|
||||
gl_success("glProgramUniform2fv");
|
||||
}
|
||||
|
||||
void shader_setvec3(sparam_t param, const struct vec3 *val)
|
||||
void gs_shader_set_vec3(gs_sparam_t param, const struct vec3 *val)
|
||||
{
|
||||
struct gs_shader *shader = param->shader;
|
||||
glProgramUniform3fv(shader->program, param->param, 1, val->ptr);
|
||||
gl_success("glProgramUniform3fv");
|
||||
}
|
||||
|
||||
void shader_setvec4(sparam_t param, const struct vec4 *val)
|
||||
void gs_shader_set_vec4(gs_sparam_t param, const struct vec4 *val)
|
||||
{
|
||||
struct gs_shader *shader = param->shader;
|
||||
glProgramUniform4fv(shader->program, param->param, 1, val->ptr);
|
||||
gl_success("glProgramUniform4fv");
|
||||
}
|
||||
|
||||
void shader_settexture(sparam_t param, texture_t val)
|
||||
void gs_shader_set_texture(gs_sparam_t param, gs_texture_t val)
|
||||
{
|
||||
param->texture = val;
|
||||
}
|
||||
|
||||
static void shader_setval_data(sparam_t param, const void *val, int count)
|
||||
static void shader_setval_data(gs_sparam_t param, const void *val, int count)
|
||||
{
|
||||
struct gs_shader *shader = param->shader;
|
||||
|
||||
if (param->type == SHADER_PARAM_BOOL ||
|
||||
param->type == SHADER_PARAM_INT) {
|
||||
if (param->type == GS_SHADER_PARAM_BOOL ||
|
||||
param->type == GS_SHADER_PARAM_INT) {
|
||||
glProgramUniform1iv(shader->program, param->param, count, val);
|
||||
gl_success("glProgramUniform1iv");
|
||||
|
||||
} else if (param->type == SHADER_PARAM_FLOAT) {
|
||||
} else if (param->type == GS_SHADER_PARAM_FLOAT) {
|
||||
glProgramUniform1fv(shader->program, param->param, count, val);
|
||||
gl_success("glProgramUniform1fv");
|
||||
|
||||
} else if (param->type == SHADER_PARAM_VEC2) {
|
||||
} else if (param->type == GS_SHADER_PARAM_VEC2) {
|
||||
glProgramUniform2fv(shader->program, param->param, count, val);
|
||||
gl_success("glProgramUniform2fv");
|
||||
|
||||
} else if (param->type == SHADER_PARAM_VEC3) {
|
||||
} else if (param->type == GS_SHADER_PARAM_VEC3) {
|
||||
glProgramUniform3fv(shader->program, param->param, count, val);
|
||||
gl_success("glProgramUniform3fv");
|
||||
|
||||
} else if (param->type == SHADER_PARAM_VEC4) {
|
||||
} else if (param->type == GS_SHADER_PARAM_VEC4) {
|
||||
glProgramUniform4fv(shader->program, param->param, count, val);
|
||||
gl_success("glProgramUniform4fv");
|
||||
|
||||
} else if (param->type == SHADER_PARAM_MATRIX4X4) {
|
||||
} else if (param->type == GS_SHADER_PARAM_MATRIX4X4) {
|
||||
glProgramUniformMatrix4fv(shader->program, param->param,
|
||||
count, false, val);
|
||||
gl_success("glProgramUniformMatrix4fv");
|
||||
|
@ -456,15 +460,15 @@ void shader_update_textures(struct gs_shader *shader)
|
|||
{
|
||||
size_t i;
|
||||
for (i = 0; i < shader->params.num; i++) {
|
||||
struct shader_param *param = shader->params.array+i;
|
||||
struct gs_shader_param *param = shader->params.array+i;
|
||||
|
||||
if (param->type == SHADER_PARAM_TEXTURE)
|
||||
if (param->type == GS_SHADER_PARAM_TEXTURE)
|
||||
device_load_texture(shader->device, param->texture,
|
||||
param->texture_id);
|
||||
}
|
||||
}
|
||||
|
||||
void shader_setval(sparam_t param, const void *val, size_t size)
|
||||
void gs_shader_set_val(gs_sparam_t param, const void *val, size_t size)
|
||||
{
|
||||
int count = param->array_count;
|
||||
size_t expected_size = 0;
|
||||
|
@ -472,14 +476,14 @@ void shader_setval(sparam_t param, const void *val, size_t size)
|
|||
count = 1;
|
||||
|
||||
switch ((uint32_t)param->type) {
|
||||
case SHADER_PARAM_FLOAT: expected_size = sizeof(float); break;
|
||||
case SHADER_PARAM_BOOL:
|
||||
case SHADER_PARAM_INT: expected_size = sizeof(int); break;
|
||||
case SHADER_PARAM_VEC2: expected_size = sizeof(float)*2; break;
|
||||
case SHADER_PARAM_VEC3: expected_size = sizeof(float)*3; break;
|
||||
case SHADER_PARAM_VEC4: expected_size = sizeof(float)*4; break;
|
||||
case SHADER_PARAM_MATRIX4X4: expected_size = sizeof(float)*4*4; break;
|
||||
case SHADER_PARAM_TEXTURE: expected_size = sizeof(void*); break;
|
||||
case GS_SHADER_PARAM_FLOAT: expected_size = sizeof(float); break;
|
||||
case GS_SHADER_PARAM_BOOL:
|
||||
case GS_SHADER_PARAM_INT: expected_size = sizeof(int); break;
|
||||
case GS_SHADER_PARAM_VEC2: expected_size = sizeof(float)*2; break;
|
||||
case GS_SHADER_PARAM_VEC3: expected_size = sizeof(float)*3; break;
|
||||
case GS_SHADER_PARAM_VEC4: expected_size = sizeof(float)*4; break;
|
||||
case GS_SHADER_PARAM_MATRIX4X4: expected_size = sizeof(float)*4*4;break;
|
||||
case GS_SHADER_PARAM_TEXTURE: expected_size = sizeof(void*); break;
|
||||
default: expected_size = 0;
|
||||
}
|
||||
|
||||
|
@ -488,18 +492,18 @@ void shader_setval(sparam_t param, const void *val, size_t size)
|
|||
return;
|
||||
|
||||
if (expected_size != size) {
|
||||
blog(LOG_ERROR, "shader_setval (GL): Size of shader param does "
|
||||
"not match the size of the input");
|
||||
blog(LOG_ERROR, "gs_shader_set_val (GL): Size of shader "
|
||||
"param does not match the size of the input");
|
||||
return;
|
||||
}
|
||||
|
||||
if (param->type == SHADER_PARAM_TEXTURE)
|
||||
shader_settexture(param, *(texture_t*)val);
|
||||
if (param->type == GS_SHADER_PARAM_TEXTURE)
|
||||
gs_shader_set_texture(param, *(gs_texture_t*)val);
|
||||
else
|
||||
shader_setval_data(param, val, count);
|
||||
}
|
||||
|
||||
void shader_setdefault(sparam_t param)
|
||||
void gs_shader_set_default(gs_sparam_t param)
|
||||
{
|
||||
shader_setval(param, param->def_value.array, param->def_value.num);
|
||||
gs_shader_set_val(param, param->def_value.array, param->def_value.num);
|
||||
}
|
||||
|
|
|
@ -218,7 +218,7 @@ static void gl_write_struct(struct gl_shader_parser *glsp,
|
|||
|
||||
static void gl_write_interface_block(struct gl_shader_parser *glsp)
|
||||
{
|
||||
if (glsp->type == SHADER_VERTEX) {
|
||||
if (glsp->type == GS_SHADER_VERTEX) {
|
||||
dstr_cat(&glsp->gl_string, "out gl_PerVertex {\n"
|
||||
"\tvec4 gl_Position;\n};\n\n");
|
||||
}
|
||||
|
@ -470,7 +470,7 @@ static inline void gl_write_main_interface_assign(
|
|||
const char *src)
|
||||
{
|
||||
/* vertex shaders: write gl_Position */
|
||||
if (glsp->type == SHADER_VERTEX &&
|
||||
if (glsp->type == GS_SHADER_VERTEX &&
|
||||
strcmp(var->mapping, "POSITION") == 0) {
|
||||
dstr_cat(&glsp->gl_string, "\tgl_Position = ");
|
||||
dstr_cat(&glsp->gl_string, src);
|
||||
|
|
|
@ -43,7 +43,7 @@ static inline void gl_parser_attrib_free(struct gl_parser_attrib *attr)
|
|||
}
|
||||
|
||||
struct gl_shader_parser {
|
||||
enum shader_type type;
|
||||
enum gs_shader_type type;
|
||||
const char *input_prefix;
|
||||
const char *output_prefix;
|
||||
struct shader_parser parser;
|
||||
|
@ -54,14 +54,14 @@ struct gl_shader_parser {
|
|||
};
|
||||
|
||||
static inline void gl_shader_parser_init(struct gl_shader_parser *glsp,
|
||||
enum shader_type type)
|
||||
enum gs_shader_type type)
|
||||
{
|
||||
glsp->type = type;
|
||||
|
||||
if (type == SHADER_VERTEX) {
|
||||
if (type == GS_SHADER_VERTEX) {
|
||||
glsp->input_prefix = "_input_attrib";
|
||||
glsp->output_prefix = "_vertex_shader_attrib";
|
||||
} else if (type == SHADER_PIXEL) {
|
||||
} else if (type == GS_SHADER_PIXEL) {
|
||||
glsp->input_prefix = "_vertex_shader_attrib";
|
||||
glsp->output_prefix = "_pixel_shader_attrib";
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ static bool create_pixel_pack_buffer(struct gs_stage_surface *surf)
|
|||
return success;
|
||||
}
|
||||
|
||||
stagesurf_t device_create_stagesurface(device_t device, uint32_t width,
|
||||
gs_stagesurf_t device_stagesurface_create(gs_device_t device, uint32_t width,
|
||||
uint32_t height, enum gs_color_format color_format)
|
||||
{
|
||||
struct gs_stage_surface *surf;
|
||||
|
@ -57,15 +57,15 @@ stagesurf_t device_create_stagesurface(device_t device, uint32_t width,
|
|||
surf->bytes_per_pixel = gs_get_format_bpp(color_format)/8;
|
||||
|
||||
if (!create_pixel_pack_buffer(surf)) {
|
||||
blog(LOG_ERROR, "device_create_stagesurface (GL) failed");
|
||||
stagesurface_destroy(surf);
|
||||
blog(LOG_ERROR, "device_stagesurface_create (GL) failed");
|
||||
gs_stagesurface_destroy(surf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return surf;
|
||||
}
|
||||
|
||||
void stagesurface_destroy(stagesurf_t stagesurf)
|
||||
void gs_stagesurface_destroy(gs_stagesurf_t stagesurf)
|
||||
{
|
||||
if (stagesurf) {
|
||||
if (stagesurf->pack_buffer)
|
||||
|
@ -110,7 +110,8 @@ static bool can_stage(struct gs_stage_surface *dst, struct gs_texture_2d *src)
|
|||
|
||||
/* Apparently for mac, PBOs won't do an asynchronous transfer unless you use
|
||||
* FBOs aong with glReadPixels, which is really dumb. */
|
||||
void device_stage_texture(device_t device, stagesurf_t dst, texture_t src)
|
||||
void device_stage_texture(gs_device_t device, gs_stagesurf_t dst,
|
||||
gs_texture_t src)
|
||||
{
|
||||
struct gs_texture_2d *tex2d = (struct gs_texture_2d*)src;
|
||||
struct fbo_info *fbo;
|
||||
|
@ -155,7 +156,8 @@ failed:
|
|||
|
||||
#else
|
||||
|
||||
void device_stage_texture(device_t device, stagesurf_t dst, texture_t src)
|
||||
void device_stage_texture(gs_device_t device, gs_stagesurf_t dst,
|
||||
gs_texture_t src)
|
||||
{
|
||||
struct gs_texture_2d *tex2d = (struct gs_texture_2d*)src;
|
||||
if (!can_stage(dst, tex2d))
|
||||
|
@ -184,22 +186,23 @@ failed:
|
|||
|
||||
#endif
|
||||
|
||||
uint32_t stagesurface_getwidth(stagesurf_t stagesurf)
|
||||
uint32_t gs_stagesurface_get_width(gs_stagesurf_t stagesurf)
|
||||
{
|
||||
return stagesurf->width;
|
||||
}
|
||||
|
||||
uint32_t stagesurface_getheight(stagesurf_t stagesurf)
|
||||
uint32_t gs_stagesurface_get_height(gs_stagesurf_t stagesurf)
|
||||
{
|
||||
return stagesurf->height;
|
||||
}
|
||||
|
||||
enum gs_color_format stagesurface_getcolorformat(stagesurf_t stagesurf)
|
||||
enum gs_color_format gs_stagesurface_get_color_format(gs_stagesurf_t stagesurf)
|
||||
{
|
||||
return stagesurf->format;
|
||||
}
|
||||
|
||||
bool stagesurface_map(stagesurf_t stagesurf, uint8_t **data, uint32_t *linesize)
|
||||
bool gs_stagesurface_map(gs_stagesurf_t stagesurf, uint8_t **data,
|
||||
uint32_t *linesize)
|
||||
{
|
||||
if (!gl_bind_buffer(GL_PIXEL_PACK_BUFFER, stagesurf->pack_buffer))
|
||||
goto fail;
|
||||
|
@ -218,7 +221,7 @@ fail:
|
|||
return false;
|
||||
}
|
||||
|
||||
void stagesurface_unmap(stagesurf_t stagesurf)
|
||||
void gs_stagesurface_unmap(gs_stagesurf_t stagesurf)
|
||||
{
|
||||
if (!gl_bind_buffer(GL_PIXEL_PACK_BUFFER, stagesurf->pack_buffer))
|
||||
return;
|
||||
|
|
|
@ -182,12 +182,12 @@ void convert_sampler_info(struct gs_sampler_state *sampler,
|
|||
info->max_anisotropy, sampler->max_anisotropy);
|
||||
}
|
||||
|
||||
const char *device_name(void)
|
||||
const char *device_get_name(void)
|
||||
{
|
||||
return "OpenGL";
|
||||
}
|
||||
|
||||
int device_type(void)
|
||||
int device_get_type(void)
|
||||
{
|
||||
return GS_DEVICE_OPENGL;
|
||||
}
|
||||
|
@ -197,7 +197,7 @@ const char *device_preprocessor_name(void)
|
|||
return "_OPENGL";
|
||||
}
|
||||
|
||||
int device_create(device_t *p_device, struct gs_init_data *info)
|
||||
int device_create(gs_device_t *p_device, struct gs_init_data *info)
|
||||
{
|
||||
struct gs_device *device = bzalloc(sizeof(struct gs_device));
|
||||
int errorcode = GS_ERROR_FAIL;
|
||||
|
@ -221,7 +221,7 @@ int device_create(device_t *p_device, struct gs_init_data *info)
|
|||
if (!gl_success("glBindProgramPipeline"))
|
||||
goto fail;
|
||||
|
||||
device_leavecontext(device);
|
||||
device_leave_context(device);
|
||||
device->cur_swap = gl_platform_getswap(device->plat);
|
||||
|
||||
*p_device = device;
|
||||
|
@ -235,7 +235,7 @@ fail:
|
|||
return errorcode;
|
||||
}
|
||||
|
||||
void device_destroy(device_t device)
|
||||
void device_destroy(gs_device_t device)
|
||||
{
|
||||
if (device) {
|
||||
size_t i;
|
||||
|
@ -252,7 +252,8 @@ void device_destroy(device_t device)
|
|||
}
|
||||
}
|
||||
|
||||
swapchain_t device_create_swapchain(device_t device, struct gs_init_data *info)
|
||||
gs_swapchain_t device_swapchain_create(gs_device_t device,
|
||||
struct gs_init_data *info)
|
||||
{
|
||||
struct gs_swap_chain *swap = bzalloc(sizeof(struct gs_swap_chain));
|
||||
|
||||
|
@ -260,21 +261,21 @@ swapchain_t device_create_swapchain(device_t device, struct gs_init_data *info)
|
|||
swap->info = *info;
|
||||
swap->wi = gl_windowinfo_create(info);
|
||||
if (!swap->wi) {
|
||||
blog(LOG_ERROR, "device_create_swapchain (GL) failed");
|
||||
swapchain_destroy(swap);
|
||||
blog(LOG_ERROR, "device_swapchain_create (GL) failed");
|
||||
gs_swapchain_destroy(swap);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!gl_platform_init_swapchain(swap)) {
|
||||
blog(LOG_ERROR, "gl_platform_init_swapchain failed");
|
||||
swapchain_destroy(swap);
|
||||
gs_swapchain_destroy(swap);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return swap;
|
||||
}
|
||||
|
||||
void device_resize(device_t device, uint32_t cx, uint32_t cy)
|
||||
void device_resize(gs_device_t device, uint32_t cx, uint32_t cy)
|
||||
{
|
||||
/* GL automatically resizes the device, so it doesn't do much */
|
||||
device->cur_swap->info.cx = cx;
|
||||
|
@ -283,23 +284,23 @@ void device_resize(device_t device, uint32_t cx, uint32_t cy)
|
|||
gl_update(device);
|
||||
}
|
||||
|
||||
void device_getsize(device_t device, uint32_t *cx, uint32_t *cy)
|
||||
void device_get_size(gs_device_t device, uint32_t *cx, uint32_t *cy)
|
||||
{
|
||||
*cx = device->cur_swap->info.cx;
|
||||
*cy = device->cur_swap->info.cy;
|
||||
}
|
||||
|
||||
uint32_t device_getwidth(device_t device)
|
||||
uint32_t device_get_width(gs_device_t device)
|
||||
{
|
||||
return device->cur_swap->info.cx;
|
||||
}
|
||||
|
||||
uint32_t device_getheight(device_t device)
|
||||
uint32_t device_get_height(gs_device_t device)
|
||||
{
|
||||
return device->cur_swap->info.cy;
|
||||
}
|
||||
|
||||
texture_t device_create_volumetexture(device_t device, uint32_t width,
|
||||
gs_texture_t device_voltexture_create(gs_device_t device, uint32_t width,
|
||||
uint32_t height, uint32_t depth,
|
||||
enum gs_color_format color_format, uint32_t levels,
|
||||
const uint8_t **data, uint32_t flags)
|
||||
|
@ -316,7 +317,7 @@ texture_t device_create_volumetexture(device_t device, uint32_t width,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
samplerstate_t device_create_samplerstate(device_t device,
|
||||
gs_samplerstate_t device_samplerstate_create(gs_device_t device,
|
||||
struct gs_sampler_info *info)
|
||||
{
|
||||
struct gs_sampler_state *sampler;
|
||||
|
@ -329,7 +330,7 @@ samplerstate_t device_create_samplerstate(device_t device,
|
|||
return sampler;
|
||||
}
|
||||
|
||||
enum gs_texture_type device_gettexturetype(texture_t texture)
|
||||
enum gs_texture_type device_get_texture_type(gs_texture_t texture)
|
||||
{
|
||||
return texture->type;
|
||||
}
|
||||
|
@ -362,7 +363,7 @@ static inline void apply_swizzle(struct gs_texture *tex)
|
|||
}
|
||||
}
|
||||
|
||||
static bool load_texture_sampler(texture_t tex, samplerstate_t ss)
|
||||
static bool load_texture_sampler(gs_texture_t tex, gs_samplerstate_t ss)
|
||||
{
|
||||
bool success = true;
|
||||
GLint min_filter;
|
||||
|
@ -379,7 +380,7 @@ static bool load_texture_sampler(texture_t tex, samplerstate_t ss)
|
|||
samplerstate_addref(ss);
|
||||
|
||||
min_filter = ss->min_filter;
|
||||
if (texture_isrect(tex))
|
||||
if (gs_texture_is_rect(tex))
|
||||
strip_mipmap_filter(&min_filter);
|
||||
|
||||
if (!gl_tex_param_i(tex->gl_target, GL_TEXTURE_MIN_FILTER,
|
||||
|
@ -403,14 +404,15 @@ static bool load_texture_sampler(texture_t tex, samplerstate_t ss)
|
|||
return success;
|
||||
}
|
||||
|
||||
static inline struct shader_param *get_texture_param(device_t device, int unit)
|
||||
static inline struct gs_shader_param *get_texture_param(gs_device_t device,
|
||||
int unit)
|
||||
{
|
||||
struct gs_shader *shader = device->cur_pixel_shader;
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < shader->params.num; i++) {
|
||||
struct shader_param *param = shader->params.array+i;
|
||||
if (param->type == SHADER_PARAM_TEXTURE) {
|
||||
struct gs_shader_param *param = shader->params.array+i;
|
||||
if (param->type == GS_SHADER_PARAM_TEXTURE) {
|
||||
if (param->texture_id == unit)
|
||||
return param;
|
||||
}
|
||||
|
@ -419,9 +421,9 @@ static inline struct shader_param *get_texture_param(device_t device, int unit)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void device_load_texture(device_t device, texture_t tex, int unit)
|
||||
void device_load_texture(gs_device_t device, gs_texture_t tex, int unit)
|
||||
{
|
||||
struct shader_param *param;
|
||||
struct gs_shader_param *param;
|
||||
struct gs_sampler_state *sampler;
|
||||
struct gs_texture *cur_tex = device->cur_textures[unit];
|
||||
|
||||
|
@ -463,16 +465,16 @@ fail:
|
|||
blog(LOG_ERROR, "device_load_texture (GL) failed");
|
||||
}
|
||||
|
||||
static bool load_sampler_on_textures(device_t device, samplerstate_t ss,
|
||||
static bool load_sampler_on_textures(gs_device_t device, gs_samplerstate_t ss,
|
||||
int sampler_unit)
|
||||
{
|
||||
struct gs_shader *shader = device->cur_pixel_shader;
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < shader->params.num; i++) {
|
||||
struct shader_param *param = shader->params.array+i;
|
||||
struct gs_shader_param *param = shader->params.array+i;
|
||||
|
||||
if (param->type == SHADER_PARAM_TEXTURE &&
|
||||
if (param->type == GS_SHADER_PARAM_TEXTURE &&
|
||||
param->sampler_id == (uint32_t)sampler_unit &&
|
||||
param->texture) {
|
||||
if (!gl_active_texture(GL_TEXTURE0 + param->texture_id))
|
||||
|
@ -485,7 +487,8 @@ static bool load_sampler_on_textures(device_t device, samplerstate_t ss,
|
|||
return true;
|
||||
}
|
||||
|
||||
void device_load_samplerstate(device_t device, samplerstate_t ss, int unit)
|
||||
void device_load_samplerstate(gs_device_t device, gs_samplerstate_t ss,
|
||||
int unit)
|
||||
{
|
||||
/* need a pixel shader to properly bind samplers */
|
||||
if (!device->cur_pixel_shader)
|
||||
|
@ -505,15 +508,15 @@ void device_load_samplerstate(device_t device, samplerstate_t ss, int unit)
|
|||
return;
|
||||
}
|
||||
|
||||
void device_load_vertexshader(device_t device, shader_t vertshader)
|
||||
void device_load_vertexshader(gs_device_t device, gs_shader_t vertshader)
|
||||
{
|
||||
GLuint program = 0;
|
||||
vertbuffer_t cur_vb = device->cur_vertex_buffer;
|
||||
gs_vertbuffer_t cur_vb = device->cur_vertex_buffer;
|
||||
|
||||
if (device->cur_vertex_shader == vertshader)
|
||||
return;
|
||||
|
||||
if (vertshader && vertshader->type != SHADER_VERTEX) {
|
||||
if (vertshader && vertshader->type != GS_SHADER_VERTEX) {
|
||||
blog(LOG_ERROR, "Specified shader is not a vertex shader");
|
||||
goto fail;
|
||||
}
|
||||
|
@ -557,13 +560,13 @@ static void load_default_pixelshader_samplers(struct gs_device *device,
|
|||
device->cur_samplers[i] = NULL;
|
||||
}
|
||||
|
||||
void device_load_pixelshader(device_t device, shader_t pixelshader)
|
||||
void device_load_pixelshader(gs_device_t device, gs_shader_t pixelshader)
|
||||
{
|
||||
GLuint program = 0;
|
||||
if (device->cur_pixel_shader == pixelshader)
|
||||
return;
|
||||
|
||||
if (pixelshader && pixelshader->type != SHADER_PIXEL) {
|
||||
if (pixelshader && pixelshader->type != GS_SHADER_PIXEL) {
|
||||
blog(LOG_ERROR, "Specified shader is not a pixel shader");
|
||||
goto fail;
|
||||
}
|
||||
|
@ -587,7 +590,7 @@ fail:
|
|||
blog(LOG_ERROR, "device_load_pixelshader (GL) failed");
|
||||
}
|
||||
|
||||
void device_load_defaultsamplerstate(device_t device, bool b_3d, int unit)
|
||||
void device_load_default_samplerstate(gs_device_t device, bool b_3d, int unit)
|
||||
{
|
||||
/* TODO */
|
||||
UNUSED_PARAMETER(device);
|
||||
|
@ -595,27 +598,28 @@ void device_load_defaultsamplerstate(device_t device, bool b_3d, int unit)
|
|||
UNUSED_PARAMETER(unit);
|
||||
}
|
||||
|
||||
shader_t device_getvertexshader(device_t device)
|
||||
gs_shader_t device_get_vertex_shader(gs_device_t device)
|
||||
{
|
||||
return device->cur_vertex_shader;
|
||||
}
|
||||
|
||||
shader_t device_getpixelshader(device_t device)
|
||||
gs_shader_t device_get_pixel_shader(gs_device_t device)
|
||||
{
|
||||
return device->cur_pixel_shader;
|
||||
}
|
||||
|
||||
texture_t device_getrendertarget(device_t device)
|
||||
gs_texture_t device_get_render_target(gs_device_t device)
|
||||
{
|
||||
return device->cur_render_target;
|
||||
}
|
||||
|
||||
zstencil_t device_getzstenciltarget(device_t device)
|
||||
gs_zstencil_t device_get_zstencil_target(gs_device_t device)
|
||||
{
|
||||
return device->cur_zstencil_buffer;
|
||||
}
|
||||
|
||||
static bool get_tex_dimensions(texture_t tex, uint32_t *width, uint32_t *height)
|
||||
static bool get_tex_dimensions(gs_texture_t tex, uint32_t *width,
|
||||
uint32_t *height)
|
||||
{
|
||||
if (tex->type == GS_TEXTURE_2D) {
|
||||
struct gs_texture_2d *tex2d = (struct gs_texture_2d*)tex;
|
||||
|
@ -671,7 +675,7 @@ struct fbo_info *get_fbo(struct gs_device *device,
|
|||
}
|
||||
|
||||
static inline struct fbo_info *get_fbo_by_tex(struct gs_device *device,
|
||||
texture_t tex)
|
||||
gs_texture_t tex)
|
||||
{
|
||||
uint32_t width, height;
|
||||
if (!get_tex_dimensions(tex, &width, &height))
|
||||
|
@ -680,7 +684,7 @@ static inline struct fbo_info *get_fbo_by_tex(struct gs_device *device,
|
|||
return get_fbo(device, width, height, tex->format);
|
||||
}
|
||||
|
||||
static bool set_current_fbo(device_t device, struct fbo_info *fbo)
|
||||
static bool set_current_fbo(gs_device_t device, struct fbo_info *fbo)
|
||||
{
|
||||
if (device->cur_fbo != fbo) {
|
||||
GLuint fbo_obj = fbo ? fbo->fbo : 0;
|
||||
|
@ -692,7 +696,8 @@ static bool set_current_fbo(device_t device, struct fbo_info *fbo)
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool attach_rendertarget(struct fbo_info *fbo, texture_t tex, int side)
|
||||
static bool attach_rendertarget(struct fbo_info *fbo, gs_texture_t tex,
|
||||
int side)
|
||||
{
|
||||
if (fbo->cur_render_target == tex)
|
||||
return true;
|
||||
|
@ -717,7 +722,7 @@ static bool attach_rendertarget(struct fbo_info *fbo, texture_t tex, int side)
|
|||
return gl_success("glFramebufferTexture2D");
|
||||
}
|
||||
|
||||
static bool attach_zstencil(struct fbo_info *fbo, zstencil_t zs)
|
||||
static bool attach_zstencil(struct fbo_info *fbo, gs_zstencil_t zs)
|
||||
{
|
||||
GLuint zsbuffer = 0;
|
||||
GLenum zs_attachment = GL_DEPTH_STENCIL_ATTACHMENT;
|
||||
|
@ -740,7 +745,8 @@ static bool attach_zstencil(struct fbo_info *fbo, zstencil_t zs)
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool set_target(device_t device, texture_t tex, int side, zstencil_t zs)
|
||||
static bool set_target(gs_device_t device, gs_texture_t tex, int side,
|
||||
gs_zstencil_t zs)
|
||||
{
|
||||
struct fbo_info *fbo;
|
||||
|
||||
|
@ -770,7 +776,8 @@ static bool set_target(device_t device, texture_t tex, int side, zstencil_t zs)
|
|||
return true;
|
||||
}
|
||||
|
||||
void device_setrendertarget(device_t device, texture_t tex, zstencil_t zstencil)
|
||||
void device_set_render_target(gs_device_t device, gs_texture_t tex,
|
||||
gs_zstencil_t zstencil)
|
||||
{
|
||||
if (tex) {
|
||||
if (tex->type != GS_TEXTURE_2D) {
|
||||
|
@ -790,11 +797,11 @@ void device_setrendertarget(device_t device, texture_t tex, zstencil_t zstencil)
|
|||
return;
|
||||
|
||||
fail:
|
||||
blog(LOG_ERROR, "device_setrendertarget (GL) failed");
|
||||
blog(LOG_ERROR, "device_set_render_target (GL) failed");
|
||||
}
|
||||
|
||||
void device_setcuberendertarget(device_t device, texture_t cubetex,
|
||||
int side, zstencil_t zstencil)
|
||||
void device_set_cube_render_target(gs_device_t device, gs_texture_t cubetex,
|
||||
int side, gs_zstencil_t zstencil)
|
||||
{
|
||||
if (cubetex) {
|
||||
if (cubetex->type != GS_TEXTURE_CUBE) {
|
||||
|
@ -814,12 +821,12 @@ void device_setcuberendertarget(device_t device, texture_t cubetex,
|
|||
return;
|
||||
|
||||
fail:
|
||||
blog(LOG_ERROR, "device_setcuberendertarget (GL) failed");
|
||||
blog(LOG_ERROR, "device_set_cube_render_target (GL) failed");
|
||||
}
|
||||
|
||||
void device_copy_texture_region(device_t device,
|
||||
texture_t dst, uint32_t dst_x, uint32_t dst_y,
|
||||
texture_t src, uint32_t src_x, uint32_t src_y,
|
||||
void device_copy_texture_region(gs_device_t device,
|
||||
gs_texture_t 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)
|
||||
{
|
||||
struct gs_texture_2d *src2d = (struct gs_texture_2d*)src;
|
||||
|
@ -851,7 +858,7 @@ void device_copy_texture_region(device_t device,
|
|||
|
||||
if (dst2d->width - dst_x < nw || dst2d->height - dst_y < nh) {
|
||||
blog(LOG_ERROR, "Destination texture region is not big "
|
||||
"enough to hold the source region");
|
||||
"enough to hold the source region");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -866,17 +873,17 @@ fail:
|
|||
blog(LOG_ERROR, "device_copy_texture (GL) failed");
|
||||
}
|
||||
|
||||
void device_copy_texture(device_t device, texture_t dst, texture_t src)
|
||||
void device_copy_texture(gs_device_t device, gs_texture_t dst, gs_texture_t src)
|
||||
{
|
||||
device_copy_texture_region(device, dst, 0, 0, src, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
void device_beginscene(device_t device)
|
||||
void device_begin_scene(gs_device_t device)
|
||||
{
|
||||
clear_textures(device);
|
||||
}
|
||||
|
||||
static inline bool can_render(device_t device)
|
||||
static inline bool can_render(gs_device_t device)
|
||||
{
|
||||
if (!device->cur_vertex_shader) {
|
||||
blog(LOG_ERROR, "No vertex shader specified");
|
||||
|
@ -906,10 +913,10 @@ static void update_viewproj_matrix(struct gs_device *device)
|
|||
matrix4_transpose(&device->cur_viewproj, &device->cur_viewproj);
|
||||
|
||||
if (vs->viewproj)
|
||||
shader_setmatrix4(vs->viewproj, &device->cur_viewproj);
|
||||
gs_shader_set_matrix4(vs->viewproj, &device->cur_viewproj);
|
||||
}
|
||||
|
||||
static inline bool check_shader_pipeline_validity(device_t device)
|
||||
static inline bool check_shader_pipeline_validity(gs_device_t device)
|
||||
{
|
||||
int valid = false;
|
||||
|
||||
|
@ -927,18 +934,18 @@ static inline bool check_shader_pipeline_validity(device_t device)
|
|||
return valid != 0;
|
||||
}
|
||||
|
||||
void device_draw(device_t device, enum gs_draw_mode draw_mode,
|
||||
void device_draw(gs_device_t device, enum gs_draw_mode draw_mode,
|
||||
uint32_t start_vert, uint32_t num_verts)
|
||||
{
|
||||
struct gs_index_buffer *ib = device->cur_index_buffer;
|
||||
GLenum topology = convert_gs_topology(draw_mode);
|
||||
effect_t effect = gs_geteffect();
|
||||
gs_effect_t effect = gs_get_effect();
|
||||
|
||||
if (!can_render(device))
|
||||
goto fail;
|
||||
|
||||
if (effect)
|
||||
effect_updateparams(effect);
|
||||
gs_effect_update_params(effect);
|
||||
|
||||
shader_update_textures(device->cur_pixel_shader);
|
||||
|
||||
|
@ -972,13 +979,13 @@ fail:
|
|||
blog(LOG_ERROR, "device_draw (GL) failed");
|
||||
}
|
||||
|
||||
void device_endscene(device_t device)
|
||||
void device_end_scene(gs_device_t device)
|
||||
{
|
||||
/* does nothing */
|
||||
UNUSED_PARAMETER(device);
|
||||
}
|
||||
|
||||
void device_clear(device_t device, uint32_t clear_flags,
|
||||
void device_clear(gs_device_t device, uint32_t clear_flags,
|
||||
struct vec4 *color, float depth, uint8_t stencil)
|
||||
{
|
||||
GLbitfield gl_flags = 0;
|
||||
|
@ -1005,14 +1012,14 @@ void device_clear(device_t device, uint32_t clear_flags,
|
|||
UNUSED_PARAMETER(device);
|
||||
}
|
||||
|
||||
void device_flush(device_t device)
|
||||
void device_flush(gs_device_t device)
|
||||
{
|
||||
glFlush();
|
||||
|
||||
UNUSED_PARAMETER(device);
|
||||
}
|
||||
|
||||
void device_setcullmode(device_t device, enum gs_cull_mode mode)
|
||||
void device_set_cull_mode(gs_device_t device, enum gs_cull_mode mode)
|
||||
{
|
||||
if (device->cur_cull_mode == mode)
|
||||
return;
|
||||
|
@ -1030,12 +1037,12 @@ void device_setcullmode(device_t device, enum gs_cull_mode mode)
|
|||
gl_disable(GL_CULL_FACE);
|
||||
}
|
||||
|
||||
enum gs_cull_mode device_getcullmode(device_t device)
|
||||
enum gs_cull_mode device_get_cull_mode(gs_device_t device)
|
||||
{
|
||||
return device->cur_cull_mode;
|
||||
}
|
||||
|
||||
void device_enable_blending(device_t device, bool enable)
|
||||
void device_enable_blending(gs_device_t device, bool enable)
|
||||
{
|
||||
if (enable)
|
||||
gl_enable(GL_BLEND);
|
||||
|
@ -1045,7 +1052,7 @@ void device_enable_blending(device_t device, bool enable)
|
|||
UNUSED_PARAMETER(device);
|
||||
}
|
||||
|
||||
void device_enable_depthtest(device_t device, bool enable)
|
||||
void device_enable_depth_test(gs_device_t device, bool enable)
|
||||
{
|
||||
if (enable)
|
||||
gl_enable(GL_DEPTH_TEST);
|
||||
|
@ -1055,7 +1062,7 @@ void device_enable_depthtest(device_t device, bool enable)
|
|||
UNUSED_PARAMETER(device);
|
||||
}
|
||||
|
||||
void device_enable_stenciltest(device_t device, bool enable)
|
||||
void device_enable_stencil_test(gs_device_t device, bool enable)
|
||||
{
|
||||
if (enable)
|
||||
gl_enable(GL_STENCIL_TEST);
|
||||
|
@ -1065,7 +1072,7 @@ void device_enable_stenciltest(device_t device, bool enable)
|
|||
UNUSED_PARAMETER(device);
|
||||
}
|
||||
|
||||
void device_enable_stencilwrite(device_t device, bool enable)
|
||||
void device_enable_stencil_write(gs_device_t device, bool enable)
|
||||
{
|
||||
if (enable)
|
||||
glStencilMask(0xFFFFFFFF);
|
||||
|
@ -1075,7 +1082,7 @@ void device_enable_stencilwrite(device_t device, bool enable)
|
|||
UNUSED_PARAMETER(device);
|
||||
}
|
||||
|
||||
void device_enable_color(device_t device, bool red, bool green,
|
||||
void device_enable_color(gs_device_t device, bool red, bool green,
|
||||
bool blue, bool alpha)
|
||||
{
|
||||
glColorMask(red, green, blue, alpha);
|
||||
|
@ -1083,7 +1090,7 @@ void device_enable_color(device_t device, bool red, bool green,
|
|||
UNUSED_PARAMETER(device);
|
||||
}
|
||||
|
||||
void device_blendfunction(device_t device, enum gs_blend_type src,
|
||||
void device_blend_function(gs_device_t device, enum gs_blend_type src,
|
||||
enum gs_blend_type dest)
|
||||
{
|
||||
GLenum gl_src = convert_gs_blend_type(src);
|
||||
|
@ -1091,23 +1098,23 @@ void device_blendfunction(device_t device, enum gs_blend_type src,
|
|||
|
||||
glBlendFunc(gl_src, gl_dst);
|
||||
if (!gl_success("glBlendFunc"))
|
||||
blog(LOG_ERROR, "device_blendfunction (GL) failed");
|
||||
blog(LOG_ERROR, "device_blend_function (GL) failed");
|
||||
|
||||
UNUSED_PARAMETER(device);
|
||||
}
|
||||
|
||||
void device_depthfunction(device_t device, enum gs_depth_test test)
|
||||
void device_depth_function(gs_device_t device, enum gs_depth_test test)
|
||||
{
|
||||
GLenum gl_test = convert_gs_depth_test(test);
|
||||
|
||||
glDepthFunc(gl_test);
|
||||
if (!gl_success("glDepthFunc"))
|
||||
blog(LOG_ERROR, "device_depthfunction (GL) failed");
|
||||
blog(LOG_ERROR, "device_depth_function (GL) failed");
|
||||
|
||||
UNUSED_PARAMETER(device);
|
||||
}
|
||||
|
||||
void device_stencilfunction(device_t device, enum gs_stencil_side side,
|
||||
void device_stencil_function(gs_device_t device, enum gs_stencil_side side,
|
||||
enum gs_depth_test test)
|
||||
{
|
||||
GLenum gl_side = convert_gs_stencil_side(side);
|
||||
|
@ -1115,14 +1122,14 @@ void device_stencilfunction(device_t device, enum gs_stencil_side side,
|
|||
|
||||
glStencilFuncSeparate(gl_side, gl_test, 0, 0xFFFFFFFF);
|
||||
if (!gl_success("glStencilFuncSeparate"))
|
||||
blog(LOG_ERROR, "device_stencilfunction (GL) failed");
|
||||
blog(LOG_ERROR, "device_stencil_function (GL) failed");
|
||||
|
||||
UNUSED_PARAMETER(device);
|
||||
}
|
||||
|
||||
void device_stencilop(device_t device, enum gs_stencil_side side,
|
||||
enum gs_stencil_op fail, enum gs_stencil_op zfail,
|
||||
enum gs_stencil_op zpass)
|
||||
void device_stencil_op(gs_device_t device, enum gs_stencil_side side,
|
||||
enum gs_stencil_op_type fail, enum gs_stencil_op_type zfail,
|
||||
enum gs_stencil_op_type zpass)
|
||||
{
|
||||
GLenum gl_side = convert_gs_stencil_side(side);
|
||||
GLenum gl_fail = convert_gs_stencil_op(fail);
|
||||
|
@ -1131,7 +1138,7 @@ void device_stencilop(device_t device, enum gs_stencil_side side,
|
|||
|
||||
glStencilOpSeparate(gl_side, gl_fail, gl_zfail, gl_zpass);
|
||||
if (!gl_success("glStencilOpSeparate"))
|
||||
blog(LOG_ERROR, "device_stencilop (GL) failed");
|
||||
blog(LOG_ERROR, "device_stencil_op (GL) failed");
|
||||
|
||||
UNUSED_PARAMETER(device);
|
||||
}
|
||||
|
@ -1139,15 +1146,15 @@ void device_stencilop(device_t device, enum gs_stencil_side side,
|
|||
static inline uint32_t get_target_height(struct gs_device *device)
|
||||
{
|
||||
if (!device->cur_render_target)
|
||||
return device_getheight(device);
|
||||
return device_get_height(device);
|
||||
|
||||
if (device->cur_render_target->type == GS_TEXTURE_2D)
|
||||
return texture_getheight(device->cur_render_target);
|
||||
return gs_texture_get_height(device->cur_render_target);
|
||||
else /* cube map */
|
||||
return cubetexture_getsize(device->cur_render_target);
|
||||
return gs_cubetexture_get_size(device->cur_render_target);
|
||||
}
|
||||
|
||||
void device_setviewport(device_t device, int x, int y, int width,
|
||||
void device_set_viewport(gs_device_t device, int x, int y, int width,
|
||||
int height)
|
||||
{
|
||||
uint32_t base_height;
|
||||
|
@ -1162,7 +1169,7 @@ void device_setviewport(device_t device, int x, int y, int width,
|
|||
|
||||
glViewport(x, base_height - y - height, width, height);
|
||||
if (!gl_success("glViewport"))
|
||||
blog(LOG_ERROR, "device_setviewport (GL) failed");
|
||||
blog(LOG_ERROR, "device_set_viewport (GL) failed");
|
||||
|
||||
device->cur_viewport.x = x;
|
||||
device->cur_viewport.y = y;
|
||||
|
@ -1170,12 +1177,12 @@ void device_setviewport(device_t device, int x, int y, int width,
|
|||
device->cur_viewport.cy = height;
|
||||
}
|
||||
|
||||
void device_getviewport(device_t device, struct gs_rect *rect)
|
||||
void device_get_viewport(gs_device_t device, struct gs_rect *rect)
|
||||
{
|
||||
*rect = device->cur_viewport;
|
||||
}
|
||||
|
||||
void device_setscissorrect(device_t device, struct gs_rect *rect)
|
||||
void device_set_scissor_rect(gs_device_t device, struct gs_rect *rect)
|
||||
{
|
||||
UNUSED_PARAMETER(device);
|
||||
|
||||
|
@ -1188,10 +1195,10 @@ void device_setscissorrect(device_t device, struct gs_rect *rect)
|
|||
return;
|
||||
}
|
||||
|
||||
blog(LOG_ERROR, "device_setscissorrect (GL) failed");
|
||||
blog(LOG_ERROR, "device_set_scissor_rect (GL) failed");
|
||||
}
|
||||
|
||||
void device_ortho(device_t device, float left, float right,
|
||||
void device_ortho(gs_device_t device, float left, float right,
|
||||
float top, float bottom, float near, float far)
|
||||
{
|
||||
struct matrix4 *dst = &device->cur_proj;
|
||||
|
@ -1217,7 +1224,7 @@ void device_ortho(device_t device, float left, float right,
|
|||
dst->t.w = 1.0f;
|
||||
}
|
||||
|
||||
void device_frustum(device_t device, float left, float right,
|
||||
void device_frustum(gs_device_t device, float left, float right,
|
||||
float top, float bottom, float near, float far)
|
||||
{
|
||||
struct matrix4 *dst = &device->cur_proj;
|
||||
|
@ -1244,12 +1251,12 @@ void device_frustum(device_t device, float left, float right,
|
|||
dst->z.w = -1.0f;
|
||||
}
|
||||
|
||||
void device_projection_push(device_t device)
|
||||
void device_projection_push(gs_device_t device)
|
||||
{
|
||||
da_push_back(device->proj_stack, &device->cur_proj);
|
||||
}
|
||||
|
||||
void device_projection_pop(device_t device)
|
||||
void device_projection_pop(gs_device_t device)
|
||||
{
|
||||
struct matrix4 *end;
|
||||
if (!device->proj_stack.num)
|
||||
|
@ -1260,7 +1267,7 @@ void device_projection_pop(device_t device)
|
|||
da_pop_back(device->proj_stack);
|
||||
}
|
||||
|
||||
void swapchain_destroy(swapchain_t swapchain)
|
||||
void gs_swapchain_destroy(gs_swapchain_t swapchain)
|
||||
{
|
||||
if (!swapchain)
|
||||
return;
|
||||
|
@ -1274,41 +1281,41 @@ void swapchain_destroy(swapchain_t swapchain)
|
|||
bfree(swapchain);
|
||||
}
|
||||
|
||||
void volumetexture_destroy(texture_t voltex)
|
||||
void gs_voltexture_destroy(gs_texture_t voltex)
|
||||
{
|
||||
/* TODO */
|
||||
UNUSED_PARAMETER(voltex);
|
||||
}
|
||||
|
||||
uint32_t volumetexture_getwidth(texture_t voltex)
|
||||
uint32_t gs_voltexture_get_width(gs_texture_t voltex)
|
||||
{
|
||||
/* TODO */
|
||||
UNUSED_PARAMETER(voltex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t volumetexture_getheight(texture_t voltex)
|
||||
uint32_t gs_voltexture_get_height(gs_texture_t voltex)
|
||||
{
|
||||
/* TODO */
|
||||
UNUSED_PARAMETER(voltex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t volumetexture_getdepth(texture_t voltex)
|
||||
uint32_t gs_voltexture_getdepth(gs_texture_t voltex)
|
||||
{
|
||||
/* TODO */
|
||||
UNUSED_PARAMETER(voltex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
enum gs_color_format volumetexture_getcolorformat(texture_t voltex)
|
||||
enum gs_color_format gs_voltexture_get_color_format(gs_texture_t voltex)
|
||||
{
|
||||
/* TODO */
|
||||
UNUSED_PARAMETER(voltex);
|
||||
return GS_UNKNOWN;
|
||||
}
|
||||
|
||||
void samplerstate_destroy(samplerstate_t samplerstate)
|
||||
void gs_samplerstate_destroy(gs_samplerstate_t samplerstate)
|
||||
{
|
||||
if (!samplerstate)
|
||||
return;
|
||||
|
|
|
@ -143,7 +143,7 @@ static inline GLenum convert_gs_depth_test(enum gs_depth_test test)
|
|||
return GL_NEVER;
|
||||
}
|
||||
|
||||
static inline GLenum convert_gs_stencil_op(enum gs_stencil_op op)
|
||||
static inline GLenum convert_gs_stencil_op(enum gs_stencil_op_type op)
|
||||
{
|
||||
switch (op) {
|
||||
case GS_KEEP: return GL_KEEP;
|
||||
|
@ -187,11 +187,11 @@ static inline GLenum convert_gs_blend_type(enum gs_blend_type type)
|
|||
return GL_ONE;
|
||||
}
|
||||
|
||||
static inline GLenum convert_shader_type(enum shader_type type)
|
||||
static inline GLenum convert_shader_type(enum gs_shader_type type)
|
||||
{
|
||||
switch (type) {
|
||||
case SHADER_VERTEX: return GL_VERTEX_SHADER;
|
||||
case SHADER_PIXEL: return GL_FRAGMENT_SHADER;
|
||||
case GS_SHADER_VERTEX: return GL_VERTEX_SHADER;
|
||||
case GS_SHADER_PIXEL: return GL_FRAGMENT_SHADER;
|
||||
}
|
||||
|
||||
return GL_VERTEX_SHADER;
|
||||
|
@ -273,7 +273,7 @@ extern void convert_sampler_info(struct gs_sampler_state *sampler,
|
|||
struct gs_sampler_info *info);
|
||||
|
||||
struct gs_sampler_state {
|
||||
device_t device;
|
||||
gs_device_t device;
|
||||
volatile long ref;
|
||||
|
||||
GLint min_filter;
|
||||
|
@ -284,22 +284,22 @@ struct gs_sampler_state {
|
|||
GLint max_anisotropy;
|
||||
};
|
||||
|
||||
static inline void samplerstate_addref(samplerstate_t ss)
|
||||
static inline void samplerstate_addref(gs_samplerstate_t ss)
|
||||
{
|
||||
os_atomic_inc_long(&ss->ref);
|
||||
}
|
||||
|
||||
static inline void samplerstate_release(samplerstate_t ss)
|
||||
static inline void samplerstate_release(gs_samplerstate_t ss)
|
||||
{
|
||||
if (os_atomic_dec_long(&ss->ref) == 0)
|
||||
bfree(ss);
|
||||
}
|
||||
|
||||
struct shader_param {
|
||||
enum shader_param_type type;
|
||||
struct gs_shader_param {
|
||||
enum gs_shader_param_type type;
|
||||
|
||||
char *name;
|
||||
shader_t shader;
|
||||
gs_shader_t shader;
|
||||
GLint param;
|
||||
GLint texture_id;
|
||||
size_t sampler_id;
|
||||
|
@ -328,16 +328,16 @@ struct shader_attrib {
|
|||
};
|
||||
|
||||
struct gs_shader {
|
||||
device_t device;
|
||||
enum shader_type type;
|
||||
gs_device_t device;
|
||||
enum gs_shader_type type;
|
||||
GLuint program;
|
||||
|
||||
struct shader_param *viewproj;
|
||||
struct shader_param *world;
|
||||
struct gs_shader_param *viewproj;
|
||||
struct gs_shader_param *world;
|
||||
|
||||
DARRAY(struct shader_attrib) attribs;
|
||||
DARRAY(struct shader_param) params;
|
||||
DARRAY(samplerstate_t) samplers;
|
||||
DARRAY(struct shader_attrib) attribs;
|
||||
DARRAY(struct gs_shader_param) params;
|
||||
DARRAY(gs_samplerstate_t) samplers;
|
||||
};
|
||||
|
||||
extern void shader_update_textures(struct gs_shader *shader);
|
||||
|
@ -351,20 +351,20 @@ struct gs_vertex_buffer {
|
|||
DARRAY(GLuint) uv_buffers;
|
||||
DARRAY(size_t) uv_sizes;
|
||||
|
||||
device_t device;
|
||||
gs_device_t device;
|
||||
size_t num;
|
||||
bool dynamic;
|
||||
struct vb_data *data;
|
||||
struct gs_vb_data *data;
|
||||
};
|
||||
|
||||
extern bool vertexbuffer_load(device_t device, vertbuffer_t vb);
|
||||
extern bool vertexbuffer_load(gs_device_t device, gs_vertbuffer_t vb);
|
||||
|
||||
struct gs_index_buffer {
|
||||
GLuint buffer;
|
||||
enum gs_index_type type;
|
||||
GLuint gl_type;
|
||||
|
||||
device_t device;
|
||||
gs_device_t device;
|
||||
void *data;
|
||||
size_t num;
|
||||
size_t width;
|
||||
|
@ -373,7 +373,7 @@ struct gs_index_buffer {
|
|||
};
|
||||
|
||||
struct gs_texture {
|
||||
device_t device;
|
||||
gs_device_t device;
|
||||
enum gs_texture_type type;
|
||||
enum gs_color_format format;
|
||||
GLenum gl_format;
|
||||
|
@ -387,7 +387,7 @@ struct gs_texture {
|
|||
bool is_dummy;
|
||||
bool gen_mipmaps;
|
||||
|
||||
samplerstate_t cur_sampler;
|
||||
gs_samplerstate_t cur_sampler;
|
||||
};
|
||||
|
||||
struct gs_texture_2d {
|
||||
|
@ -406,7 +406,7 @@ struct gs_texture_cube {
|
|||
};
|
||||
|
||||
struct gs_stage_surface {
|
||||
device_t device;
|
||||
gs_device_t device;
|
||||
|
||||
enum gs_color_format format;
|
||||
uint32_t width;
|
||||
|
@ -420,14 +420,14 @@ struct gs_stage_surface {
|
|||
};
|
||||
|
||||
struct gs_zstencil_buffer {
|
||||
device_t device;
|
||||
gs_device_t device;
|
||||
GLuint buffer;
|
||||
GLuint attachment;
|
||||
GLenum format;
|
||||
};
|
||||
|
||||
struct gs_swap_chain {
|
||||
device_t device;
|
||||
gs_device_t device;
|
||||
struct gl_windowinfo *wi;
|
||||
struct gs_init_data info;
|
||||
};
|
||||
|
@ -438,9 +438,9 @@ struct fbo_info {
|
|||
uint32_t height;
|
||||
enum gs_color_format format;
|
||||
|
||||
texture_t cur_render_target;
|
||||
gs_texture_t cur_render_target;
|
||||
int cur_render_side;
|
||||
zstencil_t cur_zstencil_buffer;
|
||||
gs_zstencil_t cur_zstencil_buffer;
|
||||
};
|
||||
|
||||
static inline void fbo_info_destroy(struct fbo_info *fbo)
|
||||
|
@ -458,16 +458,16 @@ struct gs_device {
|
|||
GLuint pipeline;
|
||||
enum copy_type copy_type;
|
||||
|
||||
texture_t cur_render_target;
|
||||
zstencil_t cur_zstencil_buffer;
|
||||
gs_texture_t cur_render_target;
|
||||
gs_zstencil_t cur_zstencil_buffer;
|
||||
int cur_render_side;
|
||||
texture_t cur_textures[GS_MAX_TEXTURES];
|
||||
samplerstate_t cur_samplers[GS_MAX_TEXTURES];
|
||||
vertbuffer_t cur_vertex_buffer;
|
||||
indexbuffer_t cur_index_buffer;
|
||||
shader_t cur_vertex_shader;
|
||||
shader_t cur_pixel_shader;
|
||||
swapchain_t cur_swap;
|
||||
gs_texture_t cur_textures[GS_MAX_TEXTURES];
|
||||
gs_samplerstate_t cur_samplers[GS_MAX_TEXTURES];
|
||||
gs_vertbuffer_t cur_vertex_buffer;
|
||||
gs_indexbuffer_t cur_index_buffer;
|
||||
gs_shader_t cur_vertex_shader;
|
||||
gs_shader_t cur_pixel_shader;
|
||||
gs_swapchain_t cur_swap;
|
||||
|
||||
enum gs_cull_mode cur_cull_mode;
|
||||
struct gs_rect cur_viewport;
|
||||
|
@ -485,9 +485,9 @@ struct gs_device {
|
|||
extern struct fbo_info *get_fbo(struct gs_device *device,
|
||||
uint32_t width, uint32_t height, enum gs_color_format format);
|
||||
|
||||
extern void gl_update(device_t device);
|
||||
extern void gl_update(gs_device_t device);
|
||||
|
||||
extern struct gl_platform *gl_platform_create(device_t device,
|
||||
extern struct gl_platform *gl_platform_create(gs_device_t device,
|
||||
struct gs_init_data *info);
|
||||
extern struct gs_swap_chain *gl_platform_getswap(struct gl_platform *platform);
|
||||
extern void gl_platform_destroy(struct gl_platform *platform);
|
||||
|
|
|
@ -26,7 +26,7 @@ static bool upload_texture_2d(struct gs_texture_2d *tex, const uint8_t **data)
|
|||
bool success;
|
||||
|
||||
if (!num_levels)
|
||||
num_levels = gs_num_total_levels(tex->width, tex->height);
|
||||
num_levels = gs_get_total_levels(tex->width, tex->height);
|
||||
|
||||
if (!gl_bind_texture(GL_TEXTURE_2D, tex->base.texture))
|
||||
return false;
|
||||
|
@ -74,7 +74,7 @@ static bool create_pixel_unpack_buffer(struct gs_texture_2d *tex)
|
|||
return success;
|
||||
}
|
||||
|
||||
texture_t device_create_texture(device_t device, uint32_t width,
|
||||
gs_texture_t device_texture_create(gs_device_t device, uint32_t width,
|
||||
uint32_t height, enum gs_color_format color_format,
|
||||
uint32_t levels, const uint8_t **data, uint32_t flags)
|
||||
{
|
||||
|
@ -87,10 +87,10 @@ texture_t device_create_texture(device_t device, uint32_t width,
|
|||
tex->base.gl_internal_format = convert_gs_internal_format(color_format);
|
||||
tex->base.gl_type = get_gl_format_type(color_format);
|
||||
tex->base.gl_target = GL_TEXTURE_2D;
|
||||
tex->base.is_dynamic = (flags & GS_DYNAMIC) != 0;
|
||||
tex->base.is_render_target = (flags & GS_RENDERTARGET) != 0;
|
||||
tex->base.is_dummy = (flags & GS_GL_DUMMYTEX) != 0;
|
||||
tex->base.gen_mipmaps = (flags & GS_BUILDMIPMAPS) != 0;
|
||||
tex->base.is_dynamic = (flags & GS_DYNAMIC) != 0;
|
||||
tex->base.is_render_target = (flags & GS_RENDER_TARGET) != 0;
|
||||
tex->base.is_dummy = (flags & GS_GL_DUMMYTEX) != 0;
|
||||
tex->base.gen_mipmaps = (flags & GS_BUILD_MIPMAPS) != 0;
|
||||
tex->width = width;
|
||||
tex->height = height;
|
||||
|
||||
|
@ -104,15 +104,15 @@ texture_t device_create_texture(device_t device, uint32_t width,
|
|||
goto fail;
|
||||
}
|
||||
|
||||
return (texture_t)tex;
|
||||
return (gs_texture_t)tex;
|
||||
|
||||
fail:
|
||||
texture_destroy((texture_t)tex);
|
||||
blog(LOG_ERROR, "device_create_texture (GL) failed");
|
||||
gs_texture_destroy((gs_texture_t)tex);
|
||||
blog(LOG_ERROR, "device_texture_create (GL) failed");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline bool is_texture_2d(texture_t tex, const char *func)
|
||||
static inline bool is_texture_2d(gs_texture_t tex, const char *func)
|
||||
{
|
||||
bool is_tex2d = tex->type == GS_TEXTURE_2D;
|
||||
if (!is_tex2d)
|
||||
|
@ -120,17 +120,17 @@ static inline bool is_texture_2d(texture_t tex, const char *func)
|
|||
return is_tex2d;
|
||||
}
|
||||
|
||||
void texture_destroy(texture_t tex)
|
||||
void gs_texture_destroy(gs_texture_t tex)
|
||||
{
|
||||
struct gs_texture_2d *tex2d = (struct gs_texture_2d*)tex;
|
||||
if (!tex)
|
||||
return;
|
||||
|
||||
if (!is_texture_2d(tex, "texture_destroy"))
|
||||
if (!is_texture_2d(tex, "gs_texture_destroy"))
|
||||
return;
|
||||
|
||||
if (tex->cur_sampler)
|
||||
samplerstate_destroy(tex->cur_sampler);
|
||||
gs_samplerstate_destroy(tex->cur_sampler);
|
||||
|
||||
if (!tex->is_dummy && tex->is_dynamic && tex2d->unpack_buffer)
|
||||
gl_delete_buffers(1, &tex2d->unpack_buffer);
|
||||
|
@ -141,34 +141,34 @@ void texture_destroy(texture_t tex)
|
|||
bfree(tex);
|
||||
}
|
||||
|
||||
uint32_t texture_getwidth(texture_t tex)
|
||||
uint32_t gs_texture_get_width(gs_texture_t tex)
|
||||
{
|
||||
struct gs_texture_2d *tex2d = (struct gs_texture_2d*)tex;
|
||||
if (!is_texture_2d(tex, "texture_getwidth"))
|
||||
if (!is_texture_2d(tex, "gs_texture_get_width"))
|
||||
return 0;
|
||||
|
||||
return tex2d->width;
|
||||
}
|
||||
|
||||
uint32_t texture_getheight(texture_t tex)
|
||||
uint32_t gs_texture_get_height(gs_texture_t tex)
|
||||
{
|
||||
struct gs_texture_2d *tex2d = (struct gs_texture_2d*)tex;
|
||||
if (!is_texture_2d(tex, "texture_getheight"))
|
||||
if (!is_texture_2d(tex, "gs_texture_get_height"))
|
||||
return 0;
|
||||
|
||||
return tex2d->height;
|
||||
}
|
||||
|
||||
enum gs_color_format texture_getcolorformat(texture_t tex)
|
||||
enum gs_color_format gs_texture_get_color_format(gs_texture_t tex)
|
||||
{
|
||||
return tex->format;
|
||||
}
|
||||
|
||||
bool texture_map(texture_t tex, uint8_t **ptr, uint32_t *linesize)
|
||||
bool gs_texture_map(gs_texture_t tex, uint8_t **ptr, uint32_t *linesize)
|
||||
{
|
||||
struct gs_texture_2d *tex2d = (struct gs_texture_2d*)tex;
|
||||
|
||||
if (!is_texture_2d(tex, "texture_map"))
|
||||
if (!is_texture_2d(tex, "gs_texture_map"))
|
||||
goto fail;
|
||||
|
||||
if (!tex2d->base.is_dynamic) {
|
||||
|
@ -190,14 +190,14 @@ bool texture_map(texture_t tex, uint8_t **ptr, uint32_t *linesize)
|
|||
return true;
|
||||
|
||||
fail:
|
||||
blog(LOG_ERROR, "texture_map (GL) failed");
|
||||
blog(LOG_ERROR, "gs_texture_map (GL) failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
void texture_unmap(texture_t tex)
|
||||
void gs_texture_unmap(gs_texture_t tex)
|
||||
{
|
||||
struct gs_texture_2d *tex2d = (struct gs_texture_2d*)tex;
|
||||
if (!is_texture_2d(tex, "texture_unmap"))
|
||||
if (!is_texture_2d(tex, "gs_texture_unmap"))
|
||||
goto failed;
|
||||
|
||||
if (!gl_bind_buffer(GL_PIXEL_UNPACK_BUFFER, tex2d->unpack_buffer))
|
||||
|
@ -223,25 +223,25 @@ void texture_unmap(texture_t tex)
|
|||
failed:
|
||||
gl_bind_buffer(GL_PIXEL_UNPACK_BUFFER, 0);
|
||||
gl_bind_texture(GL_TEXTURE_2D, 0);
|
||||
blog(LOG_ERROR, "texture_unmap (GL) failed");
|
||||
blog(LOG_ERROR, "gs_texture_unmap (GL) failed");
|
||||
}
|
||||
|
||||
bool texture_isrect(texture_t tex)
|
||||
bool gs_texture_is_rect(gs_texture_t tex)
|
||||
{
|
||||
struct gs_texture_2d *tex2d = (struct gs_texture_2d*)tex;
|
||||
if (!is_texture_2d(tex, "texture_unmap")) {
|
||||
blog(LOG_ERROR, "texture_isrect (GL) failed");
|
||||
if (!is_texture_2d(tex, "gs_texture_unmap")) {
|
||||
blog(LOG_ERROR, "gs_texture_is_rect (GL) failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return tex2d->base.gl_target == GL_TEXTURE_RECTANGLE;
|
||||
}
|
||||
|
||||
void *texture_getobj(texture_t tex)
|
||||
void *gs_texture_get_obj(gs_texture_t tex)
|
||||
{
|
||||
struct gs_texture_2d *tex2d = (struct gs_texture_2d*)tex;
|
||||
if (!is_texture_2d(tex, "texture_unmap")) {
|
||||
blog(LOG_ERROR, "texture_getobj (GL) failed");
|
||||
if (!is_texture_2d(tex, "gs_texture_unmap")) {
|
||||
blog(LOG_ERROR, "gs_texture_get_obj (GL) failed");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ static inline bool upload_texture_cube(struct gs_texture_cube *tex,
|
|||
uint32_t i;
|
||||
|
||||
if (!num_levels)
|
||||
num_levels = gs_num_total_levels(tex->size, tex->size);
|
||||
num_levels = gs_get_total_levels(tex->size, tex->size);
|
||||
|
||||
for (i = 0; i < 6; i++) {
|
||||
GLenum target = GL_TEXTURE_CUBE_MAP_POSITIVE_X + i;
|
||||
|
@ -58,7 +58,7 @@ static inline bool upload_texture_cube(struct gs_texture_cube *tex,
|
|||
return success;
|
||||
}
|
||||
|
||||
texture_t device_create_cubetexture(device_t device, uint32_t size,
|
||||
gs_texture_t device_cubetexture_create(gs_device_t device, uint32_t size,
|
||||
enum gs_color_format color_format, uint32_t levels,
|
||||
const uint8_t **data, uint32_t flags)
|
||||
{
|
||||
|
@ -70,8 +70,8 @@ texture_t device_create_cubetexture(device_t device, uint32_t size,
|
|||
tex->base.gl_format = convert_gs_format(color_format);
|
||||
tex->base.gl_internal_format = convert_gs_internal_format(color_format);
|
||||
tex->base.gl_target = GL_TEXTURE_CUBE_MAP;
|
||||
tex->base.is_render_target = (flags & GS_RENDERTARGET) != 0;
|
||||
tex->base.gen_mipmaps = (flags & GS_BUILDMIPMAPS) != 0;
|
||||
tex->base.is_render_target = (flags & GS_RENDER_TARGET) != 0;
|
||||
tex->base.gen_mipmaps = (flags & GS_BUILD_MIPMAPS) != 0;
|
||||
tex->size = size;
|
||||
|
||||
if (!gl_gen_textures(1, &tex->base.texture))
|
||||
|
@ -79,15 +79,15 @@ texture_t device_create_cubetexture(device_t device, uint32_t size,
|
|||
if (!upload_texture_cube(tex, data))
|
||||
goto fail;
|
||||
|
||||
return (texture_t)tex;
|
||||
return (gs_texture_t)tex;
|
||||
|
||||
fail:
|
||||
cubetexture_destroy((texture_t)tex);
|
||||
blog(LOG_ERROR, "device_create_cubetexture (GL) failed");
|
||||
gs_cubetexture_destroy((gs_texture_t)tex);
|
||||
blog(LOG_ERROR, "device_cubetexture_create (GL) failed");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void cubetexture_destroy(texture_t tex)
|
||||
void gs_cubetexture_destroy(gs_texture_t tex)
|
||||
{
|
||||
if (!tex)
|
||||
return;
|
||||
|
@ -100,7 +100,7 @@ void cubetexture_destroy(texture_t tex)
|
|||
bfree(tex);
|
||||
}
|
||||
|
||||
static inline bool is_texture_cube(texture_t tex, const char *func)
|
||||
static inline bool is_texture_cube(gs_texture_t tex, const char *func)
|
||||
{
|
||||
bool is_texcube = tex->type == GS_TEXTURE_CUBE;
|
||||
if (!is_texcube)
|
||||
|
@ -108,16 +108,16 @@ static inline bool is_texture_cube(texture_t tex, const char *func)
|
|||
return is_texcube;
|
||||
}
|
||||
|
||||
uint32_t cubetexture_getsize(texture_t cubetex)
|
||||
uint32_t gs_cubetexture_get_size(gs_texture_t cubetex)
|
||||
{
|
||||
struct gs_texture_cube *cube = (struct gs_texture_cube*)cubetex;
|
||||
if (!is_texture_cube(cubetex, "cubetexture_getsize"))
|
||||
if (!is_texture_cube(cubetex, "gs_cubetexture_get_size"))
|
||||
return 0;
|
||||
|
||||
return cube->size;
|
||||
}
|
||||
|
||||
enum gs_color_format cubetexture_getcolorformat(texture_t cubetex)
|
||||
enum gs_color_format gs_cubetexture_get_color_format(gs_texture_t cubetex)
|
||||
{
|
||||
return cubetex->format;
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ static bool create_buffers(struct gs_vertex_buffer *vb)
|
|||
|
||||
for (i = 0; i < vb->data->num_tex; i++) {
|
||||
GLuint tex_buffer;
|
||||
struct tvertarray *tv = vb->data->tvarray+i;
|
||||
struct gs_tvertarray *tv = vb->data->tvarray+i;
|
||||
size_t size = vb->data->num * sizeof(float) * tv->width;
|
||||
|
||||
if (!gl_create_buffer(GL_ARRAY_BUFFER, &tex_buffer, size,
|
||||
|
@ -66,7 +66,7 @@ static bool create_buffers(struct gs_vertex_buffer *vb)
|
|||
}
|
||||
|
||||
if (!vb->dynamic) {
|
||||
vbdata_destroy(vb->data);
|
||||
gs_vbdata_destroy(vb->data);
|
||||
vb->data = NULL;
|
||||
}
|
||||
|
||||
|
@ -76,8 +76,8 @@ static bool create_buffers(struct gs_vertex_buffer *vb)
|
|||
return true;
|
||||
}
|
||||
|
||||
vertbuffer_t device_create_vertexbuffer(device_t device,
|
||||
struct vb_data *data, uint32_t flags)
|
||||
gs_vertbuffer_t device_vertexbuffer_create(gs_device_t device,
|
||||
struct gs_vb_data *data, uint32_t flags)
|
||||
{
|
||||
struct gs_vertex_buffer *vb = bzalloc(sizeof(struct gs_vertex_buffer));
|
||||
vb->device = device;
|
||||
|
@ -86,15 +86,15 @@ vertbuffer_t device_create_vertexbuffer(device_t device,
|
|||
vb->dynamic = flags & GS_DYNAMIC;
|
||||
|
||||
if (!create_buffers(vb)) {
|
||||
blog(LOG_ERROR, "device_create_vertexbuffer (GL) failed");
|
||||
vertexbuffer_destroy(vb);
|
||||
blog(LOG_ERROR, "device_vertexbuffer_create (GL) failed");
|
||||
gs_vertexbuffer_destroy(vb);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return vb;
|
||||
}
|
||||
|
||||
void vertexbuffer_destroy(vertbuffer_t vb)
|
||||
void gs_vertexbuffer_destroy(gs_vertbuffer_t vb)
|
||||
{
|
||||
if (vb) {
|
||||
if (vb->vertex_buffer)
|
||||
|
@ -114,13 +114,13 @@ void vertexbuffer_destroy(vertbuffer_t vb)
|
|||
|
||||
da_free(vb->uv_sizes);
|
||||
da_free(vb->uv_buffers);
|
||||
vbdata_destroy(vb->data);
|
||||
gs_vbdata_destroy(vb->data);
|
||||
|
||||
bfree(vb);
|
||||
}
|
||||
}
|
||||
|
||||
void vertexbuffer_flush(vertbuffer_t vb)
|
||||
void gs_vertexbuffer_flush(gs_vertbuffer_t vb)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
|
@ -157,7 +157,7 @@ void vertexbuffer_flush(vertbuffer_t vb)
|
|||
|
||||
for (i = 0; i < vb->data->num_tex; i++) {
|
||||
GLuint buffer = vb->uv_buffers.array[i];
|
||||
struct tvertarray *tv = vb->data->tvarray+i;
|
||||
struct gs_tvertarray *tv = vb->data->tvarray+i;
|
||||
size_t size = vb->data->num * tv->width * sizeof(float);
|
||||
|
||||
if (!update_buffer(GL_ARRAY_BUFFER, buffer, tv->array, size))
|
||||
|
@ -167,10 +167,10 @@ void vertexbuffer_flush(vertbuffer_t vb)
|
|||
return;
|
||||
|
||||
failed:
|
||||
blog(LOG_ERROR, "vertexbuffer_flush (GL) failed");
|
||||
blog(LOG_ERROR, "gs_vertexbuffer_flush (GL) failed");
|
||||
}
|
||||
|
||||
struct vb_data *vertexbuffer_getdata(vertbuffer_t vb)
|
||||
struct gs_vb_data *gs_vertexbuffer_get_data(gs_vertbuffer_t vb)
|
||||
{
|
||||
return vb->data;
|
||||
}
|
||||
|
@ -251,7 +251,7 @@ static inline bool load_vb_buffers(struct gs_shader *shader,
|
|||
return true;
|
||||
}
|
||||
|
||||
bool vertexbuffer_load(device_t device, vertbuffer_t vb)
|
||||
bool vertexbuffer_load(gs_device_t device, gs_vertbuffer_t vb)
|
||||
{
|
||||
if (device->cur_vertex_buffer == vb)
|
||||
return true;
|
||||
|
@ -268,7 +268,7 @@ bool vertexbuffer_load(device_t device, vertbuffer_t vb)
|
|||
return true;
|
||||
}
|
||||
|
||||
void device_load_vertexbuffer(device_t device, vertbuffer_t vb)
|
||||
void device_load_vertexbuffer(gs_device_t device, gs_vertbuffer_t vb)
|
||||
{
|
||||
if (!vertexbuffer_load(device, vb))
|
||||
blog(LOG_ERROR, "device_load_vertexbuffer (GL) failed");
|
||||
|
|
|
@ -350,7 +350,7 @@ static struct gl_windowinfo *gl_windowinfo_bare(struct gs_init_data *info)
|
|||
return wi;
|
||||
}
|
||||
|
||||
static bool init_default_swap(struct gl_platform *plat, device_t device,
|
||||
static bool init_default_swap(struct gl_platform *plat, gs_device_t device,
|
||||
int pixel_format, PIXELFORMATDESCRIPTOR *pfd,
|
||||
struct gs_init_data *info)
|
||||
{
|
||||
|
@ -366,13 +366,13 @@ static bool init_default_swap(struct gl_platform *plat, device_t device,
|
|||
return true;
|
||||
}
|
||||
|
||||
void gl_update(device_t device)
|
||||
void gl_update(gs_device_t device)
|
||||
{
|
||||
/* does nothing on windows */
|
||||
UNUSED_PARAMETER(device);
|
||||
}
|
||||
|
||||
struct gl_platform *gl_platform_create(device_t device,
|
||||
struct gl_platform *gl_platform_create(gs_device_t device,
|
||||
struct gs_init_data *info)
|
||||
{
|
||||
struct gl_platform *plat = bzalloc(sizeof(struct gl_platform));
|
||||
|
@ -475,7 +475,7 @@ void gl_windowinfo_destroy(struct gl_windowinfo *wi)
|
|||
}
|
||||
}
|
||||
|
||||
void device_entercontext(device_t device)
|
||||
void device_enter_context(gs_device_t device)
|
||||
{
|
||||
HDC hdc = device->plat->swap.wi->hdc;
|
||||
if (device->cur_swap)
|
||||
|
@ -485,13 +485,13 @@ void device_entercontext(device_t device)
|
|||
blog(LOG_ERROR, "device_load_swapchain (GL) failed");
|
||||
}
|
||||
|
||||
void device_leavecontext(device_t device)
|
||||
void device_leave_context(gs_device_t device)
|
||||
{
|
||||
wglMakeCurrent(NULL, NULL);
|
||||
UNUSED_PARAMETER(device);
|
||||
}
|
||||
|
||||
void device_load_swapchain(device_t device, swapchain_t swap)
|
||||
void device_load_swapchain(gs_device_t device, gs_swapchain_t swap)
|
||||
{
|
||||
HDC hdc;
|
||||
if (!swap)
|
||||
|
@ -510,7 +510,7 @@ void device_load_swapchain(device_t device, swapchain_t swap)
|
|||
}
|
||||
}
|
||||
|
||||
void device_present(device_t device)
|
||||
void device_present(gs_device_t device)
|
||||
{
|
||||
if (!SwapBuffers(device->cur_swap->wi->hdc)) {
|
||||
blog(LOG_ERROR, "SwapBuffers failed, GetLastError "
|
||||
|
@ -528,7 +528,7 @@ extern void gl_getclientsize(struct gs_swap_chain *swap,
|
|||
*height = rc.bottom;
|
||||
}
|
||||
|
||||
EXPORT bool gdi_texture_available(void)
|
||||
EXPORT bool device_gdi_texture_available(void)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -135,7 +135,7 @@ static bool handle_x_error(Display *disp, const char *error_string)
|
|||
return false;
|
||||
}
|
||||
|
||||
struct gl_platform *gl_platform_create(device_t device,
|
||||
struct gl_platform *gl_platform_create(gs_device_t device,
|
||||
struct gs_init_data *info)
|
||||
{
|
||||
int num_configs = 0;
|
||||
|
@ -366,7 +366,7 @@ void gl_platform_cleanup_swapchain(struct gs_swap_chain *swap)
|
|||
info->int_id = 0;
|
||||
}
|
||||
|
||||
void device_entercontext(device_t device)
|
||||
void device_enter_context(gs_device_t device)
|
||||
{
|
||||
GLXContext context = device->plat->context;
|
||||
XID window = device->cur_swap->wi->glxid;
|
||||
|
@ -377,7 +377,7 @@ void device_entercontext(device_t device)
|
|||
}
|
||||
}
|
||||
|
||||
void device_leavecontext(device_t device)
|
||||
void device_leave_context(gs_device_t device)
|
||||
{
|
||||
Display *display = device->cur_swap->wi->display;
|
||||
|
||||
|
@ -386,7 +386,7 @@ void device_leavecontext(device_t device)
|
|||
}
|
||||
}
|
||||
|
||||
void gl_update(device_t device)
|
||||
void gl_update(gs_device_t device)
|
||||
{
|
||||
Display *display = device->cur_swap->wi->display;
|
||||
XID window = device->cur_swap->wi->int_id;
|
||||
|
@ -395,7 +395,7 @@ void gl_update(device_t device)
|
|||
device->cur_swap->info.cx, device->cur_swap->info.cy);
|
||||
}
|
||||
|
||||
void device_load_swapchain(device_t device, swapchain_t swap)
|
||||
void device_load_swapchain(gs_device_t device, gs_swapchain_t swap)
|
||||
{
|
||||
if (!swap)
|
||||
swap = &device->plat->swap;
|
||||
|
@ -414,7 +414,7 @@ void device_load_swapchain(device_t device, swapchain_t swap)
|
|||
}
|
||||
}
|
||||
|
||||
void device_present(device_t device)
|
||||
void device_present(gs_device_t device)
|
||||
{
|
||||
Display *display = device->cur_swap->wi->display;
|
||||
XID window = device->cur_swap->wi->glxid;
|
||||
|
|
|
@ -48,7 +48,7 @@ static inline GLenum get_attachment(enum gs_zstencil_format format)
|
|||
return 0;
|
||||
}
|
||||
|
||||
zstencil_t device_create_zstencil(device_t device, uint32_t width,
|
||||
gs_zstencil_t device_zstencil_create(gs_device_t device, uint32_t width,
|
||||
uint32_t height, enum gs_zstencil_format format)
|
||||
{
|
||||
struct gs_zstencil_buffer *zs;
|
||||
|
@ -59,15 +59,15 @@ zstencil_t device_create_zstencil(device_t device, uint32_t width,
|
|||
zs->device = device;
|
||||
|
||||
if (!gl_init_zsbuffer(zs, width, height)) {
|
||||
blog(LOG_ERROR, "device_create_zstencil (GL) failed");
|
||||
zstencil_destroy(zs);
|
||||
blog(LOG_ERROR, "device_zstencil_create (GL) failed");
|
||||
gs_zstencil_destroy(zs);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return zs;
|
||||
}
|
||||
|
||||
void zstencil_destroy(zstencil_t zs)
|
||||
void gs_zstencil_destroy(gs_zstencil_t zs)
|
||||
{
|
||||
if (zs) {
|
||||
if (zs->buffer) {
|
||||
|
|
|
@ -23,114 +23,121 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
EXPORT const char *device_name(void);
|
||||
EXPORT int device_type(void);
|
||||
EXPORT const char *device_get_name(void);
|
||||
EXPORT int device_get_type(void);
|
||||
EXPORT const char *device_preprocessor_name(void);
|
||||
EXPORT int device_create(device_t *device, struct gs_init_data *data);
|
||||
EXPORT void device_destroy(device_t device);
|
||||
EXPORT void device_entercontext(device_t device);
|
||||
EXPORT void device_leavecontext(device_t device);
|
||||
EXPORT swapchain_t device_create_swapchain(device_t device,
|
||||
EXPORT int device_create(gs_device_t *device, struct gs_init_data *data);
|
||||
EXPORT void device_destroy(gs_device_t device);
|
||||
EXPORT void device_enter_context(gs_device_t device);
|
||||
EXPORT void device_leave_context(gs_device_t device);
|
||||
EXPORT gs_swapchain_t device_swapchain_create(gs_device_t device,
|
||||
struct gs_init_data *data);
|
||||
EXPORT void device_resize(device_t device, uint32_t x, uint32_t y);
|
||||
EXPORT void device_getsize(device_t device, uint32_t *x, uint32_t *y);
|
||||
EXPORT uint32_t device_getwidth(device_t device);
|
||||
EXPORT uint32_t device_getheight(device_t device);
|
||||
EXPORT texture_t device_create_texture(device_t device, uint32_t width,
|
||||
EXPORT void device_resize(gs_device_t device, uint32_t x, uint32_t y);
|
||||
EXPORT void device_get_size(gs_device_t device, uint32_t *x, uint32_t *y);
|
||||
EXPORT uint32_t device_get_width(gs_device_t device);
|
||||
EXPORT uint32_t device_get_height(gs_device_t device);
|
||||
EXPORT gs_texture_t device_texture_create(gs_device_t device, uint32_t width,
|
||||
uint32_t height, enum gs_color_format color_format,
|
||||
uint32_t levels, const uint8_t **data, uint32_t flags);
|
||||
EXPORT texture_t device_create_cubetexture(device_t device, uint32_t size,
|
||||
EXPORT gs_texture_t device_cubetexture_create(gs_device_t device, uint32_t size,
|
||||
enum gs_color_format color_format, uint32_t levels,
|
||||
const uint8_t **data, uint32_t flags);
|
||||
EXPORT texture_t device_create_volumetexture(device_t device, uint32_t width,
|
||||
EXPORT gs_texture_t device_voltexture_create(gs_device_t device, uint32_t width,
|
||||
uint32_t height, uint32_t depth,
|
||||
enum gs_color_format color_format, uint32_t levels,
|
||||
const uint8_t **data, uint32_t flags);
|
||||
EXPORT zstencil_t device_create_zstencil(device_t device, uint32_t width,
|
||||
EXPORT gs_zstencil_t device_zstencil_create(gs_device_t device, uint32_t width,
|
||||
uint32_t height, enum gs_zstencil_format format);
|
||||
EXPORT stagesurf_t device_create_stagesurface(device_t device, uint32_t width,
|
||||
uint32_t height, enum gs_color_format color_format);
|
||||
EXPORT samplerstate_t device_create_samplerstate(device_t device,
|
||||
EXPORT gs_stagesurf_t device_stagesurface_create(gs_device_t device,
|
||||
uint32_t width, uint32_t height,
|
||||
enum gs_color_format color_format);
|
||||
EXPORT gs_samplerstate_t device_samplerstate_create(gs_device_t device,
|
||||
struct gs_sampler_info *info);
|
||||
EXPORT shader_t device_create_vertexshader(device_t device,
|
||||
EXPORT gs_shader_t device_vertexshader_create(gs_device_t device,
|
||||
const char *shader, const char *file,
|
||||
char **error_string);
|
||||
EXPORT shader_t device_create_pixelshader(device_t device,
|
||||
EXPORT gs_shader_t device_pixelshader_create(gs_device_t device,
|
||||
const char *shader, const char *file,
|
||||
char **error_string);
|
||||
EXPORT vertbuffer_t device_create_vertexbuffer(device_t device,
|
||||
struct vb_data *data, uint32_t flags);
|
||||
EXPORT indexbuffer_t device_create_indexbuffer(device_t device,
|
||||
EXPORT gs_vertbuffer_t device_vertexbuffer_create(gs_device_t device,
|
||||
struct gs_vb_data *data, uint32_t flags);
|
||||
EXPORT gs_indexbuffer_t device_indexbuffer_create(gs_device_t device,
|
||||
enum gs_index_type type, void *indices, size_t num,
|
||||
uint32_t flags);
|
||||
EXPORT enum gs_texture_type device_gettexturetype(texture_t texture);
|
||||
EXPORT void device_load_vertexbuffer(device_t device, vertbuffer_t vertbuffer);
|
||||
EXPORT void device_load_indexbuffer(device_t device, indexbuffer_t indexbuffer);
|
||||
EXPORT void device_load_texture(device_t device, texture_t tex, int unit);
|
||||
EXPORT void device_load_samplerstate(device_t device,
|
||||
samplerstate_t samplerstate, int unit);
|
||||
EXPORT void device_load_vertexshader(device_t device, shader_t vertshader);
|
||||
EXPORT void device_load_pixelshader(device_t device, shader_t pixelshader);
|
||||
EXPORT void device_load_defaultsamplerstate(device_t device, bool b_3d,
|
||||
EXPORT enum gs_texture_type device_get_texture_type(gs_texture_t texture);
|
||||
EXPORT void device_load_vertexbuffer(gs_device_t device,
|
||||
gs_vertbuffer_t vertbuffer);
|
||||
EXPORT void device_load_indexbuffer(gs_device_t device,
|
||||
gs_indexbuffer_t indexbuffer);
|
||||
EXPORT void device_load_texture(gs_device_t device, gs_texture_t tex, int unit);
|
||||
EXPORT void device_load_samplerstate(gs_device_t device,
|
||||
gs_samplerstate_t samplerstate, int unit);
|
||||
EXPORT void device_load_vertexshader(gs_device_t device,
|
||||
gs_shader_t vertshader);
|
||||
EXPORT void device_load_pixelshader(gs_device_t device,
|
||||
gs_shader_t pixelshader);
|
||||
EXPORT void device_load_default_samplerstate(gs_device_t device, bool b_3d,
|
||||
int unit);
|
||||
EXPORT shader_t device_getvertexshader(device_t device);
|
||||
EXPORT shader_t device_getpixelshader(device_t device);
|
||||
EXPORT texture_t device_getrendertarget(device_t device);
|
||||
EXPORT zstencil_t device_getzstenciltarget(device_t device);
|
||||
EXPORT void device_setrendertarget(device_t device, texture_t tex,
|
||||
zstencil_t zstencil);
|
||||
EXPORT void device_setcuberendertarget(device_t device, texture_t cubetex,
|
||||
int side, zstencil_t zstencil);
|
||||
EXPORT void device_copy_texture(device_t device, texture_t dst, texture_t src);
|
||||
EXPORT void device_copy_texture_region(device_t device,
|
||||
texture_t dst, uint32_t dst_x, uint32_t dst_y,
|
||||
texture_t src, uint32_t src_x, uint32_t src_y,
|
||||
EXPORT gs_shader_t device_get_vertex_shader(gs_device_t device);
|
||||
EXPORT gs_shader_t device_get_pixel_shader(gs_device_t device);
|
||||
EXPORT gs_texture_t device_get_render_target(gs_device_t device);
|
||||
EXPORT gs_zstencil_t device_get_zstencil_target(gs_device_t device);
|
||||
EXPORT void device_set_render_target(gs_device_t device, gs_texture_t tex,
|
||||
gs_zstencil_t zstencil);
|
||||
EXPORT void device_set_cube_render_target(gs_device_t device,
|
||||
gs_texture_t cubetex,
|
||||
int side, gs_zstencil_t zstencil);
|
||||
EXPORT void device_copy_texture(gs_device_t device, gs_texture_t dst,
|
||||
gs_texture_t src);
|
||||
EXPORT void device_copy_texture_region(gs_device_t device,
|
||||
gs_texture_t 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);
|
||||
EXPORT void device_stage_texture(device_t device, stagesurf_t dst,
|
||||
texture_t src);
|
||||
EXPORT void device_beginscene(device_t device);
|
||||
EXPORT void device_draw(device_t device, enum gs_draw_mode draw_mode,
|
||||
EXPORT void device_stage_texture(gs_device_t device, gs_stagesurf_t dst,
|
||||
gs_texture_t src);
|
||||
EXPORT void device_begin_scene(gs_device_t device);
|
||||
EXPORT void device_draw(gs_device_t device, enum gs_draw_mode draw_mode,
|
||||
uint32_t start_vert, uint32_t num_verts);
|
||||
EXPORT void device_endscene(device_t device);
|
||||
EXPORT void device_load_swapchain(device_t device, swapchain_t swapchain);
|
||||
EXPORT void device_clear(device_t device, uint32_t clear_flags,
|
||||
EXPORT void device_end_scene(gs_device_t device);
|
||||
EXPORT void device_load_swapchain(gs_device_t device, gs_swapchain_t swapchain);
|
||||
EXPORT void device_clear(gs_device_t device, uint32_t clear_flags,
|
||||
struct vec4 *color, float depth, uint8_t stencil);
|
||||
EXPORT void device_present(device_t device);
|
||||
EXPORT void device_flush(device_t device);
|
||||
EXPORT void device_setcullmode(device_t device, enum gs_cull_mode mode);
|
||||
EXPORT enum gs_cull_mode device_getcullmode(device_t device);
|
||||
EXPORT void device_enable_blending(device_t device, bool enable);
|
||||
EXPORT void device_enable_depthtest(device_t device, bool enable);
|
||||
EXPORT void device_enable_stenciltest(device_t device, bool enable);
|
||||
EXPORT void device_enable_stencilwrite(device_t device, bool enable);
|
||||
EXPORT void device_enable_color(device_t device, bool red, bool green,
|
||||
EXPORT void device_present(gs_device_t device);
|
||||
EXPORT void device_flush(gs_device_t device);
|
||||
EXPORT void device_set_cull_mode(gs_device_t device, enum gs_cull_mode mode);
|
||||
EXPORT enum gs_cull_mode device_get_cull_mode(gs_device_t device);
|
||||
EXPORT void device_enable_blending(gs_device_t device, bool enable);
|
||||
EXPORT void device_enable_depth_test(gs_device_t device, bool enable);
|
||||
EXPORT void device_enable_stencil_test(gs_device_t device, bool enable);
|
||||
EXPORT void device_enable_stencil_write(gs_device_t device, bool enable);
|
||||
EXPORT void device_enable_color(gs_device_t device, bool red, bool green,
|
||||
bool blue, bool alpha);
|
||||
EXPORT void device_blendfunction(device_t device, enum gs_blend_type src,
|
||||
EXPORT void device_blend_function(gs_device_t device, enum gs_blend_type src,
|
||||
enum gs_blend_type dest);
|
||||
EXPORT void device_depthfunction(device_t device, enum gs_depth_test test);
|
||||
EXPORT void device_stencilfunction(device_t device, enum gs_stencil_side side,
|
||||
enum gs_depth_test test);
|
||||
EXPORT void device_stencilop(device_t device, enum gs_stencil_side side,
|
||||
enum gs_stencil_op fail, enum gs_stencil_op zfail,
|
||||
enum gs_stencil_op zpass);
|
||||
EXPORT void device_enable_fullscreen(device_t device, bool enable);
|
||||
EXPORT int device_fullscreen_enabled(device_t device);
|
||||
EXPORT void device_setdisplaymode(device_t device,
|
||||
EXPORT void device_depth_function(gs_device_t device, enum gs_depth_test test);
|
||||
EXPORT void device_stencil_function(gs_device_t device,
|
||||
enum gs_stencil_side side, enum gs_depth_test test);
|
||||
EXPORT void device_stencil_op(gs_device_t device, enum gs_stencil_side side,
|
||||
enum gs_stencil_op_type fail, enum gs_stencil_op_type zfail,
|
||||
enum gs_stencil_op_type zpass);
|
||||
EXPORT void device_enable_fullscreen(gs_device_t device, bool enable);
|
||||
EXPORT int device_fullscreen_enabled(gs_device_t device);
|
||||
EXPORT void device_setdisplaymode(gs_device_t device,
|
||||
const struct gs_display_mode *mode);
|
||||
EXPORT void device_getdisplaymode(device_t device,
|
||||
EXPORT void device_getdisplaymode(gs_device_t device,
|
||||
struct gs_display_mode *mode);
|
||||
EXPORT void device_setcolorramp(device_t device, float gamma, float brightness,
|
||||
float contrast);
|
||||
EXPORT void device_setviewport(device_t device, int x, int y, int width,
|
||||
EXPORT void device_setcolorramp(gs_device_t device, float gamma,
|
||||
float brightness, float contrast);
|
||||
EXPORT void device_set_viewport(gs_device_t device, int x, int y, int width,
|
||||
int height);
|
||||
EXPORT void device_getviewport(device_t device, struct gs_rect *rect);
|
||||
EXPORT void device_setscissorrect(device_t device, struct gs_rect *rect);
|
||||
EXPORT void device_ortho(device_t device, float left, float right,
|
||||
EXPORT void device_get_viewport(gs_device_t device, struct gs_rect *rect);
|
||||
EXPORT void device_set_scissor_rect(gs_device_t device, struct gs_rect *rect);
|
||||
EXPORT void device_ortho(gs_device_t device, float left, float right,
|
||||
float top, float bottom, float znear, float zfar);
|
||||
EXPORT void device_frustum(device_t device, float left, float right,
|
||||
EXPORT void device_frustum(gs_device_t device, float left, float right,
|
||||
float top, float bottom, float znear, float zfar);
|
||||
EXPORT void device_projection_push(device_t device);
|
||||
EXPORT void device_projection_pop(device_t device);
|
||||
EXPORT void device_projection_push(gs_device_t device);
|
||||
EXPORT void device_projection_pop(gs_device_t device);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -919,7 +919,7 @@ static bool ep_compile(struct effect_parser *ep);
|
|||
|
||||
extern const char *gs_preprocessor_name(void);
|
||||
|
||||
bool ep_parse(struct effect_parser *ep, effect_t effect,
|
||||
bool ep_parse(struct effect_parser *ep, gs_effect_t effect,
|
||||
const char *effect_string, const char *file)
|
||||
{
|
||||
bool success;
|
||||
|
@ -1283,7 +1283,7 @@ static void ep_makeshaderstring(struct effect_parser *ep,
|
|||
|
||||
static void ep_compile_param(struct effect_parser *ep, size_t idx)
|
||||
{
|
||||
struct effect_param *param;
|
||||
struct gs_effect_param *param;
|
||||
struct ep_param *param_in;
|
||||
|
||||
param = ep->effect->params.array+idx;
|
||||
|
@ -1296,21 +1296,21 @@ static void ep_compile_param(struct effect_parser *ep, size_t idx)
|
|||
da_move(param->default_val, param_in->default_val);
|
||||
|
||||
if (strcmp(param_in->type, "bool") == 0)
|
||||
param->type = SHADER_PARAM_BOOL;
|
||||
param->type = GS_SHADER_PARAM_BOOL;
|
||||
else if (strcmp(param_in->type, "float") == 0)
|
||||
param->type = SHADER_PARAM_FLOAT;
|
||||
param->type = GS_SHADER_PARAM_FLOAT;
|
||||
else if (strcmp(param_in->type, "int") == 0)
|
||||
param->type = SHADER_PARAM_INT;
|
||||
param->type = GS_SHADER_PARAM_INT;
|
||||
else if (strcmp(param_in->type, "float2") == 0)
|
||||
param->type = SHADER_PARAM_VEC2;
|
||||
param->type = GS_SHADER_PARAM_VEC2;
|
||||
else if (strcmp(param_in->type, "float3") == 0)
|
||||
param->type = SHADER_PARAM_VEC3;
|
||||
param->type = GS_SHADER_PARAM_VEC3;
|
||||
else if (strcmp(param_in->type, "float4") == 0)
|
||||
param->type = SHADER_PARAM_VEC4;
|
||||
param->type = GS_SHADER_PARAM_VEC4;
|
||||
else if (strcmp(param_in->type, "float4x4") == 0)
|
||||
param->type = SHADER_PARAM_MATRIX4X4;
|
||||
param->type = GS_SHADER_PARAM_MATRIX4X4;
|
||||
else if (param_in->is_texture)
|
||||
param->type = SHADER_PARAM_TEXTURE;
|
||||
param->type = GS_SHADER_PARAM_TEXTURE;
|
||||
|
||||
if (strcmp(param_in->name, "ViewProj") == 0)
|
||||
ep->effect->view_proj = param;
|
||||
|
@ -1320,7 +1320,7 @@ static void ep_compile_param(struct effect_parser *ep, size_t idx)
|
|||
|
||||
static bool ep_compile_pass_shaderparams(struct effect_parser *ep,
|
||||
struct darray *pass_params, struct darray *used_params,
|
||||
shader_t shader)
|
||||
gs_shader_t shader)
|
||||
{
|
||||
size_t i;
|
||||
darray_resize(sizeof(struct pass_shaderparam), pass_params,
|
||||
|
@ -1334,9 +1334,9 @@ static bool ep_compile_pass_shaderparams(struct effect_parser *ep,
|
|||
param = darray_item(sizeof(struct pass_shaderparam),
|
||||
pass_params, i);
|
||||
|
||||
param->eparam = effect_getparambyname(ep->effect,
|
||||
param->eparam = gs_effect_get_param_by_name(ep->effect,
|
||||
param_name->array);
|
||||
param->sparam = shader_getparambyname(shader,
|
||||
param->sparam = gs_shader_get_param_by_name(shader,
|
||||
param_name->array);
|
||||
|
||||
if (!param->sparam) {
|
||||
|
@ -1349,15 +1349,15 @@ static bool ep_compile_pass_shaderparams(struct effect_parser *ep,
|
|||
}
|
||||
|
||||
static inline bool ep_compile_pass_shader(struct effect_parser *ep,
|
||||
struct effect_technique *tech,
|
||||
struct effect_pass *pass, struct ep_pass *pass_in,
|
||||
size_t pass_idx, enum shader_type type)
|
||||
struct gs_effect_technique *tech,
|
||||
struct gs_effect_pass *pass, struct ep_pass *pass_in,
|
||||
size_t pass_idx, enum gs_shader_type type)
|
||||
{
|
||||
struct dstr shader_str;
|
||||
struct dstr location;
|
||||
struct darray used_params; /* struct dstr */
|
||||
struct darray *pass_params = NULL; /* struct pass_shaderparam */
|
||||
shader_t shader = NULL;
|
||||
gs_shader_t shader = NULL;
|
||||
bool success = true;
|
||||
|
||||
dstr_init(&shader_str);
|
||||
|
@ -1365,9 +1365,9 @@ static inline bool ep_compile_pass_shader(struct effect_parser *ep,
|
|||
dstr_init(&location);
|
||||
|
||||
dstr_copy(&location, ep->cfp.lex.file);
|
||||
if (type == SHADER_VERTEX)
|
||||
if (type == GS_SHADER_VERTEX)
|
||||
dstr_cat(&location, " (Vertex ");
|
||||
else if (type == SHADER_PIXEL)
|
||||
else if (type == GS_SHADER_PIXEL)
|
||||
dstr_cat(&location, " (Pixel ");
|
||||
/*else if (type == SHADER_GEOMETRY)
|
||||
dstr_cat(&location, " (Geometry ");*/
|
||||
|
@ -1375,20 +1375,20 @@ static inline bool ep_compile_pass_shader(struct effect_parser *ep,
|
|||
dstr_catf(&location, "shader, technique %s, pass %u)", tech->name,
|
||||
pass_idx);
|
||||
|
||||
if (type == SHADER_VERTEX) {
|
||||
if (type == GS_SHADER_VERTEX) {
|
||||
ep_makeshaderstring(ep, &shader_str,
|
||||
&pass_in->vertex_program.da, &used_params);
|
||||
|
||||
pass->vertshader = gs_create_vertexshader(shader_str.array,
|
||||
pass->vertshader = gs_vertexshader_create(shader_str.array,
|
||||
location.array, NULL);
|
||||
|
||||
shader = pass->vertshader;
|
||||
pass_params = &pass->vertshader_params.da;
|
||||
} else if (type == SHADER_PIXEL) {
|
||||
} else if (type == GS_SHADER_PIXEL) {
|
||||
ep_makeshaderstring(ep, &shader_str,
|
||||
&pass_in->fragment_program.da, &used_params);
|
||||
|
||||
pass->pixelshader = gs_create_pixelshader(shader_str.array,
|
||||
pass->pixelshader = gs_pixelshader_create(shader_str.array,
|
||||
location.array, NULL);
|
||||
|
||||
shader = pass->pixelshader;
|
||||
|
@ -1418,11 +1418,11 @@ static inline bool ep_compile_pass_shader(struct effect_parser *ep,
|
|||
}
|
||||
|
||||
static bool ep_compile_pass(struct effect_parser *ep,
|
||||
struct effect_technique *tech,
|
||||
struct gs_effect_technique *tech,
|
||||
struct ep_technique *tech_in,
|
||||
size_t idx)
|
||||
{
|
||||
struct effect_pass *pass;
|
||||
struct gs_effect_pass *pass;
|
||||
struct ep_pass *pass_in;
|
||||
bool success = true;
|
||||
|
||||
|
@ -1433,11 +1433,11 @@ static bool ep_compile_pass(struct effect_parser *ep,
|
|||
pass->section = EFFECT_PASS;
|
||||
|
||||
if (!ep_compile_pass_shader(ep, tech, pass, pass_in, idx,
|
||||
SHADER_VERTEX))
|
||||
GS_SHADER_VERTEX))
|
||||
success = false;
|
||||
|
||||
if (!ep_compile_pass_shader(ep, tech, pass, pass_in, idx,
|
||||
SHADER_PIXEL))
|
||||
GS_SHADER_PIXEL))
|
||||
success = false;
|
||||
|
||||
return success;
|
||||
|
@ -1445,7 +1445,7 @@ static bool ep_compile_pass(struct effect_parser *ep,
|
|||
|
||||
static inline bool ep_compile_technique(struct effect_parser *ep, size_t idx)
|
||||
{
|
||||
struct effect_technique *tech;
|
||||
struct gs_effect_technique *tech;
|
||||
struct ep_technique *tech_in;
|
||||
bool success = true;
|
||||
size_t i;
|
||||
|
|
|
@ -61,7 +61,7 @@ struct ep_param {
|
|||
char *type, *name;
|
||||
DARRAY(uint8_t) default_val;
|
||||
DARRAY(char*) properties;
|
||||
struct effect_param *param;
|
||||
struct gs_effect_param *param;
|
||||
bool is_const, is_property, is_uniform, is_texture, written;
|
||||
int writeorder, array_count;
|
||||
};
|
||||
|
@ -162,7 +162,7 @@ struct ep_pass {
|
|||
char *name;
|
||||
DARRAY(struct cf_token) vertex_program;
|
||||
DARRAY(struct cf_token) fragment_program;
|
||||
struct effect_pass *pass;
|
||||
struct gs_effect_pass *pass;
|
||||
};
|
||||
|
||||
static inline void ep_pass_init(struct ep_pass *epp)
|
||||
|
@ -243,7 +243,7 @@ static inline void ep_func_free(struct ep_func *epf)
|
|||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
struct effect_parser {
|
||||
effect_t effect;
|
||||
gs_effect_t effect;
|
||||
|
||||
DARRAY(struct ep_param) params;
|
||||
DARRAY(struct ep_struct) structs;
|
||||
|
@ -254,7 +254,7 @@ struct effect_parser {
|
|||
/* internal vars */
|
||||
DARRAY(struct cf_lexer) files;
|
||||
DARRAY(struct cf_token) tokens;
|
||||
struct effect_pass *cur_pass;
|
||||
struct gs_effect_pass *cur_pass;
|
||||
|
||||
struct cf_parser cfp;
|
||||
};
|
||||
|
@ -275,7 +275,7 @@ static inline void ep_init(struct effect_parser *ep)
|
|||
|
||||
extern void ep_free(struct effect_parser *ep);
|
||||
|
||||
extern bool ep_parse(struct effect_parser *ep, effect_t effect,
|
||||
extern bool ep_parse(struct effect_parser *ep, gs_effect_t effect,
|
||||
const char *effect_string, const char *file);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include "vec3.h"
|
||||
#include "vec4.h"
|
||||
|
||||
void effect_destroy(effect_t effect)
|
||||
void gs_effect_destroy(gs_effect_t effect)
|
||||
{
|
||||
if (effect) {
|
||||
effect_free(effect);
|
||||
|
@ -29,12 +29,12 @@ void effect_destroy(effect_t effect)
|
|||
}
|
||||
}
|
||||
|
||||
technique_t effect_gettechnique(effect_t effect, const char *name)
|
||||
gs_technique_t gs_effect_get_technique(gs_effect_t effect, const char *name)
|
||||
{
|
||||
if (!effect) return NULL;
|
||||
|
||||
for (size_t i = 0; i < effect->techniques.num; i++) {
|
||||
struct effect_technique *tech = effect->techniques.array+i;
|
||||
struct gs_effect_technique *tech = effect->techniques.array+i;
|
||||
if (strcmp(tech->name, name) == 0)
|
||||
return tech;
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ technique_t effect_gettechnique(effect_t effect, const char *name)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
size_t technique_begin(technique_t tech)
|
||||
size_t gs_technique_begin(gs_technique_t tech)
|
||||
{
|
||||
if (!tech) return 0;
|
||||
|
||||
|
@ -52,12 +52,12 @@ size_t technique_begin(technique_t tech)
|
|||
return tech->passes.num;
|
||||
}
|
||||
|
||||
void technique_end(technique_t tech)
|
||||
void gs_technique_end(gs_technique_t tech)
|
||||
{
|
||||
if (!tech) return;
|
||||
|
||||
struct gs_effect *effect = tech->effect;
|
||||
struct effect_param *params = effect->params.array;
|
||||
struct gs_effect_param *params = effect->params.array;
|
||||
size_t i;
|
||||
|
||||
gs_load_vertexshader(NULL);
|
||||
|
@ -67,7 +67,7 @@ void technique_end(technique_t tech)
|
|||
tech->effect->graphics->cur_effect = NULL;
|
||||
|
||||
for (i = 0; i < effect->params.num; i++) {
|
||||
struct effect_param *param = params+i;
|
||||
struct gs_effect_param *param = params+i;
|
||||
|
||||
da_free(param->cur_val);
|
||||
param->changed = false;
|
||||
|
@ -90,8 +90,8 @@ static void upload_shader_params(struct darray *pass_params, bool changed_only)
|
|||
|
||||
for (i = 0; i < pass_params->num; i++) {
|
||||
struct pass_shaderparam *param = params+i;
|
||||
struct effect_param *eparam = param->eparam;
|
||||
sparam_t sparam = param->sparam;
|
||||
struct gs_effect_param *eparam = param->eparam;
|
||||
gs_sparam_t sparam = param->sparam;
|
||||
|
||||
if (changed_only && !eparam->changed)
|
||||
continue;
|
||||
|
@ -103,7 +103,7 @@ static void upload_shader_params(struct darray *pass_params, bool changed_only)
|
|||
continue;
|
||||
}
|
||||
|
||||
shader_setval(sparam, eparam->cur_val.array,
|
||||
gs_shader_set_val(sparam, eparam->cur_val.array,
|
||||
eparam->cur_val.num);
|
||||
}
|
||||
}
|
||||
|
@ -125,16 +125,16 @@ static inline void upload_parameters(struct gs_effect *effect,
|
|||
reset_params(pshader_params);
|
||||
}
|
||||
|
||||
void effect_updateparams(effect_t effect)
|
||||
void gs_effect_update_params(gs_effect_t effect)
|
||||
{
|
||||
if (effect)
|
||||
upload_parameters(effect, true);
|
||||
}
|
||||
|
||||
bool technique_beginpass(technique_t tech, size_t idx)
|
||||
bool gs_technique_begin_pass(gs_technique_t tech, size_t idx)
|
||||
{
|
||||
struct effect_pass *passes;
|
||||
struct effect_pass *cur_pass;
|
||||
struct gs_effect_pass *passes;
|
||||
struct gs_effect_pass *cur_pass;
|
||||
|
||||
if (!tech || idx >= tech->passes.num)
|
||||
return false;
|
||||
|
@ -150,16 +150,16 @@ bool technique_beginpass(technique_t tech, size_t idx)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool technique_beginpassbyname(technique_t tech,
|
||||
bool gs_technique_begin_pass_by_name(gs_technique_t tech,
|
||||
const char *name)
|
||||
{
|
||||
if (!tech)
|
||||
return false;
|
||||
|
||||
for (size_t i = 0; i < tech->passes.num; i++) {
|
||||
struct effect_pass *pass = tech->passes.array+i;
|
||||
struct gs_effect_pass *pass = tech->passes.array+i;
|
||||
if (strcmp(pass->name, name) == 0) {
|
||||
technique_beginpass(tech, i);
|
||||
gs_technique_begin_pass(tech, i);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -173,19 +173,19 @@ static inline void clear_tex_params(struct darray *in_params)
|
|||
|
||||
for (size_t i = 0; i < in_params->num; i++) {
|
||||
struct pass_shaderparam *param = params+i;
|
||||
struct shader_param_info info;
|
||||
struct gs_shader_param_info info;
|
||||
|
||||
shader_getparaminfo(param->sparam, &info);
|
||||
if (info.type == SHADER_PARAM_TEXTURE)
|
||||
shader_settexture(param->sparam, NULL);
|
||||
gs_shader_get_param_info(param->sparam, &info);
|
||||
if (info.type == GS_SHADER_PARAM_TEXTURE)
|
||||
gs_shader_set_texture(param->sparam, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void technique_endpass(technique_t tech)
|
||||
void gs_technique_end_pass(gs_technique_t tech)
|
||||
{
|
||||
if (!tech) return;
|
||||
|
||||
struct effect_pass *pass = tech->effect->cur_pass;
|
||||
struct gs_effect_pass *pass = tech->effect->cur_pass;
|
||||
if (!pass)
|
||||
return;
|
||||
|
||||
|
@ -194,30 +194,30 @@ void technique_endpass(technique_t tech)
|
|||
tech->effect->cur_pass = NULL;
|
||||
}
|
||||
|
||||
size_t effect_numparams(effect_t effect)
|
||||
size_t gs_effect_get_num_params(gs_effect_t effect)
|
||||
{
|
||||
return effect ? effect->params.num : 0;
|
||||
}
|
||||
|
||||
eparam_t effect_getparambyidx(effect_t effect, size_t param)
|
||||
gs_eparam_t gs_effect_get_param_by_idx(gs_effect_t effect, size_t param)
|
||||
{
|
||||
if (!effect) return NULL;
|
||||
|
||||
struct effect_param *params = effect->params.array;
|
||||
struct gs_effect_param *params = effect->params.array;
|
||||
if (param >= effect->params.num)
|
||||
return NULL;
|
||||
|
||||
return params+param;
|
||||
}
|
||||
|
||||
eparam_t effect_getparambyname(effect_t effect, const char *name)
|
||||
gs_eparam_t gs_effect_get_param_by_name(gs_effect_t effect, const char *name)
|
||||
{
|
||||
if (!effect) return NULL;
|
||||
|
||||
struct effect_param *params = effect->params.array;
|
||||
struct gs_effect_param *params = effect->params.array;
|
||||
|
||||
for (size_t i = 0; i < effect->params.num; i++) {
|
||||
struct effect_param *param = params+i;
|
||||
struct gs_effect_param *param = params+i;
|
||||
|
||||
if (strcmp(param->name, name) == 0)
|
||||
return param;
|
||||
|
@ -226,17 +226,18 @@ eparam_t effect_getparambyname(effect_t effect, const char *name)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
eparam_t effect_getviewprojmatrix(effect_t effect)
|
||||
gs_eparam_t gs_effect_get_viewproj_matrix(gs_effect_t effect)
|
||||
{
|
||||
return effect ? effect->view_proj : NULL;
|
||||
}
|
||||
|
||||
eparam_t effect_getworldmatrix(effect_t effect)
|
||||
gs_eparam_t gs_effect_get_world_matrix(gs_effect_t effect)
|
||||
{
|
||||
return effect ? effect->world : NULL;
|
||||
}
|
||||
|
||||
void effect_getparaminfo(eparam_t param, struct effect_param_info *info)
|
||||
void gs_effect_get_param_info(gs_eparam_t param,
|
||||
struct gs_effect_param_info *info)
|
||||
{
|
||||
if (!param)
|
||||
return;
|
||||
|
@ -245,7 +246,7 @@ void effect_getparaminfo(eparam_t param, struct effect_param_info *info)
|
|||
info->type = param->type;
|
||||
}
|
||||
|
||||
static inline void effect_setval_inline(eparam_t param,
|
||||
static inline void effect_setval_inline(gs_eparam_t param,
|
||||
const void *data, size_t size)
|
||||
{
|
||||
bool size_changed;
|
||||
|
@ -271,52 +272,52 @@ static inline void effect_setval_inline(eparam_t param,
|
|||
}
|
||||
}
|
||||
|
||||
void effect_setbool(eparam_t param, bool val)
|
||||
void gs_effect_set_bool(gs_eparam_t param, bool val)
|
||||
{
|
||||
effect_setval_inline(param, &val, sizeof(bool));
|
||||
}
|
||||
|
||||
void effect_setfloat(eparam_t param, float val)
|
||||
void gs_effect_set_float(gs_eparam_t param, float val)
|
||||
{
|
||||
effect_setval_inline(param, &val, sizeof(float));
|
||||
}
|
||||
|
||||
void effect_setint(eparam_t param, int val)
|
||||
void gs_effect_set_int(gs_eparam_t param, int val)
|
||||
{
|
||||
effect_setval_inline(param, &val, sizeof(int));
|
||||
}
|
||||
|
||||
void effect_setmatrix4(eparam_t param, const struct matrix4 *val)
|
||||
void gs_effect_set_matrix4(gs_eparam_t param, const struct matrix4 *val)
|
||||
{
|
||||
effect_setval_inline(param, val, sizeof(struct matrix4));
|
||||
}
|
||||
|
||||
void effect_setvec2(eparam_t param, const struct vec2 *val)
|
||||
void gs_effect_set_vec2(gs_eparam_t param, const struct vec2 *val)
|
||||
{
|
||||
effect_setval_inline(param, val, sizeof(struct vec2));
|
||||
}
|
||||
|
||||
void effect_setvec3(eparam_t param, const struct vec3 *val)
|
||||
void gs_effect_set_vec3(gs_eparam_t param, const struct vec3 *val)
|
||||
{
|
||||
effect_setval_inline(param, val, sizeof(float) * 3);
|
||||
}
|
||||
|
||||
void effect_setvec4(eparam_t param, const struct vec4 *val)
|
||||
void gs_effect_set_vec4(gs_eparam_t param, const struct vec4 *val)
|
||||
{
|
||||
effect_setval_inline(param, val, sizeof(struct vec4));
|
||||
}
|
||||
|
||||
void effect_settexture(eparam_t param, texture_t val)
|
||||
void gs_effect_set_texture(gs_eparam_t param, gs_texture_t val)
|
||||
{
|
||||
effect_setval_inline(param, &val, sizeof(texture_t));
|
||||
effect_setval_inline(param, &val, sizeof(gs_texture_t));
|
||||
}
|
||||
|
||||
void effect_setval(eparam_t param, const void *val, size_t size)
|
||||
void gs_effect_set_val(gs_eparam_t param, const void *val, size_t size)
|
||||
{
|
||||
effect_setval_inline(param, val, size);
|
||||
}
|
||||
|
||||
void effect_setdefault(eparam_t param)
|
||||
void gs_effect_set_default(gs_eparam_t param)
|
||||
{
|
||||
effect_setval_inline(param, param->default_val.array,
|
||||
param->default_val.num);
|
||||
|
|
|
@ -46,28 +46,28 @@ enum effect_section {
|
|||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
struct effect_param {
|
||||
struct gs_effect_param {
|
||||
char *name;
|
||||
enum effect_section section;
|
||||
|
||||
enum shader_param_type type;
|
||||
enum gs_shader_param_type type;
|
||||
|
||||
bool changed;
|
||||
DARRAY(uint8_t) cur_val;
|
||||
DARRAY(uint8_t) default_val;
|
||||
|
||||
effect_t effect;
|
||||
gs_effect_t effect;
|
||||
|
||||
/*char *full_name;
|
||||
float scroller_min, scroller_max, scroller_inc, scroller_mul;*/
|
||||
};
|
||||
|
||||
static inline void effect_param_init(struct effect_param *param)
|
||||
static inline void effect_param_init(struct gs_effect_param *param)
|
||||
{
|
||||
memset(param, 0, sizeof(struct effect_param));
|
||||
memset(param, 0, sizeof(struct gs_effect_param));
|
||||
}
|
||||
|
||||
static inline void effect_param_free(struct effect_param *param)
|
||||
static inline void effect_param_free(struct gs_effect_param *param)
|
||||
{
|
||||
bfree(param->name);
|
||||
//bfree(param->full_name);
|
||||
|
@ -75,56 +75,56 @@ static inline void effect_param_free(struct effect_param *param)
|
|||
da_free(param->default_val);
|
||||
}
|
||||
|
||||
EXPORT void effect_param_parse_property(eparam_t param,
|
||||
EXPORT void effect_param_parse_property(gs_eparam_t param,
|
||||
const char *property);
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
struct pass_shaderparam {
|
||||
struct effect_param *eparam;
|
||||
sparam_t sparam;
|
||||
struct gs_effect_param *eparam;
|
||||
gs_sparam_t sparam;
|
||||
};
|
||||
|
||||
struct effect_pass {
|
||||
struct gs_effect_pass {
|
||||
char *name;
|
||||
enum effect_section section;
|
||||
|
||||
shader_t vertshader;
|
||||
shader_t pixelshader;
|
||||
gs_shader_t vertshader;
|
||||
gs_shader_t pixelshader;
|
||||
DARRAY(struct pass_shaderparam) vertshader_params;
|
||||
DARRAY(struct pass_shaderparam) pixelshader_params;
|
||||
};
|
||||
|
||||
static inline void effect_pass_init(struct effect_pass *pass)
|
||||
static inline void effect_pass_init(struct gs_effect_pass *pass)
|
||||
{
|
||||
memset(pass, 0, sizeof(struct effect_pass));
|
||||
memset(pass, 0, sizeof(struct gs_effect_pass));
|
||||
}
|
||||
|
||||
static inline void effect_pass_free(struct effect_pass *pass)
|
||||
static inline void effect_pass_free(struct gs_effect_pass *pass)
|
||||
{
|
||||
bfree(pass->name);
|
||||
da_free(pass->vertshader_params);
|
||||
da_free(pass->pixelshader_params);
|
||||
shader_destroy(pass->vertshader);
|
||||
shader_destroy(pass->pixelshader);
|
||||
gs_shader_destroy(pass->vertshader);
|
||||
gs_shader_destroy(pass->pixelshader);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
struct effect_technique {
|
||||
struct gs_effect_technique {
|
||||
char *name;
|
||||
enum effect_section section;
|
||||
struct gs_effect *effect;
|
||||
|
||||
DARRAY(struct effect_pass) passes;
|
||||
DARRAY(struct gs_effect_pass) passes;
|
||||
};
|
||||
|
||||
static inline void effect_technique_init(struct effect_technique *t)
|
||||
static inline void effect_technique_init(struct gs_effect_technique *t)
|
||||
{
|
||||
memset(t, 0, sizeof(struct effect_technique));
|
||||
memset(t, 0, sizeof(struct gs_effect_technique));
|
||||
}
|
||||
|
||||
static inline void effect_technique_free(struct effect_technique *t)
|
||||
static inline void effect_technique_free(struct gs_effect_technique *t)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < t->passes.num; i++)
|
||||
|
@ -139,22 +139,22 @@ struct gs_effect {
|
|||
bool processing;
|
||||
char *effect_path, *effect_dir;
|
||||
|
||||
DARRAY(struct effect_param) params;
|
||||
DARRAY(struct effect_technique) techniques;
|
||||
DARRAY(struct gs_effect_param) params;
|
||||
DARRAY(struct gs_effect_technique) techniques;
|
||||
|
||||
struct effect_technique *cur_technique;
|
||||
struct effect_pass *cur_pass;
|
||||
struct gs_effect_technique *cur_technique;
|
||||
struct gs_effect_pass *cur_pass;
|
||||
|
||||
eparam_t view_proj, world, scale;
|
||||
gs_eparam_t view_proj, world, scale;
|
||||
graphics_t graphics;
|
||||
};
|
||||
|
||||
static inline void effect_init(effect_t effect)
|
||||
static inline void effect_init(gs_effect_t effect)
|
||||
{
|
||||
memset(effect, 0, sizeof(struct gs_effect));
|
||||
}
|
||||
|
||||
static inline void effect_free(effect_t effect)
|
||||
static inline void effect_free(gs_effect_t effect)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < effect->params.num; i++)
|
||||
|
@ -171,8 +171,8 @@ static inline void effect_free(effect_t effect)
|
|||
effect->effect_dir = NULL;
|
||||
}
|
||||
|
||||
EXPORT void effect_upload_params(effect_t effect, bool changed_only);
|
||||
EXPORT void effect_upload_shader_params(effect_t effect, shader_t shader,
|
||||
EXPORT void effect_upload_params(gs_effect_t effect, bool changed_only);
|
||||
EXPORT void effect_upload_shader_params(gs_effect_t effect, gs_shader_t shader,
|
||||
struct darray *pass_params, bool changed_only);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -201,15 +201,15 @@ static inline enum gs_color_format convert_format(enum AVPixelFormat format)
|
|||
return GS_BGRX;
|
||||
}
|
||||
|
||||
texture_t gs_create_texture_from_file(const char *file)
|
||||
gs_texture_t gs_texture_create_from_file(const char *file)
|
||||
{
|
||||
struct ffmpeg_image image;
|
||||
texture_t tex = NULL;
|
||||
gs_texture_t tex = NULL;
|
||||
|
||||
if (ffmpeg_image_init(&image, file)) {
|
||||
uint8_t *data = malloc(image.cx * image.cy * 4);
|
||||
if (ffmpeg_image_decode(&image, data, image.cx * 4)) {
|
||||
tex = gs_create_texture(image.cx, image.cy,
|
||||
tex = gs_texture_create(image.cx, image.cy,
|
||||
convert_format(image.format),
|
||||
1, (const uint8_t**)&data, 0);
|
||||
}
|
||||
|
|
|
@ -40,143 +40,143 @@ bool load_graphics_imports(struct gs_exports *exports, void *module,
|
|||
{
|
||||
bool success = true;
|
||||
|
||||
GRAPHICS_IMPORT(device_name);
|
||||
GRAPHICS_IMPORT(device_type);
|
||||
GRAPHICS_IMPORT(device_get_name);
|
||||
GRAPHICS_IMPORT(device_get_type);
|
||||
GRAPHICS_IMPORT(device_preprocessor_name);
|
||||
GRAPHICS_IMPORT(device_create);
|
||||
GRAPHICS_IMPORT(device_destroy);
|
||||
GRAPHICS_IMPORT(device_entercontext);
|
||||
GRAPHICS_IMPORT(device_leavecontext);
|
||||
GRAPHICS_IMPORT(device_create_swapchain);
|
||||
GRAPHICS_IMPORT(device_enter_context);
|
||||
GRAPHICS_IMPORT(device_leave_context);
|
||||
GRAPHICS_IMPORT(device_swapchain_create);
|
||||
GRAPHICS_IMPORT(device_resize);
|
||||
GRAPHICS_IMPORT(device_getsize);
|
||||
GRAPHICS_IMPORT(device_getwidth);
|
||||
GRAPHICS_IMPORT(device_getheight);
|
||||
GRAPHICS_IMPORT(device_create_texture);
|
||||
GRAPHICS_IMPORT(device_create_cubetexture);
|
||||
GRAPHICS_IMPORT(device_create_volumetexture);
|
||||
GRAPHICS_IMPORT(device_create_zstencil);
|
||||
GRAPHICS_IMPORT(device_create_stagesurface);
|
||||
GRAPHICS_IMPORT(device_create_samplerstate);
|
||||
GRAPHICS_IMPORT(device_create_vertexshader);
|
||||
GRAPHICS_IMPORT(device_create_pixelshader);
|
||||
GRAPHICS_IMPORT(device_create_vertexbuffer);
|
||||
GRAPHICS_IMPORT(device_create_indexbuffer);
|
||||
GRAPHICS_IMPORT(device_gettexturetype);
|
||||
GRAPHICS_IMPORT(device_get_size);
|
||||
GRAPHICS_IMPORT(device_get_width);
|
||||
GRAPHICS_IMPORT(device_get_height);
|
||||
GRAPHICS_IMPORT(device_texture_create);
|
||||
GRAPHICS_IMPORT(device_cubetexture_create);
|
||||
GRAPHICS_IMPORT(device_voltexture_create);
|
||||
GRAPHICS_IMPORT(device_zstencil_create);
|
||||
GRAPHICS_IMPORT(device_stagesurface_create);
|
||||
GRAPHICS_IMPORT(device_samplerstate_create);
|
||||
GRAPHICS_IMPORT(device_vertexshader_create);
|
||||
GRAPHICS_IMPORT(device_pixelshader_create);
|
||||
GRAPHICS_IMPORT(device_vertexbuffer_create);
|
||||
GRAPHICS_IMPORT(device_indexbuffer_create);
|
||||
GRAPHICS_IMPORT(device_get_texture_type);
|
||||
GRAPHICS_IMPORT(device_load_vertexbuffer);
|
||||
GRAPHICS_IMPORT(device_load_indexbuffer);
|
||||
GRAPHICS_IMPORT(device_load_texture);
|
||||
GRAPHICS_IMPORT(device_load_samplerstate);
|
||||
GRAPHICS_IMPORT(device_load_vertexshader);
|
||||
GRAPHICS_IMPORT(device_load_pixelshader);
|
||||
GRAPHICS_IMPORT(device_load_defaultsamplerstate);
|
||||
GRAPHICS_IMPORT(device_getvertexshader);
|
||||
GRAPHICS_IMPORT(device_getpixelshader);
|
||||
GRAPHICS_IMPORT(device_getrendertarget);
|
||||
GRAPHICS_IMPORT(device_getzstenciltarget);
|
||||
GRAPHICS_IMPORT(device_setrendertarget);
|
||||
GRAPHICS_IMPORT(device_setcuberendertarget);
|
||||
GRAPHICS_IMPORT(device_load_default_samplerstate);
|
||||
GRAPHICS_IMPORT(device_get_vertex_shader);
|
||||
GRAPHICS_IMPORT(device_get_pixel_shader);
|
||||
GRAPHICS_IMPORT(device_get_render_target);
|
||||
GRAPHICS_IMPORT(device_get_zstencil_target);
|
||||
GRAPHICS_IMPORT(device_set_render_target);
|
||||
GRAPHICS_IMPORT(device_set_cube_render_target);
|
||||
GRAPHICS_IMPORT(device_copy_texture_region);
|
||||
GRAPHICS_IMPORT(device_copy_texture);
|
||||
GRAPHICS_IMPORT(device_stage_texture);
|
||||
GRAPHICS_IMPORT(device_beginscene);
|
||||
GRAPHICS_IMPORT(device_begin_scene);
|
||||
GRAPHICS_IMPORT(device_draw);
|
||||
GRAPHICS_IMPORT(device_load_swapchain);
|
||||
GRAPHICS_IMPORT(device_endscene);
|
||||
GRAPHICS_IMPORT(device_end_scene);
|
||||
GRAPHICS_IMPORT(device_clear);
|
||||
GRAPHICS_IMPORT(device_present);
|
||||
GRAPHICS_IMPORT(device_flush);
|
||||
GRAPHICS_IMPORT(device_setcullmode);
|
||||
GRAPHICS_IMPORT(device_getcullmode);
|
||||
GRAPHICS_IMPORT(device_set_cull_mode);
|
||||
GRAPHICS_IMPORT(device_get_cull_mode);
|
||||
GRAPHICS_IMPORT(device_enable_blending);
|
||||
GRAPHICS_IMPORT(device_enable_depthtest);
|
||||
GRAPHICS_IMPORT(device_enable_stenciltest);
|
||||
GRAPHICS_IMPORT(device_enable_stencilwrite);
|
||||
GRAPHICS_IMPORT(device_enable_depth_test);
|
||||
GRAPHICS_IMPORT(device_enable_stencil_test);
|
||||
GRAPHICS_IMPORT(device_enable_stencil_write);
|
||||
GRAPHICS_IMPORT(device_enable_color);
|
||||
GRAPHICS_IMPORT(device_blendfunction);
|
||||
GRAPHICS_IMPORT(device_depthfunction);
|
||||
GRAPHICS_IMPORT(device_stencilfunction);
|
||||
GRAPHICS_IMPORT(device_stencilop);
|
||||
GRAPHICS_IMPORT(device_setviewport);
|
||||
GRAPHICS_IMPORT(device_getviewport);
|
||||
GRAPHICS_IMPORT(device_setscissorrect);
|
||||
GRAPHICS_IMPORT(device_blend_function);
|
||||
GRAPHICS_IMPORT(device_depth_function);
|
||||
GRAPHICS_IMPORT(device_stencil_function);
|
||||
GRAPHICS_IMPORT(device_stencil_op);
|
||||
GRAPHICS_IMPORT(device_set_viewport);
|
||||
GRAPHICS_IMPORT(device_get_viewport);
|
||||
GRAPHICS_IMPORT(device_set_scissor_rect);
|
||||
GRAPHICS_IMPORT(device_ortho);
|
||||
GRAPHICS_IMPORT(device_frustum);
|
||||
GRAPHICS_IMPORT(device_projection_push);
|
||||
GRAPHICS_IMPORT(device_projection_pop);
|
||||
|
||||
GRAPHICS_IMPORT(swapchain_destroy);
|
||||
GRAPHICS_IMPORT(gs_swapchain_destroy);
|
||||
|
||||
GRAPHICS_IMPORT(texture_destroy);
|
||||
GRAPHICS_IMPORT(texture_getwidth);
|
||||
GRAPHICS_IMPORT(texture_getheight);
|
||||
GRAPHICS_IMPORT(texture_getcolorformat);
|
||||
GRAPHICS_IMPORT(texture_map);
|
||||
GRAPHICS_IMPORT(texture_unmap);
|
||||
GRAPHICS_IMPORT_OPTIONAL(texture_isrect);
|
||||
GRAPHICS_IMPORT(texture_getobj);
|
||||
GRAPHICS_IMPORT(gs_texture_destroy);
|
||||
GRAPHICS_IMPORT(gs_texture_get_width);
|
||||
GRAPHICS_IMPORT(gs_texture_get_height);
|
||||
GRAPHICS_IMPORT(gs_texture_get_color_format);
|
||||
GRAPHICS_IMPORT(gs_texture_map);
|
||||
GRAPHICS_IMPORT(gs_texture_unmap);
|
||||
GRAPHICS_IMPORT_OPTIONAL(gs_texture_is_rect);
|
||||
GRAPHICS_IMPORT(gs_texture_get_obj);
|
||||
|
||||
GRAPHICS_IMPORT(cubetexture_destroy);
|
||||
GRAPHICS_IMPORT(cubetexture_getsize);
|
||||
GRAPHICS_IMPORT(cubetexture_getcolorformat);
|
||||
GRAPHICS_IMPORT(gs_cubetexture_destroy);
|
||||
GRAPHICS_IMPORT(gs_cubetexture_get_size);
|
||||
GRAPHICS_IMPORT(gs_cubetexture_get_color_format);
|
||||
|
||||
GRAPHICS_IMPORT(volumetexture_destroy);
|
||||
GRAPHICS_IMPORT(volumetexture_getwidth);
|
||||
GRAPHICS_IMPORT(volumetexture_getheight);
|
||||
GRAPHICS_IMPORT(volumetexture_getdepth);
|
||||
GRAPHICS_IMPORT(volumetexture_getcolorformat);
|
||||
GRAPHICS_IMPORT(gs_voltexture_destroy);
|
||||
GRAPHICS_IMPORT(gs_voltexture_get_width);
|
||||
GRAPHICS_IMPORT(gs_voltexture_get_height);
|
||||
GRAPHICS_IMPORT(gs_voltexture_getdepth);
|
||||
GRAPHICS_IMPORT(gs_voltexture_get_color_format);
|
||||
|
||||
GRAPHICS_IMPORT(stagesurface_destroy);
|
||||
GRAPHICS_IMPORT(stagesurface_getwidth);
|
||||
GRAPHICS_IMPORT(stagesurface_getheight);
|
||||
GRAPHICS_IMPORT(stagesurface_getcolorformat);
|
||||
GRAPHICS_IMPORT(stagesurface_map);
|
||||
GRAPHICS_IMPORT(stagesurface_unmap);
|
||||
GRAPHICS_IMPORT(gs_stagesurface_destroy);
|
||||
GRAPHICS_IMPORT(gs_stagesurface_get_width);
|
||||
GRAPHICS_IMPORT(gs_stagesurface_get_height);
|
||||
GRAPHICS_IMPORT(gs_stagesurface_get_color_format);
|
||||
GRAPHICS_IMPORT(gs_stagesurface_map);
|
||||
GRAPHICS_IMPORT(gs_stagesurface_unmap);
|
||||
|
||||
GRAPHICS_IMPORT(zstencil_destroy);
|
||||
GRAPHICS_IMPORT(gs_zstencil_destroy);
|
||||
|
||||
GRAPHICS_IMPORT(samplerstate_destroy);
|
||||
GRAPHICS_IMPORT(gs_samplerstate_destroy);
|
||||
|
||||
GRAPHICS_IMPORT(vertexbuffer_destroy);
|
||||
GRAPHICS_IMPORT(vertexbuffer_flush);
|
||||
GRAPHICS_IMPORT(vertexbuffer_getdata);
|
||||
GRAPHICS_IMPORT(gs_vertexbuffer_destroy);
|
||||
GRAPHICS_IMPORT(gs_vertexbuffer_flush);
|
||||
GRAPHICS_IMPORT(gs_vertexbuffer_get_data);
|
||||
|
||||
GRAPHICS_IMPORT(indexbuffer_destroy);
|
||||
GRAPHICS_IMPORT(indexbuffer_flush);
|
||||
GRAPHICS_IMPORT(indexbuffer_getdata);
|
||||
GRAPHICS_IMPORT(indexbuffer_numindices);
|
||||
GRAPHICS_IMPORT(indexbuffer_gettype);
|
||||
GRAPHICS_IMPORT(gs_indexbuffer_destroy);
|
||||
GRAPHICS_IMPORT(gs_indexbuffer_flush);
|
||||
GRAPHICS_IMPORT(gs_indexbuffer_get_data);
|
||||
GRAPHICS_IMPORT(gs_indexbuffer_get_num_indices);
|
||||
GRAPHICS_IMPORT(gs_indexbuffer_get_type);
|
||||
|
||||
GRAPHICS_IMPORT(shader_destroy);
|
||||
GRAPHICS_IMPORT(shader_numparams);
|
||||
GRAPHICS_IMPORT(shader_getparambyidx);
|
||||
GRAPHICS_IMPORT(shader_getparambyname);
|
||||
GRAPHICS_IMPORT(shader_getviewprojmatrix);
|
||||
GRAPHICS_IMPORT(shader_getworldmatrix);
|
||||
GRAPHICS_IMPORT(shader_getparaminfo);
|
||||
GRAPHICS_IMPORT(shader_setbool);
|
||||
GRAPHICS_IMPORT(shader_setfloat);
|
||||
GRAPHICS_IMPORT(shader_setint);
|
||||
GRAPHICS_IMPORT(shader_setmatrix3);
|
||||
GRAPHICS_IMPORT(shader_setmatrix4);
|
||||
GRAPHICS_IMPORT(shader_setvec2);
|
||||
GRAPHICS_IMPORT(shader_setvec3);
|
||||
GRAPHICS_IMPORT(shader_setvec4);
|
||||
GRAPHICS_IMPORT(shader_settexture);
|
||||
GRAPHICS_IMPORT(shader_setval);
|
||||
GRAPHICS_IMPORT(shader_setdefault);
|
||||
GRAPHICS_IMPORT(gs_shader_destroy);
|
||||
GRAPHICS_IMPORT(gs_shader_get_num_params);
|
||||
GRAPHICS_IMPORT(gs_shader_get_param_by_idx);
|
||||
GRAPHICS_IMPORT(gs_shader_get_param_by_name);
|
||||
GRAPHICS_IMPORT(gs_shader_get_viewproj_matrix);
|
||||
GRAPHICS_IMPORT(gs_shader_get_world_matrix);
|
||||
GRAPHICS_IMPORT(gs_shader_get_param_info);
|
||||
GRAPHICS_IMPORT(gs_shader_set_bool);
|
||||
GRAPHICS_IMPORT(gs_shader_set_float);
|
||||
GRAPHICS_IMPORT(gs_shader_set_int);
|
||||
GRAPHICS_IMPORT(gs_shader_setmatrix3);
|
||||
GRAPHICS_IMPORT(gs_shader_set_matrix4);
|
||||
GRAPHICS_IMPORT(gs_shader_set_vec2);
|
||||
GRAPHICS_IMPORT(gs_shader_set_vec3);
|
||||
GRAPHICS_IMPORT(gs_shader_set_vec4);
|
||||
GRAPHICS_IMPORT(gs_shader_set_texture);
|
||||
GRAPHICS_IMPORT(gs_shader_set_val);
|
||||
GRAPHICS_IMPORT(gs_shader_set_default);
|
||||
|
||||
/* OSX/Cocoa specific functions */
|
||||
#ifdef __APPLE__
|
||||
GRAPHICS_IMPORT_OPTIONAL(texture_create_from_iosurface);
|
||||
GRAPHICS_IMPORT_OPTIONAL(texture_rebind_iosurface);
|
||||
GRAPHICS_IMPORT_OPTIONAL(device_texture_create_from_iosurface);
|
||||
GRAPHICS_IMPORT_OPTIONAL(gs_texture_rebind_iosurface);
|
||||
|
||||
/* win32 specific functions */
|
||||
#elif _WIN32
|
||||
GRAPHICS_IMPORT(gdi_texture_available);
|
||||
GRAPHICS_IMPORT_OPTIONAL(device_create_gdi_texture);
|
||||
GRAPHICS_IMPORT_OPTIONAL(texture_get_dc);
|
||||
GRAPHICS_IMPORT_OPTIONAL(texture_release_dc);
|
||||
GRAPHICS_IMPORT(device_gdi_texture_available);
|
||||
GRAPHICS_IMPORT_OPTIONAL(device_texture_create_gdi);
|
||||
GRAPHICS_IMPORT_OPTIONAL(gs_texture_get_dc);
|
||||
GRAPHICS_IMPORT_OPTIONAL(gs_texture_release_dc);
|
||||
#endif
|
||||
|
||||
return success;
|
||||
|
|
|
@ -24,189 +24,208 @@
|
|||
#include "matrix4.h"
|
||||
|
||||
struct gs_exports {
|
||||
const char *(*device_name)(void);
|
||||
int (*device_type)(void);
|
||||
const char *(*device_get_name)(void);
|
||||
int (*device_get_type)(void);
|
||||
const char *(*device_preprocessor_name)(void);
|
||||
int (*device_create)(device_t *device, struct gs_init_data *data);
|
||||
void (*device_destroy)(device_t device);
|
||||
void (*device_entercontext)(device_t device);
|
||||
void (*device_leavecontext)(device_t device);
|
||||
swapchain_t (*device_create_swapchain)(device_t device,
|
||||
int (*device_create)(gs_device_t *device, struct gs_init_data *data);
|
||||
void (*device_destroy)(gs_device_t device);
|
||||
void (*device_enter_context)(gs_device_t device);
|
||||
void (*device_leave_context)(gs_device_t device);
|
||||
gs_swapchain_t (*device_swapchain_create)(gs_device_t device,
|
||||
struct gs_init_data *data);
|
||||
void (*device_resize)(device_t device, uint32_t x, uint32_t y);
|
||||
void (*device_getsize)(device_t device, uint32_t *x, uint32_t *y);
|
||||
uint32_t (*device_getwidth)(device_t device);
|
||||
uint32_t (*device_getheight)(device_t device);
|
||||
texture_t (*device_create_texture)(device_t device, uint32_t width,
|
||||
uint32_t height, enum gs_color_format color_format,
|
||||
uint32_t levels, const uint8_t **data, uint32_t flags);
|
||||
texture_t (*device_create_cubetexture)(device_t device, uint32_t size,
|
||||
void (*device_resize)(gs_device_t device, uint32_t x, uint32_t y);
|
||||
void (*device_get_size)(gs_device_t device, uint32_t *x, uint32_t *y);
|
||||
uint32_t (*device_get_width)(gs_device_t device);
|
||||
uint32_t (*device_get_height)(gs_device_t device);
|
||||
gs_texture_t (*device_texture_create)(gs_device_t device,
|
||||
uint32_t width, uint32_t height,
|
||||
enum gs_color_format color_format, uint32_t levels,
|
||||
const uint8_t **data, uint32_t flags);
|
||||
texture_t (*device_create_volumetexture)(device_t device,
|
||||
gs_texture_t (*device_cubetexture_create)(gs_device_t device,
|
||||
uint32_t size, enum gs_color_format color_format,
|
||||
uint32_t levels, const uint8_t **data, uint32_t flags);
|
||||
gs_texture_t (*device_voltexture_create)(gs_device_t device,
|
||||
uint32_t width, uint32_t height, uint32_t depth,
|
||||
enum gs_color_format color_format, uint32_t levels,
|
||||
const uint8_t **data, uint32_t flags);
|
||||
zstencil_t (*device_create_zstencil)(device_t device,
|
||||
gs_zstencil_t (*device_zstencil_create)(gs_device_t device,
|
||||
uint32_t width, uint32_t height,
|
||||
enum gs_zstencil_format format);
|
||||
stagesurf_t (*device_create_stagesurface)(device_t device,
|
||||
gs_stagesurf_t (*device_stagesurface_create)(gs_device_t device,
|
||||
uint32_t width, uint32_t height,
|
||||
enum gs_color_format color_format);
|
||||
samplerstate_t (*device_create_samplerstate)(device_t device,
|
||||
gs_samplerstate_t (*device_samplerstate_create)(gs_device_t device,
|
||||
struct gs_sampler_info *info);
|
||||
shader_t (*device_create_vertexshader)(device_t device,
|
||||
gs_shader_t (*device_vertexshader_create)(gs_device_t device,
|
||||
const char *shader, const char *file,
|
||||
char **error_string);
|
||||
shader_t (*device_create_pixelshader)(device_t device,
|
||||
gs_shader_t (*device_pixelshader_create)(gs_device_t device,
|
||||
const char *shader, const char *file,
|
||||
char **error_string);
|
||||
vertbuffer_t (*device_create_vertexbuffer)(device_t device,
|
||||
struct vb_data *data, uint32_t flags);
|
||||
indexbuffer_t (*device_create_indexbuffer)(device_t device,
|
||||
gs_vertbuffer_t (*device_vertexbuffer_create)(gs_device_t device,
|
||||
struct gs_vb_data *data, uint32_t flags);
|
||||
gs_indexbuffer_t (*device_indexbuffer_create)(gs_device_t device,
|
||||
enum gs_index_type type, void *indices, size_t num,
|
||||
uint32_t flags);
|
||||
enum gs_texture_type (*device_gettexturetype)(texture_t texture);
|
||||
void (*device_load_vertexbuffer)(device_t device,
|
||||
vertbuffer_t vertbuffer);
|
||||
void (*device_load_indexbuffer)(device_t device,
|
||||
indexbuffer_t indexbuffer);
|
||||
void (*device_load_texture)(device_t device, texture_t tex, int unit);
|
||||
void (*device_load_samplerstate)(device_t device,
|
||||
samplerstate_t samplerstate, int unit);
|
||||
void (*device_load_vertexshader)(device_t device, shader_t vertshader);
|
||||
void (*device_load_pixelshader)(device_t device, shader_t pixelshader);
|
||||
void (*device_load_defaultsamplerstate)(device_t device, bool b_3d,
|
||||
enum gs_texture_type (*device_get_texture_type)(gs_texture_t texture);
|
||||
void (*device_load_vertexbuffer)(gs_device_t device,
|
||||
gs_vertbuffer_t vertbuffer);
|
||||
void (*device_load_indexbuffer)(gs_device_t device,
|
||||
gs_indexbuffer_t indexbuffer);
|
||||
void (*device_load_texture)(gs_device_t device, gs_texture_t tex,
|
||||
int unit);
|
||||
shader_t (*device_getvertexshader)(device_t device);
|
||||
shader_t (*device_getpixelshader)(device_t device);
|
||||
texture_t (*device_getrendertarget)(device_t device);
|
||||
zstencil_t (*device_getzstenciltarget)(device_t device);
|
||||
void (*device_setrendertarget)(device_t device, texture_t tex,
|
||||
zstencil_t zstencil);
|
||||
void (*device_setcuberendertarget)(device_t device, texture_t cubetex,
|
||||
int side, zstencil_t zstencil);
|
||||
void (*device_copy_texture)(device_t device, texture_t dst,
|
||||
texture_t src);
|
||||
void (*device_copy_texture_region)(device_t device,
|
||||
texture_t dst, uint32_t dst_x, uint32_t dst_y,
|
||||
texture_t src, uint32_t src_x, uint32_t src_y,
|
||||
void (*device_load_samplerstate)(gs_device_t device,
|
||||
gs_samplerstate_t samplerstate, int unit);
|
||||
void (*device_load_vertexshader)(gs_device_t device,
|
||||
gs_shader_t vertshader);
|
||||
void (*device_load_pixelshader)(gs_device_t device,
|
||||
gs_shader_t pixelshader);
|
||||
void (*device_load_default_samplerstate)(gs_device_t device,
|
||||
bool b_3d, int unit);
|
||||
gs_shader_t (*device_get_vertex_shader)(gs_device_t device);
|
||||
gs_shader_t (*device_get_pixel_shader)(gs_device_t device);
|
||||
gs_texture_t (*device_get_render_target)(gs_device_t device);
|
||||
gs_zstencil_t (*device_get_zstencil_target)(gs_device_t device);
|
||||
void (*device_set_render_target)(gs_device_t device, gs_texture_t tex,
|
||||
gs_zstencil_t zstencil);
|
||||
void (*device_set_cube_render_target)(gs_device_t device,
|
||||
gs_texture_t cubetex, int side, gs_zstencil_t zstencil);
|
||||
void (*device_copy_texture)(gs_device_t device, gs_texture_t dst,
|
||||
gs_texture_t src);
|
||||
void (*device_copy_texture_region)(gs_device_t device,
|
||||
gs_texture_t 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);
|
||||
void (*device_stage_texture)(device_t device, stagesurf_t dst,
|
||||
texture_t src);
|
||||
void (*device_beginscene)(device_t device);
|
||||
void (*device_draw)(device_t device, enum gs_draw_mode draw_mode,
|
||||
void (*device_stage_texture)(gs_device_t device, gs_stagesurf_t dst,
|
||||
gs_texture_t src);
|
||||
void (*device_begin_scene)(gs_device_t device);
|
||||
void (*device_draw)(gs_device_t device, enum gs_draw_mode draw_mode,
|
||||
uint32_t start_vert, uint32_t num_verts);
|
||||
void (*device_endscene)(device_t device);
|
||||
void (*device_load_swapchain)(device_t device, swapchain_t swaphchain);
|
||||
void (*device_clear)(device_t device, uint32_t clear_flags,
|
||||
void (*device_end_scene)(gs_device_t device);
|
||||
void (*device_load_swapchain)(gs_device_t device,
|
||||
gs_swapchain_t swaphchain);
|
||||
void (*device_clear)(gs_device_t device, uint32_t clear_flags,
|
||||
struct vec4 *color, float depth, uint8_t stencil);
|
||||
void (*device_present)(device_t device);
|
||||
void (*device_flush)(device_t device);
|
||||
void (*device_setcullmode)(device_t device, enum gs_cull_mode mode);
|
||||
enum gs_cull_mode (*device_getcullmode)(device_t device);
|
||||
void (*device_enable_blending)(device_t device, bool enable);
|
||||
void (*device_enable_depthtest)(device_t device, bool enable);
|
||||
void (*device_enable_stenciltest)(device_t device, bool enable);
|
||||
void (*device_enable_stencilwrite)(device_t device, bool enable);
|
||||
void (*device_enable_color)(device_t device, bool red, bool green,
|
||||
void (*device_present)(gs_device_t device);
|
||||
void (*device_flush)(gs_device_t device);
|
||||
void (*device_set_cull_mode)(gs_device_t device,
|
||||
enum gs_cull_mode mode);
|
||||
enum gs_cull_mode (*device_get_cull_mode)(gs_device_t device);
|
||||
void (*device_enable_blending)(gs_device_t device, bool enable);
|
||||
void (*device_enable_depth_test)(gs_device_t device, bool enable);
|
||||
void (*device_enable_stencil_test)(gs_device_t device, bool enable);
|
||||
void (*device_enable_stencil_write)(gs_device_t device, bool enable);
|
||||
void (*device_enable_color)(gs_device_t device, bool red, bool green,
|
||||
bool blue, bool alpha);
|
||||
void (*device_blendfunction)(device_t device, enum gs_blend_type src,
|
||||
enum gs_blend_type dest);
|
||||
void (*device_depthfunction)(device_t device, enum gs_depth_test test);
|
||||
void (*device_stencilfunction)(device_t device,
|
||||
void (*device_blend_function)(gs_device_t device,
|
||||
enum gs_blend_type src, enum gs_blend_type dest);
|
||||
void (*device_depth_function)(gs_device_t device,
|
||||
enum gs_depth_test test);
|
||||
void (*device_stencil_function)(gs_device_t device,
|
||||
enum gs_stencil_side side, enum gs_depth_test test);
|
||||
void (*device_stencilop)(device_t device, enum gs_stencil_side side,
|
||||
enum gs_stencil_op fail, enum gs_stencil_op zfail,
|
||||
enum gs_stencil_op zpass);
|
||||
void (*device_setviewport)(device_t device, int x, int y, int width,
|
||||
void (*device_stencil_op)(gs_device_t device, enum gs_stencil_side side,
|
||||
enum gs_stencil_op_type fail,
|
||||
enum gs_stencil_op_type zfail,
|
||||
enum gs_stencil_op_type zpass);
|
||||
void (*device_set_viewport)(gs_device_t device, int x, int y, int width,
|
||||
int height);
|
||||
void (*device_getviewport)(device_t device, struct gs_rect *rect);
|
||||
void (*device_setscissorrect)(device_t device, struct gs_rect *rect);
|
||||
void (*device_ortho)(device_t device, float left, float right,
|
||||
void (*device_get_viewport)(gs_device_t device, struct gs_rect *rect);
|
||||
void (*device_set_scissor_rect)(gs_device_t device,
|
||||
struct gs_rect *rect);
|
||||
void (*device_ortho)(gs_device_t device, float left, float right,
|
||||
float top, float bottom, float znear, float zfar);
|
||||
void (*device_frustum)(device_t device, float left, float right,
|
||||
void (*device_frustum)(gs_device_t device, float left, float right,
|
||||
float top, float bottom, float znear, float zfar);
|
||||
void (*device_projection_push)(device_t device);
|
||||
void (*device_projection_pop)(device_t device);
|
||||
void (*device_projection_push)(gs_device_t device);
|
||||
void (*device_projection_pop)(gs_device_t device);
|
||||
|
||||
void (*swapchain_destroy)(swapchain_t swapchain);
|
||||
void (*gs_swapchain_destroy)(gs_swapchain_t swapchain);
|
||||
|
||||
void (*texture_destroy)(texture_t tex);
|
||||
uint32_t (*texture_getwidth)(texture_t tex);
|
||||
uint32_t (*texture_getheight)(texture_t tex);
|
||||
enum gs_color_format (*texture_getcolorformat)(texture_t tex);
|
||||
bool (*texture_map)(texture_t tex, uint8_t **ptr,
|
||||
void (*gs_texture_destroy)(gs_texture_t tex);
|
||||
uint32_t (*gs_texture_get_width)(gs_texture_t tex);
|
||||
uint32_t (*gs_texture_get_height)(gs_texture_t tex);
|
||||
enum gs_color_format (*gs_texture_get_color_format)(gs_texture_t tex);
|
||||
bool (*gs_texture_map)(gs_texture_t tex, uint8_t **ptr,
|
||||
uint32_t *linesize);
|
||||
void (*texture_unmap)(texture_t tex);
|
||||
bool (*texture_isrect)(texture_t tex);
|
||||
void *(*texture_getobj)(texture_t tex);
|
||||
void (*gs_texture_unmap)(gs_texture_t tex);
|
||||
bool (*gs_texture_is_rect)(gs_texture_t tex);
|
||||
void *(*gs_texture_get_obj)(gs_texture_t tex);
|
||||
|
||||
void (*cubetexture_destroy)(texture_t cubetex);
|
||||
uint32_t (*cubetexture_getsize)(texture_t cubetex);
|
||||
enum gs_color_format (*cubetexture_getcolorformat)(texture_t cubetex);
|
||||
void (*gs_cubetexture_destroy)(gs_texture_t cubetex);
|
||||
uint32_t (*gs_cubetexture_get_size)(gs_texture_t cubetex);
|
||||
enum gs_color_format (*gs_cubetexture_get_color_format)(
|
||||
gs_texture_t cubetex);
|
||||
|
||||
void (*volumetexture_destroy)(texture_t voltex);
|
||||
uint32_t (*volumetexture_getwidth)(texture_t voltex);
|
||||
uint32_t (*volumetexture_getheight)(texture_t voltex);
|
||||
uint32_t (*volumetexture_getdepth)(texture_t voltex);
|
||||
enum gs_color_format (*volumetexture_getcolorformat)(texture_t voltex);
|
||||
void (*gs_voltexture_destroy)(gs_texture_t voltex);
|
||||
uint32_t (*gs_voltexture_get_width)(gs_texture_t voltex);
|
||||
uint32_t (*gs_voltexture_get_height)(gs_texture_t voltex);
|
||||
uint32_t (*gs_voltexture_getdepth)(gs_texture_t voltex);
|
||||
enum gs_color_format (*gs_voltexture_get_color_format)(
|
||||
gs_texture_t voltex);
|
||||
|
||||
void (*stagesurface_destroy)(stagesurf_t stagesurf);
|
||||
uint32_t (*stagesurface_getwidth)(stagesurf_t stagesurf);
|
||||
uint32_t (*stagesurface_getheight)(stagesurf_t stagesurf);
|
||||
enum gs_color_format (*stagesurface_getcolorformat)(
|
||||
stagesurf_t stagesurf);
|
||||
bool (*stagesurface_map)(stagesurf_t stagesurf,
|
||||
void (*gs_stagesurface_destroy)(gs_stagesurf_t stagesurf);
|
||||
uint32_t (*gs_stagesurface_get_width)(gs_stagesurf_t stagesurf);
|
||||
uint32_t (*gs_stagesurface_get_height)(gs_stagesurf_t stagesurf);
|
||||
enum gs_color_format (*gs_stagesurface_get_color_format)(
|
||||
gs_stagesurf_t stagesurf);
|
||||
bool (*gs_stagesurface_map)(gs_stagesurf_t stagesurf,
|
||||
uint8_t **data, uint32_t *linesize);
|
||||
void (*stagesurface_unmap)(stagesurf_t stagesurf);
|
||||
void (*gs_stagesurface_unmap)(gs_stagesurf_t stagesurf);
|
||||
|
||||
void (*zstencil_destroy)(zstencil_t zstencil);
|
||||
void (*gs_zstencil_destroy)(gs_zstencil_t zstencil);
|
||||
|
||||
void (*samplerstate_destroy)(samplerstate_t samplerstate);
|
||||
void (*gs_samplerstate_destroy)(gs_samplerstate_t samplerstate);
|
||||
|
||||
void (*vertexbuffer_destroy)(vertbuffer_t vertbuffer);
|
||||
void (*vertexbuffer_flush)(vertbuffer_t vertbuffer);
|
||||
struct vb_data *(*vertexbuffer_getdata)(vertbuffer_t vertbuffer);
|
||||
void (*gs_vertexbuffer_destroy)(gs_vertbuffer_t vertbuffer);
|
||||
void (*gs_vertexbuffer_flush)(gs_vertbuffer_t vertbuffer);
|
||||
struct gs_vb_data *(*gs_vertexbuffer_get_data)(
|
||||
gs_vertbuffer_t vertbuffer);
|
||||
|
||||
void (*indexbuffer_destroy)(indexbuffer_t indexbuffer);
|
||||
void (*indexbuffer_flush)(indexbuffer_t indexbuffer);
|
||||
void *(*indexbuffer_getdata)(indexbuffer_t indexbuffer);
|
||||
size_t (*indexbuffer_numindices)(indexbuffer_t indexbuffer);
|
||||
enum gs_index_type (*indexbuffer_gettype)(indexbuffer_t indexbuffer);
|
||||
void (*gs_indexbuffer_destroy)(gs_indexbuffer_t indexbuffer);
|
||||
void (*gs_indexbuffer_flush)(gs_indexbuffer_t indexbuffer);
|
||||
void *(*gs_indexbuffer_get_data)(gs_indexbuffer_t indexbuffer);
|
||||
size_t (*gs_indexbuffer_get_num_indices)(gs_indexbuffer_t indexbuffer);
|
||||
enum gs_index_type (*gs_indexbuffer_get_type)(
|
||||
gs_indexbuffer_t indexbuffer);
|
||||
|
||||
void (*shader_destroy)(shader_t shader);
|
||||
int (*shader_numparams)(shader_t shader);
|
||||
sparam_t (*shader_getparambyidx)(shader_t shader, uint32_t param);
|
||||
sparam_t (*shader_getparambyname)(shader_t shader, const char *name);
|
||||
sparam_t (*shader_getviewprojmatrix)(shader_t shader);
|
||||
sparam_t (*shader_getworldmatrix)(shader_t shader);
|
||||
void (*shader_getparaminfo)(sparam_t param,
|
||||
struct shader_param_info *info);
|
||||
void (*shader_setbool)(sparam_t param, bool val);
|
||||
void (*shader_setfloat)(sparam_t param, float val);
|
||||
void (*shader_setint)(sparam_t param, int val);
|
||||
void (*shader_setmatrix3)(sparam_t param, const struct matrix3 *val);
|
||||
void (*shader_setmatrix4)(sparam_t param, const struct matrix4 *val);
|
||||
void (*shader_setvec2)(sparam_t param, const struct vec2 *val);
|
||||
void (*shader_setvec3)(sparam_t param, const struct vec3 *val);
|
||||
void (*shader_setvec4)(sparam_t param, const struct vec4 *val);
|
||||
void (*shader_settexture)(sparam_t param, texture_t val);
|
||||
void (*shader_setval)(sparam_t param, const void *val, size_t size);
|
||||
void (*shader_setdefault)(sparam_t param);
|
||||
void (*gs_shader_destroy)(gs_shader_t shader);
|
||||
int (*gs_shader_get_num_params)(gs_shader_t shader);
|
||||
gs_sparam_t (*gs_shader_get_param_by_idx)(gs_shader_t shader,
|
||||
uint32_t param);
|
||||
gs_sparam_t (*gs_shader_get_param_by_name)(gs_shader_t shader,
|
||||
const char *name);
|
||||
gs_sparam_t (*gs_shader_get_viewproj_matrix)(gs_shader_t shader);
|
||||
gs_sparam_t (*gs_shader_get_world_matrix)(gs_shader_t shader);
|
||||
void (*gs_shader_get_param_info)(gs_sparam_t param,
|
||||
struct gs_shader_param_info *info);
|
||||
void (*gs_shader_set_bool)(gs_sparam_t param, bool val);
|
||||
void (*gs_shader_set_float)(gs_sparam_t param, float val);
|
||||
void (*gs_shader_set_int)(gs_sparam_t param, int val);
|
||||
void (*gs_shader_setmatrix3)(gs_sparam_t param,
|
||||
const struct matrix3 *val);
|
||||
void (*gs_shader_set_matrix4)(gs_sparam_t param,
|
||||
const struct matrix4 *val);
|
||||
void (*gs_shader_set_vec2)(gs_sparam_t param, const struct vec2 *val);
|
||||
void (*gs_shader_set_vec3)(gs_sparam_t param, const struct vec3 *val);
|
||||
void (*gs_shader_set_vec4)(gs_sparam_t param, const struct vec4 *val);
|
||||
void (*gs_shader_set_texture)(gs_sparam_t param, gs_texture_t val);
|
||||
void (*gs_shader_set_val)(gs_sparam_t param, const void *val,
|
||||
size_t size);
|
||||
void (*gs_shader_set_default)(gs_sparam_t param);
|
||||
|
||||
#ifdef __APPLE__
|
||||
/* OSX/Cocoa specific functions */
|
||||
texture_t (*texture_create_from_iosurface)(device_t dev, void *iosurf);
|
||||
bool (*texture_rebind_iosurface)(texture_t texture, void *iosurf);
|
||||
gs_texture_t (*device_texture_create_from_iosurface)(gs_device_t dev,
|
||||
void *iosurf);
|
||||
bool (*gs_texture_rebind_iosurface)(gs_texture_t texture, void *iosurf);
|
||||
|
||||
#elif _WIN32
|
||||
bool (*gdi_texture_available)(void);
|
||||
texture_t (*device_create_gdi_texture)(device_t device,
|
||||
bool (*device_gdi_texture_available)(void);
|
||||
gs_texture_t (*device_texture_create_gdi)(gs_device_t device,
|
||||
uint32_t width, uint32_t height);
|
||||
|
||||
void *(*texture_get_dc)(texture_t gdi_tex);
|
||||
void (*texture_release_dc)(texture_t gdi_tex);
|
||||
void *(*gs_texture_get_dc)(gs_texture_t gdi_tex);
|
||||
void (*gs_texture_release_dc)(gs_texture_t gdi_tex);
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -218,7 +237,7 @@ struct blend_state {
|
|||
|
||||
struct graphics_subsystem {
|
||||
void *module;
|
||||
device_t device;
|
||||
gs_device_t device;
|
||||
struct gs_exports exports;
|
||||
|
||||
DARRAY(struct gs_rect) viewport_stack;
|
||||
|
@ -229,11 +248,11 @@ struct graphics_subsystem {
|
|||
struct matrix4 projection;
|
||||
struct gs_effect *cur_effect;
|
||||
|
||||
vertbuffer_t sprite_buffer;
|
||||
gs_vertbuffer_t sprite_buffer;
|
||||
|
||||
bool using_immediate;
|
||||
struct vb_data *vbd;
|
||||
vertbuffer_t immediate_vertbuffer;
|
||||
struct gs_vb_data *vbd;
|
||||
gs_vertbuffer_t immediate_vertbuffer;
|
||||
DARRAY(struct vec3) verts;
|
||||
DARRAY(struct vec3) norms;
|
||||
DARRAY(uint32_t) colors;
|
||||
|
|
|
@ -14,9 +14,9 @@ void gs_free_image_deps()
|
|||
MagickCoreTerminus();
|
||||
}
|
||||
|
||||
texture_t gs_create_texture_from_file(const char *file)
|
||||
gs_texture_t gs_texture_create_from_file(const char *file)
|
||||
{
|
||||
texture_t tex = NULL;
|
||||
gs_texture_t tex = NULL;
|
||||
ImageInfo *info;
|
||||
ExceptionInfo *exception;
|
||||
Image *image;
|
||||
|
@ -37,7 +37,7 @@ texture_t gs_create_texture_from_file(const char *file)
|
|||
ExportImagePixels(image, 0, 0, cx, cy, "BGRA", CharPixel,
|
||||
data, exception);
|
||||
if (exception->severity == UndefinedException)
|
||||
tex = gs_create_texture(cx, cy, GS_BGRA, 1,
|
||||
tex = gs_texture_create(cx, cy, GS_BGRA, 1,
|
||||
(const uint8_t**)&data, 0);
|
||||
else
|
||||
blog(LOG_WARNING, "magickcore warning/error getting "
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -124,7 +124,7 @@ enum gs_stencil_side {
|
|||
GS_STENCIL_BOTH
|
||||
};
|
||||
|
||||
enum gs_stencil_op {
|
||||
enum gs_stencil_op_type {
|
||||
GS_KEEP,
|
||||
GS_ZERO,
|
||||
GS_REPLACE,
|
||||
|
@ -168,12 +168,12 @@ enum gs_texture_type {
|
|||
GS_TEXTURE_CUBE
|
||||
};
|
||||
|
||||
struct tvertarray {
|
||||
struct gs_tvertarray {
|
||||
size_t width;
|
||||
void *array;
|
||||
};
|
||||
|
||||
struct vb_data {
|
||||
struct gs_vb_data {
|
||||
size_t num;
|
||||
struct vec3 *points;
|
||||
struct vec3 *normals;
|
||||
|
@ -181,15 +181,15 @@ struct vb_data {
|
|||
uint32_t *colors;
|
||||
|
||||
size_t num_tex;
|
||||
struct tvertarray *tvarray;
|
||||
struct gs_tvertarray *tvarray;
|
||||
};
|
||||
|
||||
static inline struct vb_data *vbdata_create(void)
|
||||
static inline struct gs_vb_data *gs_vbdata_create(void)
|
||||
{
|
||||
return (struct vb_data*)bzalloc(sizeof(struct vb_data));
|
||||
return (struct gs_vb_data*)bzalloc(sizeof(struct gs_vb_data));
|
||||
}
|
||||
|
||||
static inline void vbdata_destroy(struct vb_data *data)
|
||||
static inline void gs_vbdata_destroy(struct gs_vb_data *data)
|
||||
{
|
||||
uint32_t i;
|
||||
if (!data)
|
||||
|
@ -239,154 +239,161 @@ struct gs_sampler_state;
|
|||
struct gs_shader;
|
||||
struct gs_swap_chain;
|
||||
struct gs_texrender;
|
||||
struct shader_param;
|
||||
struct gs_shader_param;
|
||||
struct gs_effect;
|
||||
struct effect_technique;
|
||||
struct effect_pass;
|
||||
struct effect_param;
|
||||
struct gs_effect_technique;
|
||||
struct gs_effect_pass;
|
||||
struct gs_effect_param;
|
||||
struct gs_device;
|
||||
struct graphics_subsystem;
|
||||
|
||||
typedef struct gs_texture *texture_t;
|
||||
typedef struct gs_stage_surface *stagesurf_t;
|
||||
typedef struct gs_zstencil_buffer *zstencil_t;
|
||||
typedef struct gs_vertex_buffer *vertbuffer_t;
|
||||
typedef struct gs_index_buffer *indexbuffer_t;
|
||||
typedef struct gs_sampler_state *samplerstate_t;
|
||||
typedef struct gs_swap_chain *swapchain_t;
|
||||
typedef struct gs_texture_render *texrender_t;
|
||||
typedef struct gs_shader *shader_t;
|
||||
typedef struct shader_param *sparam_t;
|
||||
typedef struct gs_effect *effect_t;
|
||||
typedef struct effect_technique *technique_t;
|
||||
typedef struct effect_param *eparam_t;
|
||||
typedef struct gs_device *device_t;
|
||||
typedef struct graphics_subsystem *graphics_t;
|
||||
typedef struct gs_texture *gs_texture_t;
|
||||
typedef struct gs_stage_surface *gs_stagesurf_t;
|
||||
typedef struct gs_zstencil_buffer *gs_zstencil_t;
|
||||
typedef struct gs_vertex_buffer *gs_vertbuffer_t;
|
||||
typedef struct gs_index_buffer *gs_indexbuffer_t;
|
||||
typedef struct gs_sampler_state *gs_samplerstate_t;
|
||||
typedef struct gs_swap_chain *gs_swapchain_t;
|
||||
typedef struct gs_texture_render *gs_texrender_t;
|
||||
typedef struct gs_shader *gs_shader_t;
|
||||
typedef struct gs_shader_param *gs_sparam_t;
|
||||
typedef struct gs_effect *gs_effect_t;
|
||||
typedef struct gs_effect_technique *gs_technique_t;
|
||||
typedef struct gs_effect_param *gs_eparam_t;
|
||||
typedef struct gs_device *gs_device_t;
|
||||
typedef struct graphics_subsystem *graphics_t;
|
||||
|
||||
/* ---------------------------------------------------
|
||||
* shader functions
|
||||
* --------------------------------------------------- */
|
||||
|
||||
enum shader_param_type {
|
||||
SHADER_PARAM_UNKNOWN,
|
||||
SHADER_PARAM_BOOL,
|
||||
SHADER_PARAM_FLOAT,
|
||||
SHADER_PARAM_INT,
|
||||
SHADER_PARAM_STRING,
|
||||
SHADER_PARAM_VEC2,
|
||||
SHADER_PARAM_VEC3,
|
||||
SHADER_PARAM_VEC4,
|
||||
SHADER_PARAM_MATRIX4X4,
|
||||
SHADER_PARAM_TEXTURE,
|
||||
enum gs_shader_param_type {
|
||||
GS_SHADER_PARAM_UNKNOWN,
|
||||
GS_SHADER_PARAM_BOOL,
|
||||
GS_SHADER_PARAM_FLOAT,
|
||||
GS_SHADER_PARAM_INT,
|
||||
GS_SHADER_PARAM_STRING,
|
||||
GS_SHADER_PARAM_VEC2,
|
||||
GS_SHADER_PARAM_VEC3,
|
||||
GS_SHADER_PARAM_VEC4,
|
||||
GS_SHADER_PARAM_MATRIX4X4,
|
||||
GS_SHADER_PARAM_TEXTURE,
|
||||
};
|
||||
|
||||
struct shader_param_info {
|
||||
enum shader_param_type type;
|
||||
struct gs_shader_param_info {
|
||||
enum gs_shader_param_type type;
|
||||
const char *name;
|
||||
};
|
||||
|
||||
enum shader_type {
|
||||
SHADER_VERTEX,
|
||||
SHADER_PIXEL,
|
||||
enum gs_shader_type {
|
||||
GS_SHADER_VERTEX,
|
||||
GS_SHADER_PIXEL,
|
||||
};
|
||||
|
||||
EXPORT void shader_destroy(shader_t shader);
|
||||
EXPORT void gs_shader_destroy(gs_shader_t shader);
|
||||
|
||||
EXPORT int shader_numparams(shader_t shader);
|
||||
EXPORT sparam_t shader_getparambyidx(shader_t shader, uint32_t param);
|
||||
EXPORT sparam_t shader_getparambyname(shader_t shader, const char *name);
|
||||
EXPORT int gs_shader_get_num_params(gs_shader_t shader);
|
||||
EXPORT gs_sparam_t gs_shader_get_param_by_idx(gs_shader_t shader,
|
||||
uint32_t param);
|
||||
EXPORT gs_sparam_t gs_shader_get_param_by_name(gs_shader_t shader,
|
||||
const char *name);
|
||||
|
||||
EXPORT sparam_t shader_getviewprojmatrix(shader_t shader);
|
||||
EXPORT sparam_t shader_getworldmatrix(shader_t shader);
|
||||
EXPORT gs_sparam_t gs_shader_get_viewproj_matrix(gs_shader_t shader);
|
||||
EXPORT gs_sparam_t gs_shader_get_world_matrix(gs_shader_t shader);
|
||||
|
||||
EXPORT void shader_getparaminfo(sparam_t param, struct shader_param_info *info);
|
||||
EXPORT void shader_setbool(sparam_t param, bool val);
|
||||
EXPORT void shader_setfloat(sparam_t param, float val);
|
||||
EXPORT void shader_setint(sparam_t param, int val);
|
||||
EXPORT void shader_setmatrix3(sparam_t param, const struct matrix3 *val);
|
||||
EXPORT void shader_setmatrix4(sparam_t param, const struct matrix4 *val);
|
||||
EXPORT void shader_setvec2(sparam_t param, const struct vec2 *val);
|
||||
EXPORT void shader_setvec3(sparam_t param, const struct vec3 *val);
|
||||
EXPORT void shader_setvec4(sparam_t param, const struct vec4 *val);
|
||||
EXPORT void shader_settexture(sparam_t param, texture_t val);
|
||||
EXPORT void shader_setval(sparam_t param, const void *val, size_t size);
|
||||
EXPORT void shader_setdefault(sparam_t param);
|
||||
EXPORT void gs_shader_get_param_info(gs_sparam_t param,
|
||||
struct gs_shader_param_info *info);
|
||||
EXPORT void gs_shader_set_bool(gs_sparam_t param, bool val);
|
||||
EXPORT void gs_shader_set_float(gs_sparam_t param, float val);
|
||||
EXPORT void gs_shader_set_int(gs_sparam_t param, int val);
|
||||
EXPORT void gs_shader_setmatrix3(gs_sparam_t param, const struct matrix3 *val);
|
||||
EXPORT void gs_shader_set_matrix4(gs_sparam_t param, const struct matrix4 *val);
|
||||
EXPORT void gs_shader_set_vec2(gs_sparam_t param, const struct vec2 *val);
|
||||
EXPORT void gs_shader_set_vec3(gs_sparam_t param, const struct vec3 *val);
|
||||
EXPORT void gs_shader_set_vec4(gs_sparam_t param, const struct vec4 *val);
|
||||
EXPORT void gs_shader_set_texture(gs_sparam_t param, gs_texture_t val);
|
||||
EXPORT void gs_shader_set_val(gs_sparam_t param, const void *val, size_t size);
|
||||
EXPORT void gs_shader_set_default(gs_sparam_t param);
|
||||
|
||||
/* ---------------------------------------------------
|
||||
* effect functions
|
||||
* --------------------------------------------------- */
|
||||
|
||||
/*enum effect_property_type {
|
||||
EFFECT_NONE,
|
||||
EFFECT_BOOL,
|
||||
EFFECT_FLOAT,
|
||||
EFFECT_COLOR,
|
||||
EFFECT_TEXTURE
|
||||
/*enum gs_effect_property_type {
|
||||
GS_EFFECT_NONE,
|
||||
GS_EFFECT_BOOL,
|
||||
GS_EFFECT_FLOAT,
|
||||
GS_EFFECT_COLOR,
|
||||
GS_EFFECT_TEXTURE
|
||||
};*/
|
||||
|
||||
struct effect_param_info {
|
||||
struct gs_effect_param_info {
|
||||
const char *name;
|
||||
enum shader_param_type type;
|
||||
enum gs_shader_param_type type;
|
||||
|
||||
/* const char *full_name;
|
||||
enum effect_property_type prop_type;
|
||||
enum gs_effect_property_type prop_type;
|
||||
|
||||
float min, max, inc, mul; */
|
||||
};
|
||||
|
||||
EXPORT void effect_destroy(effect_t effect);
|
||||
EXPORT void gs_effect_destroy(gs_effect_t effect);
|
||||
|
||||
EXPORT technique_t effect_gettechnique(effect_t effect, const char *name);
|
||||
|
||||
EXPORT size_t technique_begin(technique_t technique);
|
||||
EXPORT void technique_end(technique_t technique);
|
||||
EXPORT bool technique_beginpass(technique_t technique, size_t pass);
|
||||
EXPORT bool technique_beginpassbyname(technique_t technique,
|
||||
EXPORT gs_technique_t gs_effect_get_technique(gs_effect_t effect,
|
||||
const char *name);
|
||||
EXPORT void technique_endpass(technique_t technique);
|
||||
|
||||
EXPORT size_t effect_numparams(effect_t effect);
|
||||
EXPORT eparam_t effect_getparambyidx(effect_t effect, size_t param);
|
||||
EXPORT eparam_t effect_getparambyname(effect_t effect, const char *name);
|
||||
EXPORT size_t gs_technique_begin(gs_technique_t technique);
|
||||
EXPORT void gs_technique_end(gs_technique_t technique);
|
||||
EXPORT bool gs_technique_begin_pass(gs_technique_t technique, size_t pass);
|
||||
EXPORT bool gs_technique_begin_pass_by_name(gs_technique_t technique,
|
||||
const char *name);
|
||||
EXPORT void gs_technique_end_pass(gs_technique_t technique);
|
||||
|
||||
EXPORT size_t gs_effect_get_num_params(gs_effect_t effect);
|
||||
EXPORT gs_eparam_t gs_effect_get_param_by_idx(gs_effect_t effect, size_t param);
|
||||
EXPORT gs_eparam_t gs_effect_get_param_by_name(gs_effect_t effect,
|
||||
const char *name);
|
||||
|
||||
/** used internally */
|
||||
EXPORT void effect_updateparams(effect_t effect);
|
||||
EXPORT void gs_effect_update_params(gs_effect_t effect);
|
||||
|
||||
EXPORT eparam_t effect_getviewprojmatrix(effect_t effect);
|
||||
EXPORT eparam_t effect_getworldmatrix(effect_t effect);
|
||||
EXPORT gs_eparam_t gs_effect_get_viewproj_matrix(gs_effect_t effect);
|
||||
EXPORT gs_eparam_t gs_effect_get_world_matrix(gs_effect_t effect);
|
||||
|
||||
EXPORT void effect_getparaminfo(eparam_t param, struct effect_param_info *info);
|
||||
EXPORT void effect_setbool(eparam_t param, bool val);
|
||||
EXPORT void effect_setfloat(eparam_t param, float val);
|
||||
EXPORT void effect_setint(eparam_t param, int val);
|
||||
EXPORT void effect_setmatrix4(eparam_t param, const struct matrix4 *val);
|
||||
EXPORT void effect_setvec2(eparam_t param, const struct vec2 *val);
|
||||
EXPORT void effect_setvec3(eparam_t param, const struct vec3 *val);
|
||||
EXPORT void effect_setvec4(eparam_t param, const struct vec4 *val);
|
||||
EXPORT void effect_settexture(eparam_t param, texture_t val);
|
||||
EXPORT void effect_setval(eparam_t param, const void *val, size_t size);
|
||||
EXPORT void effect_setdefault(eparam_t param);
|
||||
EXPORT void gs_effect_get_param_info(gs_eparam_t param,
|
||||
struct gs_effect_param_info *info);
|
||||
EXPORT void gs_effect_set_bool(gs_eparam_t param, bool val);
|
||||
EXPORT void gs_effect_set_float(gs_eparam_t param, float val);
|
||||
EXPORT void gs_effect_set_int(gs_eparam_t param, int val);
|
||||
EXPORT void gs_effect_set_matrix4(gs_eparam_t param, const struct matrix4 *val);
|
||||
EXPORT void gs_effect_set_vec2(gs_eparam_t param, const struct vec2 *val);
|
||||
EXPORT void gs_effect_set_vec3(gs_eparam_t param, const struct vec3 *val);
|
||||
EXPORT void gs_effect_set_vec4(gs_eparam_t param, const struct vec4 *val);
|
||||
EXPORT void gs_effect_set_texture(gs_eparam_t param, gs_texture_t val);
|
||||
EXPORT void gs_effect_set_val(gs_eparam_t param, const void *val, size_t size);
|
||||
EXPORT void gs_effect_set_default(gs_eparam_t param);
|
||||
|
||||
/* ---------------------------------------------------
|
||||
* texture render helper functions
|
||||
* --------------------------------------------------- */
|
||||
|
||||
EXPORT texrender_t texrender_create(enum gs_color_format format,
|
||||
EXPORT gs_texrender_t gs_texrender_create(enum gs_color_format format,
|
||||
enum gs_zstencil_format zsformat);
|
||||
EXPORT void texrender_destroy(texrender_t texrender);
|
||||
EXPORT bool texrender_begin(texrender_t texrender, uint32_t cx, uint32_t cy);
|
||||
EXPORT void texrender_end(texrender_t texrender);
|
||||
EXPORT void texrender_reset(texrender_t texrender);
|
||||
EXPORT texture_t texrender_gettexture(texrender_t texrender);
|
||||
EXPORT void gs_texrender_destroy(gs_texrender_t texrender);
|
||||
EXPORT bool gs_texrender_begin(gs_texrender_t texrender, uint32_t cx,
|
||||
uint32_t cy);
|
||||
EXPORT void gs_texrender_end(gs_texrender_t texrender);
|
||||
EXPORT void gs_texrender_reset(gs_texrender_t texrender);
|
||||
EXPORT gs_texture_t gs_texrender_get_texture(gs_texrender_t texrender);
|
||||
|
||||
/* ---------------------------------------------------
|
||||
* graphics subsystem
|
||||
* --------------------------------------------------- */
|
||||
|
||||
#define GS_BUILDMIPMAPS (1<<0)
|
||||
#define GS_DYNAMIC (1<<1)
|
||||
#define GS_RENDERTARGET (1<<2)
|
||||
#define GS_GL_DUMMYTEX (1<<3) /**<< texture with no allocated texture data */
|
||||
#define GS_BUILD_MIPMAPS (1<<0)
|
||||
#define GS_DYNAMIC (1<<1)
|
||||
#define GS_RENDER_TARGET (1<<2)
|
||||
#define GS_GL_DUMMYTEX (1<<3) /**<< texture with no allocated texture data */
|
||||
|
||||
/* ---------------- */
|
||||
/* global functions */
|
||||
|
@ -420,16 +427,16 @@ struct gs_init_data {
|
|||
#define GS_DEVICE_OPENGL 1
|
||||
#define GS_DEVICE_DIRECT3D_11 2
|
||||
|
||||
EXPORT const char *gs_device_name(void);
|
||||
EXPORT int gs_device_type(void);
|
||||
EXPORT const char *gs_get_device_name(void);
|
||||
EXPORT int gs_get_device_type(void);
|
||||
|
||||
EXPORT int gs_create(graphics_t *graphics, const char *module,
|
||||
struct gs_init_data *data);
|
||||
EXPORT void gs_destroy(graphics_t graphics);
|
||||
|
||||
EXPORT void gs_entercontext(graphics_t graphics);
|
||||
EXPORT void gs_leavecontext(void);
|
||||
EXPORT graphics_t gs_getcontext(void);
|
||||
EXPORT void gs_enter_context(graphics_t graphics);
|
||||
EXPORT void gs_leave_context(void);
|
||||
EXPORT graphics_t gs_get_context(void);
|
||||
|
||||
EXPORT void gs_matrix_push(void);
|
||||
EXPORT void gs_matrix_pop(void);
|
||||
|
@ -446,9 +453,9 @@ EXPORT void gs_matrix_rotaa4f(float x, float y, float z, float angle);
|
|||
EXPORT void gs_matrix_translate3f(float x, float y, float z);
|
||||
EXPORT void gs_matrix_scale3f(float x, float y, float z);
|
||||
|
||||
EXPORT void gs_renderstart(bool b_new);
|
||||
EXPORT void gs_renderstop(enum gs_draw_mode mode);
|
||||
EXPORT vertbuffer_t gs_rendersave(void);
|
||||
EXPORT void gs_render_start(bool b_new);
|
||||
EXPORT void gs_render_stop(enum gs_draw_mode mode);
|
||||
EXPORT gs_vertbuffer_t gs_render_save(void);
|
||||
EXPORT void gs_vertex2f(float x, float y);
|
||||
EXPORT void gs_vertex3f(float x, float y, float z);
|
||||
EXPORT void gs_normal3f(float x, float y, float z);
|
||||
|
@ -460,20 +467,20 @@ EXPORT void gs_normal3v(const struct vec3 *v);
|
|||
EXPORT void gs_color4v(const struct vec4 *v);
|
||||
EXPORT void gs_texcoord2v(const struct vec2 *v, int unit);
|
||||
|
||||
EXPORT input_t gs_getinput(void);
|
||||
EXPORT effect_t gs_geteffect(void);
|
||||
EXPORT input_t gs_get_input(void);
|
||||
EXPORT gs_effect_t gs_get_effect(void);
|
||||
|
||||
EXPORT effect_t gs_create_effect_from_file(const char *file,
|
||||
EXPORT gs_effect_t gs_effect_create_from_file(const char *file,
|
||||
char **error_string);
|
||||
EXPORT effect_t gs_create_effect(const char *effect_string,
|
||||
EXPORT gs_effect_t gs_effect_create(const char *effect_string,
|
||||
const char *filename, char **error_string);
|
||||
|
||||
EXPORT shader_t gs_create_vertexshader_from_file(const char *file,
|
||||
EXPORT gs_shader_t gs_vertexshader_create_from_file(const char *file,
|
||||
char **error_string);
|
||||
EXPORT shader_t gs_create_pixelshader_from_file(const char *file,
|
||||
EXPORT gs_shader_t gs_pixelshader_create_from_file(const char *file,
|
||||
char **error_string);
|
||||
|
||||
EXPORT texture_t gs_create_texture_from_file(const char *file);
|
||||
EXPORT gs_texture_t gs_texture_create_from_file(const char *file);
|
||||
|
||||
#define GS_FLIP_U (1<<0)
|
||||
#define GS_FLIP_V (1<<1)
|
||||
|
@ -485,26 +492,26 @@ EXPORT texture_t gs_create_texture_from_file(const char *file);
|
|||
* The flip value specifies whether the texture shoudl be flipped on the U or V
|
||||
* axis with GS_FLIP_U and GS_FLIP_V.
|
||||
*/
|
||||
EXPORT void gs_draw_sprite(texture_t tex, uint32_t flip, uint32_t width,
|
||||
EXPORT void gs_draw_sprite(gs_texture_t tex, uint32_t flip, uint32_t width,
|
||||
uint32_t height);
|
||||
|
||||
EXPORT void gs_draw_cube_backdrop(texture_t cubetex, const struct quat *rot,
|
||||
EXPORT void gs_draw_cube_backdrop(gs_texture_t cubetex, const struct quat *rot,
|
||||
float left, float right, float top, float bottom, float znear);
|
||||
|
||||
/** sets the viewport to current swap chain size */
|
||||
EXPORT void gs_resetviewport(void);
|
||||
EXPORT void gs_reset_viewport(void);
|
||||
|
||||
/** sets default screen-sized orthographich mode */
|
||||
EXPORT void gs_set2dmode(void);
|
||||
EXPORT void gs_set_2d_mode(void);
|
||||
/** sets default screen-sized perspective mode */
|
||||
EXPORT void gs_set3dmode(double fovy, double znear, double zvar);
|
||||
EXPORT void gs_set_3d_mode(double fovy, double znear, double zvar);
|
||||
|
||||
EXPORT void gs_viewport_push(void);
|
||||
EXPORT void gs_viewport_pop(void);
|
||||
|
||||
EXPORT void texture_setimage(texture_t tex, const uint8_t *data,
|
||||
EXPORT void gs_texture_set_image(gs_texture_t tex, const uint8_t *data,
|
||||
uint32_t linesize, bool invert);
|
||||
EXPORT void cubetexture_setimage(texture_t cubetex, uint32_t side,
|
||||
EXPORT void gs_cubetexture_set_image(gs_texture_t cubetex, uint32_t side,
|
||||
const void *data, uint32_t linesize, bool invert);
|
||||
|
||||
EXPORT void gs_perspective(float fovy, float aspect, float znear, float zfar);
|
||||
|
@ -514,104 +521,106 @@ EXPORT void gs_reset_blend_state(void);
|
|||
/* -------------------------- */
|
||||
/* library-specific functions */
|
||||
|
||||
EXPORT swapchain_t gs_create_swapchain(struct gs_init_data *data);
|
||||
EXPORT gs_swapchain_t gs_swapchain_create(struct gs_init_data *data);
|
||||
|
||||
EXPORT void gs_resize(uint32_t x, uint32_t y);
|
||||
EXPORT void gs_getsize(uint32_t *x, uint32_t *y);
|
||||
EXPORT uint32_t gs_getwidth(void);
|
||||
EXPORT uint32_t gs_getheight(void);
|
||||
EXPORT void gs_get_size(uint32_t *x, uint32_t *y);
|
||||
EXPORT uint32_t gs_get_width(void);
|
||||
EXPORT uint32_t gs_get_height(void);
|
||||
|
||||
EXPORT texture_t gs_create_texture(uint32_t width, uint32_t height,
|
||||
EXPORT gs_texture_t gs_texture_create(uint32_t width, uint32_t height,
|
||||
enum gs_color_format color_format, uint32_t levels,
|
||||
const uint8_t **data, uint32_t flags);
|
||||
EXPORT texture_t gs_create_cubetexture(uint32_t size,
|
||||
EXPORT gs_texture_t gs_cubetexture_create(uint32_t size,
|
||||
enum gs_color_format color_format, uint32_t levels,
|
||||
const uint8_t **data, uint32_t flags);
|
||||
EXPORT texture_t gs_create_volumetexture(uint32_t width, uint32_t height,
|
||||
EXPORT gs_texture_t gs_voltexture_create(uint32_t width, uint32_t height,
|
||||
uint32_t depth, enum gs_color_format color_format,
|
||||
uint32_t levels, const uint8_t **data, uint32_t flags);
|
||||
|
||||
EXPORT zstencil_t gs_create_zstencil(uint32_t width, uint32_t height,
|
||||
EXPORT gs_zstencil_t gs_zstencil_create(uint32_t width, uint32_t height,
|
||||
enum gs_zstencil_format format);
|
||||
|
||||
EXPORT stagesurf_t gs_create_stagesurface(uint32_t width, uint32_t height,
|
||||
EXPORT gs_stagesurf_t gs_stagesurface_create(uint32_t width, uint32_t height,
|
||||
enum gs_color_format color_format);
|
||||
|
||||
EXPORT samplerstate_t gs_create_samplerstate(struct gs_sampler_info *info);
|
||||
EXPORT gs_samplerstate_t gs_samplerstate_create(struct gs_sampler_info *info);
|
||||
|
||||
EXPORT shader_t gs_create_vertexshader(const char *shader,
|
||||
EXPORT gs_shader_t gs_vertexshader_create(const char *shader,
|
||||
const char *file, char **error_string);
|
||||
EXPORT shader_t gs_create_pixelshader(const char *shader,
|
||||
EXPORT gs_shader_t gs_pixelshader_create(const char *shader,
|
||||
const char *file, char **error_string);
|
||||
|
||||
EXPORT vertbuffer_t gs_create_vertexbuffer(struct vb_data *data,
|
||||
EXPORT gs_vertbuffer_t gs_vertexbuffer_create(struct gs_vb_data *data,
|
||||
uint32_t flags);
|
||||
EXPORT indexbuffer_t gs_create_indexbuffer(enum gs_index_type type,
|
||||
EXPORT gs_indexbuffer_t gs_indexbuffer_create(enum gs_index_type type,
|
||||
void *indices, size_t num, uint32_t flags);
|
||||
|
||||
EXPORT enum gs_texture_type gs_gettexturetype(texture_t texture);
|
||||
EXPORT enum gs_texture_type gs_get_texture_type(gs_texture_t texture);
|
||||
|
||||
EXPORT void gs_load_vertexbuffer(vertbuffer_t vertbuffer);
|
||||
EXPORT void gs_load_indexbuffer(indexbuffer_t indexbuffer);
|
||||
EXPORT void gs_load_texture(texture_t tex, int unit);
|
||||
EXPORT void gs_load_samplerstate(samplerstate_t samplerstate, int unit);
|
||||
EXPORT void gs_load_vertexshader(shader_t vertshader);
|
||||
EXPORT void gs_load_pixelshader(shader_t pixelshader);
|
||||
EXPORT void gs_load_vertexbuffer(gs_vertbuffer_t vertbuffer);
|
||||
EXPORT void gs_load_indexbuffer(gs_indexbuffer_t indexbuffer);
|
||||
EXPORT void gs_load_texture(gs_texture_t tex, int unit);
|
||||
EXPORT void gs_load_samplerstate(gs_samplerstate_t samplerstate, int unit);
|
||||
EXPORT void gs_load_vertexshader(gs_shader_t vertshader);
|
||||
EXPORT void gs_load_pixelshader(gs_shader_t pixelshader);
|
||||
|
||||
EXPORT void gs_load_defaultsamplerstate(bool b_3d, int unit);
|
||||
EXPORT void gs_load_default_samplerstate(bool b_3d, int unit);
|
||||
|
||||
EXPORT shader_t gs_getvertexshader(void);
|
||||
EXPORT shader_t gs_getpixelshader(void);
|
||||
EXPORT gs_shader_t gs_get_vertex_shader(void);
|
||||
EXPORT gs_shader_t gs_get_pixel_shader(void);
|
||||
|
||||
EXPORT texture_t gs_getrendertarget(void);
|
||||
EXPORT zstencil_t gs_getzstenciltarget(void);
|
||||
EXPORT gs_texture_t gs_get_render_target(void);
|
||||
EXPORT gs_zstencil_t gs_get_zstencil_target(void);
|
||||
|
||||
EXPORT void gs_setrendertarget(texture_t tex, zstencil_t zstencil);
|
||||
EXPORT void gs_setcuberendertarget(texture_t cubetex, int side,
|
||||
zstencil_t zstencil);
|
||||
EXPORT void gs_set_render_target(gs_texture_t tex, gs_zstencil_t zstencil);
|
||||
EXPORT void gs_set_cube_render_target(gs_texture_t cubetex, int side,
|
||||
gs_zstencil_t zstencil);
|
||||
|
||||
EXPORT void gs_copy_texture(texture_t dst, texture_t src);
|
||||
EXPORT void gs_copy_texture(gs_texture_t dst, gs_texture_t src);
|
||||
EXPORT void gs_copy_texture_region(
|
||||
texture_t dst, uint32_t dst_x, uint32_t dst_y,
|
||||
texture_t src, uint32_t src_x, uint32_t src_y,
|
||||
gs_texture_t 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);
|
||||
EXPORT void gs_stage_texture(stagesurf_t dst, texture_t src);
|
||||
EXPORT void gs_stage_texture(gs_stagesurf_t dst, gs_texture_t src);
|
||||
|
||||
EXPORT void gs_beginscene(void);
|
||||
EXPORT void gs_begin_scene(void);
|
||||
EXPORT void gs_draw(enum gs_draw_mode draw_mode, uint32_t start_vert,
|
||||
uint32_t num_verts);
|
||||
EXPORT void gs_endscene(void);
|
||||
EXPORT void gs_end_scene(void);
|
||||
|
||||
#define GS_CLEAR_COLOR (1<<0)
|
||||
#define GS_CLEAR_DEPTH (1<<1)
|
||||
#define GS_CLEAR_STENCIL (1<<2)
|
||||
|
||||
EXPORT void gs_load_swapchain(swapchain_t swapchain);
|
||||
EXPORT void gs_load_swapchain(gs_swapchain_t swapchain);
|
||||
EXPORT void gs_clear(uint32_t clear_flags, struct vec4 *color,
|
||||
float depth, uint8_t stencil);
|
||||
EXPORT void gs_present(void);
|
||||
EXPORT void gs_flush(void);
|
||||
|
||||
EXPORT void gs_setcullmode(enum gs_cull_mode mode);
|
||||
EXPORT enum gs_cull_mode gs_getcullmode(void);
|
||||
EXPORT void gs_set_cull_mode(enum gs_cull_mode mode);
|
||||
EXPORT enum gs_cull_mode gs_get_cull_mode(void);
|
||||
|
||||
EXPORT void gs_enable_blending(bool enable);
|
||||
EXPORT void gs_enable_depthtest(bool enable);
|
||||
EXPORT void gs_enable_stenciltest(bool enable);
|
||||
EXPORT void gs_enable_stencilwrite(bool enable);
|
||||
EXPORT void gs_enable_depth_test(bool enable);
|
||||
EXPORT void gs_enable_stencil_test(bool enable);
|
||||
EXPORT void gs_enable_stencil_write(bool enable);
|
||||
EXPORT void gs_enable_color(bool red, bool green, bool blue, bool alpha);
|
||||
|
||||
EXPORT void gs_blendfunction(enum gs_blend_type src, enum gs_blend_type dest);
|
||||
EXPORT void gs_depthfunction(enum gs_depth_test test);
|
||||
EXPORT void gs_blend_function(enum gs_blend_type src, enum gs_blend_type dest);
|
||||
EXPORT void gs_depth_function(enum gs_depth_test test);
|
||||
|
||||
EXPORT void gs_stencilfunction(enum gs_stencil_side side,
|
||||
EXPORT void gs_stencil_function(enum gs_stencil_side side,
|
||||
enum gs_depth_test test);
|
||||
EXPORT void gs_stencilop(enum gs_stencil_side side, enum gs_stencil_op fail,
|
||||
enum gs_stencil_op zfail, enum gs_stencil_op zpass);
|
||||
EXPORT void gs_stencil_op(enum gs_stencil_side side,
|
||||
enum gs_stencil_op_type fail,
|
||||
enum gs_stencil_op_type zfail,
|
||||
enum gs_stencil_op_type zpass);
|
||||
|
||||
EXPORT void gs_setviewport(int x, int y, int width, int height);
|
||||
EXPORT void gs_getviewport(struct gs_rect *rect);
|
||||
EXPORT void gs_setscissorrect(struct gs_rect *rect);
|
||||
EXPORT void gs_set_viewport(int x, int y, int width, int height);
|
||||
EXPORT void gs_get_viewport(struct gs_rect *rect);
|
||||
EXPORT void gs_set_scissor_rect(struct gs_rect *rect);
|
||||
|
||||
EXPORT void gs_ortho(float left, float right, float top, float bottom,
|
||||
float znear, float zfar);
|
||||
|
@ -621,72 +630,75 @@ EXPORT void gs_frustum(float left, float right, float top, float bottom,
|
|||
EXPORT void gs_projection_push(void);
|
||||
EXPORT void gs_projection_pop(void);
|
||||
|
||||
EXPORT void swapchain_destroy(swapchain_t swapchain);
|
||||
EXPORT void gs_swapchain_destroy(gs_swapchain_t swapchain);
|
||||
|
||||
EXPORT void texture_destroy(texture_t tex);
|
||||
EXPORT uint32_t texture_getwidth(texture_t tex);
|
||||
EXPORT uint32_t texture_getheight(texture_t tex);
|
||||
EXPORT enum gs_color_format texture_getcolorformat(texture_t tex);
|
||||
EXPORT bool texture_map(texture_t tex, uint8_t **ptr, uint32_t *linesize);
|
||||
EXPORT void texture_unmap(texture_t tex);
|
||||
EXPORT void gs_texture_destroy(gs_texture_t tex);
|
||||
EXPORT uint32_t gs_texture_get_width(gs_texture_t tex);
|
||||
EXPORT uint32_t gs_texture_get_height(gs_texture_t tex);
|
||||
EXPORT enum gs_color_format gs_texture_get_color_format(gs_texture_t tex);
|
||||
EXPORT bool gs_texture_map(gs_texture_t tex, uint8_t **ptr,
|
||||
uint32_t *linesize);
|
||||
EXPORT void gs_texture_unmap(gs_texture_t tex);
|
||||
/** special-case function (GL only) - specifies whether the texture is a
|
||||
* GL_TEXTURE_RECTANGLE type, which doesn't use normalized texture
|
||||
* coordinates, doesn't support mipmapping, and requires address clamping */
|
||||
EXPORT bool texture_isrect(texture_t tex);
|
||||
EXPORT bool gs_texture_is_rect(gs_texture_t tex);
|
||||
/**
|
||||
* Gets a pointer to the context-specific object associated with the texture.
|
||||
* For example, for GL, this is a GLuint*. For D3D11, ID3D11Texture2D*.
|
||||
*/
|
||||
EXPORT void *texture_getobj(texture_t tex);
|
||||
EXPORT void *gs_texture_get_obj(gs_texture_t tex);
|
||||
|
||||
EXPORT void cubetexture_destroy(texture_t cubetex);
|
||||
EXPORT uint32_t cubetexture_getsize(texture_t cubetex);
|
||||
EXPORT enum gs_color_format cubetexture_getcolorformat(texture_t cubetex);
|
||||
EXPORT void gs_cubetexture_destroy(gs_texture_t cubetex);
|
||||
EXPORT uint32_t gs_cubetexture_get_size(gs_texture_t cubetex);
|
||||
EXPORT enum gs_color_format gs_cubetexture_get_color_format(
|
||||
gs_texture_t cubetex);
|
||||
|
||||
EXPORT void volumetexture_destroy(texture_t voltex);
|
||||
EXPORT uint32_t volumetexture_getwidth(texture_t voltex);
|
||||
EXPORT uint32_t volumetexture_getheight(texture_t voltex);
|
||||
EXPORT uint32_t volumetexture_getdepth(texture_t voltex);
|
||||
EXPORT enum gs_color_format volumetexture_getcolorformat(texture_t voltex);
|
||||
EXPORT void gs_voltexture_destroy(gs_texture_t voltex);
|
||||
EXPORT uint32_t gs_voltexture_get_width(gs_texture_t voltex);
|
||||
EXPORT uint32_t gs_voltexture_get_height(gs_texture_t voltex);
|
||||
EXPORT uint32_t gs_voltexture_getdepth(gs_texture_t voltex);
|
||||
EXPORT enum gs_color_format gs_voltexture_get_color_format(gs_texture_t voltex);
|
||||
|
||||
EXPORT void stagesurface_destroy(stagesurf_t stagesurf);
|
||||
EXPORT uint32_t stagesurface_getwidth(stagesurf_t stagesurf);
|
||||
EXPORT uint32_t stagesurface_getheight(stagesurf_t stagesurf);
|
||||
EXPORT enum gs_color_format stagesurface_getcolorformat(stagesurf_t stagesurf);
|
||||
EXPORT bool stagesurface_map(stagesurf_t stagesurf, uint8_t **data,
|
||||
EXPORT void gs_stagesurface_destroy(gs_stagesurf_t stagesurf);
|
||||
EXPORT uint32_t gs_stagesurface_get_width(gs_stagesurf_t stagesurf);
|
||||
EXPORT uint32_t gs_stagesurface_get_height(gs_stagesurf_t stagesurf);
|
||||
EXPORT enum gs_color_format gs_stagesurface_get_color_format(
|
||||
gs_stagesurf_t stagesurf);
|
||||
EXPORT bool gs_stagesurface_map(gs_stagesurf_t stagesurf, uint8_t **data,
|
||||
uint32_t *linesize);
|
||||
EXPORT void stagesurface_unmap(stagesurf_t stagesurf);
|
||||
EXPORT void gs_stagesurface_unmap(gs_stagesurf_t stagesurf);
|
||||
|
||||
EXPORT void zstencil_destroy(zstencil_t zstencil);
|
||||
EXPORT void gs_zstencil_destroy(gs_zstencil_t zstencil);
|
||||
|
||||
EXPORT void samplerstate_destroy(samplerstate_t samplerstate);
|
||||
EXPORT void gs_samplerstate_destroy(gs_samplerstate_t samplerstate);
|
||||
|
||||
EXPORT void vertexbuffer_destroy(vertbuffer_t vertbuffer);
|
||||
EXPORT void vertexbuffer_flush(vertbuffer_t vertbuffer);
|
||||
EXPORT struct vb_data *vertexbuffer_getdata(vertbuffer_t vertbuffer);
|
||||
EXPORT void gs_vertexbuffer_destroy(gs_vertbuffer_t vertbuffer);
|
||||
EXPORT void gs_vertexbuffer_flush(gs_vertbuffer_t vertbuffer);
|
||||
EXPORT struct gs_vb_data *gs_vertexbuffer_get_data(gs_vertbuffer_t vertbuffer);
|
||||
|
||||
EXPORT void indexbuffer_destroy(indexbuffer_t indexbuffer);
|
||||
EXPORT void indexbuffer_flush(indexbuffer_t indexbuffer);
|
||||
EXPORT void *indexbuffer_getdata(indexbuffer_t indexbuffer);
|
||||
EXPORT size_t indexbuffer_numindices(indexbuffer_t indexbuffer);
|
||||
EXPORT enum gs_index_type indexbuffer_gettype(indexbuffer_t indexbuffer);
|
||||
EXPORT void gs_indexbuffer_destroy(gs_indexbuffer_t indexbuffer);
|
||||
EXPORT void gs_indexbuffer_flush(gs_indexbuffer_t indexbuffer);
|
||||
EXPORT void *gs_indexbuffer_get_data(gs_indexbuffer_t indexbuffer);
|
||||
EXPORT size_t gs_indexbuffer_get_num_indices(gs_indexbuffer_t indexbuffer);
|
||||
EXPORT enum gs_index_type gs_indexbuffer_get_type(gs_indexbuffer_t indexbuffer);
|
||||
|
||||
#ifdef __APPLE__
|
||||
|
||||
/** platform specific function for creating (GL_TEXTURE_RECTANGLE) textures
|
||||
* from shared surface resources */
|
||||
EXPORT texture_t gs_create_texture_from_iosurface(void *iosurf);
|
||||
EXPORT bool texture_rebind_iosurface(texture_t texture, void *iosurf);
|
||||
EXPORT gs_texture_t gs_texture_create_from_iosurface(void *iosurf);
|
||||
EXPORT bool gs_texture_rebind_iosurface(gs_texture_t texture, void *iosurf);
|
||||
|
||||
#elif _WIN32
|
||||
|
||||
EXPORT bool gs_gdi_texture_available(void);
|
||||
|
||||
/** creates a windows GDI-lockable texture */
|
||||
EXPORT texture_t gs_create_gdi_texture(uint32_t width, uint32_t height);
|
||||
EXPORT gs_texture_t gs_texture_create_gdi(uint32_t width, uint32_t height);
|
||||
|
||||
EXPORT void *texture_get_dc(texture_t gdi_tex);
|
||||
EXPORT void texture_release_dc(texture_t gdi_tex);
|
||||
EXPORT void *gs_texture_get_dc(gs_texture_t gdi_tex);
|
||||
EXPORT void gs_texture_release_dc(gs_texture_t gdi_tex);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -723,7 +735,7 @@ static inline bool gs_is_compressed_format(enum gs_color_format format)
|
|||
return (format == GS_DXT1 || format == GS_DXT3 || format == GS_DXT5);
|
||||
}
|
||||
|
||||
static inline uint32_t gs_num_total_levels(uint32_t width, uint32_t height)
|
||||
static inline uint32_t gs_get_total_levels(uint32_t width, uint32_t height)
|
||||
{
|
||||
uint32_t size = width > height ? width : height;
|
||||
uint32_t num_levels = 0;
|
||||
|
|
|
@ -17,28 +17,28 @@
|
|||
|
||||
#include "shader-parser.h"
|
||||
|
||||
enum shader_param_type get_shader_param_type(const char *type)
|
||||
enum gs_shader_param_type get_shader_param_type(const char *type)
|
||||
{
|
||||
if (strcmp(type, "float") == 0)
|
||||
return SHADER_PARAM_FLOAT;
|
||||
return GS_SHADER_PARAM_FLOAT;
|
||||
else if (strcmp(type, "float2") == 0)
|
||||
return SHADER_PARAM_VEC2;
|
||||
return GS_SHADER_PARAM_VEC2;
|
||||
else if (strcmp(type, "float3") == 0)
|
||||
return SHADER_PARAM_VEC3;
|
||||
return GS_SHADER_PARAM_VEC3;
|
||||
else if (strcmp(type, "float4") == 0)
|
||||
return SHADER_PARAM_VEC4;
|
||||
return GS_SHADER_PARAM_VEC4;
|
||||
else if (astrcmp_n(type, "texture", 7) == 0)
|
||||
return SHADER_PARAM_TEXTURE;
|
||||
return GS_SHADER_PARAM_TEXTURE;
|
||||
else if (strcmp(type, "float4x4") == 0)
|
||||
return SHADER_PARAM_MATRIX4X4;
|
||||
return GS_SHADER_PARAM_MATRIX4X4;
|
||||
else if (strcmp(type, "bool") == 0)
|
||||
return SHADER_PARAM_BOOL;
|
||||
return GS_SHADER_PARAM_BOOL;
|
||||
else if (strcmp(type, "int") == 0)
|
||||
return SHADER_PARAM_INT;
|
||||
return GS_SHADER_PARAM_INT;
|
||||
else if (strcmp(type, "string") == 0)
|
||||
return SHADER_PARAM_STRING;
|
||||
return GS_SHADER_PARAM_STRING;
|
||||
|
||||
return SHADER_PARAM_UNKNOWN;
|
||||
return GS_SHADER_PARAM_UNKNOWN;
|
||||
}
|
||||
|
||||
enum gs_sample_filter get_sample_filter(const char *filter)
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
EXPORT enum shader_param_type get_shader_param_type(const char *type);
|
||||
EXPORT enum gs_shader_param_type get_shader_param_type(const char *type);
|
||||
EXPORT enum gs_sample_filter get_sample_filter(const char *filter);
|
||||
EXPORT enum gs_address_mode get_address_mode(const char *address_mode);
|
||||
|
||||
|
|
|
@ -24,8 +24,8 @@
|
|||
#include "graphics.h"
|
||||
|
||||
struct gs_texture_render {
|
||||
texture_t target, prev_target;
|
||||
zstencil_t zs, prev_zs;
|
||||
gs_texture_t target, prev_target;
|
||||
gs_zstencil_t zs, prev_zs;
|
||||
|
||||
uint32_t cx, cy;
|
||||
|
||||
|
@ -35,7 +35,7 @@ struct gs_texture_render {
|
|||
bool rendered;
|
||||
};
|
||||
|
||||
texrender_t texrender_create(enum gs_color_format format,
|
||||
gs_texrender_t gs_texrender_create(enum gs_color_format format,
|
||||
enum gs_zstencil_format zsformat)
|
||||
{
|
||||
struct gs_texture_render *texrender;
|
||||
|
@ -46,38 +46,38 @@ texrender_t texrender_create(enum gs_color_format format,
|
|||
return texrender;
|
||||
}
|
||||
|
||||
void texrender_destroy(texrender_t texrender)
|
||||
void gs_texrender_destroy(gs_texrender_t texrender)
|
||||
{
|
||||
if (texrender) {
|
||||
texture_destroy(texrender->target);
|
||||
zstencil_destroy(texrender->zs);
|
||||
gs_texture_destroy(texrender->target);
|
||||
gs_zstencil_destroy(texrender->zs);
|
||||
bfree(texrender);
|
||||
}
|
||||
}
|
||||
|
||||
static bool texrender_resetbuffer(texrender_t texrender, uint32_t cx,
|
||||
static bool texrender_resetbuffer(gs_texrender_t texrender, uint32_t cx,
|
||||
uint32_t cy)
|
||||
{
|
||||
if (!texrender)
|
||||
return false;
|
||||
|
||||
texture_destroy(texrender->target);
|
||||
zstencil_destroy(texrender->zs);
|
||||
gs_texture_destroy(texrender->target);
|
||||
gs_zstencil_destroy(texrender->zs);
|
||||
|
||||
texrender->target = NULL;
|
||||
texrender->zs = NULL;
|
||||
texrender->cx = cx;
|
||||
texrender->cy = cy;
|
||||
|
||||
texrender->target = gs_create_texture(cx, cy, texrender->format,
|
||||
1, NULL, GS_RENDERTARGET);
|
||||
texrender->target = gs_texture_create(cx, cy, texrender->format,
|
||||
1, NULL, GS_RENDER_TARGET);
|
||||
if (!texrender->target)
|
||||
return false;
|
||||
|
||||
if (texrender->zsformat != GS_ZS_NONE) {
|
||||
texrender->zs = gs_create_zstencil(cx, cy, texrender->zsformat);
|
||||
texrender->zs = gs_zstencil_create(cx, cy, texrender->zsformat);
|
||||
if (!texrender->zs) {
|
||||
texture_destroy(texrender->target);
|
||||
gs_texture_destroy(texrender->target);
|
||||
texrender->target = NULL;
|
||||
|
||||
return false;
|
||||
|
@ -87,15 +87,15 @@ static bool texrender_resetbuffer(texrender_t texrender, uint32_t cx,
|
|||
return true;
|
||||
}
|
||||
|
||||
bool texrender_begin(texrender_t texrender, uint32_t cx, uint32_t cy)
|
||||
bool gs_texrender_begin(gs_texrender_t texrender, uint32_t cx, uint32_t cy)
|
||||
{
|
||||
if (!texrender || texrender->rendered)
|
||||
return false;
|
||||
|
||||
if (cx == 0)
|
||||
cx = gs_getwidth();
|
||||
cx = gs_get_width();
|
||||
if (cy == 0)
|
||||
cy = gs_getheight();
|
||||
cy = gs_get_height();
|
||||
|
||||
assert(cx && cy);
|
||||
if (!cx || !cy)
|
||||
|
@ -110,21 +110,21 @@ bool texrender_begin(texrender_t texrender, uint32_t cx, uint32_t cy)
|
|||
gs_matrix_push();
|
||||
gs_matrix_identity();
|
||||
|
||||
texrender->prev_target = gs_getrendertarget();
|
||||
texrender->prev_zs = gs_getzstenciltarget();
|
||||
gs_setrendertarget(texrender->target, texrender->zs);
|
||||
texrender->prev_target = gs_get_render_target();
|
||||
texrender->prev_zs = gs_get_zstencil_target();
|
||||
gs_set_render_target(texrender->target, texrender->zs);
|
||||
|
||||
gs_setviewport(0, 0, texrender->cx, texrender->cy);
|
||||
gs_set_viewport(0, 0, texrender->cx, texrender->cy);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void texrender_end(texrender_t texrender)
|
||||
void gs_texrender_end(gs_texrender_t texrender)
|
||||
{
|
||||
if (!texrender)
|
||||
return;
|
||||
|
||||
gs_setrendertarget(texrender->prev_target, texrender->prev_zs);
|
||||
gs_set_render_target(texrender->prev_target, texrender->prev_zs);
|
||||
|
||||
gs_matrix_pop();
|
||||
gs_projection_pop();
|
||||
|
@ -133,13 +133,13 @@ void texrender_end(texrender_t texrender)
|
|||
texrender->rendered = true;
|
||||
}
|
||||
|
||||
void texrender_reset(texrender_t texrender)
|
||||
void gs_texrender_reset(gs_texrender_t texrender)
|
||||
{
|
||||
if (texrender)
|
||||
texrender->rendered = false;
|
||||
}
|
||||
|
||||
texture_t texrender_gettexture(texrender_t texrender)
|
||||
gs_texture_t gs_texrender_get_texture(gs_texrender_t texrender)
|
||||
{
|
||||
return texrender ? texrender->target : NULL;
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ bool obs_display_init(struct obs_display *display,
|
|||
pthread_mutex_init_value(&display->draw_callbacks_mutex);
|
||||
|
||||
if (graphics_data) {
|
||||
display->swap = gs_create_swapchain(graphics_data);
|
||||
display->swap = gs_swapchain_create(graphics_data);
|
||||
if (!display->swap) {
|
||||
blog(LOG_ERROR, "obs_display_init: Failed to "
|
||||
"create swap chain");
|
||||
|
@ -48,7 +48,7 @@ obs_display_t obs_display_create(struct gs_init_data *graphics_data)
|
|||
{
|
||||
struct obs_display *display = bzalloc(sizeof(struct obs_display));
|
||||
|
||||
gs_entercontext(obs->video.graphics);
|
||||
gs_enter_context(obs->video.graphics);
|
||||
|
||||
if (!graphics_data->num_backbuffers)
|
||||
graphics_data->num_backbuffers = 1;
|
||||
|
@ -66,7 +66,7 @@ obs_display_t obs_display_create(struct gs_init_data *graphics_data)
|
|||
pthread_mutex_unlock(&obs->data.displays_mutex);
|
||||
}
|
||||
|
||||
gs_leavecontext();
|
||||
gs_leave_context();
|
||||
|
||||
return display;
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ void obs_display_free(obs_display_t display)
|
|||
da_free(display->draw_callbacks);
|
||||
|
||||
if (display->swap) {
|
||||
swapchain_destroy(display->swap);
|
||||
gs_swapchain_destroy(display->swap);
|
||||
display->swap = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -149,24 +149,24 @@ static inline void render_display_begin(struct obs_display *display)
|
|||
display->size_changed = false;
|
||||
}
|
||||
|
||||
gs_beginscene();
|
||||
gs_begin_scene();
|
||||
|
||||
vec4_set(&clear_color, 0.3f, 0.3f, 0.3f, 1.0f);
|
||||
gs_clear(GS_CLEAR_COLOR | GS_CLEAR_DEPTH | GS_CLEAR_STENCIL,
|
||||
&clear_color, 1.0f, 0);
|
||||
|
||||
gs_enable_depthtest(false);
|
||||
gs_enable_depth_test(false);
|
||||
/* gs_enable_blending(false); */
|
||||
gs_setcullmode(GS_NEITHER);
|
||||
gs_set_cull_mode(GS_NEITHER);
|
||||
|
||||
gs_ortho(0.0f, (float)display->cx,
|
||||
0.0f, (float)display->cy, -100.0f, 100.0f);
|
||||
gs_setviewport(0, 0, display->cx, display->cy);
|
||||
gs_set_viewport(0, 0, display->cx, display->cy);
|
||||
}
|
||||
|
||||
static inline void render_display_end()
|
||||
{
|
||||
gs_endscene();
|
||||
gs_end_scene();
|
||||
gs_present();
|
||||
}
|
||||
|
||||
|
|
|
@ -113,7 +113,7 @@ extern void obs_view_free(struct obs_view *view);
|
|||
struct obs_display {
|
||||
bool size_changed;
|
||||
uint32_t cx, cy;
|
||||
swapchain_t swap;
|
||||
gs_swapchain_t swap;
|
||||
pthread_mutex_t draw_callbacks_mutex;
|
||||
DARRAY(struct draw_callback) draw_callbacks;
|
||||
|
||||
|
@ -131,19 +131,19 @@ extern void obs_display_free(struct obs_display *display);
|
|||
|
||||
struct obs_core_video {
|
||||
graphics_t graphics;
|
||||
stagesurf_t copy_surfaces[NUM_TEXTURES];
|
||||
texture_t render_textures[NUM_TEXTURES];
|
||||
texture_t output_textures[NUM_TEXTURES];
|
||||
texture_t convert_textures[NUM_TEXTURES];
|
||||
gs_stagesurf_t copy_surfaces[NUM_TEXTURES];
|
||||
gs_texture_t render_textures[NUM_TEXTURES];
|
||||
gs_texture_t output_textures[NUM_TEXTURES];
|
||||
gs_texture_t convert_textures[NUM_TEXTURES];
|
||||
bool textures_rendered[NUM_TEXTURES];
|
||||
bool textures_output[NUM_TEXTURES];
|
||||
bool textures_copied[NUM_TEXTURES];
|
||||
bool textures_converted[NUM_TEXTURES];
|
||||
struct obs_source_frame convert_frames[NUM_TEXTURES];
|
||||
effect_t default_effect;
|
||||
effect_t solid_effect;
|
||||
effect_t conversion_effect;
|
||||
stagesurf_t mapped_surface;
|
||||
gs_effect_t default_effect;
|
||||
gs_effect_t solid_effect;
|
||||
gs_effect_t conversion_effect;
|
||||
gs_stagesurf_t mapped_surface;
|
||||
int cur_texture;
|
||||
|
||||
video_t video;
|
||||
|
@ -339,8 +339,8 @@ struct obs_source {
|
|||
float transition_volume;
|
||||
|
||||
/* async video data */
|
||||
texture_t async_texture;
|
||||
texrender_t async_convert_texrender;
|
||||
gs_texture_t async_texture;
|
||||
gs_texrender_t async_convert_texrender;
|
||||
bool async_gpu_conversion;
|
||||
enum video_format async_format;
|
||||
enum gs_color_format async_texture_format;
|
||||
|
@ -362,7 +362,7 @@ struct obs_source {
|
|||
struct obs_source *filter_target;
|
||||
DARRAY(struct obs_source*) filters;
|
||||
pthread_mutex_t filter_mutex;
|
||||
texrender_t filter_texrender;
|
||||
gs_texrender_t filter_texrender;
|
||||
bool rendering_filter;
|
||||
};
|
||||
|
||||
|
|
|
@ -297,7 +297,7 @@ static inline bool source_size_changed(struct obs_scene_item *item)
|
|||
return item->last_width != width || item->last_height != height;
|
||||
}
|
||||
|
||||
static void scene_video_render(void *data, effect_t effect)
|
||||
static void scene_video_render(void *data, gs_effect_t effect)
|
||||
{
|
||||
struct obs_scene *scene = data;
|
||||
struct obs_scene_item *item;
|
||||
|
|
|
@ -241,10 +241,10 @@ void obs_source_destroy(struct obs_source *source)
|
|||
for (i = 0; i < source->video_frames.num; i++)
|
||||
obs_source_frame_destroy(source->video_frames.array[i]);
|
||||
|
||||
gs_entercontext(obs->video.graphics);
|
||||
texrender_destroy(source->async_convert_texrender);
|
||||
texture_destroy(source->async_texture);
|
||||
gs_leavecontext();
|
||||
gs_enter_context(obs->video.graphics);
|
||||
gs_texrender_destroy(source->async_convert_texrender);
|
||||
gs_texture_destroy(source->async_texture);
|
||||
gs_leave_context();
|
||||
|
||||
for (i = 0; i < MAX_AV_PLANES; i++)
|
||||
bfree(source->audio_data.data[i]);
|
||||
|
@ -252,7 +252,7 @@ void obs_source_destroy(struct obs_source *source)
|
|||
audio_line_destroy(source->audio_line);
|
||||
audio_resampler_destroy(source->resampler);
|
||||
|
||||
texrender_destroy(source->filter_texrender);
|
||||
gs_texrender_destroy(source->filter_texrender);
|
||||
da_free(source->video_frames);
|
||||
da_free(source->filters);
|
||||
pthread_mutex_destroy(&source->filter_mutex);
|
||||
|
@ -499,7 +499,7 @@ void obs_source_video_tick(obs_source_t source, float seconds)
|
|||
|
||||
/* reset the filter render texture information once every frame */
|
||||
if (source->filter_texrender)
|
||||
texrender_reset(source->filter_texrender);
|
||||
gs_texrender_reset(source->filter_texrender);
|
||||
|
||||
if (source->context.data && source->info.video_tick)
|
||||
source->info.video_tick(source->context.data, seconds);
|
||||
|
@ -772,17 +772,17 @@ static inline bool set_async_texture_size(struct obs_source *source,
|
|||
return true;
|
||||
}
|
||||
|
||||
texture_destroy(source->async_texture);
|
||||
texrender_destroy(source->async_convert_texrender);
|
||||
gs_texture_destroy(source->async_texture);
|
||||
gs_texrender_destroy(source->async_convert_texrender);
|
||||
source->async_convert_texrender = NULL;
|
||||
|
||||
if (cur != CONVERT_NONE && init_gpu_conversion(source, frame)) {
|
||||
source->async_gpu_conversion = true;
|
||||
|
||||
source->async_convert_texrender =
|
||||
texrender_create(GS_BGRX, GS_ZS_NONE);
|
||||
gs_texrender_create(GS_BGRX, GS_ZS_NONE);
|
||||
|
||||
source->async_texture = gs_create_texture(
|
||||
source->async_texture = gs_texture_create(
|
||||
source->async_convert_width,
|
||||
source->async_convert_height,
|
||||
source->async_texture_format,
|
||||
|
@ -793,7 +793,7 @@ static inline bool set_async_texture_size(struct obs_source *source,
|
|||
frame->format);
|
||||
source->async_gpu_conversion = false;
|
||||
|
||||
source->async_texture = gs_create_texture(
|
||||
source->async_texture = gs_texture_create(
|
||||
frame->width, frame->height,
|
||||
format, 1, NULL, GS_DYNAMIC);
|
||||
}
|
||||
|
@ -806,18 +806,18 @@ static inline bool set_async_texture_size(struct obs_source *source,
|
|||
return true;
|
||||
}
|
||||
|
||||
static void upload_raw_frame(texture_t tex,
|
||||
static void upload_raw_frame(gs_texture_t tex,
|
||||
const struct obs_source_frame *frame)
|
||||
{
|
||||
switch (get_convert_type(frame->format)) {
|
||||
case CONVERT_422_U:
|
||||
case CONVERT_422_Y:
|
||||
texture_setimage(tex, frame->data[0],
|
||||
gs_texture_set_image(tex, frame->data[0],
|
||||
frame->linesize[0], false);
|
||||
break;
|
||||
|
||||
case CONVERT_420:
|
||||
texture_setimage(tex, frame->data[0],
|
||||
gs_texture_set_image(tex, frame->data[0],
|
||||
frame->width, false);
|
||||
break;
|
||||
|
||||
|
@ -860,19 +860,19 @@ static const char *select_conversion_technique(enum video_format format)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static inline void set_eparam(effect_t effect, const char *name, float val)
|
||||
static inline void set_eparam(gs_effect_t effect, const char *name, float val)
|
||||
{
|
||||
eparam_t param = effect_getparambyname(effect, name);
|
||||
effect_setfloat(param, val);
|
||||
gs_eparam_t param = gs_effect_get_param_by_name(effect, name);
|
||||
gs_effect_set_float(param, val);
|
||||
}
|
||||
|
||||
static bool update_async_texrender(struct obs_source *source,
|
||||
const struct obs_source_frame *frame)
|
||||
{
|
||||
texture_t tex = source->async_texture;
|
||||
texrender_t texrender = source->async_convert_texrender;
|
||||
gs_texture_t tex = source->async_texture;
|
||||
gs_texrender_t texrender = source->async_convert_texrender;
|
||||
|
||||
texrender_reset(texrender);
|
||||
gs_texrender_reset(texrender);
|
||||
|
||||
upload_raw_frame(tex, frame);
|
||||
|
||||
|
@ -882,17 +882,17 @@ static bool update_async_texrender(struct obs_source *source,
|
|||
float convert_width = (float)source->async_convert_width;
|
||||
float convert_height = (float)source->async_convert_height;
|
||||
|
||||
effect_t conv = obs->video.conversion_effect;
|
||||
technique_t tech = effect_gettechnique(conv,
|
||||
gs_effect_t conv = obs->video.conversion_effect;
|
||||
gs_technique_t tech = gs_effect_get_technique(conv,
|
||||
select_conversion_technique(frame->format));
|
||||
|
||||
if (!texrender_begin(texrender, cx, cy))
|
||||
if (!gs_texrender_begin(texrender, cx, cy))
|
||||
return false;
|
||||
|
||||
technique_begin(tech);
|
||||
technique_beginpass(tech, 0);
|
||||
gs_technique_begin(tech);
|
||||
gs_technique_begin_pass(tech, 0);
|
||||
|
||||
effect_settexture(effect_getparambyname(conv, "image"), tex);
|
||||
gs_effect_set_texture(gs_effect_get_param_by_name(conv, "image"), tex);
|
||||
set_eparam(conv, "width", (float)cx);
|
||||
set_eparam(conv, "height", (float)cy);
|
||||
set_eparam(conv, "width_i", 1.0f / cx);
|
||||
|
@ -916,10 +916,10 @@ static bool update_async_texrender(struct obs_source *source,
|
|||
|
||||
gs_draw_sprite(tex, 0, cx, cy);
|
||||
|
||||
technique_endpass(tech);
|
||||
technique_end(tech);
|
||||
gs_technique_end_pass(tech);
|
||||
gs_technique_end(tech);
|
||||
|
||||
texrender_end(texrender);
|
||||
gs_texrender_end(texrender);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -927,8 +927,8 @@ static bool update_async_texrender(struct obs_source *source,
|
|||
static bool update_async_texture(struct obs_source *source,
|
||||
const struct obs_source_frame *frame)
|
||||
{
|
||||
texture_t tex = source->async_texture;
|
||||
texrender_t texrender = source->async_convert_texrender;
|
||||
gs_texture_t tex = source->async_texture;
|
||||
gs_texrender_t texrender = source->async_convert_texrender;
|
||||
enum convert_type type = get_convert_type(frame->format);
|
||||
uint8_t *ptr;
|
||||
uint32_t linesize;
|
||||
|
@ -947,12 +947,12 @@ static bool update_async_texture(struct obs_source *source,
|
|||
return update_async_texrender(source, frame);
|
||||
|
||||
if (type == CONVERT_NONE) {
|
||||
texture_setimage(tex, frame->data[0], frame->linesize[0],
|
||||
gs_texture_set_image(tex, frame->data[0], frame->linesize[0],
|
||||
false);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!texture_map(tex, &ptr, &linesize))
|
||||
if (!gs_texture_map(tex, &ptr, &linesize))
|
||||
return false;
|
||||
|
||||
if (type == CONVERT_420)
|
||||
|
@ -973,57 +973,57 @@ static bool update_async_texture(struct obs_source *source,
|
|||
decompress_422(frame->data[0], frame->linesize[0],
|
||||
0, frame->height, ptr, linesize, false);
|
||||
|
||||
texture_unmap(tex);
|
||||
gs_texture_unmap(tex);
|
||||
return true;
|
||||
}
|
||||
|
||||
static inline void obs_source_draw_texture(struct obs_source *source,
|
||||
effect_t effect, float *color_matrix,
|
||||
gs_effect_t effect, float *color_matrix,
|
||||
float const *color_range_min, float const *color_range_max)
|
||||
{
|
||||
texture_t tex = source->async_texture;
|
||||
eparam_t param;
|
||||
gs_texture_t tex = source->async_texture;
|
||||
gs_eparam_t param;
|
||||
|
||||
if (source->async_convert_texrender)
|
||||
tex = texrender_gettexture(source->async_convert_texrender);
|
||||
tex = gs_texrender_get_texture(source->async_convert_texrender);
|
||||
|
||||
if (color_range_min) {
|
||||
size_t const size = sizeof(float) * 3;
|
||||
param = effect_getparambyname(effect, "color_range_min");
|
||||
effect_setval(param, color_range_min, size);
|
||||
param = gs_effect_get_param_by_name(effect, "color_range_min");
|
||||
gs_effect_set_val(param, color_range_min, size);
|
||||
}
|
||||
|
||||
if (color_range_max) {
|
||||
size_t const size = sizeof(float) * 3;
|
||||
param = effect_getparambyname(effect, "color_range_max");
|
||||
effect_setval(param, color_range_max, size);
|
||||
param = gs_effect_get_param_by_name(effect, "color_range_max");
|
||||
gs_effect_set_val(param, color_range_max, size);
|
||||
}
|
||||
|
||||
if (color_matrix) {
|
||||
param = effect_getparambyname(effect, "color_matrix");
|
||||
effect_setval(param, color_matrix, sizeof(float) * 16);
|
||||
param = gs_effect_get_param_by_name(effect, "color_matrix");
|
||||
gs_effect_set_val(param, color_matrix, sizeof(float) * 16);
|
||||
}
|
||||
|
||||
param = effect_getparambyname(effect, "image");
|
||||
effect_settexture(param, tex);
|
||||
param = gs_effect_get_param_by_name(effect, "image");
|
||||
gs_effect_set_texture(param, tex);
|
||||
|
||||
gs_draw_sprite(tex, source->async_flip ? GS_FLIP_V : 0, 0, 0);
|
||||
}
|
||||
|
||||
static void obs_source_draw_async_texture(struct obs_source *source)
|
||||
{
|
||||
effect_t effect = gs_geteffect();
|
||||
bool yuv = format_is_yuv(source->async_format);
|
||||
bool limited_range = yuv && !source->async_full_range;
|
||||
const char *type = yuv ? "DrawMatrix" : "Draw";
|
||||
bool def_draw = (!effect);
|
||||
technique_t tech = NULL;
|
||||
gs_effect_t effect = gs_get_effect();
|
||||
bool yuv = format_is_yuv(source->async_format);
|
||||
bool limited_range = yuv && !source->async_full_range;
|
||||
const char *type = yuv ? "DrawMatrix" : "Draw";
|
||||
bool def_draw = (!effect);
|
||||
gs_technique_t tech = NULL;
|
||||
|
||||
if (def_draw) {
|
||||
effect = obs_get_default_effect();
|
||||
tech = effect_gettechnique(effect, type);
|
||||
technique_begin(tech);
|
||||
technique_beginpass(tech, 0);
|
||||
tech = gs_effect_get_technique(effect, type);
|
||||
gs_technique_begin(tech);
|
||||
gs_technique_begin_pass(tech, 0);
|
||||
}
|
||||
|
||||
obs_source_draw_texture(source, effect,
|
||||
|
@ -1032,8 +1032,8 @@ static void obs_source_draw_async_texture(struct obs_source *source)
|
|||
limited_range ? source->async_color_range_max : NULL);
|
||||
|
||||
if (def_draw) {
|
||||
technique_endpass(tech);
|
||||
technique_end(tech);
|
||||
gs_technique_end_pass(tech);
|
||||
gs_technique_end(tech);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1063,19 +1063,19 @@ static inline void obs_source_render_filters(obs_source_t source)
|
|||
static inline void obs_source_default_render(obs_source_t source,
|
||||
bool color_matrix)
|
||||
{
|
||||
effect_t effect = obs->video.default_effect;
|
||||
const char *tech_name = color_matrix ? "DrawMatrix" : "Draw";
|
||||
technique_t tech = effect_gettechnique(effect, tech_name);
|
||||
size_t passes, i;
|
||||
gs_effect_t effect = obs->video.default_effect;
|
||||
const char *tech_name = color_matrix ? "DrawMatrix" : "Draw";
|
||||
gs_technique_t tech = gs_effect_get_technique(effect, tech_name);
|
||||
size_t passes, i;
|
||||
|
||||
passes = technique_begin(tech);
|
||||
passes = gs_technique_begin(tech);
|
||||
for (i = 0; i < passes; i++) {
|
||||
technique_beginpass(tech, i);
|
||||
gs_technique_begin_pass(tech, i);
|
||||
if (source->context.data)
|
||||
source->info.video_render(source->context.data, effect);
|
||||
technique_endpass(tech);
|
||||
gs_technique_end_pass(tech);
|
||||
}
|
||||
technique_end(tech);
|
||||
gs_technique_end(tech);
|
||||
}
|
||||
|
||||
static inline void obs_source_main_render(obs_source_t source)
|
||||
|
@ -1091,7 +1091,7 @@ static inline void obs_source_main_render(obs_source_t source)
|
|||
obs_source_default_render(source, color_matrix);
|
||||
else if (source->context.data)
|
||||
source->info.video_render(source->context.data,
|
||||
custom_draw ? NULL : gs_geteffect());
|
||||
custom_draw ? NULL : gs_get_effect());
|
||||
}
|
||||
|
||||
void obs_source_video_render(obs_source_t source)
|
||||
|
@ -1652,42 +1652,42 @@ const char *obs_source_get_id(obs_source_t source)
|
|||
return source ? source->info.id : NULL;
|
||||
}
|
||||
|
||||
static inline void render_filter_bypass(obs_source_t target, effect_t effect,
|
||||
static inline void render_filter_bypass(obs_source_t target, gs_effect_t effect,
|
||||
bool use_matrix)
|
||||
{
|
||||
const char *tech_name = use_matrix ? "DrawMatrix" : "Draw";
|
||||
technique_t tech = effect_gettechnique(effect, tech_name);
|
||||
gs_technique_t tech = gs_effect_get_technique(effect, tech_name);
|
||||
size_t passes, i;
|
||||
|
||||
passes = technique_begin(tech);
|
||||
passes = gs_technique_begin(tech);
|
||||
for (i = 0; i < passes; i++) {
|
||||
technique_beginpass(tech, i);
|
||||
gs_technique_begin_pass(tech, i);
|
||||
obs_source_video_render(target);
|
||||
technique_endpass(tech);
|
||||
gs_technique_end_pass(tech);
|
||||
}
|
||||
technique_end(tech);
|
||||
gs_technique_end(tech);
|
||||
}
|
||||
|
||||
static inline void render_filter_tex(texture_t tex, effect_t effect,
|
||||
static inline void render_filter_tex(gs_texture_t tex, gs_effect_t effect,
|
||||
uint32_t width, uint32_t height, bool use_matrix)
|
||||
{
|
||||
const char *tech_name = use_matrix ? "DrawMatrix" : "Draw";
|
||||
technique_t tech = effect_gettechnique(effect, tech_name);
|
||||
eparam_t image = effect_getparambyname(effect, "image");
|
||||
gs_technique_t tech = gs_effect_get_technique(effect, tech_name);
|
||||
gs_eparam_t image = gs_effect_get_param_by_name(effect, "image");
|
||||
size_t passes, i;
|
||||
|
||||
effect_settexture(image, tex);
|
||||
gs_effect_set_texture(image, tex);
|
||||
|
||||
passes = technique_begin(tech);
|
||||
passes = gs_technique_begin(tech);
|
||||
for (i = 0; i < passes; i++) {
|
||||
technique_beginpass(tech, i);
|
||||
gs_technique_begin_pass(tech, i);
|
||||
gs_draw_sprite(tex, width, height, 0);
|
||||
technique_endpass(tech);
|
||||
gs_technique_end_pass(tech);
|
||||
}
|
||||
technique_end(tech);
|
||||
gs_technique_end(tech);
|
||||
}
|
||||
|
||||
void obs_source_process_filter(obs_source_t filter, effect_t effect,
|
||||
void obs_source_process_filter(obs_source_t filter, gs_effect_t effect,
|
||||
uint32_t width, uint32_t height, enum gs_color_format format,
|
||||
enum obs_allow_direct_render allow_direct)
|
||||
{
|
||||
|
@ -1718,21 +1718,21 @@ void obs_source_process_filter(obs_source_t filter, effect_t effect,
|
|||
}
|
||||
|
||||
if (!filter->filter_texrender)
|
||||
filter->filter_texrender = texrender_create(format,
|
||||
filter->filter_texrender = gs_texrender_create(format,
|
||||
GS_ZS_NONE);
|
||||
|
||||
if (texrender_begin(filter->filter_texrender, cx, cy)) {
|
||||
if (gs_texrender_begin(filter->filter_texrender, cx, cy)) {
|
||||
gs_ortho(0.0f, (float)cx, 0.0f, (float)cy, -100.0f, 100.0f);
|
||||
if (expects_def && parent == target)
|
||||
obs_source_default_render(parent, use_matrix);
|
||||
else
|
||||
obs_source_video_render(target);
|
||||
texrender_end(filter->filter_texrender);
|
||||
gs_texrender_end(filter->filter_texrender);
|
||||
}
|
||||
|
||||
/* --------------------------- */
|
||||
|
||||
render_filter_tex(texrender_gettexture(filter->filter_texrender),
|
||||
render_filter_tex(gs_texrender_get_texture(filter->filter_texrender),
|
||||
effect, width, height, use_matrix);
|
||||
}
|
||||
|
||||
|
|
|
@ -222,7 +222,7 @@ struct obs_source_info {
|
|||
* be NULL, and the source is expected to process with
|
||||
* an effect manually.
|
||||
*/
|
||||
void (*video_render)(void *data, effect_t effect);
|
||||
void (*video_render)(void *data, gs_effect_t effect);
|
||||
|
||||
/**
|
||||
* Called to filter raw async video data.
|
||||
|
|
|
@ -58,7 +58,7 @@ static inline void render_displays(void)
|
|||
if (!obs->data.valid)
|
||||
return;
|
||||
|
||||
gs_entercontext(obs->video.graphics);
|
||||
gs_enter_context(obs->video.graphics);
|
||||
|
||||
/* render extra displays/swaps */
|
||||
pthread_mutex_lock(&obs->data.displays_mutex);
|
||||
|
@ -74,23 +74,23 @@ static inline void render_displays(void)
|
|||
/* render main display */
|
||||
render_display(&obs->video.main_display);
|
||||
|
||||
gs_leavecontext();
|
||||
gs_leave_context();
|
||||
}
|
||||
|
||||
static inline void set_render_size(uint32_t width, uint32_t height)
|
||||
{
|
||||
gs_enable_depthtest(false);
|
||||
gs_enable_depth_test(false);
|
||||
gs_enable_blending(false);
|
||||
gs_setcullmode(GS_NEITHER);
|
||||
gs_set_cull_mode(GS_NEITHER);
|
||||
|
||||
gs_ortho(0.0f, (float)width, 0.0f, (float)height, -100.0f, 100.0f);
|
||||
gs_setviewport(0, 0, width, height);
|
||||
gs_set_viewport(0, 0, width, height);
|
||||
}
|
||||
|
||||
static inline void unmap_last_surface(struct obs_core_video *video)
|
||||
{
|
||||
if (video->mapped_surface) {
|
||||
stagesurface_unmap(video->mapped_surface);
|
||||
gs_stagesurface_unmap(video->mapped_surface);
|
||||
video->mapped_surface = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ static inline void render_main_texture(struct obs_core_video *video,
|
|||
struct vec4 clear_color;
|
||||
vec4_set(&clear_color, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
gs_setrendertarget(video->render_textures[cur_texture], NULL);
|
||||
gs_set_render_target(video->render_textures[cur_texture], NULL);
|
||||
gs_clear(GS_CLEAR_COLOR, &clear_color, 1.0f, 0);
|
||||
|
||||
set_render_size(video->base_width, video->base_height);
|
||||
|
@ -113,22 +113,23 @@ static inline void render_main_texture(struct obs_core_video *video,
|
|||
static inline void render_output_texture(struct obs_core_video *video,
|
||||
int cur_texture, int prev_texture)
|
||||
{
|
||||
texture_t texture = video->render_textures[prev_texture];
|
||||
texture_t target = video->output_textures[cur_texture];
|
||||
uint32_t width = texture_getwidth(target);
|
||||
uint32_t height = texture_getheight(target);
|
||||
gs_texture_t texture = video->render_textures[prev_texture];
|
||||
gs_texture_t target = video->output_textures[cur_texture];
|
||||
uint32_t width = gs_texture_get_width(target);
|
||||
uint32_t height = gs_texture_get_height(target);
|
||||
|
||||
/* TODO: replace with actual downscalers or unpackers */
|
||||
effect_t effect = video->default_effect;
|
||||
technique_t tech = effect_gettechnique(effect, "DrawMatrix");
|
||||
eparam_t image = effect_getparambyname(effect, "image");
|
||||
eparam_t matrix = effect_getparambyname(effect, "color_matrix");
|
||||
gs_effect_t effect = video->default_effect;
|
||||
gs_technique_t tech = gs_effect_get_technique(effect, "DrawMatrix");
|
||||
gs_eparam_t image = gs_effect_get_param_by_name(effect, "image");
|
||||
gs_eparam_t matrix = gs_effect_get_param_by_name(effect,
|
||||
"color_matrix");
|
||||
size_t passes, i;
|
||||
|
||||
if (!video->textures_rendered[prev_texture])
|
||||
return;
|
||||
|
||||
gs_setrendertarget(target, NULL);
|
||||
gs_set_render_target(target, NULL);
|
||||
set_render_size(width, height);
|
||||
|
||||
/* TODO: replace with programmable code */
|
||||
|
@ -140,38 +141,38 @@ static inline void render_output_texture(struct obs_core_video *video,
|
|||
0.000000f, 0.000000f, 0.000000f, 1.000000f
|
||||
};
|
||||
|
||||
effect_setval(matrix, mat_val, sizeof(mat_val));
|
||||
effect_settexture(image, texture);
|
||||
gs_effect_set_val(matrix, mat_val, sizeof(mat_val));
|
||||
gs_effect_set_texture(image, texture);
|
||||
|
||||
passes = technique_begin(tech);
|
||||
passes = gs_technique_begin(tech);
|
||||
for (i = 0; i < passes; i++) {
|
||||
technique_beginpass(tech, i);
|
||||
gs_technique_begin_pass(tech, i);
|
||||
gs_draw_sprite(texture, 0, width, height);
|
||||
technique_endpass(tech);
|
||||
gs_technique_end_pass(tech);
|
||||
}
|
||||
technique_end(tech);
|
||||
gs_technique_end(tech);
|
||||
|
||||
video->textures_output[cur_texture] = true;
|
||||
}
|
||||
|
||||
static inline void set_eparam(effect_t effect, const char *name, float val)
|
||||
static inline void set_eparam(gs_effect_t effect, const char *name, float val)
|
||||
{
|
||||
eparam_t param = effect_getparambyname(effect, name);
|
||||
effect_setfloat(param, val);
|
||||
gs_eparam_t param = gs_effect_get_param_by_name(effect, name);
|
||||
gs_effect_set_float(param, val);
|
||||
}
|
||||
|
||||
static void render_convert_texture(struct obs_core_video *video,
|
||||
int cur_texture, int prev_texture)
|
||||
{
|
||||
texture_t texture = video->output_textures[prev_texture];
|
||||
texture_t target = video->convert_textures[cur_texture];
|
||||
float fwidth = (float)video->output_width;
|
||||
float fheight = (float)video->output_height;
|
||||
size_t passes, i;
|
||||
gs_texture_t texture = video->output_textures[prev_texture];
|
||||
gs_texture_t target = video->convert_textures[cur_texture];
|
||||
float fwidth = (float)video->output_width;
|
||||
float fheight = (float)video->output_height;
|
||||
size_t passes, i;
|
||||
|
||||
effect_t effect = video->conversion_effect;
|
||||
eparam_t image = effect_getparambyname(effect, "image");
|
||||
technique_t tech = effect_gettechnique(effect,
|
||||
gs_effect_t effect = video->conversion_effect;
|
||||
gs_eparam_t image = gs_effect_get_param_by_name(effect, "image");
|
||||
gs_technique_t tech = gs_effect_get_technique(effect,
|
||||
video->conversion_tech);
|
||||
|
||||
if (!video->textures_output[prev_texture])
|
||||
|
@ -189,19 +190,19 @@ static void render_convert_texture(struct obs_core_video *video,
|
|||
set_eparam(effect, "height_d2_i", 1.0f / (fheight * 0.5f));
|
||||
set_eparam(effect, "input_height", (float)video->conversion_height);
|
||||
|
||||
effect_settexture(image, texture);
|
||||
gs_effect_set_texture(image, texture);
|
||||
|
||||
gs_setrendertarget(target, NULL);
|
||||
gs_set_render_target(target, NULL);
|
||||
set_render_size(video->output_width, video->conversion_height);
|
||||
|
||||
passes = technique_begin(tech);
|
||||
passes = gs_technique_begin(tech);
|
||||
for (i = 0; i < passes; i++) {
|
||||
technique_beginpass(tech, i);
|
||||
gs_technique_begin_pass(tech, i);
|
||||
gs_draw_sprite(texture, 0, video->output_width,
|
||||
video->conversion_height);
|
||||
technique_endpass(tech);
|
||||
gs_technique_end_pass(tech);
|
||||
}
|
||||
technique_end(tech);
|
||||
gs_technique_end(tech);
|
||||
|
||||
video->textures_converted[cur_texture] = true;
|
||||
}
|
||||
|
@ -209,9 +210,9 @@ static void render_convert_texture(struct obs_core_video *video,
|
|||
static inline void stage_output_texture(struct obs_core_video *video,
|
||||
int cur_texture, int prev_texture)
|
||||
{
|
||||
texture_t texture;
|
||||
gs_texture_t texture;
|
||||
bool texture_ready;
|
||||
stagesurf_t copy = video->copy_surfaces[cur_texture];
|
||||
gs_stagesurf_t copy = video->copy_surfaces[cur_texture];
|
||||
|
||||
if (video->gpu_conversion) {
|
||||
texture = video->convert_textures[prev_texture];
|
||||
|
@ -234,10 +235,10 @@ static inline void stage_output_texture(struct obs_core_video *video,
|
|||
static inline void render_video(struct obs_core_video *video, int cur_texture,
|
||||
int prev_texture)
|
||||
{
|
||||
gs_beginscene();
|
||||
gs_begin_scene();
|
||||
|
||||
gs_enable_depthtest(false);
|
||||
gs_setcullmode(GS_NEITHER);
|
||||
gs_enable_depth_test(false);
|
||||
gs_set_cull_mode(GS_NEITHER);
|
||||
|
||||
render_main_texture(video, cur_texture);
|
||||
render_output_texture(video, cur_texture, prev_texture);
|
||||
|
@ -246,21 +247,21 @@ static inline void render_video(struct obs_core_video *video, int cur_texture,
|
|||
|
||||
stage_output_texture(video, cur_texture, prev_texture);
|
||||
|
||||
gs_setrendertarget(NULL, NULL);
|
||||
gs_set_render_target(NULL, NULL);
|
||||
gs_enable_blending(true);
|
||||
|
||||
gs_endscene();
|
||||
gs_end_scene();
|
||||
}
|
||||
|
||||
static inline bool download_frame(struct obs_core_video *video,
|
||||
int prev_texture, struct video_data *frame)
|
||||
{
|
||||
stagesurf_t surface = video->copy_surfaces[prev_texture];
|
||||
gs_stagesurf_t surface = video->copy_surfaces[prev_texture];
|
||||
|
||||
if (!video->textures_copied[prev_texture])
|
||||
return false;
|
||||
|
||||
if (!stagesurface_map(surface, &frame->data[0], &frame->linesize[0]))
|
||||
if (!gs_stagesurface_map(surface, &frame->data[0], &frame->linesize[0]))
|
||||
return false;
|
||||
|
||||
video->mapped_surface = surface;
|
||||
|
@ -413,12 +414,12 @@ static inline void output_frame(uint64_t timestamp)
|
|||
memset(&frame, 0, sizeof(struct video_data));
|
||||
frame.timestamp = timestamp;
|
||||
|
||||
gs_entercontext(video->graphics);
|
||||
gs_enter_context(video->graphics);
|
||||
|
||||
render_video(video, cur_texture, prev_texture);
|
||||
frame_ready = download_frame(video, prev_texture, &frame);
|
||||
|
||||
gs_leavecontext();
|
||||
gs_leave_context();
|
||||
|
||||
if (frame_ready)
|
||||
output_video_data(video, &frame, cur_texture);
|
||||
|
|
60
libobs/obs.c
60
libobs/obs.c
|
@ -146,9 +146,9 @@ static bool obs_init_gpu_conversion(struct obs_video_info *ovi)
|
|||
}
|
||||
|
||||
for (size_t i = 0; i < NUM_TEXTURES; i++) {
|
||||
video->convert_textures[i] = gs_create_texture(
|
||||
video->convert_textures[i] = gs_texture_create(
|
||||
ovi->output_width, video->conversion_height,
|
||||
GS_RGBA, 1, NULL, GS_RENDERTARGET);
|
||||
GS_RGBA, 1, NULL, GS_RENDER_TARGET);
|
||||
|
||||
if (!video->convert_textures[i])
|
||||
return false;
|
||||
|
@ -166,22 +166,22 @@ static bool obs_init_textures(struct obs_video_info *ovi)
|
|||
size_t i;
|
||||
|
||||
for (i = 0; i < NUM_TEXTURES; i++) {
|
||||
video->copy_surfaces[i] = gs_create_stagesurface(
|
||||
video->copy_surfaces[i] = gs_stagesurface_create(
|
||||
ovi->output_width, output_height, GS_RGBA);
|
||||
|
||||
if (!video->copy_surfaces[i])
|
||||
return false;
|
||||
|
||||
video->render_textures[i] = gs_create_texture(
|
||||
video->render_textures[i] = gs_texture_create(
|
||||
ovi->base_width, ovi->base_height,
|
||||
GS_RGBA, 1, NULL, GS_RENDERTARGET);
|
||||
GS_RGBA, 1, NULL, GS_RENDER_TARGET);
|
||||
|
||||
if (!video->render_textures[i])
|
||||
return false;
|
||||
|
||||
video->output_textures[i] = gs_create_texture(
|
||||
video->output_textures[i] = gs_texture_create(
|
||||
ovi->output_width, ovi->output_height,
|
||||
GS_RGBA, 1, NULL, GS_RENDERTARGET);
|
||||
GS_RGBA, 1, NULL, GS_RENDER_TARGET);
|
||||
|
||||
if (!video->output_textures[i])
|
||||
return false;
|
||||
|
@ -217,20 +217,20 @@ static int obs_init_graphics(struct obs_video_info *ovi)
|
|||
}
|
||||
}
|
||||
|
||||
gs_entercontext(video->graphics);
|
||||
gs_enter_context(video->graphics);
|
||||
|
||||
char *filename = find_libobs_data_file("default.effect");
|
||||
video->default_effect = gs_create_effect_from_file(filename,
|
||||
video->default_effect = gs_effect_create_from_file(filename,
|
||||
NULL);
|
||||
bfree(filename);
|
||||
|
||||
filename = find_libobs_data_file("solid.effect");
|
||||
video->solid_effect = gs_create_effect_from_file(filename,
|
||||
video->solid_effect = gs_effect_create_from_file(filename,
|
||||
NULL);
|
||||
bfree(filename);
|
||||
|
||||
filename = find_libobs_data_file("format_conversion.effect");
|
||||
video->conversion_effect = gs_create_effect_from_file(filename,
|
||||
video->conversion_effect = gs_effect_create_from_file(filename,
|
||||
NULL);
|
||||
bfree(filename);
|
||||
|
||||
|
@ -241,7 +241,7 @@ static int obs_init_graphics(struct obs_video_info *ovi)
|
|||
if (!video->conversion_effect)
|
||||
success = false;
|
||||
|
||||
gs_leavecontext();
|
||||
gs_leave_context();
|
||||
return success ? OBS_VIDEO_SUCCESS : OBS_VIDEO_FAIL;
|
||||
}
|
||||
|
||||
|
@ -276,14 +276,14 @@ static int obs_init_video(struct obs_video_info *ovi)
|
|||
video->main_display.cx = ovi->window_width;
|
||||
video->main_display.cy = ovi->window_height;
|
||||
|
||||
gs_entercontext(video->graphics);
|
||||
gs_enter_context(video->graphics);
|
||||
|
||||
if (ovi->gpu_conversion && !obs_init_gpu_conversion(ovi))
|
||||
return OBS_VIDEO_FAIL;
|
||||
if (!obs_init_textures(ovi))
|
||||
return OBS_VIDEO_FAIL;
|
||||
|
||||
gs_leavecontext();
|
||||
gs_leave_context();
|
||||
|
||||
errorcode = pthread_create(&video->video_thread, NULL,
|
||||
obs_video_thread, obs);
|
||||
|
@ -338,18 +338,18 @@ static void obs_free_video(void)
|
|||
if (!video->graphics)
|
||||
return;
|
||||
|
||||
gs_entercontext(video->graphics);
|
||||
gs_enter_context(video->graphics);
|
||||
|
||||
if (video->mapped_surface) {
|
||||
stagesurface_unmap(video->mapped_surface);
|
||||
gs_stagesurface_unmap(video->mapped_surface);
|
||||
video->mapped_surface = NULL;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < NUM_TEXTURES; i++) {
|
||||
stagesurface_destroy(video->copy_surfaces[i]);
|
||||
texture_destroy(video->render_textures[i]);
|
||||
texture_destroy(video->convert_textures[i]);
|
||||
texture_destroy(video->output_textures[i]);
|
||||
gs_stagesurface_destroy(video->copy_surfaces[i]);
|
||||
gs_texture_destroy(video->render_textures[i]);
|
||||
gs_texture_destroy(video->convert_textures[i]);
|
||||
gs_texture_destroy(video->output_textures[i]);
|
||||
obs_source_frame_free(&video->convert_frames[i]);
|
||||
|
||||
video->copy_surfaces[i] = NULL;
|
||||
|
@ -358,7 +358,7 @@ static void obs_free_video(void)
|
|||
video->output_textures[i] = NULL;
|
||||
}
|
||||
|
||||
gs_leavecontext();
|
||||
gs_leave_context();
|
||||
|
||||
video->cur_texture = 0;
|
||||
}
|
||||
|
@ -369,14 +369,14 @@ static void obs_free_graphics(void)
|
|||
struct obs_core_video *video = &obs->video;
|
||||
|
||||
if (video->graphics) {
|
||||
gs_entercontext(video->graphics);
|
||||
gs_enter_context(video->graphics);
|
||||
|
||||
effect_destroy(video->default_effect);
|
||||
effect_destroy(video->solid_effect);
|
||||
effect_destroy(video->conversion_effect);
|
||||
gs_effect_destroy(video->default_effect);
|
||||
gs_effect_destroy(video->solid_effect);
|
||||
gs_effect_destroy(video->conversion_effect);
|
||||
video->default_effect = NULL;
|
||||
|
||||
gs_leavecontext();
|
||||
gs_leave_context();
|
||||
|
||||
gs_destroy(video->graphics);
|
||||
video->graphics = NULL;
|
||||
|
@ -812,13 +812,13 @@ bool obs_enum_service_types(size_t idx, const char **id)
|
|||
void obs_enter_graphics(void)
|
||||
{
|
||||
if (obs && obs->video.graphics)
|
||||
gs_entercontext(obs->video.graphics);
|
||||
gs_enter_context(obs->video.graphics);
|
||||
}
|
||||
|
||||
void obs_leave_graphics(void)
|
||||
{
|
||||
if (obs && obs->video.graphics)
|
||||
gs_leavecontext();
|
||||
gs_leave_context();
|
||||
}
|
||||
|
||||
audio_t obs_get_audio(void)
|
||||
|
@ -1075,13 +1075,13 @@ obs_service_t obs_get_service_by_name(const char *name)
|
|||
&obs->data.services_mutex);
|
||||
}
|
||||
|
||||
effect_t obs_get_default_effect(void)
|
||||
gs_effect_t obs_get_default_effect(void)
|
||||
{
|
||||
if (!obs) return NULL;
|
||||
return obs->video.default_effect;
|
||||
}
|
||||
|
||||
effect_t obs_get_solid_effect(void)
|
||||
gs_effect_t obs_get_solid_effect(void)
|
||||
{
|
||||
if (!obs) return NULL;
|
||||
return obs->video.solid_effect;
|
||||
|
|
|
@ -450,10 +450,10 @@ EXPORT obs_encoder_t obs_get_encoder_by_name(const char *name);
|
|||
EXPORT obs_service_t obs_get_service_by_name(const char *name);
|
||||
|
||||
/** Returns the default effect for generic RGB/YUV drawing */
|
||||
EXPORT effect_t obs_get_default_effect(void);
|
||||
EXPORT gs_effect_t obs_get_default_effect(void);
|
||||
|
||||
/** Returns the solid effect for drawing solid colors */
|
||||
EXPORT effect_t obs_get_solid_effect(void);
|
||||
EXPORT gs_effect_t obs_get_solid_effect(void);
|
||||
|
||||
/** Returns the primary obs signal handler */
|
||||
EXPORT signal_handler_t obs_get_signal_handler(void);
|
||||
|
@ -727,7 +727,7 @@ EXPORT void obs_source_release_frame(obs_source_t source,
|
|||
struct obs_source_frame *frame);
|
||||
|
||||
/** Default RGB filter handler for generic effect filters */
|
||||
EXPORT void obs_source_process_filter(obs_source_t filter, effect_t effect,
|
||||
EXPORT void obs_source_process_filter(obs_source_t filter, gs_effect_t effect,
|
||||
uint32_t width, uint32_t height, enum gs_color_format format,
|
||||
enum obs_allow_direct_render allow_direct);
|
||||
|
||||
|
|
|
@ -494,20 +494,20 @@ void OBSBasic::InitPrimitives()
|
|||
{
|
||||
obs_enter_graphics();
|
||||
|
||||
gs_renderstart(true);
|
||||
gs_render_start(true);
|
||||
gs_vertex2f(0.0f, 0.0f);
|
||||
gs_vertex2f(0.0f, 1.0f);
|
||||
gs_vertex2f(1.0f, 1.0f);
|
||||
gs_vertex2f(1.0f, 0.0f);
|
||||
gs_vertex2f(0.0f, 0.0f);
|
||||
box = gs_rendersave();
|
||||
box = gs_render_save();
|
||||
|
||||
gs_renderstart(true);
|
||||
gs_render_start(true);
|
||||
for (int i = 0; i <= 360; i += (360/20)) {
|
||||
float pos = RAD(float(i));
|
||||
gs_vertex2f(cosf(pos), sinf(pos));
|
||||
}
|
||||
circle = gs_rendersave();
|
||||
circle = gs_render_save();
|
||||
|
||||
obs_leave_graphics();
|
||||
}
|
||||
|
@ -590,8 +590,8 @@ OBSBasic::~OBSBasic()
|
|||
ui->scenes->clear();
|
||||
|
||||
obs_enter_graphics();
|
||||
vertexbuffer_destroy(box);
|
||||
vertexbuffer_destroy(circle);
|
||||
gs_vertexbuffer_destroy(box);
|
||||
gs_vertexbuffer_destroy(circle);
|
||||
obs_leave_graphics();
|
||||
|
||||
obs_shutdown();
|
||||
|
@ -1070,16 +1070,16 @@ void OBSBasic::DrawBackdrop(float cx, float cy)
|
|||
if (!box)
|
||||
return;
|
||||
|
||||
effect_t solid = obs_get_solid_effect();
|
||||
eparam_t color = effect_getparambyname(solid, "color");
|
||||
technique_t tech = effect_gettechnique(solid, "Solid");
|
||||
gs_effect_t solid = obs_get_solid_effect();
|
||||
gs_eparam_t color = gs_effect_get_param_by_name(solid, "color");
|
||||
gs_technique_t tech = gs_effect_get_technique(solid, "Solid");
|
||||
|
||||
vec4 colorVal;
|
||||
vec4_set(&colorVal, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
effect_setvec4(color, &colorVal);
|
||||
gs_effect_set_vec4(color, &colorVal);
|
||||
|
||||
technique_begin(tech);
|
||||
technique_beginpass(tech, 0);
|
||||
gs_technique_begin(tech);
|
||||
gs_technique_begin_pass(tech, 0);
|
||||
gs_matrix_push();
|
||||
gs_matrix_identity();
|
||||
gs_matrix_scale3f(float(cx), float(cy), 1.0f);
|
||||
|
@ -1088,8 +1088,8 @@ void OBSBasic::DrawBackdrop(float cx, float cy)
|
|||
gs_draw(GS_TRISTRIP, 0, 0);
|
||||
|
||||
gs_matrix_pop();
|
||||
technique_endpass(tech);
|
||||
technique_end(tech);
|
||||
gs_technique_end_pass(tech);
|
||||
gs_technique_end(tech);
|
||||
|
||||
gs_load_vertexbuffer(nullptr);
|
||||
}
|
||||
|
@ -1111,7 +1111,7 @@ void OBSBasic::RenderMain(void *data, uint32_t cx, uint32_t cy)
|
|||
|
||||
gs_ortho(0.0f, float(ovi.base_width), 0.0f, float(ovi.base_height),
|
||||
-100.0f, 100.0f);
|
||||
gs_setviewport(window->previewX, window->previewY,
|
||||
gs_set_viewport(window->previewX, window->previewY,
|
||||
window->previewCX, window->previewCY);
|
||||
|
||||
window->DrawBackdrop(float(ovi.base_width), float(ovi.base_height));
|
||||
|
@ -1128,7 +1128,7 @@ void OBSBasic::RenderMain(void *data, uint32_t cx, uint32_t cy)
|
|||
gs_ortho(-window->previewX, right,
|
||||
-window->previewY, bottom,
|
||||
-100.0f, 100.0f);
|
||||
gs_resetviewport();
|
||||
gs_reset_viewport();
|
||||
|
||||
window->ui->preview->DrawSceneEditing();
|
||||
|
||||
|
|
|
@ -79,8 +79,8 @@ private:
|
|||
obs_encoder_t aac = nullptr;
|
||||
obs_encoder_t x264 = nullptr;
|
||||
|
||||
vertbuffer_t box = nullptr;
|
||||
vertbuffer_t circle = nullptr;
|
||||
gs_vertbuffer_t box = nullptr;
|
||||
gs_vertbuffer_t circle = nullptr;
|
||||
|
||||
bool sceneChanging = false;
|
||||
|
||||
|
|
|
@ -729,15 +729,15 @@ void OBSBasicPreview::DrawSceneEditing()
|
|||
{
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic*>(App()->GetMainWindow());
|
||||
|
||||
effect_t solid = obs_get_solid_effect();
|
||||
technique_t tech = effect_gettechnique(solid, "Solid");
|
||||
gs_effect_t solid = obs_get_solid_effect();
|
||||
gs_technique_t tech = gs_effect_get_technique(solid, "Solid");
|
||||
|
||||
vec4 color;
|
||||
vec4_set(&color, 1.0f, 0.0f, 0.0f, 1.0f);
|
||||
effect_setvec4(effect_getparambyname(solid, "color"), &color);
|
||||
gs_effect_set_vec4(gs_effect_get_param_by_name(solid, "color"), &color);
|
||||
|
||||
technique_begin(tech);
|
||||
technique_beginpass(tech, 0);
|
||||
gs_technique_begin(tech);
|
||||
gs_technique_begin_pass(tech, 0);
|
||||
|
||||
OBSScene scene = main->GetCurrentScene();
|
||||
if (scene)
|
||||
|
@ -745,6 +745,6 @@ void OBSBasicPreview::DrawSceneEditing()
|
|||
|
||||
gs_load_vertexbuffer(nullptr);
|
||||
|
||||
technique_endpass(tech);
|
||||
technique_end(tech);
|
||||
gs_technique_end_pass(tech);
|
||||
gs_technique_end(tech);
|
||||
}
|
||||
|
|
|
@ -91,7 +91,7 @@ void OBSBasicProperties::DrawPreview(void *data, uint32_t cx, uint32_t cy)
|
|||
gs_projection_push();
|
||||
gs_ortho(0.0f, float(sourceCX), 0.0f, float(sourceCY),
|
||||
-100.0f, 100.0f);
|
||||
gs_setviewport(x, y, newCX, newCY);
|
||||
gs_set_viewport(x, y, newCX, newCY);
|
||||
|
||||
obs_source_video_render(window->source);
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
struct image_source {
|
||||
obs_source_t source;
|
||||
|
||||
texture_t tex;
|
||||
gs_texture_t tex;
|
||||
uint32_t cx;
|
||||
uint32_t cy;
|
||||
};
|
||||
|
@ -25,15 +25,15 @@ static void image_source_update(void *data, obs_data_t settings)
|
|||
obs_enter_graphics();
|
||||
|
||||
if (context->tex) {
|
||||
texture_destroy(context->tex);
|
||||
gs_texture_destroy(context->tex);
|
||||
context->tex = NULL;
|
||||
}
|
||||
|
||||
if (file && *file) {
|
||||
context->tex = gs_create_texture_from_file(file);
|
||||
context->tex = gs_texture_create_from_file(file);
|
||||
if (context->tex) {
|
||||
context->cx = texture_getwidth(context->tex);
|
||||
context->cy = texture_getheight(context->tex);
|
||||
context->cx = gs_texture_get_width(context->tex);
|
||||
context->cy = gs_texture_get_height(context->tex);
|
||||
} else {
|
||||
warn("failed to load texture '%s'", file);
|
||||
context->cx = 0;
|
||||
|
@ -58,7 +58,7 @@ static void image_source_destroy(void *data)
|
|||
struct image_source *context = data;
|
||||
|
||||
obs_enter_graphics();
|
||||
texture_destroy(context->tex);
|
||||
gs_texture_destroy(context->tex);
|
||||
obs_leave_graphics();
|
||||
|
||||
bfree(context);
|
||||
|
@ -76,14 +76,15 @@ static uint32_t image_source_getheight(void *data)
|
|||
return context->cy;
|
||||
}
|
||||
|
||||
static void image_source_render(void *data, effect_t effect)
|
||||
static void image_source_render(void *data, gs_effect_t effect)
|
||||
{
|
||||
struct image_source *context = data;
|
||||
if (!context->tex)
|
||||
return;
|
||||
|
||||
gs_reset_blend_state();
|
||||
effect_settexture(effect_getparambyname(effect, "image"), context->tex);
|
||||
gs_effect_set_texture(gs_effect_get_param_by_name(effect, "image"),
|
||||
context->tex);
|
||||
gs_draw_sprite(context->tex, 0, context->cx, context->cy);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ static void xcompcap_video_tick(void* data, float seconds)
|
|||
cc->tick(seconds);
|
||||
}
|
||||
|
||||
static void xcompcap_video_render(void* data, effect_t effect)
|
||||
static void xcompcap_video_render(void* data, gs_effect_t effect)
|
||||
{
|
||||
XCompcapMain* cc = (XCompcapMain*)data;
|
||||
cc->render(effect);
|
||||
|
|
|
@ -137,8 +137,8 @@ struct XCompcapMain_private
|
|||
|
||||
Pixmap pixmap;
|
||||
GLXPixmap glxpixmap;
|
||||
texture_t tex;
|
||||
texture_t gltex;
|
||||
gs_texture_t tex;
|
||||
gs_texture_t gltex;
|
||||
|
||||
pthread_mutex_t lock;
|
||||
pthread_mutexattr_t lockattr;
|
||||
|
@ -160,7 +160,7 @@ XCompcapMain::~XCompcapMain()
|
|||
ObsGsContextHolder obsctx;
|
||||
|
||||
if (p->tex) {
|
||||
texture_destroy(p->tex);
|
||||
gs_texture_destroy(p->tex);
|
||||
p->tex = 0;
|
||||
}
|
||||
|
||||
|
@ -210,7 +210,7 @@ static Window getWindowFromString(std::string wstr)
|
|||
static void xcc_cleanup(XCompcapMain_private *p)
|
||||
{
|
||||
if (p->gltex) {
|
||||
texture_destroy(p->gltex);
|
||||
gs_texture_destroy(p->gltex);
|
||||
p->gltex = 0;
|
||||
}
|
||||
|
||||
|
@ -303,7 +303,7 @@ void XCompcapMain::updateSettings(obs_data_t settings)
|
|||
}
|
||||
|
||||
if (p->tex)
|
||||
texture_destroy(p->tex);
|
||||
gs_texture_destroy(p->tex);
|
||||
|
||||
uint8_t *texData = new uint8_t[width() * height() * 4];
|
||||
|
||||
|
@ -316,13 +316,13 @@ void XCompcapMain::updateSettings(obs_data_t settings)
|
|||
|
||||
const uint8_t* texDataArr[] = { texData, 0 };
|
||||
|
||||
p->tex = gs_create_texture(width(), height(), cf, 1,
|
||||
p->tex = gs_texture_create(width(), height(), cf, 1,
|
||||
texDataArr, 0);
|
||||
|
||||
delete[] texData;
|
||||
|
||||
if (p->swapRedBlue) {
|
||||
GLuint tex = *(GLuint*)texture_getobj(p->tex);
|
||||
GLuint tex = *(GLuint*)gs_texture_get_obj(p->tex);
|
||||
glBindTexture(GL_TEXTURE_2D, tex);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_RED);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_BLUE);
|
||||
|
@ -387,10 +387,10 @@ void XCompcapMain::updateSettings(obs_data_t settings)
|
|||
|
||||
XFree(configs);
|
||||
|
||||
p->gltex = gs_create_texture(p->width, p->height, cf, 1, 0,
|
||||
p->gltex = gs_texture_create(p->width, p->height, cf, 1, 0,
|
||||
GS_GL_DUMMYTEX);
|
||||
|
||||
GLuint gltex = *(GLuint*)texture_getobj(p->gltex);
|
||||
GLuint gltex = *(GLuint*)gs_texture_get_obj(p->gltex);
|
||||
glBindTexture(GL_TEXTURE_2D, gltex);
|
||||
glXBindTexImageEXT(xdisp, p->glxpixmap, GLX_FRONT_LEFT_EXT, NULL);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
|
@ -430,15 +430,15 @@ void XCompcapMain::tick(float seconds)
|
|||
obs_leave_graphics();
|
||||
}
|
||||
|
||||
void XCompcapMain::render(effect_t effect)
|
||||
void XCompcapMain::render(gs_effect_t effect)
|
||||
{
|
||||
PLock lock(&p->lock, true);
|
||||
|
||||
if (!lock.isLocked() || !p->tex)
|
||||
return;
|
||||
|
||||
eparam_t image = effect_getparambyname(effect, "image");
|
||||
effect_settexture(image, p->tex);
|
||||
gs_eparam_t image = gs_effect_get_param_by_name(effect, "image");
|
||||
gs_effect_set_texture(image, p->tex);
|
||||
|
||||
gs_enable_blending(false);
|
||||
gs_draw_sprite(p->tex, 0, 0, 0);
|
||||
|
|
|
@ -17,7 +17,7 @@ class XCompcapMain
|
|||
void updateSettings(obs_data_t settings);
|
||||
|
||||
void tick(float seconds);
|
||||
void render(effect_t effect);
|
||||
void render(gs_effect_t effect);
|
||||
|
||||
uint32_t width();
|
||||
uint32_t height();
|
||||
|
|
|
@ -48,13 +48,13 @@ static void xcursor_create(xcursor_t *data, XFixesCursorImage *xc) {
|
|||
if (data->tex
|
||||
&& data->last_height == xc->width
|
||||
&& data->last_width == xc->height) {
|
||||
texture_setimage(data->tex, (const uint8_t *) pixels,
|
||||
gs_texture_set_image(data->tex, (const uint8_t *) pixels,
|
||||
xc->width * sizeof(uint32_t), False);
|
||||
} else {
|
||||
if (data->tex)
|
||||
texture_destroy(data->tex);
|
||||
gs_texture_destroy(data->tex);
|
||||
|
||||
data->tex = gs_create_texture(xc->width, xc->height,
|
||||
data->tex = gs_texture_create(xc->width, xc->height,
|
||||
GS_BGRA, 1, (const uint8_t **) &pixels, GS_DYNAMIC);
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,7 @@ xcursor_t *xcursor_init(Display *dpy) {
|
|||
|
||||
void xcursor_destroy(xcursor_t *data) {
|
||||
if (data->tex)
|
||||
texture_destroy(data->tex);
|
||||
gs_texture_destroy(data->tex);
|
||||
bfree(data);
|
||||
}
|
||||
|
||||
|
@ -93,17 +93,17 @@ void xcursor_tick(xcursor_t *data) {
|
|||
|
||||
void xcursor_render(xcursor_t *data) {
|
||||
/* TODO: why do i need effects ? */
|
||||
effect_t effect = gs_geteffect();
|
||||
eparam_t image = effect_getparambyname(effect, "image");
|
||||
gs_effect_t effect = gs_get_effect();
|
||||
gs_eparam_t image = gs_effect_get_param_by_name(effect, "image");
|
||||
|
||||
effect_settexture(image, data->tex);
|
||||
gs_effect_set_texture(image, data->tex);
|
||||
|
||||
gs_matrix_push();
|
||||
|
||||
gs_matrix_translate3f(-data->pos_x, -data->pos_y, 0);
|
||||
|
||||
gs_enable_blending(True);
|
||||
gs_blendfunction(GS_BLEND_ONE, GS_BLEND_INVSRCALPHA);
|
||||
gs_blend_function(GS_BLEND_ONE, GS_BLEND_INVSRCALPHA);
|
||||
gs_draw_sprite(data->tex, 0, 0, 0);
|
||||
|
||||
gs_matrix_pop();
|
||||
|
|
|
@ -30,7 +30,7 @@ typedef struct {
|
|||
unsigned long last_serial;
|
||||
uint_fast32_t last_width;
|
||||
uint_fast32_t last_height;
|
||||
texture_t tex;
|
||||
gs_texture_t tex;
|
||||
|
||||
int_fast32_t x_org;
|
||||
int_fast32_t y_org;
|
||||
|
|
|
@ -35,7 +35,7 @@ struct xshm_data {
|
|||
int_fast32_t width, height;
|
||||
|
||||
xshm_t *xshm;
|
||||
texture_t texture;
|
||||
gs_texture_t texture;
|
||||
|
||||
bool show_cursor;
|
||||
xcursor_t *cursor;
|
||||
|
@ -53,8 +53,8 @@ static void xshm_resize_texture(struct xshm_data *data)
|
|||
obs_enter_graphics();
|
||||
|
||||
if (data->texture)
|
||||
texture_destroy(data->texture);
|
||||
data->texture = gs_create_texture(data->width, data->height,
|
||||
gs_texture_destroy(data->texture);
|
||||
data->texture = gs_texture_create(data->width, data->height,
|
||||
GS_BGRA, 1, NULL, GS_DYNAMIC);
|
||||
|
||||
obs_leave_graphics();
|
||||
|
@ -186,7 +186,7 @@ static void xshm_destroy(void *vptr)
|
|||
obs_enter_graphics();
|
||||
|
||||
if (data->texture)
|
||||
texture_destroy(data->texture);
|
||||
gs_texture_destroy(data->texture);
|
||||
if (data->cursor)
|
||||
xcursor_destroy(data->cursor);
|
||||
|
||||
|
@ -249,7 +249,7 @@ static void xshm_video_tick(void *vptr, float seconds)
|
|||
|
||||
XShmGetImage(data->dpy, XRootWindowOfScreen(data->screen),
|
||||
data->xshm->image, data->x_org, data->y_org, AllPlanes);
|
||||
texture_setimage(data->texture, (void *) data->xshm->image->data,
|
||||
gs_texture_set_image(data->texture, (void *) data->xshm->image->data,
|
||||
data->width * 4, false);
|
||||
|
||||
xcursor_tick(data->cursor);
|
||||
|
@ -260,15 +260,15 @@ static void xshm_video_tick(void *vptr, float seconds)
|
|||
/**
|
||||
* Render the capture data
|
||||
*/
|
||||
static void xshm_video_render(void *vptr, effect_t effect)
|
||||
static void xshm_video_render(void *vptr, gs_effect_t effect)
|
||||
{
|
||||
XSHM_DATA(vptr);
|
||||
|
||||
if (!data->xshm)
|
||||
return;
|
||||
|
||||
eparam_t image = effect_getparambyname(effect, "image");
|
||||
effect_settexture(image, data->texture);
|
||||
gs_eparam_t image = gs_effect_get_param_by_name(effect, "image");
|
||||
gs_effect_set_texture(image, data->texture);
|
||||
|
||||
gs_enable_blending(false);
|
||||
gs_draw_sprite(data->texture, 0, 0, 0);
|
||||
|
|
|
@ -9,9 +9,9 @@
|
|||
struct display_capture {
|
||||
obs_source_t source;
|
||||
|
||||
samplerstate_t sampler;
|
||||
effect_t draw_effect;
|
||||
texture_t tex;
|
||||
gs_samplerstate_t sampler;
|
||||
gs_effect_t draw_effect;
|
||||
gs_texture_t tex;
|
||||
|
||||
unsigned display;
|
||||
uint32_t width, height;
|
||||
|
@ -32,7 +32,7 @@ static void destroy_display_stream(struct display_capture *dc)
|
|||
}
|
||||
|
||||
if (dc->tex) {
|
||||
texture_destroy(dc->tex);
|
||||
gs_texture_destroy(dc->tex);
|
||||
dc->tex = NULL;
|
||||
}
|
||||
|
||||
|
@ -68,9 +68,9 @@ static void display_capture_destroy(void *data)
|
|||
destroy_display_stream(dc);
|
||||
|
||||
if (dc->sampler)
|
||||
samplerstate_destroy(dc->sampler);
|
||||
gs_samplerstate_destroy(dc->sampler);
|
||||
if (dc->draw_effect)
|
||||
effect_destroy(dc->draw_effect);
|
||||
gs_effect_destroy(dc->draw_effect);
|
||||
|
||||
obs_leave_graphics();
|
||||
|
||||
|
@ -178,12 +178,12 @@ static void *display_capture_create(obs_data_t settings,
|
|||
.address_w = GS_ADDRESS_CLAMP,
|
||||
.max_anisotropy = 1,
|
||||
};
|
||||
dc->sampler = gs_create_samplerstate(&info);
|
||||
dc->sampler = gs_samplerstate_create(&info);
|
||||
if (!dc->sampler)
|
||||
goto fail;
|
||||
|
||||
char *effect_file = obs_module_file("draw_rect.effect");
|
||||
dc->draw_effect = gs_create_effect_from_file(effect_file, NULL);
|
||||
dc->draw_effect = gs_effect_create_from_file(effect_file, NULL);
|
||||
bfree(effect_file);
|
||||
if (!dc->draw_effect)
|
||||
goto fail;
|
||||
|
@ -225,9 +225,9 @@ static void display_capture_video_tick(void *data, float seconds)
|
|||
|
||||
obs_enter_graphics();
|
||||
if (dc->tex)
|
||||
texture_rebind_iosurface(dc->tex, dc->prev);
|
||||
gs_texture_rebind_iosurface(dc->tex, dc->prev);
|
||||
else
|
||||
dc->tex = gs_create_texture_from_iosurface(dc->prev);
|
||||
dc->tex = gs_texture_create_from_iosurface(dc->prev);
|
||||
obs_leave_graphics();
|
||||
|
||||
if (prev_prev) {
|
||||
|
@ -236,7 +236,7 @@ static void display_capture_video_tick(void *data, float seconds)
|
|||
}
|
||||
}
|
||||
|
||||
static void display_capture_video_render(void *data, effect_t effect)
|
||||
static void display_capture_video_render(void *data, gs_effect_t effect)
|
||||
{
|
||||
UNUSED_PARAMETER(effect);
|
||||
|
||||
|
@ -246,16 +246,17 @@ static void display_capture_video_render(void *data, effect_t effect)
|
|||
return;
|
||||
|
||||
gs_load_samplerstate(dc->sampler, 0);
|
||||
technique_t tech = effect_gettechnique(dc->draw_effect, "Default");
|
||||
effect_settexture(effect_getparambyidx(dc->draw_effect, 1),
|
||||
gs_technique_t tech = gs_effect_get_technique(dc->draw_effect,
|
||||
"Default");
|
||||
gs_effect_set_texture(gs_effect_get_param_by_idx(dc->draw_effect, 1),
|
||||
dc->tex);
|
||||
technique_begin(tech);
|
||||
technique_beginpass(tech, 0);
|
||||
gs_technique_begin(tech);
|
||||
gs_technique_begin_pass(tech, 0);
|
||||
|
||||
gs_draw_sprite(dc->tex, 0, 0, 0);
|
||||
|
||||
technique_endpass(tech);
|
||||
technique_end(tech);
|
||||
gs_technique_end_pass(tech);
|
||||
gs_technique_end(tech);
|
||||
}
|
||||
|
||||
static const char *display_capture_getname(void)
|
||||
|
|
|
@ -7,11 +7,11 @@ static inline void init_textures(struct dc_capture *capture)
|
|||
{
|
||||
for (int i = 0; i < capture->num_textures; i++) {
|
||||
if (capture->compatibility)
|
||||
capture->textures[i] = gs_create_texture(
|
||||
capture->textures[i] = gs_texture_create(
|
||||
capture->width, capture->height,
|
||||
GS_BGRA, 1, NULL, GS_DYNAMIC);
|
||||
else
|
||||
capture->textures[i] = gs_create_gdi_texture(
|
||||
capture->textures[i] = gs_texture_create_gdi(
|
||||
capture->width, capture->height);
|
||||
|
||||
if (!capture->textures[i]) {
|
||||
|
@ -79,7 +79,7 @@ void dc_capture_free(struct dc_capture *capture)
|
|||
obs_enter_graphics();
|
||||
|
||||
for (int i = 0; i < capture->num_textures; i++)
|
||||
texture_destroy(capture->textures[i]);
|
||||
gs_texture_destroy(capture->textures[i]);
|
||||
|
||||
obs_leave_graphics();
|
||||
|
||||
|
@ -126,16 +126,16 @@ static inline HDC dc_capture_get_dc(struct dc_capture *capture)
|
|||
if (capture->compatibility)
|
||||
return capture->hdc;
|
||||
else
|
||||
return texture_get_dc(capture->textures[capture->cur_tex]);
|
||||
return gs_texture_get_dc(capture->textures[capture->cur_tex]);
|
||||
}
|
||||
|
||||
static inline void dc_capture_release_dc(struct dc_capture *capture)
|
||||
{
|
||||
if (capture->compatibility) {
|
||||
texture_setimage(capture->textures[capture->cur_tex],
|
||||
gs_texture_set_image(capture->textures[capture->cur_tex],
|
||||
capture->bits, capture->width*4, false);
|
||||
} else {
|
||||
texture_release_dc(capture->textures[capture->cur_tex]);
|
||||
gs_texture_release_dc(capture->textures[capture->cur_tex]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -175,30 +175,30 @@ void dc_capture_capture(struct dc_capture *capture, HWND window)
|
|||
capture->textures_written[capture->cur_tex] = true;
|
||||
}
|
||||
|
||||
static void draw_texture(struct dc_capture *capture, int id, effect_t effect)
|
||||
static void draw_texture(struct dc_capture *capture, int id, gs_effect_t effect)
|
||||
{
|
||||
texture_t texture = capture->textures[id];
|
||||
technique_t tech = effect_gettechnique(effect, "Draw");
|
||||
eparam_t image = effect_getparambyname(effect, "image");
|
||||
gs_texture_t texture = capture->textures[id];
|
||||
gs_technique_t tech = gs_effect_get_technique(effect, "Draw");
|
||||
gs_eparam_t image = gs_effect_get_param_by_name(effect, "image");
|
||||
size_t passes;
|
||||
|
||||
effect_settexture(image, texture);
|
||||
gs_effect_set_texture(image, texture);
|
||||
|
||||
passes = technique_begin(tech);
|
||||
passes = gs_technique_begin(tech);
|
||||
for (size_t i = 0; i < passes; i++) {
|
||||
if (technique_beginpass(tech, i)) {
|
||||
if (gs_technique_begin_pass(tech, i)) {
|
||||
if (capture->compatibility)
|
||||
gs_draw_sprite(texture, GS_FLIP_V, 0, 0);
|
||||
else
|
||||
gs_draw_sprite(texture, 0, 0, 0);
|
||||
|
||||
technique_endpass(tech);
|
||||
gs_technique_end_pass(tech);
|
||||
}
|
||||
}
|
||||
technique_end(tech);
|
||||
gs_technique_end(tech);
|
||||
}
|
||||
|
||||
void dc_capture_render(struct dc_capture *capture, effect_t effect)
|
||||
void dc_capture_render(struct dc_capture *capture, gs_effect_t effect)
|
||||
{
|
||||
int last_tex = (capture->cur_tex > 0) ?
|
||||
capture->cur_tex-1 : capture->num_textures-1;
|
||||
|
@ -210,9 +210,9 @@ void dc_capture_render(struct dc_capture *capture, effect_t effect)
|
|||
draw_texture(capture, last_tex, effect);
|
||||
}
|
||||
|
||||
effect_t create_opaque_effect(void)
|
||||
gs_effect_t create_opaque_effect(void)
|
||||
{
|
||||
effect_t opaque_effect;
|
||||
gs_effect_t opaque_effect;
|
||||
char *effect_file;
|
||||
char *error_string = NULL;
|
||||
|
||||
|
@ -225,7 +225,7 @@ effect_t create_opaque_effect(void)
|
|||
|
||||
obs_enter_graphics();
|
||||
|
||||
opaque_effect = gs_create_effect_from_file(effect_file, &error_string);
|
||||
opaque_effect = gs_effect_create_from_file(effect_file, &error_string);
|
||||
|
||||
if (!opaque_effect) {
|
||||
if (error_string)
|
||||
|
|
|
@ -8,24 +8,24 @@
|
|||
#define NUM_TEXTURES 2
|
||||
|
||||
struct dc_capture {
|
||||
int cur_tex;
|
||||
texture_t textures[NUM_TEXTURES];
|
||||
bool textures_written[NUM_TEXTURES];
|
||||
int x, y;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
int num_textures;
|
||||
int cur_tex;
|
||||
gs_texture_t textures[NUM_TEXTURES];
|
||||
bool textures_written[NUM_TEXTURES];
|
||||
int x, y;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
int num_textures;
|
||||
|
||||
bool compatibility;
|
||||
HDC hdc;
|
||||
HBITMAP bmp, old_bmp;
|
||||
BYTE *bits;
|
||||
bool compatibility;
|
||||
HDC hdc;
|
||||
HBITMAP bmp, old_bmp;
|
||||
BYTE *bits;
|
||||
|
||||
bool capture_cursor;
|
||||
bool cursor_captured;
|
||||
CURSORINFO ci;
|
||||
bool capture_cursor;
|
||||
bool cursor_captured;
|
||||
CURSORINFO ci;
|
||||
|
||||
bool valid;
|
||||
bool valid;
|
||||
};
|
||||
|
||||
extern void dc_capture_init(struct dc_capture *capture, int x, int y,
|
||||
|
@ -34,6 +34,6 @@ extern void dc_capture_init(struct dc_capture *capture, int x, int y,
|
|||
extern void dc_capture_free(struct dc_capture *capture);
|
||||
|
||||
extern void dc_capture_capture(struct dc_capture *capture, HWND window);
|
||||
extern void dc_capture_render(struct dc_capture *capture, effect_t effect);
|
||||
extern void dc_capture_render(struct dc_capture *capture, gs_effect_t effect);
|
||||
|
||||
extern effect_t create_opaque_effect(void);
|
||||
extern gs_effect_t create_opaque_effect(void);
|
||||
|
|
|
@ -10,7 +10,7 @@ struct monitor_capture {
|
|||
|
||||
struct dc_capture data;
|
||||
|
||||
effect_t opaque_effect;
|
||||
gs_effect_t opaque_effect;
|
||||
};
|
||||
|
||||
struct monitor_info {
|
||||
|
@ -95,7 +95,7 @@ static void monitor_capture_destroy(void *data)
|
|||
obs_enter_graphics();
|
||||
|
||||
dc_capture_free(&capture->data);
|
||||
effect_destroy(capture->opaque_effect);
|
||||
gs_effect_destroy(capture->opaque_effect);
|
||||
|
||||
obs_leave_graphics();
|
||||
|
||||
|
@ -112,7 +112,7 @@ static void monitor_capture_defaults(obs_data_t settings)
|
|||
static void *monitor_capture_create(obs_data_t settings, obs_source_t source)
|
||||
{
|
||||
struct monitor_capture *capture;
|
||||
effect_t opaque_effect = create_opaque_effect();
|
||||
gs_effect_t opaque_effect = create_opaque_effect();
|
||||
|
||||
if (!opaque_effect)
|
||||
return NULL;
|
||||
|
@ -137,7 +137,7 @@ static void monitor_capture_tick(void *data, float seconds)
|
|||
UNUSED_PARAMETER(seconds);
|
||||
}
|
||||
|
||||
static void monitor_capture_render(void *data, effect_t effect)
|
||||
static void monitor_capture_render(void *data, gs_effect_t effect)
|
||||
{
|
||||
struct monitor_capture *capture = data;
|
||||
dc_capture_render(&capture->data, capture->opaque_effect);
|
||||
|
|
|
@ -33,7 +33,7 @@ struct window_capture {
|
|||
|
||||
float resize_timer;
|
||||
|
||||
effect_t opaque_effect;
|
||||
gs_effect_t opaque_effect;
|
||||
|
||||
HWND window;
|
||||
RECT last_rect;
|
||||
|
@ -311,7 +311,7 @@ static const char *wc_getname(void)
|
|||
static void *wc_create(obs_data_t settings, obs_source_t source)
|
||||
{
|
||||
struct window_capture *wc;
|
||||
effect_t opaque_effect = create_opaque_effect();
|
||||
gs_effect_t opaque_effect = create_opaque_effect();
|
||||
if (!opaque_effect)
|
||||
return NULL;
|
||||
|
||||
|
@ -335,7 +335,7 @@ static void wc_destroy(void *data)
|
|||
bfree(wc->executable);
|
||||
|
||||
obs_enter_graphics();
|
||||
effect_destroy(wc->opaque_effect);
|
||||
gs_effect_destroy(wc->opaque_effect);
|
||||
obs_leave_graphics();
|
||||
|
||||
bfree(wc);
|
||||
|
@ -441,7 +441,7 @@ static void wc_tick(void *data, float seconds)
|
|||
obs_leave_graphics();
|
||||
}
|
||||
|
||||
static void wc_render(void *data, effect_t effect)
|
||||
static void wc_render(void *data, gs_effect_t effect)
|
||||
{
|
||||
struct window_capture *wc = data;
|
||||
dc_capture_render(&wc->capture, wc->opaque_effect);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
struct test_filter {
|
||||
obs_source_t source;
|
||||
effect_t whatever;
|
||||
gs_effect_t whatever;
|
||||
};
|
||||
|
||||
static const char *filter_getname(void)
|
||||
|
@ -17,7 +17,7 @@ static void filter_destroy(void *data)
|
|||
if (tf) {
|
||||
obs_enter_graphics();
|
||||
|
||||
effect_destroy(tf->whatever);
|
||||
gs_effect_destroy(tf->whatever);
|
||||
bfree(tf);
|
||||
|
||||
obs_leave_graphics();
|
||||
|
@ -34,7 +34,7 @@ static void *filter_create(obs_data_t settings, obs_source_t source)
|
|||
effect_file = obs_module_file("test.effect");
|
||||
|
||||
tf->source = source;
|
||||
tf->whatever = gs_create_effect_from_file(effect_file, NULL);
|
||||
tf->whatever = gs_effect_create_from_file(effect_file, NULL);
|
||||
bfree(effect_file);
|
||||
if (!tf->whatever) {
|
||||
filter_destroy(tf);
|
||||
|
@ -47,7 +47,7 @@ static void *filter_create(obs_data_t settings, obs_source_t source)
|
|||
return tf;
|
||||
}
|
||||
|
||||
static void filter_render(void *data, effect_t effect)
|
||||
static void filter_render(void *data, gs_effect_t effect)
|
||||
{
|
||||
struct test_filter *tf = data;
|
||||
obs_source_process_filter(tf->source, tf->whatever, 0, 0, GS_RGBA,
|
||||
|
|
Loading…
Reference in New Issue