Commit d2e5d3c2 authored by David Reid's avatar David Reid

Start to add some logging to the resource manager.

parent 479718d8
...@@ -160,7 +160,7 @@ int main(int argc, char** argv) ...@@ -160,7 +160,7 @@ int main(int argc, char** argv)
float posX = 0; float posX = 0;
float posZ = -1.0f; float posZ = -1.0f;
float step = 0.1f; float step = 0.1f;
float stepAngle = 0.02f; float stepAngle = 0.002f;
float angle = 0; float angle = 0;
float pitch = 1; float pitch = 1;
......
...@@ -7045,6 +7045,7 @@ static ma_decoder_config ma_resource_manager__init_decoder_config(ma_resource_ma ...@@ -7045,6 +7045,7 @@ static ma_decoder_config ma_resource_manager__init_decoder_config(ma_resource_ma
static ma_result ma_resource_manager__init_decoder(ma_resource_manager* pResourceManager, const char* pFilePath, const wchar_t* pFilePathW, ma_decoder* pDecoder) static ma_result ma_resource_manager__init_decoder(ma_resource_manager* pResourceManager, const char* pFilePath, const wchar_t* pFilePathW, ma_decoder* pDecoder)
{ {
ma_result result;
ma_decoder_config config; ma_decoder_config config;
MA_ASSERT(pResourceManager != NULL); MA_ASSERT(pResourceManager != NULL);
...@@ -7054,10 +7055,20 @@ static ma_result ma_resource_manager__init_decoder(ma_resource_manager* pResourc ...@@ -7054,10 +7055,20 @@ static ma_result ma_resource_manager__init_decoder(ma_resource_manager* pResourc
config = ma_resource_manager__init_decoder_config(pResourceManager); config = ma_resource_manager__init_decoder_config(pResourceManager);
if (pFilePath != NULL) { if (pFilePath != NULL) {
return ma_decoder_init_vfs(pResourceManager->config.pVFS, pFilePath, &config, pDecoder); result = ma_decoder_init_vfs(pResourceManager->config.pVFS, pFilePath, &config, pDecoder);
if (result != MA_SUCCESS) {
ma_log_postf(ma_resource_manager_get_log(pResourceManager), MA_LOG_LEVEL_WARNING, "Failed to load file \"%s\". %d\n", pFilePath, result);
return result;
}
} else { } else {
return ma_decoder_init_vfs_w(pResourceManager->config.pVFS, pFilePathW, &config, pDecoder); result = ma_decoder_init_vfs_w(pResourceManager->config.pVFS, pFilePathW, &config, pDecoder);
if (result != MA_SUCCESS) {
ma_log_postf(ma_resource_manager_get_log(pResourceManager), MA_LOG_LEVEL_WARNING, "Failed to load file \"%ls\". %d\n", pFilePathW, result);
return result;
}
} }
return MA_SUCCESS;
} }
static ma_result ma_resource_manager_data_buffer_init_connector(ma_resource_manager_data_buffer* pDataBuffer, ma_async_notification* pInitNotification, ma_fence* pInitFence) static ma_result ma_resource_manager_data_buffer_init_connector(ma_resource_manager_data_buffer* pDataBuffer, ma_async_notification* pInitNotification, ma_fence* pInitFence)
...@@ -7179,7 +7190,7 @@ static ma_data_source* ma_resource_manager_data_buffer_get_connector(ma_resource ...@@ -7179,7 +7190,7 @@ static ma_data_source* ma_resource_manager_data_buffer_get_connector(ma_resource
case ma_resource_manager_data_supply_type_unknown: case ma_resource_manager_data_supply_type_unknown:
default: default:
{ {
/* TODO: Post an error here. */ ma_log_postf(ma_resource_manager_get_log(pDataBuffer->pResourceManager), MA_LOG_LEVEL_ERROR, "Failed to retrieve data buffer connector. Unknown data supply type.\n");
return NULL; return NULL;
}; };
}; };
...@@ -7196,13 +7207,21 @@ static ma_result ma_resource_manager_data_buffer_node_init_supply_encoded(ma_res ...@@ -7196,13 +7207,21 @@ static ma_result ma_resource_manager_data_buffer_node_init_supply_encoded(ma_res
MA_ASSERT(pFilePath != NULL || pFilePathW != NULL); MA_ASSERT(pFilePath != NULL || pFilePathW != NULL);
result = ma_vfs_open_and_read_file_ex(pResourceManager->config.pVFS, pFilePath, pFilePathW, &pData, &dataSizeInBytes, &pResourceManager->config.allocationCallbacks, MA_ALLOCATION_TYPE_ENCODED_BUFFER); result = ma_vfs_open_and_read_file_ex(pResourceManager->config.pVFS, pFilePath, pFilePathW, &pData, &dataSizeInBytes, &pResourceManager->config.allocationCallbacks, MA_ALLOCATION_TYPE_ENCODED_BUFFER);
if (result == MA_SUCCESS) { if (result != MA_SUCCESS) {
pDataBufferNode->data.encoded.pData = pData; if (pFilePath != NULL) {
pDataBufferNode->data.encoded.sizeInBytes = dataSizeInBytes; ma_log_postf(ma_resource_manager_get_log(pResourceManager), MA_LOG_LEVEL_WARNING, "Failed to load file \"%s\". %d\n", pFilePath, result);
ma_resource_manager_data_buffer_node_set_data_supply_type(pDataBufferNode, ma_resource_manager_data_supply_type_encoded); /* <-- Must be set last. */ } else {
ma_log_postf(ma_resource_manager_get_log(pResourceManager), MA_LOG_LEVEL_WARNING, "Failed to load file \"%ls\". %d\n", pFilePathW, result);
}
return result;
} }
return result; pDataBufferNode->data.encoded.pData = pData;
pDataBufferNode->data.encoded.sizeInBytes = dataSizeInBytes;
ma_resource_manager_data_buffer_node_set_data_supply_type(pDataBufferNode, ma_resource_manager_data_supply_type_encoded); /* <-- Must be set last. */
return MA_SUCCESS;
} }
static ma_result ma_resource_manager_data_buffer_node_init_supply_decoded(ma_resource_manager* pResourceManager, ma_resource_manager_data_buffer_node* pDataBufferNode, const char* pFilePath, const wchar_t* pFilePathW, ma_decoder** ppDecoder) static ma_result ma_resource_manager_data_buffer_node_init_supply_decoded(ma_resource_manager* pResourceManager, ma_resource_manager_data_buffer_node* pDataBufferNode, const char* pFilePath, const wchar_t* pFilePathW, ma_decoder** ppDecoder)
...@@ -7366,7 +7385,8 @@ static ma_result ma_resource_manager_data_buffer_node_decode_next_page(ma_resour ...@@ -7366,7 +7385,8 @@ static ma_result ma_resource_manager_data_buffer_node_decode_next_page(ma_resour
case ma_resource_manager_data_supply_type_unknown: case ma_resource_manager_data_supply_type_unknown:
default: default:
{ {
/* Unexpected data supply type. TODO: Post an error here. */ /* Unexpected data supply type. */
ma_log_postf(ma_resource_manager_get_log(pResourceManager), MA_LOG_LEVEL_ERROR, "Unexpected data supply type (%d) when decoding page.", ma_resource_manager_data_buffer_node_get_data_supply_type(pDataBufferNode));
return MA_ERROR; return MA_ERROR;
}; };
} }
...@@ -7510,7 +7530,8 @@ static ma_result ma_resource_manager_data_buffer_node_acquire(ma_resource_manage ...@@ -7510,7 +7530,8 @@ static ma_result ma_resource_manager_data_buffer_node_acquire(ma_resource_manage
result = ma_resource_manager_post_job(pResourceManager, &job); result = ma_resource_manager_post_job(pResourceManager, &job);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
/* TODO: Post an error message. Failed to post job. Probably ran out of memory. */ /* Failed to post job. Probably ran out of memory. */
ma_log_postf(ma_resource_manager_get_log(pResourceManager), MA_LOG_LEVEL_ERROR, "Failed to post MA_JOB_LOAD_DATA_BUFFER_NODE job. %d\n", ma_result_description(result));
/* /*
Fences were acquired before posting the job, but since the job was not able to Fences were acquired before posting the job, but since the job was not able to
...@@ -7546,8 +7567,7 @@ early_exit: ...@@ -7546,8 +7567,7 @@ early_exit:
hashed name), but that node has been freed in the meantime, probably from some other hashed name), but that node has been freed in the meantime, probably from some other
thread. This is an invalid operation. thread. This is an invalid operation.
*/ */
ma_log_postf(ma_resource_manager_get_log(pResourceManager), MA_LOG_LEVEL_WARNING, "Cloning data buffer node failed because the source node was released. The source node must remain valid until the cloning has completed.\n");
/* TODO: Post an error message here. */
result = MA_INVALID_OPERATION; result = MA_INVALID_OPERATION;
goto done; goto done;
} }
...@@ -7705,7 +7725,7 @@ stage2: ...@@ -7705,7 +7725,7 @@ stage2:
result = ma_resource_manager_post_job(pResourceManager, &job); result = ma_resource_manager_post_job(pResourceManager, &job);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
/* Failed to post the job. TODO: Post an error message here. */ ma_log_postf(ma_resource_manager_get_log(pResourceManager), MA_LOG_LEVEL_ERROR, "Failed to post MA_JOB_FREE_DATA_BUFFER_NODE job. %d\n", ma_result_description(result));
return result; return result;
} }
...@@ -7877,7 +7897,7 @@ static ma_result ma_resource_manager_data_buffer_init_internal(ma_resource_manag ...@@ -7877,7 +7897,7 @@ static ma_result ma_resource_manager_data_buffer_init_internal(ma_resource_manag
result = ma_resource_manager_post_job(pResourceManager, &job); result = ma_resource_manager_post_job(pResourceManager, &job);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
/* We failed to post the job. Most likely there isn't enough room in the queue's buffer. */ /* We failed to post the job. Most likely there isn't enough room in the queue's buffer. */
/* TODO: Post an error here. */ ma_log_postf(ma_resource_manager_get_log(pResourceManager), MA_LOG_LEVEL_ERROR, "Failed to post MA_JOB_LOAD_DATA_BUFFER job. %d\n", ma_result_description(result));
c89atomic_exchange_i32(&pDataBuffer->result, result); c89atomic_exchange_i32(&pDataBuffer->result, result);
/* Release the fences after the result has been set on the data buffer. */ /* Release the fences after the result has been set on the data buffer. */
...@@ -9397,7 +9417,12 @@ static ma_result ma_resource_manager_process_job__load_data_buffer_node(ma_resou ...@@ -9397,7 +9417,12 @@ static ma_result ma_resource_manager_process_job__load_data_buffer_node(ma_resou
} }
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
/* TODO: Post a log message here. */ if (pJob->loadDataBufferNode.pFilePath != NULL) {
ma_log_postf(ma_resource_manager_get_log(pResourceManager), MA_LOG_LEVEL_WARNING, "Failed to initialize data supply for \"%s\". %d\n", pJob->loadDataBufferNode.pFilePath, result);
} else {
ma_log_postf(ma_resource_manager_get_log(pResourceManager), MA_LOG_LEVEL_WARNING, "Failed to initialize data supply for \"%ls\", %d\n", pJob->loadDataBufferNode.pFilePathW, result);
}
goto done; goto done;
} }
...@@ -9426,7 +9451,7 @@ static ma_result ma_resource_manager_process_job__load_data_buffer_node(ma_resou ...@@ -9426,7 +9451,7 @@ static ma_result ma_resource_manager_process_job__load_data_buffer_node(ma_resou
is set to MA_BUSY. is set to MA_BUSY.
*/ */
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
/* Failed to post the paging job. TODO: Post an error here. */ ma_log_postf(ma_resource_manager_get_log(pResourceManager), MA_LOG_LEVEL_ERROR, "Failed to post MA_JOB_PAGE_DATA_BUFFER_NODE job. %d\n", ma_result_description(result));
ma_decoder_uninit(pDecoder); ma_decoder_uninit(pDecoder);
ma_free(pDecoder, &pResourceManager->config.allocationCallbacks); ma_free(pDecoder, &pResourceManager->config.allocationCallbacks);
} else { } else {
...@@ -9599,7 +9624,7 @@ static ma_result ma_resource_manager_process_job__load_data_buffer(ma_resource_m ...@@ -9599,7 +9624,7 @@ static ma_result ma_resource_manager_process_job__load_data_buffer(ma_resource_m
/* We can now initialize the connector. If this fails, we need to abort. It's very rare for this to fail. */ /* We can now initialize the connector. If this fails, we need to abort. It's very rare for this to fail. */
result = ma_resource_manager_data_buffer_init_connector(pJob->loadDataBuffer.pDataBuffer, pJob->loadDataBuffer.pInitNotification, pJob->loadDataBuffer.pInitFence); result = ma_resource_manager_data_buffer_init_connector(pJob->loadDataBuffer.pDataBuffer, pJob->loadDataBuffer.pInitNotification, pJob->loadDataBuffer.pInitFence);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
/* TODO: Post error here. */ ma_log_postf(ma_resource_manager_get_log(pResourceManager), MA_LOG_LEVEL_ERROR, "Failed to initialize connector for data buffer. %d\n", ma_result_description(result));
goto done; goto done;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment