コード例 #1
0
file_t::file_t(atma::string const& filename, file_access_mask_t access)
	: filename_(filename)
	, access_(access)
	, filesize_()
	, handle_{fopen(filename.c_str(), fa[(uint)access]), [](FILE* handle) {
		if (handle)
			fclose(handle);
	  }}
{
	if (handle_ == nullptr)
		return;

	// get filesize
	fseek(handle_.get(), 0, SEEK_END);
	filesize_ = ftell(handle_.get());
	fseek(handle_.get(), 0, SEEK_SET);
}
コード例 #2
0
compute_shader_t::compute_shader_t(renderer_ptr const& renderer, atma::string const& path, void const* data, size_t data_size, bool precompiled, atma::string const& entrypoint)
	: rndr_(renderer)
{
	if (precompiled)
	{
		ATMA_ENSURE_IS(S_OK, D3DCreateBlob(data_size, d3d_blob_.assign()));
		memcpy(d3d_blob_->GetBufferPointer(), data, data_size);
	}
	else
	{
		platform::d3d_blob_ptr errors;
		D3DCompile(data, data_size, path.c_str(), nullptr, D3D_COMPILE_STANDARD_FILE_INCLUDE, entrypoint.c_str(), "cs_5_0", D3DCOMPILE_PREFER_FLOW_CONTROL | D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION, 0, d3d_blob_.assign(), errors.assign());
		if (errors.get())
		{
			SHINY_ERROR("compute-shader errors:\n", (char*)errors->GetBufferPointer());
			ATMA_HALT("bad compute-shader");
		}
	}


	auto const& device = rndr_->d3d_device();
	ATMA_ENSURE_IS(S_OK, device->CreateComputeShader(d3d_blob_->GetBufferPointer(), d3d_blob_->GetBufferSize(), nullptr, d3d_cs_.assign()));
}