|
@@ -40,7 +40,6 @@
|
|
|
Optionally provide the following defines with your own implementations:
|
|
|
|
|
|
SOKOL_ASSERT(c) - your own assert macro (default: assert(c))
|
|
|
- SOKOL_LOG(msg) - your own logging function (default: puts(msg))
|
|
|
SOKOL_UNREACHABLE() - a guard macro for unreachable code (default: assert(false))
|
|
|
SOKOL_GFX_API_DECL - public function declaration prefix (default: extern)
|
|
|
SOKOL_API_DECL - same as SOKOL_GFX_API_DECL
|
|
@@ -679,7 +678,7 @@
|
|
|
.allocator = {
|
|
|
.alloc = my_alloc,
|
|
|
.free = my_free,
|
|
|
- .user_data = ...;
|
|
|
+ .user_data = ...,
|
|
|
}
|
|
|
});
|
|
|
...
|
|
@@ -690,6 +689,27 @@
|
|
|
itself though, not any allocations in OS libraries.
|
|
|
|
|
|
|
|
|
+ LOG FUNCTION OVERRIDE
|
|
|
+ =====================
|
|
|
+ You can override the log function at initialization time like this:
|
|
|
+
|
|
|
+ void my_log(const char* message, void* user_data) {
|
|
|
+ printf("sg says: \s\n", message);
|
|
|
+ }
|
|
|
+
|
|
|
+ ...
|
|
|
+ sg_setup(&(sg_desc){
|
|
|
+ // ...
|
|
|
+ .logger = {
|
|
|
+ .log_cb = my_log,
|
|
|
+ .user_data = ...,
|
|
|
+ }
|
|
|
+ });
|
|
|
+ ...
|
|
|
+
|
|
|
+ If no overrides are provided, puts will be used on most platforms.
|
|
|
+ On Android, __android_log_write will be used instead.
|
|
|
+
|
|
|
TODO:
|
|
|
====
|
|
|
- talk about asynchronous resource creation
|
|
@@ -2454,6 +2474,17 @@ typedef struct sg_allocator {
|
|
|
void* user_data;
|
|
|
} sg_allocator;
|
|
|
|
|
|
+/*
|
|
|
+ sg_logger
|
|
|
+
|
|
|
+ Used in sg_desc to provide custom log callbacks to sokol_gfx.h.
|
|
|
+ Default behavior is SG_LOG_DEFAULT(message).
|
|
|
+*/
|
|
|
+typedef struct sg_logger {
|
|
|
+ void (*log_cb)(const char* message, void* user_data);
|
|
|
+ void* user_data;
|
|
|
+} sg_logger;
|
|
|
+
|
|
|
typedef struct sg_desc {
|
|
|
uint32_t _start_canary;
|
|
|
int buffer_pool_size;
|
|
@@ -2466,6 +2497,7 @@ typedef struct sg_desc {
|
|
|
int staging_buffer_size;
|
|
|
int sampler_cache_size;
|
|
|
sg_allocator allocator;
|
|
|
+ sg_logger logger; // optional log function override
|
|
|
sg_context_desc context;
|
|
|
uint32_t _end_canary;
|
|
|
} sg_desc;
|
|
@@ -2658,13 +2690,38 @@ inline int sg_append_buffer(sg_buffer buf_id, const sg_range& data) { return sg_
|
|
|
#ifndef SOKOL_UNREACHABLE
|
|
|
#define SOKOL_UNREACHABLE SOKOL_ASSERT(false)
|
|
|
#endif
|
|
|
-#ifndef SOKOL_LOG
|
|
|
+
|
|
|
+#if defined(SOKOL_LOG)
|
|
|
+#error "SOKOL_LOG macro is no longer supported, please use sg_desc.logger to override log functions"
|
|
|
+#endif
|
|
|
+#ifndef SOKOL_NO_LOG
|
|
|
#ifdef SOKOL_DEBUG
|
|
|
- #include <stdio.h>
|
|
|
- #define SOKOL_LOG(s) { SOKOL_ASSERT(s); puts(s); }
|
|
|
+ #define SOKOL_NO_LOG 0
|
|
|
+ #else
|
|
|
+ #define SOKOL_NO_LOG 1
|
|
|
+ #endif
|
|
|
+#endif
|
|
|
+#if !SOKOL_NO_LOG
|
|
|
+ #if defined(__ANDROID__)
|
|
|
+ #include <android/log.h> // __android_log_write
|
|
|
#else
|
|
|
- #define SOKOL_LOG(s)
|
|
|
+ #include <stdio.h> // puts
|
|
|
+ #endif
|
|
|
+ #define SG_LOG(s) { SOKOL_ASSERT(s); _sg_log(s); }
|
|
|
+ #ifndef SG_LOG_DEFAULT
|
|
|
+ #if defined(__ANDROID__)
|
|
|
+ #include <android/log.h>
|
|
|
+ #define SG_LOG_DEFAULT(s) __android_log_write(ANDROID_LOG_INFO, "SOKOL_GFX", s)
|
|
|
+ #else
|
|
|
+ #include <stdio.h>
|
|
|
+ #define SG_LOG_DEFAULT(s) puts(s)
|
|
|
+ #endif
|
|
|
#endif
|
|
|
+#else
|
|
|
+ #define SG_LOG(s)
|
|
|
+#endif
|
|
|
+#ifndef SG_LOG_DEFAULT
|
|
|
+ #define SG_LOG_DEFAULT(s)
|
|
|
#endif
|
|
|
|
|
|
#ifndef _SOKOL_PRIVATE
|
|
@@ -4323,6 +4380,17 @@ _SOKOL_PRIVATE void _sg_free(void* ptr) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+#if !SOKOL_NO_LOG
|
|
|
+_SOKOL_PRIVATE void _sg_log(const char* msg) {
|
|
|
+ SOKOL_ASSERT(msg);
|
|
|
+ if (_sg.desc.logger.log_cb) {
|
|
|
+ _sg.desc.logger.log_cb(msg, _sg.desc.logger.user_data);
|
|
|
+ } else {
|
|
|
+ SG_LOG_DEFAULT(msg);
|
|
|
+ }
|
|
|
+}
|
|
|
+#endif
|
|
|
+
|
|
|
_SOKOL_PRIVATE bool _sg_strempty(const _sg_str_t* str) {
|
|
|
return 0 == str->buf[0];
|
|
|
}
|
|
@@ -6570,16 +6638,16 @@ _SOKOL_PRIVATE sg_resource_state _sg_gl_create_image(_sg_image_t* img, const sg_
|
|
|
|
|
|
/* check if texture format is support */
|
|
|
if (!_sg_gl_supported_texture_format(img->cmn.pixel_format)) {
|
|
|
- SOKOL_LOG("texture format not supported by GL context\n");
|
|
|
+ SG_LOG("texture format not supported by GL context\n");
|
|
|
return SG_RESOURCESTATE_FAILED;
|
|
|
}
|
|
|
/* check for optional texture types */
|
|
|
if ((img->cmn.type == SG_IMAGETYPE_3D) && !_sg.features.imagetype_3d) {
|
|
|
- SOKOL_LOG("3D textures not supported by GL context\n");
|
|
|
+ SG_LOG("3D textures not supported by GL context\n");
|
|
|
return SG_RESOURCESTATE_FAILED;
|
|
|
}
|
|
|
if ((img->cmn.type == SG_IMAGETYPE_ARRAY) && !_sg.features.imagetype_array) {
|
|
|
- SOKOL_LOG("array textures not supported by GL context\n");
|
|
|
+ SG_LOG("array textures not supported by GL context\n");
|
|
|
return SG_RESOURCESTATE_FAILED;
|
|
|
}
|
|
|
|
|
@@ -6783,7 +6851,7 @@ _SOKOL_PRIVATE GLuint _sg_gl_compile_shader(sg_shader_stage stage, const char* s
|
|
|
if (log_len > 0) {
|
|
|
GLchar* log_buf = (GLchar*) _sg_malloc((size_t)log_len);
|
|
|
glGetShaderInfoLog(gl_shd, log_len, &log_len, log_buf);
|
|
|
- SOKOL_LOG(log_buf);
|
|
|
+ SG_LOG(log_buf);
|
|
|
_sg_free(log_buf);
|
|
|
}
|
|
|
glDeleteShader(gl_shd);
|
|
@@ -6826,7 +6894,7 @@ _SOKOL_PRIVATE sg_resource_state _sg_gl_create_shader(_sg_shader_t* shd, const s
|
|
|
if (log_len > 0) {
|
|
|
GLchar* log_buf = (GLchar*) _sg_malloc((size_t)log_len);
|
|
|
glGetProgramInfoLog(gl_prog, log_len, &log_len, log_buf);
|
|
|
- SOKOL_LOG(log_buf);
|
|
|
+ SG_LOG(log_buf);
|
|
|
_sg_free(log_buf);
|
|
|
}
|
|
|
glDeleteProgram(gl_prog);
|
|
@@ -6974,8 +7042,8 @@ _SOKOL_PRIVATE sg_resource_state _sg_gl_create_pipeline(_sg_pipeline_t* pip, _sg
|
|
|
pip->cmn.vertex_layout_valid[a_desc->buffer_index] = true;
|
|
|
}
|
|
|
else {
|
|
|
- SOKOL_LOG("Vertex attribute not found in shader: ");
|
|
|
- SOKOL_LOG(_sg_strptr(&shd->gl.attrs[attr_index].name));
|
|
|
+ SG_LOG("Vertex attribute not found in shader: ");
|
|
|
+ SG_LOG(_sg_strptr(&shd->gl.attrs[attr_index].name));
|
|
|
}
|
|
|
}
|
|
|
return SG_RESOURCESTATE_VALID;
|
|
@@ -7080,7 +7148,7 @@ _SOKOL_PRIVATE sg_resource_state _sg_gl_create_pass(_sg_pass_t* pass, _sg_image_
|
|
|
|
|
|
/* check if framebuffer is complete */
|
|
|
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
|
|
|
- SOKOL_LOG("Framebuffer completeness check failed!\n");
|
|
|
+ SG_LOG("Framebuffer completeness check failed!\n");
|
|
|
return SG_RESOURCESTATE_FAILED;
|
|
|
}
|
|
|
|
|
@@ -7127,7 +7195,7 @@ _SOKOL_PRIVATE sg_resource_state _sg_gl_create_pass(_sg_pass_t* pass, _sg_image_
|
|
|
}
|
|
|
/* check if framebuffer is complete */
|
|
|
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
|
|
|
- SOKOL_LOG("Framebuffer completeness check failed (msaa resolve buffer)!\n");
|
|
|
+ SG_LOG("Framebuffer completeness check failed (msaa resolve buffer)!\n");
|
|
|
return SG_RESOURCESTATE_FAILED;
|
|
|
}
|
|
|
/* setup color attachments for the framebuffer */
|
|
@@ -8637,7 +8705,7 @@ _SOKOL_PRIVATE sg_resource_state _sg_d3d11_create_buffer(_sg_buffer_t* buf, cons
|
|
|
}
|
|
|
HRESULT hr = _sg_d3d11_CreateBuffer(_sg.d3d11.dev, &d3d11_desc, init_data_ptr, &buf->d3d11.buf);
|
|
|
if (!(SUCCEEDED(hr) && buf->d3d11.buf)) {
|
|
|
- SOKOL_LOG("failed to create D3D11 buffer\n");
|
|
|
+ SG_LOG("failed to create D3D11 buffer\n");
|
|
|
return SG_RESOURCESTATE_FAILED;
|
|
|
}
|
|
|
}
|
|
@@ -8696,7 +8764,7 @@ _SOKOL_PRIVATE sg_resource_state _sg_d3d11_create_image(_sg_image_t* img, const
|
|
|
/* create only a depth-texture */
|
|
|
SOKOL_ASSERT(!injected);
|
|
|
if (img->d3d11.format == DXGI_FORMAT_UNKNOWN) {
|
|
|
- SOKOL_LOG("trying to create a D3D11 depth-texture with unsupported pixel format\n");
|
|
|
+ SG_LOG("trying to create a D3D11 depth-texture with unsupported pixel format\n");
|
|
|
return SG_RESOURCESTATE_FAILED;
|
|
|
}
|
|
|
D3D11_TEXTURE2D_DESC d3d11_desc;
|
|
@@ -8712,7 +8780,7 @@ _SOKOL_PRIVATE sg_resource_state _sg_d3d11_create_image(_sg_image_t* img, const
|
|
|
d3d11_desc.SampleDesc.Quality = (UINT) (msaa ? D3D11_STANDARD_MULTISAMPLE_PATTERN : 0);
|
|
|
hr = _sg_d3d11_CreateTexture2D(_sg.d3d11.dev, &d3d11_desc, NULL, &img->d3d11.texds);
|
|
|
if (!(SUCCEEDED(hr) && img->d3d11.texds)) {
|
|
|
- SOKOL_LOG("failed to create D3D11 texture 2D\n");
|
|
|
+ SG_LOG("failed to create D3D11 texture 2D\n");
|
|
|
return SG_RESOURCESTATE_FAILED;
|
|
|
}
|
|
|
}
|
|
@@ -8776,7 +8844,7 @@ _SOKOL_PRIVATE sg_resource_state _sg_d3d11_create_image(_sg_image_t* img, const
|
|
|
}
|
|
|
if (img->d3d11.format == DXGI_FORMAT_UNKNOWN) {
|
|
|
/* trying to create a texture format that's not supported by D3D */
|
|
|
- SOKOL_LOG("trying to create a D3D11 texture with unsupported pixel format\n");
|
|
|
+ SG_LOG("trying to create a D3D11 texture with unsupported pixel format\n");
|
|
|
return SG_RESOURCESTATE_FAILED;
|
|
|
}
|
|
|
d3d11_tex_desc.SampleDesc.Count = 1;
|
|
@@ -8785,7 +8853,7 @@ _SOKOL_PRIVATE sg_resource_state _sg_d3d11_create_image(_sg_image_t* img, const
|
|
|
|
|
|
hr = _sg_d3d11_CreateTexture2D(_sg.d3d11.dev, &d3d11_tex_desc, init_data, &img->d3d11.tex2d);
|
|
|
if (!(SUCCEEDED(hr) && img->d3d11.tex2d)) {
|
|
|
- SOKOL_LOG("failed to create D3D11 texture 2D\n");
|
|
|
+ SG_LOG("failed to create D3D11 texture 2D\n");
|
|
|
return SG_RESOURCESTATE_FAILED;
|
|
|
}
|
|
|
}
|
|
@@ -8814,7 +8882,7 @@ _SOKOL_PRIVATE sg_resource_state _sg_d3d11_create_image(_sg_image_t* img, const
|
|
|
}
|
|
|
hr = _sg_d3d11_CreateShaderResourceView(_sg.d3d11.dev, (ID3D11Resource*)img->d3d11.tex2d, &d3d11_srv_desc, &img->d3d11.srv);
|
|
|
if (!(SUCCEEDED(hr) && img->d3d11.srv)) {
|
|
|
- SOKOL_LOG("failed to create D3D11 resource view\n");
|
|
|
+ SG_LOG("failed to create D3D11 resource view\n");
|
|
|
return SG_RESOURCESTATE_FAILED;
|
|
|
}
|
|
|
}
|
|
@@ -8859,12 +8927,12 @@ _SOKOL_PRIVATE sg_resource_state _sg_d3d11_create_image(_sg_image_t* img, const
|
|
|
}
|
|
|
if (img->d3d11.format == DXGI_FORMAT_UNKNOWN) {
|
|
|
/* trying to create a texture format that's not supported by D3D */
|
|
|
- SOKOL_LOG("trying to create a D3D11 texture with unsupported pixel format\n");
|
|
|
+ SG_LOG("trying to create a D3D11 texture with unsupported pixel format\n");
|
|
|
return SG_RESOURCESTATE_FAILED;
|
|
|
}
|
|
|
hr = _sg_d3d11_CreateTexture3D(_sg.d3d11.dev, &d3d11_tex_desc, init_data, &img->d3d11.tex3d);
|
|
|
if (!(SUCCEEDED(hr) && img->d3d11.tex3d)) {
|
|
|
- SOKOL_LOG("failed to create D3D11 texture 3D\n");
|
|
|
+ SG_LOG("failed to create D3D11 texture 3D\n");
|
|
|
return SG_RESOURCESTATE_FAILED;
|
|
|
}
|
|
|
}
|
|
@@ -8877,7 +8945,7 @@ _SOKOL_PRIVATE sg_resource_state _sg_d3d11_create_image(_sg_image_t* img, const
|
|
|
d3d11_srv_desc.Texture3D.MipLevels = (UINT)img->cmn.num_mipmaps;
|
|
|
hr = _sg_d3d11_CreateShaderResourceView(_sg.d3d11.dev, (ID3D11Resource*)img->d3d11.tex3d, &d3d11_srv_desc, &img->d3d11.srv);
|
|
|
if (!(SUCCEEDED(hr) && img->d3d11.srv)) {
|
|
|
- SOKOL_LOG("failed to create D3D11 resource view\n");
|
|
|
+ SG_LOG("failed to create D3D11 resource view\n");
|
|
|
return SG_RESOURCESTATE_FAILED;
|
|
|
}
|
|
|
}
|
|
@@ -8899,7 +8967,7 @@ _SOKOL_PRIVATE sg_resource_state _sg_d3d11_create_image(_sg_image_t* img, const
|
|
|
d3d11_tex_desc.SampleDesc.Quality = (UINT)D3D11_STANDARD_MULTISAMPLE_PATTERN;
|
|
|
hr = _sg_d3d11_CreateTexture2D(_sg.d3d11.dev, &d3d11_tex_desc, NULL, &img->d3d11.texmsaa);
|
|
|
if (!(SUCCEEDED(hr) && img->d3d11.texmsaa)) {
|
|
|
- SOKOL_LOG("failed to create D3D11 texture 2D\n");
|
|
|
+ SG_LOG("failed to create D3D11 texture 2D\n");
|
|
|
return SG_RESOURCESTATE_FAILED;
|
|
|
}
|
|
|
}
|
|
@@ -8931,7 +8999,7 @@ _SOKOL_PRIVATE sg_resource_state _sg_d3d11_create_image(_sg_image_t* img, const
|
|
|
d3d11_smp_desc.MaxLOD = desc->max_lod;
|
|
|
hr = _sg_d3d11_CreateSamplerState(_sg.d3d11.dev, &d3d11_smp_desc, &img->d3d11.smp);
|
|
|
if (!(SUCCEEDED(hr) && img->d3d11.smp)) {
|
|
|
- SOKOL_LOG("failed to create D3D11 sampler state\n");
|
|
|
+ SG_LOG("failed to create D3D11 sampler state\n");
|
|
|
return SG_RESOURCESTATE_FAILED;
|
|
|
}
|
|
|
}
|
|
@@ -8970,7 +9038,7 @@ _SOKOL_PRIVATE bool _sg_d3d11_load_d3dcompiler_dll(void) {
|
|
|
_sg.d3d11.d3dcompiler_dll = LoadLibraryA("d3dcompiler_47.dll");
|
|
|
if (0 == _sg.d3d11.d3dcompiler_dll) {
|
|
|
/* don't attempt to load missing DLL in the future */
|
|
|
- SOKOL_LOG("failed to load d3dcompiler_47.dll!\n");
|
|
|
+ SG_LOG("failed to load d3dcompiler_47.dll!\n");
|
|
|
_sg.d3d11.d3dcompiler_dll_load_failed = true;
|
|
|
return false;
|
|
|
}
|
|
@@ -9008,7 +9076,7 @@ _SOKOL_PRIVATE ID3DBlob* _sg_d3d11_compile_shader(const sg_shader_stage_desc* st
|
|
|
&output, /* ppCode */
|
|
|
&errors_or_warnings); /* ppErrorMsgs */
|
|
|
if (errors_or_warnings) {
|
|
|
- SOKOL_LOG((LPCSTR)_sg_d3d11_GetBufferPointer(errors_or_warnings));
|
|
|
+ SG_LOG((LPCSTR)_sg_d3d11_GetBufferPointer(errors_or_warnings));
|
|
|
_sg_d3d11_Release(errors_or_warnings); errors_or_warnings = NULL;
|
|
|
}
|
|
|
if (FAILED(hr)) {
|
|
@@ -9050,7 +9118,7 @@ _SOKOL_PRIVATE sg_resource_state _sg_d3d11_create_shader(_sg_shader_t* shd, cons
|
|
|
cb_desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
|
|
|
hr = _sg_d3d11_CreateBuffer(_sg.d3d11.dev, &cb_desc, NULL, &d3d11_stage->cbufs[ub_index]);
|
|
|
if (!(SUCCEEDED(hr) && d3d11_stage->cbufs[ub_index])) {
|
|
|
- SOKOL_LOG("failed to create D3D11 buffer\n");
|
|
|
+ SG_LOG("failed to create D3D11 buffer\n");
|
|
|
return SG_RESOURCESTATE_FAILED;
|
|
|
}
|
|
|
}
|
|
@@ -9182,7 +9250,7 @@ _SOKOL_PRIVATE sg_resource_state _sg_d3d11_create_pipeline(_sg_pipeline_t* pip,
|
|
|
shd->d3d11.vs_blob_length, /* BytecodeLength */
|
|
|
&pip->d3d11.il);
|
|
|
if (!(SUCCEEDED(hr) && pip->d3d11.il)) {
|
|
|
- SOKOL_LOG("failed to create D3D11 input layout\n");
|
|
|
+ SG_LOG("failed to create D3D11 input layout\n");
|
|
|
return SG_RESOURCESTATE_FAILED;
|
|
|
}
|
|
|
|
|
@@ -9201,7 +9269,7 @@ _SOKOL_PRIVATE sg_resource_state _sg_d3d11_create_pipeline(_sg_pipeline_t* pip,
|
|
|
rs_desc.AntialiasedLineEnable = FALSE;
|
|
|
hr = _sg_d3d11_CreateRasterizerState(_sg.d3d11.dev, &rs_desc, &pip->d3d11.rs);
|
|
|
if (!(SUCCEEDED(hr) && pip->d3d11.rs)) {
|
|
|
- SOKOL_LOG("failed to create D3D11 rasterizer state\n");
|
|
|
+ SG_LOG("failed to create D3D11 rasterizer state\n");
|
|
|
return SG_RESOURCESTATE_FAILED;
|
|
|
}
|
|
|
|
|
@@ -9226,7 +9294,7 @@ _SOKOL_PRIVATE sg_resource_state _sg_d3d11_create_pipeline(_sg_pipeline_t* pip,
|
|
|
dss_desc.BackFace.StencilFunc = _sg_d3d11_compare_func(sb->compare);
|
|
|
hr = _sg_d3d11_CreateDepthStencilState(_sg.d3d11.dev, &dss_desc, &pip->d3d11.dss);
|
|
|
if (!(SUCCEEDED(hr) && pip->d3d11.dss)) {
|
|
|
- SOKOL_LOG("failed to create D3D11 depth stencil state\n");
|
|
|
+ SG_LOG("failed to create D3D11 depth stencil state\n");
|
|
|
return SG_RESOURCESTATE_FAILED;
|
|
|
}
|
|
|
|
|
@@ -9260,7 +9328,7 @@ _SOKOL_PRIVATE sg_resource_state _sg_d3d11_create_pipeline(_sg_pipeline_t* pip,
|
|
|
}
|
|
|
hr = _sg_d3d11_CreateBlendState(_sg.d3d11.dev, &bs_desc, &pip->d3d11.bs);
|
|
|
if (!(SUCCEEDED(hr) && pip->d3d11.bs)) {
|
|
|
- SOKOL_LOG("failed to create D3D11 blend state\n");
|
|
|
+ SG_LOG("failed to create D3D11 blend state\n");
|
|
|
return SG_RESOURCESTATE_FAILED;
|
|
|
}
|
|
|
|
|
@@ -9341,7 +9409,7 @@ _SOKOL_PRIVATE sg_resource_state _sg_d3d11_create_pass(_sg_pass_t* pass, _sg_ima
|
|
|
SOKOL_ASSERT(d3d11_res);
|
|
|
HRESULT hr = _sg_d3d11_CreateRenderTargetView(_sg.d3d11.dev, d3d11_res, &d3d11_rtv_desc, &pass->d3d11.color_atts[i].rtv);
|
|
|
if (!(SUCCEEDED(hr) && pass->d3d11.color_atts[i].rtv)) {
|
|
|
- SOKOL_LOG("failed to create D3D11 render target view\n");
|
|
|
+ SG_LOG("failed to create D3D11 render target view\n");
|
|
|
return SG_RESOURCESTATE_FAILED;
|
|
|
}
|
|
|
}
|
|
@@ -9374,7 +9442,7 @@ _SOKOL_PRIVATE sg_resource_state _sg_d3d11_create_pass(_sg_pass_t* pass, _sg_ima
|
|
|
SOKOL_ASSERT(d3d11_res);
|
|
|
HRESULT hr = _sg_d3d11_CreateDepthStencilView(_sg.d3d11.dev, d3d11_res, &d3d11_dsv_desc, &pass->d3d11.ds_att.dsv);
|
|
|
if (!(SUCCEEDED(hr) && pass->d3d11.ds_att.dsv)) {
|
|
|
- SOKOL_LOG("failed to create D3D11 depth stencil view\n");
|
|
|
+ SG_LOG("failed to create D3D11 depth stencil view\n");
|
|
|
return SG_RESOURCESTATE_FAILED;
|
|
|
}
|
|
|
}
|
|
@@ -9674,7 +9742,7 @@ _SOKOL_PRIVATE void _sg_d3d11_update_buffer(_sg_buffer_t* buf, const sg_range* d
|
|
|
memcpy(d3d11_msr.pData, data->ptr, data->size);
|
|
|
_sg_d3d11_Unmap(_sg.d3d11.ctx, (ID3D11Resource*)buf->d3d11.buf, 0);
|
|
|
} else {
|
|
|
- SOKOL_LOG("failed to map buffer while updating!\n");
|
|
|
+ SG_LOG("failed to map buffer while updating!\n");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -9690,7 +9758,7 @@ _SOKOL_PRIVATE int _sg_d3d11_append_buffer(_sg_buffer_t* buf, const sg_range* da
|
|
|
memcpy(dst_ptr, data->ptr, data->size);
|
|
|
_sg_d3d11_Unmap(_sg.d3d11.ctx, (ID3D11Resource*)buf->d3d11.buf, 0);
|
|
|
} else {
|
|
|
- SOKOL_LOG("failed to map buffer while appending!\n");
|
|
|
+ SG_LOG("failed to map buffer while appending!\n");
|
|
|
}
|
|
|
/* NOTE: this alignment is a requirement from WebGPU, but we want identical behaviour across all backend */
|
|
|
return _sg_roundup((int)data->size, 4);
|
|
@@ -9742,7 +9810,7 @@ _SOKOL_PRIVATE void _sg_d3d11_update_image(_sg_image_t* img, const sg_image_data
|
|
|
}
|
|
|
_sg_d3d11_Unmap(_sg.d3d11.ctx, d3d11_res, subres_index);
|
|
|
} else {
|
|
|
- SOKOL_LOG("failed to map texture!\n");
|
|
|
+ SG_LOG("failed to map texture!\n");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -10618,7 +10686,7 @@ _SOKOL_PRIVATE bool _sg_mtl_init_texdesc_common(MTLTextureDescriptor* mtl_desc,
|
|
|
mtl_desc.textureType = _sg_mtl_texture_type(img->cmn.type);
|
|
|
mtl_desc.pixelFormat = _sg_mtl_pixel_format(img->cmn.pixel_format);
|
|
|
if (MTLPixelFormatInvalid == mtl_desc.pixelFormat) {
|
|
|
- SOKOL_LOG("Unsupported texture pixel format!\n");
|
|
|
+ SG_LOG("Unsupported texture pixel format!\n");
|
|
|
return false;
|
|
|
}
|
|
|
mtl_desc.width = (NSUInteger)img->cmn.width;
|
|
@@ -10780,7 +10848,7 @@ _SOKOL_PRIVATE id<MTLLibrary> _sg_mtl_compile_library(const char* src) {
|
|
|
error:&err
|
|
|
];
|
|
|
if (err) {
|
|
|
- SOKOL_LOG([err.localizedDescription UTF8String]);
|
|
|
+ SG_LOG([err.localizedDescription UTF8String]);
|
|
|
}
|
|
|
return lib;
|
|
|
}
|
|
@@ -10790,7 +10858,7 @@ _SOKOL_PRIVATE id<MTLLibrary> _sg_mtl_library_from_bytecode(const void* ptr, siz
|
|
|
dispatch_data_t lib_data = dispatch_data_create(ptr, num_bytes, NULL, DISPATCH_DATA_DESTRUCTOR_DEFAULT);
|
|
|
id<MTLLibrary> lib = [_sg.mtl.device newLibraryWithData:lib_data error:&err];
|
|
|
if (err) {
|
|
|
- SOKOL_LOG([err.localizedDescription UTF8String]);
|
|
|
+ SG_LOG([err.localizedDescription UTF8String]);
|
|
|
}
|
|
|
_SG_OBJC_RELEASE(lib_data);
|
|
|
return lib;
|
|
@@ -10832,11 +10900,11 @@ _SOKOL_PRIVATE sg_resource_state _sg_mtl_create_shader(_sg_shader_t* shd, const
|
|
|
goto failed;
|
|
|
}
|
|
|
if (nil == vs_func) {
|
|
|
- SOKOL_LOG("vertex shader entry function not found\n");
|
|
|
+ SG_LOG("vertex shader entry function not found\n");
|
|
|
goto failed;
|
|
|
}
|
|
|
if (nil == fs_func) {
|
|
|
- SOKOL_LOG("fragment shader entry function not found\n");
|
|
|
+ SG_LOG("fragment shader entry function not found\n");
|
|
|
goto failed;
|
|
|
}
|
|
|
/* it is legal to call _sg_mtl_add_resource with a nil value, this will return a special 0xFFFFFFFF index */
|
|
@@ -10960,7 +11028,7 @@ _SOKOL_PRIVATE sg_resource_state _sg_mtl_create_pipeline(_sg_pipeline_t* pip, _s
|
|
|
_SG_OBJC_RELEASE(rp_desc);
|
|
|
if (nil == mtl_rps) {
|
|
|
SOKOL_ASSERT(err);
|
|
|
- SOKOL_LOG([err.localizedDescription UTF8String]);
|
|
|
+ SG_LOG([err.localizedDescription UTF8String]);
|
|
|
return SG_RESOURCESTATE_FAILED;
|
|
|
}
|
|
|
|
|
@@ -11956,7 +12024,7 @@ _SOKOL_PRIVATE void _sg_wgpu_ubpool_mapped_callback(WGPUBufferMapAsyncStatus sta
|
|
|
}
|
|
|
/* FIXME: better handling for this */
|
|
|
if (WGPUBufferMapAsyncStatus_Success != status) {
|
|
|
- SOKOL_LOG("Mapping uniform buffer failed!\n");
|
|
|
+ SG_LOG("Mapping uniform buffer failed!\n");
|
|
|
SOKOL_ASSERT(false);
|
|
|
}
|
|
|
SOKOL_ASSERT(data && (data_len == _sg.wgpu.ub.num_bytes));
|
|
@@ -12215,7 +12283,7 @@ _SOKOL_PRIVATE uint32_t _sg_wgpu_staging_copy_to_buffer(WGPUBuffer dst_buf, uint
|
|
|
SOKOL_ASSERT(data_num_bytes > 0);
|
|
|
uint32_t copy_num_bytes = _sg_roundup(data_num_bytes, 4);
|
|
|
if ((_sg.wgpu.staging.offset + copy_num_bytes) >= _sg.wgpu.staging.num_bytes) {
|
|
|
- SOKOL_LOG("WGPU: Per frame staging buffer full (in _sg_wgpu_staging_copy_to_buffer())!\n");
|
|
|
+ SG_LOG("WGPU: Per frame staging buffer full (in _sg_wgpu_staging_copy_to_buffer())!\n");
|
|
|
return false;
|
|
|
}
|
|
|
const int cur = _sg.wgpu.staging.cur;
|
|
@@ -12234,7 +12302,7 @@ _SOKOL_PRIVATE bool _sg_wgpu_staging_copy_to_texture(_sg_image_t* img, const sg_
|
|
|
SOKOL_ASSERT(_sg.wgpu.staging_cmd_enc);
|
|
|
uint32_t num_bytes = _sg_wgpu_image_data_buffer_size(img);
|
|
|
if ((_sg.wgpu.staging.offset + num_bytes) >= _sg.wgpu.staging.num_bytes) {
|
|
|
- SOKOL_LOG("WGPU: Per frame staging buffer full (in _sg_wgpu_staging_copy_to_texture)!\n");
|
|
|
+ SG_LOG("WGPU: Per frame staging buffer full (in _sg_wgpu_staging_copy_to_texture)!\n");
|
|
|
return false;
|
|
|
}
|
|
|
const int cur = _sg.wgpu.staging.cur;
|
|
@@ -12372,7 +12440,7 @@ _SOKOL_PRIVATE void _sg_wgpu_discard_backend(void) {
|
|
|
}
|
|
|
|
|
|
_SOKOL_PRIVATE void _sg_wgpu_reset_state_cache(void) {
|
|
|
- SOKOL_LOG("_sg_wgpu_reset_state_cache: FIXME\n");
|
|
|
+ SG_LOG("_sg_wgpu_reset_state_cache: FIXME\n");
|
|
|
}
|
|
|
|
|
|
_SOKOL_PRIVATE sg_resource_state _sg_wgpu_create_context(_sg_context_t* ctx) {
|
|
@@ -12388,7 +12456,7 @@ _SOKOL_PRIVATE void _sg_wgpu_destroy_context(_sg_context_t* ctx) {
|
|
|
|
|
|
_SOKOL_PRIVATE void _sg_wgpu_activate_context(_sg_context_t* ctx) {
|
|
|
(void)ctx;
|
|
|
- SOKOL_LOG("_sg_wgpu_activate_context: FIXME\n");
|
|
|
+ SG_LOG("_sg_wgpu_activate_context: FIXME\n");
|
|
|
}
|
|
|
|
|
|
_SOKOL_PRIVATE sg_resource_state _sg_wgpu_create_buffer(_sg_buffer_t* buf, const sg_buffer_desc* desc) {
|
|
@@ -14167,14 +14235,14 @@ _SOKOL_PRIVATE void _sg_validate_begin(void) {
|
|
|
_SOKOL_PRIVATE void _sg_validate(bool cond, _sg_validate_error_t err) {
|
|
|
if (!cond) {
|
|
|
_sg.validate_error = err;
|
|
|
- SOKOL_LOG(_sg_validate_string(err));
|
|
|
+ SG_LOG(_sg_validate_string(err));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
_SOKOL_PRIVATE bool _sg_validate_end(void) {
|
|
|
if (_sg.validate_error != _SG_VALIDATE_SUCCESS) {
|
|
|
#if !defined(SOKOL_VALIDATE_NON_FATAL)
|
|
|
- SOKOL_LOG("^^^^ SOKOL-GFX VALIDATION FAILED, TERMINATING ^^^^");
|
|
|
+ SG_LOG("^^^^ SOKOL-GFX VALIDATION FAILED, TERMINATING ^^^^");
|
|
|
SOKOL_ASSERT(false);
|
|
|
#endif
|
|
|
return false;
|
|
@@ -15151,7 +15219,7 @@ _SOKOL_PRIVATE bool _sg_uninit_buffer(sg_buffer buf_id) {
|
|
|
return true;
|
|
|
}
|
|
|
else {
|
|
|
- SOKOL_LOG("_sg_uninit_buffer: active context mismatch (must be same as for creation)");
|
|
|
+ SG_LOG("_sg_uninit_buffer: active context mismatch (must be same as for creation)");
|
|
|
_SG_TRACE_NOARGS(err_context_mismatch);
|
|
|
}
|
|
|
}
|
|
@@ -15167,7 +15235,7 @@ _SOKOL_PRIVATE bool _sg_uninit_image(sg_image img_id) {
|
|
|
return true;
|
|
|
}
|
|
|
else {
|
|
|
- SOKOL_LOG("_sg_uninit_image: active context mismatch (must be same as for creation)");
|
|
|
+ SG_LOG("_sg_uninit_image: active context mismatch (must be same as for creation)");
|
|
|
_SG_TRACE_NOARGS(err_context_mismatch);
|
|
|
}
|
|
|
}
|
|
@@ -15183,7 +15251,7 @@ _SOKOL_PRIVATE bool _sg_uninit_shader(sg_shader shd_id) {
|
|
|
return true;
|
|
|
}
|
|
|
else {
|
|
|
- SOKOL_LOG("_sg_uninit_shader: active context mismatch (must be same as for creation)");
|
|
|
+ SG_LOG("_sg_uninit_shader: active context mismatch (must be same as for creation)");
|
|
|
_SG_TRACE_NOARGS(err_context_mismatch);
|
|
|
}
|
|
|
}
|
|
@@ -15199,7 +15267,7 @@ _SOKOL_PRIVATE bool _sg_uninit_pipeline(sg_pipeline pip_id) {
|
|
|
return true;
|
|
|
}
|
|
|
else {
|
|
|
- SOKOL_LOG("_sg_uninit_pipeline: active context mismatch (must be same as for creation)");
|
|
|
+ SG_LOG("_sg_uninit_pipeline: active context mismatch (must be same as for creation)");
|
|
|
_SG_TRACE_NOARGS(err_context_mismatch);
|
|
|
}
|
|
|
}
|
|
@@ -15215,7 +15283,7 @@ _SOKOL_PRIVATE bool _sg_uninit_pass(sg_pass pass_id) {
|
|
|
return true;
|
|
|
}
|
|
|
else {
|
|
|
- SOKOL_LOG("_sg_uninit_pass: active context mismatch (must be same as for creation)");
|
|
|
+ SG_LOG("_sg_uninit_pass: active context mismatch (must be same as for creation)");
|
|
|
_SG_TRACE_NOARGS(err_context_mismatch);
|
|
|
}
|
|
|
}
|
|
@@ -15362,7 +15430,7 @@ SOKOL_API_IMPL sg_trace_hooks sg_install_trace_hooks(const sg_trace_hooks* trace
|
|
|
_sg.hooks = *trace_hooks;
|
|
|
#else
|
|
|
static sg_trace_hooks old_hooks;
|
|
|
- SOKOL_LOG("sg_install_trace_hooks() called, but SG_TRACE_HOOKS is not defined!");
|
|
|
+ SG_LOG("sg_install_trace_hooks() called, but SG_TRACE_HOOKS is not defined!");
|
|
|
#endif
|
|
|
return old_hooks;
|
|
|
}
|
|
@@ -15599,7 +15667,7 @@ SOKOL_API_IMPL sg_buffer sg_make_buffer(const sg_buffer_desc* desc) {
|
|
|
_sg_init_buffer(buf_id, &desc_def);
|
|
|
}
|
|
|
else {
|
|
|
- SOKOL_LOG("buffer pool exhausted!");
|
|
|
+ SG_LOG("buffer pool exhausted!");
|
|
|
_SG_TRACE_NOARGS(err_buffer_pool_exhausted);
|
|
|
}
|
|
|
_SG_TRACE_ARGS(make_buffer, &desc_def, buf_id);
|
|
@@ -15615,7 +15683,7 @@ SOKOL_API_IMPL sg_image sg_make_image(const sg_image_desc* desc) {
|
|
|
_sg_init_image(img_id, &desc_def);
|
|
|
}
|
|
|
else {
|
|
|
- SOKOL_LOG("image pool exhausted!");
|
|
|
+ SG_LOG("image pool exhausted!");
|
|
|
_SG_TRACE_NOARGS(err_image_pool_exhausted);
|
|
|
}
|
|
|
_SG_TRACE_ARGS(make_image, &desc_def, img_id);
|
|
@@ -15631,7 +15699,7 @@ SOKOL_API_IMPL sg_shader sg_make_shader(const sg_shader_desc* desc) {
|
|
|
_sg_init_shader(shd_id, &desc_def);
|
|
|
}
|
|
|
else {
|
|
|
- SOKOL_LOG("shader pool exhausted!");
|
|
|
+ SG_LOG("shader pool exhausted!");
|
|
|
_SG_TRACE_NOARGS(err_shader_pool_exhausted);
|
|
|
}
|
|
|
_SG_TRACE_ARGS(make_shader, &desc_def, shd_id);
|
|
@@ -15647,7 +15715,7 @@ SOKOL_API_IMPL sg_pipeline sg_make_pipeline(const sg_pipeline_desc* desc) {
|
|
|
_sg_init_pipeline(pip_id, &desc_def);
|
|
|
}
|
|
|
else {
|
|
|
- SOKOL_LOG("pipeline pool exhausted!");
|
|
|
+ SG_LOG("pipeline pool exhausted!");
|
|
|
_SG_TRACE_NOARGS(err_pipeline_pool_exhausted);
|
|
|
}
|
|
|
_SG_TRACE_ARGS(make_pipeline, &desc_def, pip_id);
|
|
@@ -15663,7 +15731,7 @@ SOKOL_API_IMPL sg_pass sg_make_pass(const sg_pass_desc* desc) {
|
|
|
_sg_init_pass(pass_id, &desc_def);
|
|
|
}
|
|
|
else {
|
|
|
- SOKOL_LOG("pass pool exhausted!");
|
|
|
+ SG_LOG("pass pool exhausted!");
|
|
|
_SG_TRACE_NOARGS(err_pass_pool_exhausted);
|
|
|
}
|
|
|
_SG_TRACE_ARGS(make_pass, &desc_def, pass_id);
|
|
@@ -15900,7 +15968,7 @@ SOKOL_API_IMPL void sg_draw(int base_element, int num_elements, int num_instance
|
|
|
SOKOL_ASSERT(num_instances >= 0);
|
|
|
#if defined(SOKOL_DEBUG)
|
|
|
if (!_sg.bindings_valid) {
|
|
|
- SOKOL_LOG("attempting to draw without resource bindings");
|
|
|
+ SG_LOG("attempting to draw without resource bindings");
|
|
|
}
|
|
|
#endif
|
|
|
if (!_sg.pass_valid) {
|