[Mesa-dev] [PATCH 06/10] mesa/dri: Move context flag validation down into the drivers
Kenneth Graunke
kenneth at whitecape.org
Thu Nov 7 17:01:45 PST 2013
On 10/29/2013 06:07 PM, Ian Romanick wrote:
> From: Ian Romanick <ian.d.romanick at intel.com>
>
> Soon some drivers will support a different set of flags than other
> drivers. If some flags have to be filtered in the driver, we might as
> well filter all of them in the driver.
I'm not sure that I agree, but I don't disagree enough to object.
> The changes in nouveau use tabs because nouveau seems to have it's own
> indentation rules.
>
> Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
> ---
> src/gallium/state_trackers/dri/common/dri_context.c | 5 +++++
> src/mesa/drivers/dri/i915/intel_screen.c | 5 +++++
> src/mesa/drivers/dri/i965/brw_context.c | 5 +++++
> src/mesa/drivers/dri/nouveau/nouveau_context.c | 7 ++++---
> src/mesa/drivers/dri/r200/r200_context.c | 7 ++++---
> src/mesa/drivers/dri/radeon/radeon_context.c | 7 ++++---
> 6 files changed, 27 insertions(+), 9 deletions(-)
>
> diff --git a/src/gallium/state_trackers/dri/common/dri_context.c b/src/gallium/state_trackers/dri/common/dri_context.c
> index 5cfd1ed..bf986c2 100644
> --- a/src/gallium/state_trackers/dri/common/dri_context.c
> +++ b/src/gallium/state_trackers/dri/common/dri_context.c
> @@ -101,6 +101,11 @@ dri_create_context(gl_api api, const struct gl_config * visual,
> goto fail;
> }
>
> + if (flags & ~(__DRI_CTX_FLAG_DEBUG | __DRI_CTX_FLAG_FORWARD_COMPATIBLE)) {
> + *error = __DRI_CTX_ERROR_UNKNOWN_FLAG;
> + return NULL;
> + }
This function returns a GLboolean, not a pointer. I think this should
be "goto fail" to match all the other cases.
Presumably this generates a compiler warning.
> +
> if (notify_reset) {
> *error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
> goto fail;
> diff --git a/src/mesa/drivers/dri/i915/intel_screen.c b/src/mesa/drivers/dri/i915/intel_screen.c
> index a4b40b7..9a1b378 100644
> --- a/src/mesa/drivers/dri/i915/intel_screen.c
> +++ b/src/mesa/drivers/dri/i915/intel_screen.c
> @@ -917,6 +917,11 @@ intelCreateContext(gl_api api,
> __DRIscreen *sPriv = driContextPriv->driScreenPriv;
> struct intel_screen *intelScreen = sPriv->driverPrivate;
>
> + if (flags & ~__DRI_CTX_FLAG_DEBUG) {
> + *error = __DRI_CTX_ERROR_UNKNOWN_FLAG;
> + return false;
> + }
> +
> if (notify_reset) {
> *error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
> return false;
> diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
> index 474c1ee..2bb52b6 100644
> --- a/src/mesa/drivers/dri/i965/brw_context.c
> +++ b/src/mesa/drivers/dri/i965/brw_context.c
> @@ -516,6 +516,11 @@ brwCreateContext(gl_api api,
> struct dd_function_table functions;
> struct gl_config visual;
>
> + if (flags & ~(__DRI_CTX_FLAG_DEBUG | __DRI_CTX_FLAG_FORWARD_COMPATIBLE)) {
> + *dri_ctx_error = __DRI_CTX_ERROR_UNKNOWN_FLAG;
> + return NULL;
Again, this should not be NULL. It should be "return false".
> + }
> +
> if (notify_reset) {
> *dri_ctx_error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
> return false;
> diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.c b/src/mesa/drivers/dri/nouveau/nouveau_context.c
> index a7f14b5..bdc0078 100644
> --- a/src/mesa/drivers/dri/nouveau/nouveau_context.c
> +++ b/src/mesa/drivers/dri/nouveau/nouveau_context.c
> @@ -62,9 +62,10 @@ nouveau_context_create(gl_api api,
> struct nouveau_context *nctx;
> struct gl_context *ctx;
>
> - /* API and flag filtering is handled in dri2CreateContextAttribs.
> - */
> - (void) flags;
> + if (flags & ~__DRI_CTX_FLAG_DEBUG) {
> + *error = __DRI_CTX_ERROR_UNKNOWN_FLAG;
> + return false;
> + }
The line with } is indented using spaces rather than tabs, which is
inconsistent.
>
> if (notify_reset) {
> *error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
> diff --git a/src/mesa/drivers/dri/r200/r200_context.c b/src/mesa/drivers/dri/r200/r200_context.c
> index 58c300c..d4e9ca8 100644
> --- a/src/mesa/drivers/dri/r200/r200_context.c
> +++ b/src/mesa/drivers/dri/r200/r200_context.c
> @@ -213,9 +213,10 @@ GLboolean r200CreateContext( gl_api api,
> int i;
> int tcl_mode;
>
> - /* Flag filtering is handled in dri2CreateContextAttribs.
> - */
> - (void) flags;
> + if (flags & ~__DRI_CTX_FLAG_DEBUG) {
> + *error = __DRI_CTX_ERROR_UNKNOWN_FLAG;
> + return false;
> + }
>
> if (notify_reset) {
> *error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
> diff --git a/src/mesa/drivers/dri/radeon/radeon_context.c b/src/mesa/drivers/dri/radeon/radeon_context.c
> index c2200d7..76bfe55 100644
> --- a/src/mesa/drivers/dri/radeon/radeon_context.c
> +++ b/src/mesa/drivers/dri/radeon/radeon_context.c
> @@ -180,9 +180,10 @@ r100CreateContext( gl_api api,
> int i;
> int tcl_mode, fthrottle_mode;
>
> - /* Flag filtering is handled in dri2CreateContextAttribs.
> - */
> - (void) flags;
> + if (flags & ~__DRI_CTX_FLAG_DEBUG) {
> + *error = __DRI_CTX_ERROR_UNKNOWN_FLAG;
> + return false;
> + }
>
> if (notify_reset) {
> *error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
>
More information about the mesa-dev
mailing list