コード例 #1
0
	ComPtr<ID3D11Texture2D> &D3DRenderBufferProvider::get_texture(const ComPtr<ID3D11Device> &device)
	{
		if (device)
			return get_handles(device).texture;
		else
			return handles.front()->texture;
	}
コード例 #2
0
ComPtr<ID3D11Buffer> &D3DTransferBufferProvider::get_buffer(const ComPtr<ID3D11Device> &device)
{
	if (device)
		return get_handles(device).buffer;
	else
		return handles.front()->buffer;
}
コード例 #3
0
ファイル: d3d_uniform_buffer.cpp プロジェクト: rombust/UICore
ComPtr<ID3D11Buffer> &D3DUniformBuffer::get_buffer(const ComPtr<ID3D11Device> &device)
{
    if (device)
        return get_handles(device).buffer;
    else
        return handles.front()->buffer;
}
コード例 #4
0
void D3DStorageBufferProvider::upload_data(GraphicContext &gc, const void *data, int data_size)
{
	if (data_size != size)
		throw Exception("Upload data size does not match vertex array buffer");

	const ComPtr<ID3D11Device> &device = static_cast<D3DGraphicContextProvider*>(gc.get_provider())->get_window()->get_device();
	ComPtr<ID3D11DeviceContext> device_context;
	device->GetImmediateContext(device_context.output_variable());
	device_context->UpdateSubresource(get_handles(device).buffer, 0, 0, data, 0, 0);
}
コード例 #5
0
ComPtr<ID3D11UnorderedAccessView> &D3DStorageBufferProvider::get_uav(const ComPtr<ID3D11Device> &device)
{
	DeviceHandles &handles = get_handles(device);
	if (!handles.uav)
	{
		HRESULT result = device->CreateUnorderedAccessView(handles.buffer, 0, handles.uav.output_variable());
		D3DTarget::throw_if_failed("ID3D11Device.CreateUnorderedAccessView failed", result);
	}
	return handles.uav;
}
コード例 #6
0
void D3DTransferBufferProvider::unlock()
{
	ComPtr<ID3D11DeviceContext> context;
	map_device->GetImmediateContext(context.output_variable());

	context->Unmap(get_handles(map_device).buffer, 0);
	map_device.clear();
	map_data.pData = 0;
	map_data.RowPitch = 0;
	map_data.DepthPitch = 0;
}
コード例 #7
0
ファイル: d3d_uniform_buffer.cpp プロジェクト: rombust/UICore
void D3DUniformBuffer::upload_data(const GraphicContextPtr &gc, const void *data, int data_size)
{
    if (data_size != size)
        throw Exception("Upload data size does not match vertex array buffer");

    auto d3d_window = static_cast<D3DGraphicContext*>(gc.get())->get_window();
    const auto &device = d3d_window->get_device();
    const auto &device_context = d3d_window->get_device_context();

    device_context->UpdateSubresource(get_handles(device).buffer, 0, 0, data, 0, 0);
}
コード例 #8
0
	ComPtr<ID3D11RenderTargetView> D3DRenderBufferProvider::create_rtv(const ComPtr<ID3D11Device> &device)
	{
		D3D11_RENDER_TARGET_VIEW_DESC rtv_desc;
		rtv_desc.Format = DXGI_FORMAT_UNKNOWN;
		rtv_desc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
		rtv_desc.Texture2D.MipSlice = 0;

		ComPtr<ID3D11RenderTargetView> rtv;
		HRESULT result = device->CreateRenderTargetView(get_handles(device).texture, &rtv_desc, rtv.output_variable());
		D3DTarget::throw_if_failed("ID3D11Device.CreateRenderTargetView failed", result);
		return rtv;
	}
コード例 #9
0
ファイル: barrier.c プロジェクト: arcivanov/postgres-xl
static PGXCNodeAllHandles *
SendBarrierPrepareRequest(List *coords, const char *id)
{
	PGXCNodeAllHandles *coord_handles;
	int conn;
	int msglen;
	int barrier_idlen;

	coord_handles = get_handles(NIL, coords, true, true);

	for (conn = 0; conn < coord_handles->co_conn_count; conn++)
	{
		PGXCNodeHandle *handle = coord_handles->coord_handles[conn];

		/* Invalid connection state, return error */
		if (handle->state != DN_CONNECTION_STATE_IDLE)
			ereport(ERROR,
					(errcode(ERRCODE_INTERNAL_ERROR),
					 errmsg("Failed to send CREATE BARRIER PREPARE request "
						 	"to the node")));

		barrier_idlen = strlen(id) + 1;

		msglen = 4; /* for the length itself */
		msglen += barrier_idlen;
		msglen += 1; /* for barrier command itself */

		/* msgType + msgLen */
		if (ensure_out_buffer_capacity(handle->outEnd + 1 + msglen, handle) != 0)
		{
			ereport(ERROR,
					(errcode(ERRCODE_INTERNAL_ERROR),
					 errmsg("Out of memory")));
		}

		handle->outBuffer[handle->outEnd++] = 'b';
		msglen = htonl(msglen);
		memcpy(handle->outBuffer + handle->outEnd, &msglen, 4);
		handle->outEnd += 4;

		handle->outBuffer[handle->outEnd++] = CREATE_BARRIER_PREPARE;

		memcpy(handle->outBuffer + handle->outEnd, id, barrier_idlen);
		handle->outEnd += barrier_idlen;

		handle->state = DN_CONNECTION_STATE_QUERY;

		pgxc_node_flush(handle);
	}

	return coord_handles;
}
コード例 #10
0
	ComPtr<ID3D11DepthStencilView> D3DRenderBufferProvider::create_dsv(const ComPtr<ID3D11Device> &device)
	{
		D3D11_DEPTH_STENCIL_VIEW_DESC dsv_desc;
		dsv_desc.Format = DXGI_FORMAT_UNKNOWN;
		dsv_desc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D;
		dsv_desc.Texture2D.MipSlice = 0;
		dsv_desc.Flags = 0;

		ComPtr<ID3D11DepthStencilView> dsv;
		HRESULT result = device->CreateDepthStencilView(get_handles(device).texture, &dsv_desc, dsv.output_variable());
		D3DTarget::throw_if_failed("ID3D11Device.CreateDepthStencilView failed", result);
		return dsv;
	}
コード例 #11
0
ファイル: d3d_texture_data.cpp プロジェクト: rombust/UICore
	void D3DTextureData::attach_to_another_device(ID3D11Device *not_this_device)
	{
		// This code is used to ensure the texture is copied to another provider if the (single) owner is destroyed
		std::unique_ptr<std::unique_lock<std::recursive_mutex>> mutex_section;
		for (auto gc_provider : D3DShareList::all_contexts())
		{
			if (gc_provider->get_window()->get_device() != not_this_device)
			{
				ComPtr<ID3D11Device> device = gc_provider->get_window()->get_device();
				get_handles(device);
				return;
			}
		}
	}
コード例 #12
0
	void D3DVertexArrayBufferProvider::upload_data(GraphicContext &gc, int offset, const void *data, int data_size)
	{
		if ((offset < 0) || (data_size < 0) || ((data_size + offset) > size))
			throw Exception("Vertex array buffer, invalid size");

		const ComPtr<ID3D11Device> &device = static_cast<D3DGraphicContextProvider*>(gc.get_provider())->get_window()->get_device();
		ComPtr<ID3D11DeviceContext> device_context;
		device->GetImmediateContext(device_context.output_variable());

		D3D11_BOX box;
		box.left = offset;
		box.right = offset + data_size;
		box.top = 0;
		box.bottom = 1;
		box.front = 0;
		box.back = 1;

		device_context->UpdateSubresource(get_handles(device).buffer, 0, &box, data, 0, 0);
	}
コード例 #13
0
ComPtr<ID3D11ShaderResourceView> &D3DStorageBufferProvider::get_srv(const ComPtr<ID3D11Device> &device)
{
	DeviceHandles &handles = get_handles(device);

	if (!handles.srv)
	{
		D3D11_BUFFER_DESC buffer_desc;
		handles.buffer->GetDesc(&buffer_desc);

		D3D11_SHADER_RESOURCE_VIEW_DESC srv_desc;
		srv_desc.Format = DXGI_FORMAT_UNKNOWN;
		srv_desc.ViewDimension = D3D11_SRV_DIMENSION_BUFFER;
		srv_desc.Buffer.ElementOffset = 0;
		srv_desc.Buffer.ElementWidth = buffer_desc.ByteWidth / buffer_desc.StructureByteStride;

		HRESULT result = device->CreateShaderResourceView(handles.buffer, &srv_desc, handles.srv.output_variable());
		D3DTarget::throw_if_failed("ID3D11Device.CreateShaderResourceView failed", result);
	}
	return handles.srv;
}
コード例 #14
0
void D3DStorageBufferProvider::copy_to(GraphicContext &gc, TransferBuffer &buffer, int dest_pos, int src_pos, int copy_size)
{
	const ComPtr<ID3D11Device> &device = static_cast<D3DGraphicContextProvider*>(gc.get_provider())->get_window()->get_device();
	ComPtr<ID3D11Buffer> &transfer_buffer = static_cast<D3DTransferBufferProvider*>(buffer.get_provider())->get_buffer(device);
	int transfer_buffer_size = static_cast<D3DTransferBufferProvider*>(buffer.get_provider())->get_size();

	if (copy_size == -1)
		copy_size = transfer_buffer_size;

	if (dest_pos < 0 || copy_size < 0 || dest_pos + copy_size > transfer_buffer_size || src_pos < 0 || src_pos + copy_size > size)
		throw Exception("Out of bounds!");

	ComPtr<ID3D11DeviceContext> device_context;
	device->GetImmediateContext(device_context.output_variable());

	D3D11_BOX box;
	box.left = dest_pos;
	box.right = dest_pos + copy_size;
	box.top = 0;
	box.bottom = 1;
	box.front = 0;
	box.back = 1;
	device_context->CopySubresourceRegion(transfer_buffer, 0, src_pos, 0, 0, get_handles(device).buffer, 0, &box);
}
コード例 #15
0
ファイル: d3d_uniform_buffer.cpp プロジェクト: rombust/UICore
void D3DUniformBuffer::copy_to(const GraphicContextPtr  &gc, const StagingBufferPtr &buffer, int dest_pos, int src_pos, int copy_size)
{
    auto d3d_window = static_cast<D3DGraphicContext*>(gc.get())->get_window();
    const auto &device = d3d_window->get_device();
    const auto &device_context = d3d_window->get_device_context();

    ComPtr<ID3D11Buffer> &staging_buffer = static_cast<D3DStagingBuffer*>(buffer.get())->get_buffer(device);
    int staging_buffer_size = static_cast<D3DStagingBuffer*>(buffer.get())->get_size();

    if (copy_size == -1)
        copy_size = staging_buffer_size;

    if (dest_pos < 0 || copy_size < 0 || dest_pos + copy_size > staging_buffer_size || src_pos < 0 || src_pos + copy_size > size)
        throw Exception("Out of bounds!");

    D3D11_BOX box;
    box.left = dest_pos;
    box.right = dest_pos + copy_size;
    box.top = 0;
    box.bottom = 1;
    box.front = 0;
    box.back = 1;
    device_context->CopySubresourceRegion(staging_buffer, 0, src_pos, 0, 0, get_handles(device).buffer, 0, &box);
}
コード例 #16
0
ファイル: barrier.c プロジェクト: arcivanov/postgres-xl
/*
 * Execute the barrier command on all the components, including Datanodes and
 * Coordinators.
 */
static void
ExecuteBarrier(const char *id)
{
	List *barrierDataNodeList = GetAllDataNodes();
	List *barrierCoordList = GetAllCoordNodes();
	PGXCNodeAllHandles *conn_handles;
	int conn;
	int msglen;
	int barrier_idlen;

	conn_handles = get_handles(barrierDataNodeList, barrierCoordList, false, true);

	elog(DEBUG2, "Sending CREATE BARRIER <%s> EXECUTE message to "
				 "Datanodes and Coordinator", id);
	/*
	 * Send a CREATE BARRIER request to all the Datanodes and the Coordinators
	 */
	for (conn = 0; conn < conn_handles->co_conn_count + conn_handles->dn_conn_count; conn++)
	{
		PGXCNodeHandle *handle;

		if (conn < conn_handles->co_conn_count)
			handle = conn_handles->coord_handles[conn];
		else
			handle = conn_handles->datanode_handles[conn - conn_handles->co_conn_count];

		/* Invalid connection state, return error */
		if (handle->state != DN_CONNECTION_STATE_IDLE)
			ereport(ERROR,
					(errcode(ERRCODE_INTERNAL_ERROR),
					 errmsg("Failed to send CREATE BARRIER EXECUTE request "
						 	"to the node")));

		barrier_idlen = strlen(id) + 1;

		msglen = 4; /* for the length itself */
		msglen += barrier_idlen;
		msglen += 1; /* for barrier command itself */

		/* msgType + msgLen */
		if (ensure_out_buffer_capacity(handle->outEnd + 1 + msglen, handle) != 0)
		{
			ereport(ERROR,
					(errcode(ERRCODE_INTERNAL_ERROR),
					 errmsg("Out of memory")));
		}

		handle->outBuffer[handle->outEnd++] = 'b';
		msglen = htonl(msglen);
		memcpy(handle->outBuffer + handle->outEnd, &msglen, 4);
		handle->outEnd += 4;

		handle->outBuffer[handle->outEnd++] = CREATE_BARRIER_EXECUTE;

		memcpy(handle->outBuffer + handle->outEnd, id, barrier_idlen);
		handle->outEnd += barrier_idlen;

		handle->state = DN_CONNECTION_STATE_QUERY;
		pgxc_node_flush(handle);
	}

	CheckBarrierCommandStatus(conn_handles, id, "EXECUTE");

	pfree_pgxc_all_handles(conn_handles);

	/*
	 * Also WAL log the BARRIER locally and flush the WAL buffers to disk
	 */
	{
		XLogRecData rdata[1];
		XLogRecPtr recptr;

		rdata[0].data = (char *) id;
		rdata[0].len = strlen(id) + 1;
		rdata[0].buffer = InvalidBuffer;
		rdata[0].next = NULL;

		recptr = XLogInsert(RM_BARRIER_ID, XLOG_BARRIER_CREATE, rdata);
		XLogFlush(recptr);
	}
}