Пример #1
0
gs_stage_surface::gs_stage_surface(device_t device, uint32_t width,
		uint32_t height, gs_color_format colorFormat)
	: device     (device),
	  width      (width),
	  height     (height),
	  format     (colorFormat),
	  dxgiFormat (ConvertGSTextureFormat(colorFormat))
{
	D3D11_TEXTURE2D_DESC td;
	HRESULT hr;

	memset(&td, 0, sizeof(td));
	td.Width            = width;
	td.Height           = height;
	td.MipLevels        = 1;
	td.ArraySize        = 1;
	td.Format           = dxgiFormat;
	td.SampleDesc.Count = 1;
	td.CPUAccessFlags   = D3D11_CPU_ACCESS_READ;
	td.Usage            = D3D11_USAGE_STAGING;

	hr = device->device->CreateTexture2D(&td, NULL, texture.Assign());
	if (FAILED(hr))
		throw HRError("Failed to create 2D texture", hr);
}
Пример #2
0
static inline void make_swap_desc(DXGI_SWAP_CHAIN_DESC &desc,
		gs_init_data *data)
{
	memset(&desc, 0, sizeof(desc));
	desc.BufferCount       = data->num_backbuffers;
	desc.BufferDesc.Format = ConvertGSTextureFormat(data->format);
	desc.BufferDesc.Width  = data->cx;
	desc.BufferDesc.Height = data->cy;
	desc.BufferUsage       = DXGI_USAGE_RENDER_TARGET_OUTPUT;
	desc.OutputWindow      = (HWND)data->window.hwnd;
	desc.SampleDesc.Count  = 1;
	desc.Windowed          = true;
}
Пример #3
0
void gs_swap_chain::Init(gs_init_data *data)
{
	target.device         = device;
	target.isRenderTarget = true;
	target.format         = data->format;
	target.dxgiFormat     = ConvertGSTextureFormat(data->format);
	InitTarget(data->cx, data->cy);

	zs.device     = device;
	zs.format     = data->zsformat;
	zs.dxgiFormat = ConvertGSZStencilFormat(data->zsformat);
	InitZStencilBuffer(data->cx, data->cy);
}
Пример #4
0
gs_texture_2d::gs_texture_2d(device_t device, uint32_t width, uint32_t height,
		gs_color_format colorFormat, uint32_t levels, const void **data,
		uint32_t flags, gs_texture_type type, bool gdiCompatible,
		bool shared)
	: gs_texture      (device, type, levels, colorFormat),
	  width           (width),
	  height          (height),
	  dxgiFormat      (ConvertGSTextureFormat(format)),
	  isGDICompatible (gdiCompatible),
	  isShared        (shared),
	  isDynamic       ((flags & GS_DYNAMIC) != 0),
	  isRenderTarget  ((flags & GS_RENDERTARGET) != 0),
	  genMipmaps      ((flags & GS_BUILDMIPMAPS) != 0)
{
	InitTexture(data);
	InitResourceView();

	if (isRenderTarget)
		InitRenderTargets();
}