Exemplo n.º 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);
}
Exemplo n.º 2
0
	path_t::path_t(atma::string const& str, atma::string::const_iterator const& begin)
	{
		char const* delims = "/\\";

		auto end = atma::find_first_of(str, begin, delims);
		if (end == str.end()) {
			type_ = path_type_t::file;
		}
		else {
			type_ = path_type_t::dir;
			++end;
		}

		name_ = atma::string(begin, end);

		if (end == begin)
			return;

		child_ = path_ptr(new path_t(str, end));
	}
Exemplo n.º 3
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()));
}
Exemplo n.º 4
0
	path_t::path_t(atma::string const& str)
		: path_t(str, str.begin())
	{
	}