From: Henri Verbeet Subject: Re: [PATCH 2/2] d2d1: Reuse PS constant buffers. Message-Id: Date: Mon, 7 Jun 2021 16:51:43 +0200 In-Reply-To: <20210607103622.966812-2-nsivov@codeweavers.com> References: <20210607103622.966812-1-nsivov@codeweavers.com> <20210607103622.966812-2-nsivov@codeweavers.com> On Mon, 7 Jun 2021 at 12:36, Nikolay Sivov wrote: > + if (context->ps_cb[cb_type]) > + { > + if (memcmp(&cb_data, &context->cb_data[cb_type], sizeof(cb_data))) > + { > + if (SUCCEEDED(hr = ID3D10Buffer_Map(context->ps_cb[cb_type], > + D3D10_MAP_WRITE_DISCARD, 0, &data))) > + { > + memcpy(data, &cb_data, sizeof(cb_data)); > + ID3D10Buffer_Unmap(context->ps_cb[cb_type]); > + } > + else > + ERR("Failed to map constant buffer, hr %#x.\n", hr); > + } > + } Does that memcmp() help much? It seems tempting to just store a single "ps_cb" in the d2d_device_context structure, and always map with WRITE_DISCARD here.