Beispiel #1
0
void Composite::create_output( uint32 id, const Buffer::Config &config, uint32 slot /*= 0*/ ) {
	// First check to make sure this id hasn't already been registered
	if (outputs_.find(id) != outputs_.end()) { assert(false); return; }	// TODO Tell user that it already exists!

	OutputChannel* channel = nullptr;

	// Create the actual buffer
	Buffer* buffer = nullptr;
	Buffer::InitialData data = {};
	//buffer = Buffer::Create(config, data);

	// Create the views
	if (config.bind_flags & Buffer::BIND_RENDER_TARGET) {		
		// Create a default render target view given the buffer and default settings
        std::unique_ptr<RenderTargetView> view = RenderTargetView::Create(buffer, nullptr);

		// Create the channel
		channel = new RenderTargetOutput(std::move(view), slot);

	} else if (config.bind_flags & Buffer::BIND_UNORDERED_ACCESS) {
		// Create a default unordered access view given the buffer and default settings
        std::unique_ptr<UnorderedAccessView> view = UnorderedAccessView::Create(buffer, nullptr);

		// Create the channel
		channel = new UnorderedAccessOutput(std::move(view), slot);

	} else if (config.bind_flags & Buffer::BIND_DEPTH_STENCIL) {
		// Create a default depth stencil given the buffer and default settings
		std::unique_ptr<DepthStencilView> view = DepthStencilView::Create(buffer, nullptr);

		// Create the channel
		channel = new DepthStencilOutput(std::move(view));

	} else {
		// TODO something went really wrong
		assert(false);
	}

	// Create the shader resource view now
	if (config.bind_flags & Buffer::BIND_SHADER_RESOURCE) {
        std::unique_ptr<ShaderResourceView> view = ShaderResourceView::Create(buffer, nullptr);
		channel->set_shader_resource_view(std::move(view));
	}

	// Set the buffer
	channel->set_buffer(std::unique_ptr<Buffer>(buffer));

	// Add channel to the output list
	set_output(id, channel);
}